Ticket #12: 00-channeleditor-dialogs.patch
| File 00-channeleditor-dialogs.patch, 10.2 KB (added by Matthew Wire <devel@…>, 3 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_currentChannelName = ""; 124 m_iconWizardRunning = false; 125 124 126 } 125 127 126 128 bool ChannelEditor::Create() … … 207 209 connect(m_channelList, SIGNAL(itemClicked(MythUIButtonListItem *)), 208 210 SLOT(edit(MythUIButtonListItem *))); 209 211 connect(scanButton, SIGNAL(Clicked()), SLOT(scan())); 210 connect(deleteButton, SIGNAL(Clicked()), SLOT(deleteChannels ()));212 connect(deleteButton, SIGNAL(Clicked()), SLOT(deleteChannelsMenu())); 211 213 212 214 fillList(); 213 215 … … 238 240 { 239 241 del(); 240 242 } 243 else if (action == "ESCAPE") 244 { 245 if (m_iconWizardRunning) 246 { 247 iconWizard->Close(); 248 m_iconWizardRunning = false; 249 } 250 else 251 handled = false; 252 } 241 253 else 242 254 handled = false; 243 255 } … … 374 386 } 375 387 } 376 388 377 void ChannelEditor::deleteChannels (void)389 void ChannelEditor::deleteChannelsMenu(void) 378 390 { 379 const QString currentLabel = m_sourceList->GetValue(); 391 QString chan_msg; 392 393 if (m_sourceFilter == FILTER_ALL) 394 { 395 chan_msg = tr("Are you sure you would like to delete ALL channels?"); 396 } 397 else if (m_sourceFilter == FILTER_UNASSIGNED) 398 { 399 chan_msg = tr("Are you sure you would like to delete all unassigned channels?"); 400 } 401 else 402 { 403 chan_msg = tr("Are you sure you would like to delete the channels on %1?") 404 .arg(m_sourceList->GetValue()); 405 } 380 406 381 bool del_all = m_sourceFilter == FILTER_ALL; 382 bool del_nul = m_sourceFilter == FILTER_UNASSIGNED; 407 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); 408 MythDialogBox *delChanMenu = new MythDialogBox(chan_msg, popupStack, "deletechannelsmenu"); 409 if (delChanMenu->Create()) 410 { 411 delChanMenu->SetReturnEvent(this, "deletechannelsmenu"); 412 413 delChanMenu->AddButton(tr("Yes, delete the channels")); 414 delChanMenu->AddButton(tr("No, don't")); 415 416 popupStack->AddScreen(delChanMenu); 417 } 418 else 419 delete delChanMenu; 420 } 383 421 384 QString chan_msg = 385 (del_all) ? tr("Are you sure you would like to delete ALL channels?") : 386 ((del_nul) ? 387 tr("Are you sure you would like to delete all unassigned channels?") : 388 tr("Are you sure you would like to delete the channels on %1?") 389 .arg(currentLabel)); 390 391 DialogCode val = MythPopupBox::Show2ButtonPopup( 392 gContext->GetMainWindow(), "", chan_msg, 393 tr("Yes, delete the channels"), 394 tr("No, don't"), kDialogCodeButton1); 395 396 if (kDialogCodeButton0 != val) 397 return; 398 422 void ChannelEditor::deleteChannels(void) 423 { 399 424 MSqlQuery query(MSqlQuery::InitCon()); 400 if ( del_all)425 if (m_sourceFilter == FILTER_ALL) 401 426 { 402 427 query.prepare("TRUNCATE TABLE channel"); 403 428 } 404 else if ( del_nul)429 else if (m_sourceFilter == FILTER_UNASSIGNED) 405 430 { 406 431 query.prepare("SELECT sourceid " 407 432 "FROM videosource " … … 554 579 // Get selected channel name from database 555 580 QString querystr = QString("SELECT channel.name FROM channel " 556 581 "WHERE chanid='%1'").arg(channelID); 557 QString channelname;582 558 583 MSqlQuery query(MSqlQuery::InitCon()); 559 584 query.prepare(querystr); 560 585 561 586 if (query.exec() && query.next()) 562 587 { 563 channelname = query.value(0).toString();588 m_currentChannelName = query.value(0).toString(); 564 589 } 565 590 566 QStringList buttons;567 buttons.append(tr("Cancel"));568 buttons.append(tr("Download all icons.."));569 buttons.append(tr("Rescan for missing icons.."));570 if ( !channelname.isEmpty())571 buttons.append(tr("Download icon for ") + channelname);591 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); 592 593 MythDialogBox *menuChanIcon = new MythDialogBox("Download Channel Icons", popupStack, "actionmenu"); 594 595 if (menuChanIcon->Create()) 596 popupStack->AddScreen(menuChanIcon); 572 597 573 int val = MythPopupBox::ShowButtonPopup(gContext->GetMainWindow(), 574 "", "Channel Icon Import", buttons, kDialogCodeButton2); 598 menuChanIcon->SetReturnEvent(this, "channelicons"); 575 599 600 menuChanIcon->AddButton(tr("Cancel")); 601 menuChanIcon->AddButton(tr("Download all icons..")); 602 menuChanIcon->AddButton(tr("Rescan for missing icons..")); 603 if (!m_currentChannelName.isEmpty()) 604 menuChanIcon->AddButton(tr("Download icon for ") + m_currentChannelName); 605 } 606 607 void ChannelEditor::channelIconDownload(bool refresh, const QString &channelname) 608 { 576 609 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 577 610 578 ImportIconsWizard *iconwizard; 579 if (val == kDialogCodeButton0) // Cancel pressed 580 return; 581 else if (val == kDialogCodeButton1) // Import all icons pressed 582 iconwizard = new ImportIconsWizard(mainStack, false); 583 else if (val == kDialogCodeButton2) // Rescan for missing pressed 584 iconwizard = new ImportIconsWizard(mainStack, true); 585 else if (val == kDialogCodeButton3) // Import a single channel icon 586 iconwizard = new ImportIconsWizard(mainStack, true, channelname); 587 else 588 return; 611 iconWizard = new ImportIconsWizard(mainStack, refresh, channelname); 612 m_iconWizardRunning = true; 589 613 590 if ( iconwizard->Create())614 if (!iconWizard->Create()) 591 615 { 592 connect(iconwizard, SIGNAL(Exiting()), SLOT(fillList()));593 mainStack->AddScreen(iconwizard);616 m_iconWizardRunning = false; 617 delete iconWizard; 594 618 } 595 else 596 delete iconwizard;619 620 m_currentChannelName = ""; 597 621 } 598 622 599 623 void ChannelEditor::customEvent(QEvent *event) … … 618 642 break; 619 643 } 620 644 } 645 else if (resultid == "deletechannelsmenu" && buttonnum == 0) 646 { 647 deleteChannels(); 648 } 649 else if (resultid == "channelicons") 650 { 651 switch (buttonnum) 652 { 653 case 0 : // Cancel 654 break; 655 case 1 : // Download all icons 656 channelIconDownload(false, ""); 657 break; 658 case 2 : // Download missing icons 659 channelIconDownload(true, ""); 660 break; 661 case 3 : // Download specific icon 662 channelIconDownload(true, m_currentChannelName); 663 break; 664 } 665 } 621 666 } 622 667 } -
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; … … 27 28 void scan(void); 28 29 void transportEditor(void); 29 30 void channelIconImport(void); 31 void channelIconDownload(bool refresh, const QString &channelname); 32 void deleteChannelsMenu(void); 30 33 void deleteChannels(void); 31 34 void setSortMode(MythUIButtonListItem *item); 32 35 void setSourceID(MythUIButtonListItem *item); … … 47 50 48 51 MythUIButtonList *m_channelList; 49 52 MythUIButtonList *m_sourceList; 53 54 bool m_iconWizardRunning; 55 QString m_currentChannelName; 56 ImportIconsWizard *iconWizard; 50 57 }; 51 58 52 59 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
