Ticket #12: 00-12-channeleditor-dialogs.patch
File 00-12-channeleditor-dialogs.patch, 16.9 KB (added by , 17 years ago) |
---|
-
mythtv/programs/mythtv-setup/channeleditor.cpp
23 23 #include "sourceutil.h" 24 24 25 25 #include "scanwizard.h" 26 #include "importicons.h"27 26 28 27 ChannelWizard::ChannelWizard(int id, int default_sourceid) 29 28 : ConfigurationWizard() … … 121 120 m_currentSortMode = tr("Channel Name"); 122 121 m_sourceFilter = FILTER_ALL; // All 123 122 m_currentHideMode = false; 123 m_selectedChannelName = ""; 124 m_iconWizardRunning = false; 125 124 126 } 125 127 126 128 bool ChannelEditor::Create() … … 137 139 m_sourceList = dynamic_cast<MythUIButtonList *>(GetChild("source")); 138 140 m_channelList = dynamic_cast<MythUIButtonList *>(GetChild("channels")); 139 141 140 MythUIButton *deleteButton = dynamic_cast<MythUIButton *>(GetChild("delete"));141 142 MythUIButton *scanButton = dynamic_cast<MythUIButton *>(GetChild("scan")); 142 MythUIButton *importIconButton = dynamic_cast<MythUIButton *>(GetChild("importicons"));143 143 MythUIButton *transportEditorButton = dynamic_cast<MythUIButton *>(GetChild("edittransport")); 144 144 145 145 MythUICheckBox *hideCheck = dynamic_cast<MythUICheckBox *>(GetChild("nochannum")); 146 146 147 if (!sortList || !m_sourceList || !m_channelList || !deleteButton || 148 !scanButton || !importIconButton || !transportEditorButton || 149 !hideCheck) 147 if (!sortList || !m_sourceList || !m_channelList || !scanButton || 148 !transportEditorButton || !hideCheck) 150 149 { 151 150 152 151 return false; 153 152 } 154 153 155 // Delete button help text156 deleteButton->SetHelpText(tr("Delete all channels on currently selected source(s)."));157 158 154 // Sort List 159 155 new MythUIButtonListItem(sortList, tr("Channel Name")); 160 156 new MythUIButtonListItem(sortList, tr("Channel Number")); … … 190 186 scanButton->SetHelpText(tr("Starts the channel scanner.")); 191 187 scanButton->SetEnabled(SourceUtil::IsAnySourceScanable()); 192 188 193 // Import Icons Button194 importIconButton->SetHelpText(tr("Starts the icon downloader"));195 importIconButton->SetEnabled(SourceUtil::IsAnySourceScanable());196 connect(importIconButton, SIGNAL(Clicked()), SLOT(channelIconImport()));197 198 189 // Transport Editor Button 199 190 transportEditorButton->SetHelpText( 200 191 tr("Allows you to edit the transports directly. " … … 207 198 connect(m_channelList, SIGNAL(itemClicked(MythUIButtonListItem *)), 208 199 SLOT(edit(MythUIButtonListItem *))); 209 200 connect(scanButton, SIGNAL(Clicked()), SLOT(scan())); 210 connect(deleteButton, SIGNAL(Clicked()), SLOT(deleteChannels()));211 201 212 202 fillList(); 213 203 … … 236 226 } 237 227 else if (action == "DELETE") 238 228 { 239 del(); 229 int channelID = 0; 230 MythUIButtonListItem *item = m_channelList->GetItemCurrent(); 231 if (item) 232 channelID = item->GetData().toInt(); 233 234 if (channelID > 0) 235 { 236 GetSelectedChannelName(channelID); 237 deleteChannelsMenu(); 238 } 239 else 240 handled = true; 240 241 } 242 else if (action == "ESCAPE") 243 { 244 if (m_iconWizardRunning) 245 { 246 iconWizard->Close(); 247 m_iconWizardRunning = false; 248 } 249 else 250 handled = false; 251 } 241 252 else 242 253 handled = false; 243 254 } … … 399 410 } 400 411 } 401 412 402 void ChannelEditor::deleteChannels (void)413 void ChannelEditor::deleteChannelsMenu(void) 403 414 { 404 const QString currentLabel = m_sourceList->GetValue(); 415 QString chan_msg; 416 417 if (!m_selectedChannelName.isEmpty()) 418 { 419 chan_msg = tr("Are you sure you would like to delete channel %1?") 420 .arg(m_selectedChannelName); 421 } 422 else if (m_sourceFilter == FILTER_ALL) 423 { 424 chan_msg = tr("Are you sure you would like to delete ALL channels?"); 425 } 426 else if (m_sourceFilter == FILTER_UNASSIGNED) 427 { 428 chan_msg = tr("Are you sure you would like to delete all unassigned channels?"); 429 } 430 else 431 { 432 chan_msg = tr("Are you sure you would like to delete the channels on %1?") 433 .arg(m_sourceList->GetValue()); 434 } 405 435 406 bool del_all = m_sourceFilter == FILTER_ALL; 407 bool del_nul = m_sourceFilter == FILTER_UNASSIGNED; 436 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); 437 MythDialogBox *delChanMenu = new MythDialogBox(chan_msg, popupStack, "deletechannelsmenu"); 438 if (delChanMenu->Create()) 439 { 440 delChanMenu->SetReturnEvent(this, "deletechannelsmenu"); 441 442 delChanMenu->AddButton(tr("Yes, delete the channel(s)")); 443 delChanMenu->AddButton(tr("No, don't")); 444 445 popupStack->AddScreen(delChanMenu); 446 } 447 else 448 delete delChanMenu; 449 } 408 450 409 QString chan_msg = 410 (del_all) ? tr("Are you sure you would like to delete ALL channels?") : 411 ((del_nul) ? 412 tr("Are you sure you would like to delete all unassigned channels?") : 413 tr("Are you sure you would like to delete the channels on %1?") 414 .arg(currentLabel)); 415 416 DialogCode val = MythPopupBox::Show2ButtonPopup( 417 gContext->GetMainWindow(), "", chan_msg, 418 tr("Yes, delete the channels"), 419 tr("No, don't"), kDialogCodeButton1); 420 421 if (kDialogCodeButton0 != val) 422 return; 423 451 void ChannelEditor::deleteChannels(void) 452 { 424 453 MSqlQuery query(MSqlQuery::InitCon()); 425 if ( del_all)454 if (!m_selectedChannelName.isEmpty()) 426 455 { 456 MythUIButtonListItem *item = m_channelList->GetItemCurrent(); 457 if (!item) 458 return; 459 m_id = item->GetData().toInt(); 460 461 query.prepare("DELETE FROM channel WHERE chanid = :CHID ;"); 462 query.bindValue(":CHID", m_id); 463 } 464 else if (m_sourceFilter == FILTER_ALL) 465 { 427 466 query.prepare("TRUNCATE TABLE channel"); 428 467 } 429 else if ( del_nul)468 else if (m_sourceFilter == FILTER_UNASSIGNED) 430 469 { 431 470 query.prepare("SELECT sourceid " 432 471 "FROM videosource " … … 463 502 if (!query.exec()) 464 503 MythDB::DBError("ChannelEditor Delete Channels", query); 465 504 505 m_selectedChannelName = ""; 506 466 507 fillList(); 467 508 } 468 509 … … 478 519 fillList(); 479 520 } 480 521 481 void ChannelEditor::del()482 {483 MythUIButtonListItem *item = m_channelList->GetItemCurrent();484 485 if (!item)486 return;487 488 m_id = item->GetData().toInt();489 490 DialogCode val = MythPopupBox::Show2ButtonPopup(491 gContext->GetMainWindow(),492 "", tr("Are you sure you would like to delete this channel?"),493 tr("Yes, delete the channel"),494 tr("No, don't"), kDialogCodeButton1);495 496 if (kDialogCodeButton0 == val)497 {498 MSqlQuery query(MSqlQuery::InitCon());499 query.prepare("DELETE FROM channel WHERE chanid = :CHID ;");500 query.bindValue(":CHID", m_id);501 if (!query.exec() || !query.isActive())502 MythDB::DBError("ChannelEditor Delete Channel", query);503 504 fillList();505 }506 }507 508 522 void ChannelEditor::menu() 509 523 { 510 524 MythUIButtonListItem *item = m_channelList->GetItemCurrent(); … … 517 531 edit(item); 518 532 else 519 533 { 534 GetSelectedChannelName(m_id); 535 520 536 QString label = tr("Channel Options"); 521 537 522 538 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); … … 527 543 { 528 544 menu->SetReturnEvent(this, "channelopts"); 529 545 530 menu->AddButton(tr("Edit")); 531 menu->AddButton(tr("Delete")); 546 menu->AddButton(tr("Edit channel %1").arg(m_selectedChannelName)); 547 menu->AddButton(tr("Delete channel %1").arg(m_selectedChannelName)); 548 menu->AddButton(tr("Download channel icon for %1").arg(m_selectedChannelName)); 549 QString filter = ""; 550 if (m_sourceFilter == FILTER_ALL) 551 filter = "ALL"; 552 else if (m_sourceFilter == FILTER_UNASSIGNED) 553 filter = "UNASSIGNED"; 554 else 555 filter = m_sourceList->GetValue(); 532 556 557 menu->AddButton(tr("Rescan for missing channel icons")); 558 menu->AddButton(tr("Download all channel icons")); 559 560 menu->AddButton(tr("Delete %1 channels").arg(filter)); 561 533 562 popupStack->AddScreen(menu); 534 563 } 535 564 else … … 563 592 fillList(); 564 593 } 565 594 566 void ChannelEditor::channelIcon Import(void)595 void ChannelEditor::channelIconDownload(bool refresh, const QString &channelname) 567 596 { 568 if (m_channelList->GetCount() == 0) 597 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 598 599 iconWizard = new ImportIconsWizard(mainStack, refresh, channelname); 600 m_iconWizardRunning = true; 601 602 if (!iconWizard->Create()) 569 603 { 570 ShowOkPopup(tr("Add some channels first!")); 604 m_iconWizardRunning = false; 605 delete iconWizard; 606 } 607 608 m_selectedChannelName = ""; 609 } 610 611 /** 612 * \brief Get selected channel name from database. 613 */ 614 void ChannelEditor::GetSelectedChannelName(int chanid) 615 { 616 if (chanid == 0) 617 { // If no channel selected 618 m_selectedChannelName = ""; 571 619 return; 572 620 } 573 621 574 int channelID = 0;575 MythUIButtonListItem *item = m_channelList->GetItemCurrent();576 if (item)577 channelID = item->GetData().toInt();578 579 // Get selected channel name from database580 622 QString querystr = QString("SELECT channel.name FROM channel " 581 "WHERE chanid='%1'").arg(chan nelID);582 QString channelname;623 "WHERE chanid='%1'").arg(chanid); 624 583 625 MSqlQuery query(MSqlQuery::InitCon()); 584 626 query.prepare(querystr); 585 627 586 628 if (query.exec() && query.next()) 587 629 { 588 channelname = query.value(0).toString();630 m_selectedChannelName = query.value(0).toString(); 589 631 } 590 591 QStringList buttons;592 buttons.append(tr("Cancel"));593 buttons.append(tr("Download all icons.."));594 buttons.append(tr("Rescan for missing icons.."));595 if (!channelname.isEmpty())596 buttons.append(tr("Download icon for ") + channelname);597 598 int val = MythPopupBox::ShowButtonPopup(gContext->GetMainWindow(),599 "", "Channel Icon Import", buttons, kDialogCodeButton2);600 601 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();602 603 ImportIconsWizard *iconwizard;604 if (val == kDialogCodeButton0) // Cancel pressed605 return;606 else if (val == kDialogCodeButton1) // Import all icons pressed607 iconwizard = new ImportIconsWizard(mainStack, false);608 else if (val == kDialogCodeButton2) // Rescan for missing pressed609 iconwizard = new ImportIconsWizard(mainStack, true);610 else if (val == kDialogCodeButton3) // Import a single channel icon611 iconwizard = new ImportIconsWizard(mainStack, true, channelname);612 else613 return;614 615 if (iconwizard->Create())616 {617 connect(iconwizard, SIGNAL(Exiting()), SLOT(fillList()));618 mainStack->AddScreen(iconwizard);619 }620 else621 delete iconwizard;622 632 } 623 633 624 634 void ChannelEditor::customEvent(QEvent *event) … … 635 645 { 636 646 switch (buttonnum) 637 647 { 638 case 0 : 648 case 0 : // Edit Channel 639 649 edit(m_channelList->GetItemCurrent()); 640 650 break; 641 case 1 : 642 del ();651 case 1 : // Delete single channel 652 deleteChannelsMenu(); 643 653 break; 654 case 2 : // Download specific icon 655 channelIconDownload(true, m_selectedChannelName); 656 break; 657 case 3 : // Download missing icons 658 channelIconDownload(true, ""); 659 break; 660 case 4 : // Download all icons 661 channelIconDownload(false, ""); 662 break; 663 case 5 : // Delete channels from source 664 m_selectedChannelName = ""; 665 deleteChannelsMenu(); 666 break; 644 667 } 645 668 } 669 else if (resultid == "deletechannelsmenu") 670 { 671 switch (buttonnum) 672 { 673 case 0 : // Confirm channel(s) delete 674 deleteChannels(); 675 break; 676 case 1 : // Cancel channel(s) deleteChannels 677 m_selectedChannelName = ""; 678 break; 679 } 680 } 646 681 } 647 682 } -
mythtv/programs/mythtv-setup/channeleditor.h
4 4 #include "mythscreentype.h" 5 5 6 6 #include "settings.h" 7 #include "importicons.h" 7 8 8 9 class MythUIButton; 9 10 class MythUIButtonList; … … 22 23 23 24 protected slots: 24 25 void menu(); 25 void del();26 26 void edit(MythUIButtonListItem *item); 27 27 void scan(void); 28 28 void transportEditor(void); 29 void channelIconImport(void); 29 void channelIconDownload(bool refresh, const QString &channelname); 30 void GetSelectedChannelName(int chanid); 31 void deleteChannelsMenu(void); 30 32 void deleteChannels(void); 31 33 void setSortMode(MythUIButtonListItem *item); 32 34 void setSourceID(MythUIButtonListItem *item); … … 47 49 48 50 MythUIButtonList *m_channelList; 49 51 MythUIButtonList *m_sourceList; 52 53 bool m_iconWizardRunning; 54 QString m_selectedChannelName; 55 ImportIconsWizard *iconWizard; 50 56 }; 51 57 52 58 class ChannelID; -
mythtv/programs/mythtv-setup/importicons.cpp
35 35 m_popupStack = GetMythMainWindow()->GetStack("popup stack"); 36 36 m_progressDialog = NULL; 37 37 38 m_closeDialog = false; 39 38 40 m_tmpDir = QDir(QString("%1/icontmp").arg(GetConfDir())); 39 41 40 42 if (!m_tmpDir.exists()) … … 230 232 } 231 233 m_strChannelDir += "/"; 232 234 233 bool closeDialog = false;234 235 235 QString querystring("SELECT chanid, name, xmltvid, callsign," 236 236 "dtv_multiplex.transportid, atsc_major_chan, " 237 237 "atsc_minor_chan, dtv_multiplex.networkid, " … … 332 332 m_progressDialog = NULL; 333 333 } 334 334 335 while (! closeDialog && (m_iter != m_listEntries.end()))335 while (!m_closeDialog && (m_iter != m_listEntries.end())) 336 336 { 337 337 QString message = QString("Downloading %1 / %2 : ").arg(m_nCount+1) 338 338 .arg(m_listEntries.size()) + (*m_iter).strName; … … 360 360 m_progressDialog = NULL; 361 361 } 362 362 363 if (m_missingEntries.size() == 0 || closeDialog)363 if (m_missingEntries.size() == 0 || m_closeDialog) 364 364 return false; 365 365 366 366 if (m_nMaxCount > 0) … … 720 720 } 721 721 } 722 722 723 void ImportIconsWizard::Close() 724 { 725 m_closeDialog = true; 726 } 727 723 728 void ImportIconsWizard::customEvent(QEvent *event) 724 729 { 725 730 if (event->type() == kMythDialogBoxCompletionEventType) -
mythtv/programs/mythtv-setup/importicons.h
39 39 bool Create(void); 40 40 // bool keyPressEvent(QKeyEvent *); 41 41 void customEvent(QEvent *event); 42 void Close(void); 42 43 43 44 struct SearchEntry //! search entry results 44 45 { … … 171 172 172 173 void startDialog(); 173 174 175 bool m_closeDialog; //!< Set to true when we want dialog to close 176 174 177 MythScreenStack *m_popupStack; 175 178 MythUIProgressDialog *m_progressDialog; 176 179 -
mythtv/themes/default/config-ui.xml
124 124 <position>210,430</position> 125 125 </buttonlist> 126 126 127 <button name="delete" from="basebutton">128 <position>620,427</position>129 <value>Delete</value>130 </button>131 132 127 <textarea name="nochannumlabel" from="basetextarea"> 133 128 <area>70,496,500,60</area> 134 129 <value>Hide Channels without channel number.</value> … … 143 138 <value>Channel Scan</value> 144 139 </button> 145 140 146 <button name="importicons" from="basewidebutton">147 <position>325,540</position>148 <value>Icon Download</value>149 </button>150 151 141 <button name="edittransport" from="basewidebutton"> 152 142 <position>585,540</position> 153 143 <value>Edit Transports</value>