Ticket #12: 00-12-channeleditor-dialogs.2.patch
File 00-12-channeleditor-dialogs.2.patch, 20.0 KB (added by , 17 years ago) |
---|
-
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> -
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_dialogIsRunning = 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_dialogIsRunning) 245 { 246 iconWizard->Cancel(); 247 m_dialogIsRunning = false; 248 } 249 else 250 handled = false; 251 } 241 252 else 242 253 handled = false; 243 254 } … … 250 261 251 262 void ChannelEditor::fillList(void) 252 263 { 264 m_dialogIsRunning = false; 253 265 QString currentValue = m_channelList->GetValue(); 254 266 uint currentIndex = qMax(m_channelList->GetCurrentPos(), 0); 255 267 m_channelList->Reset(); … … 399 411 } 400 412 } 401 413 402 void ChannelEditor::deleteChannels (void)414 void ChannelEditor::deleteChannelsMenu(void) 403 415 { 404 const QString currentLabel = m_sourceList->GetValue(); 416 QString chan_msg; 417 418 if (!m_selectedChannelName.isEmpty()) 419 { 420 chan_msg = tr("Are you sure you would like to delete channel %1?") 421 .arg(m_selectedChannelName); 422 } 423 else if (m_sourceFilter == FILTER_ALL) 424 { 425 chan_msg = tr("Are you sure you would like to delete ALL channels?"); 426 } 427 else if (m_sourceFilter == FILTER_UNASSIGNED) 428 { 429 chan_msg = tr("Are you sure you would like to delete all unassigned channels?"); 430 } 431 else 432 { 433 chan_msg = tr("Are you sure you would like to delete the channels on %1?") 434 .arg(m_sourceList->GetValue()); 435 } 405 436 406 bool del_all = m_sourceFilter == FILTER_ALL; 407 bool del_nul = m_sourceFilter == FILTER_UNASSIGNED; 437 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); 438 MythDialogBox *delChanMenu = new MythDialogBox(chan_msg, popupStack, "deletechannelsmenu"); 439 if (delChanMenu->Create()) 440 { 441 delChanMenu->SetReturnEvent(this, "deletechannelsmenu"); 442 443 delChanMenu->AddButton(tr("Yes, delete the channel(s)")); 444 delChanMenu->AddButton(tr("No, don't")); 445 446 popupStack->AddScreen(delChanMenu); 447 } 448 else 449 delete delChanMenu; 450 } 408 451 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 452 void ChannelEditor::deleteChannels(void) 453 { 424 454 MSqlQuery query(MSqlQuery::InitCon()); 425 if ( del_all)455 if (!m_selectedChannelName.isEmpty()) 426 456 { 457 MythUIButtonListItem *item = m_channelList->GetItemCurrent(); 458 if (!item) 459 return; 460 m_id = item->GetData().toInt(); 461 462 query.prepare("DELETE FROM channel WHERE chanid = :CHID ;"); 463 query.bindValue(":CHID", m_id); 464 } 465 else if (m_sourceFilter == FILTER_ALL) 466 { 427 467 query.prepare("TRUNCATE TABLE channel"); 428 468 } 429 else if ( del_nul)469 else if (m_sourceFilter == FILTER_UNASSIGNED) 430 470 { 431 471 query.prepare("SELECT sourceid " 432 472 "FROM videosource " … … 463 503 if (!query.exec()) 464 504 MythDB::DBError("ChannelEditor Delete Channels", query); 465 505 506 m_selectedChannelName = ""; 507 466 508 fillList(); 467 509 } 468 510 … … 478 520 fillList(); 479 521 } 480 522 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 523 void ChannelEditor::menu() 509 524 { 510 525 MythUIButtonListItem *item = m_channelList->GetItemCurrent(); … … 517 532 edit(item); 518 533 else 519 534 { 535 GetSelectedChannelName(m_id); 536 520 537 QString label = tr("Channel Options"); 521 538 522 539 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); … … 527 544 { 528 545 menu->SetReturnEvent(this, "channelopts"); 529 546 530 menu->AddButton(tr("Edit")); 531 menu->AddButton(tr("Delete")); 547 menu->AddButton(tr("Edit channel %1").arg(m_selectedChannelName)); 548 menu->AddButton(tr("Delete channel %1").arg(m_selectedChannelName)); 549 menu->AddButton(tr("Download channel icon for %1").arg(m_selectedChannelName)); 550 QString filter = ""; 551 if (m_sourceFilter == FILTER_ALL) 552 filter = "ALL"; 553 else if (m_sourceFilter == FILTER_UNASSIGNED) 554 filter = "UNASSIGNED"; 555 else 556 filter = m_sourceList->GetValue(); 532 557 558 menu->AddButton(tr("Rescan for missing channel icons")); 559 menu->AddButton(tr("Download all channel icons")); 560 561 menu->AddButton(tr("Delete %1 channels").arg(filter)); 562 533 563 popupStack->AddScreen(menu); 534 564 } 535 565 else … … 556 586 557 587 void ChannelEditor::transportEditor(void) 558 588 { 559 TransportListEditor *editor = new TransportListEditor(m_sourceFilter); 560 editor->exec(); 561 editor->deleteLater(); 589 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 562 590 591 TransportListEditor *transportedit = new TransportListEditor(mainStack, m_sourceFilter); 592 593 if (transportedit->Create()) 594 mainStack->AddScreen(transportedit); 595 else 596 delete transportedit; 597 563 598 fillList(); 564 599 } 565 600 566 void ChannelEditor::channelIcon Import(void)601 void ChannelEditor::channelIconDownload(bool refresh, const QString &channelname) 567 602 { 568 if (m_channelList->GetCount() == 0) 603 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 604 605 iconWizard = new ImportIconsWizard(mainStack, refresh, channelname); 606 607 if (iconWizard->Create()) 569 608 { 570 ShowOkPopup(tr("Add some channels first!")); 609 m_dialogIsRunning = true; 610 connect(iconWizard, SIGNAL(Exiting()), SLOT(fillList())); 611 iconWizard->Run(); 612 } 613 else 614 delete iconWizard; 615 616 m_selectedChannelName = ""; 617 } 618 619 /** 620 * \brief Get selected channel name from database. 621 */ 622 void ChannelEditor::GetSelectedChannelName(int chanid) 623 { 624 if (chanid == 0) 625 { // If no channel selected 626 m_selectedChannelName = ""; 571 627 return; 572 628 } 573 629 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 630 QString querystr = QString("SELECT channel.name FROM channel " 581 "WHERE chanid='%1'").arg(chan nelID);582 QString channelname;631 "WHERE chanid='%1'").arg(chanid); 632 583 633 MSqlQuery query(MSqlQuery::InitCon()); 584 634 query.prepare(querystr); 585 635 586 636 if (query.exec() && query.next()) 587 637 { 588 channelname = query.value(0).toString();638 m_selectedChannelName = query.value(0).toString(); 589 639 } 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 640 } 623 641 624 642 void ChannelEditor::customEvent(QEvent *event) … … 635 653 { 636 654 switch (buttonnum) 637 655 { 638 case 0 : 656 case 0 : // Edit Channel 639 657 edit(m_channelList->GetItemCurrent()); 640 658 break; 641 case 1 : 642 del ();659 case 1 : // Delete single channel 660 deleteChannelsMenu(); 643 661 break; 662 case 2 : // Download specific icon 663 channelIconDownload(false, m_selectedChannelName); 664 break; 665 case 3 : // Download missing icons 666 channelIconDownload(true, ""); 667 break; 668 case 4 : // Download all icons 669 channelIconDownload(false, ""); 670 break; 671 case 5 : // Delete channels from source 672 m_selectedChannelName = ""; 673 deleteChannelsMenu(); 674 break; 644 675 } 645 676 } 677 else if (resultid == "deletechannelsmenu") 678 { 679 switch (buttonnum) 680 { 681 case 0 : // Confirm channel(s) delete 682 deleteChannels(); 683 break; 684 case 1 : // Cancel channel(s) deleteChannels 685 m_selectedChannelName = ""; 686 break; 687 } 688 } 646 689 } 647 690 } -
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_dialogIsRunning; 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()) … … 92 94 connect(m_iconsList, SIGNAL(itemClicked(MythUIButtonListItem *)), 93 95 SLOT(menuSelection(MythUIButtonListItem *))); 94 96 95 if (!initialLoad(m_strChannelname))96 return false;97 98 97 BuildFocusList(); 99 98 100 99 enableControls(STATE_NORMAL); … … 150 149 m_missingIter++; 151 150 152 151 if (!doLoad()) 153 Close();152 return; 154 153 } 155 154 156 155 void ImportIconsWizard::menuSelection(MythUIButtonListItem *item) … … 197 196 m_missingCount++; 198 197 m_missingIter++; 199 198 if (!doLoad()) 200 Close();199 return; 201 200 } 202 201 else 203 202 { … … 207 206 if (!m_strMatches.isEmpty()) 208 207 askSubmit(m_strMatches); 209 208 else 210 Close();209 return; 211 210 } 212 213 211 } 214 212 215 bool ImportIconsWizard::initialLoad(QString name)213 void ImportIconsWizard::Run(void) 216 214 { 217 215 QString dirpath = GetConfDir(); 218 216 QDir configDir(dirpath); … … 230 228 } 231 229 m_strChannelDir += "/"; 232 230 233 bool closeDialog = false;234 235 231 QString querystring("SELECT chanid, name, xmltvid, callsign," 236 232 "dtv_multiplex.transportid, atsc_major_chan, " 237 233 "atsc_minor_chan, dtv_multiplex.networkid, " … … 240 236 "FROM channel LEFT JOIN dtv_multiplex " 241 237 "ON channel.mplexid = dtv_multiplex.mplexid " 242 238 "WHERE "); 243 if (! name.isEmpty())244 querystring.append("name=\"" + name + "\"");239 if (!m_strChannelname.isEmpty()) 240 querystring.append("name=\"" + m_strChannelname + "\""); 245 241 else 246 242 querystring.append("channel.visible"); 247 243 querystring.append(" ORDER BY name"); … … 332 328 m_progressDialog = NULL; 333 329 } 334 330 335 while (! closeDialog && (m_iter != m_listEntries.end()))331 while (!m_closeDialog && (m_iter != m_listEntries.end())) 336 332 { 337 333 QString message = QString("Downloading %1 / %2 : ").arg(m_nCount+1) 338 334 .arg(m_listEntries.size()) + (*m_iter).strName; … … 360 356 m_progressDialog = NULL; 361 357 } 362 358 363 if (m_missingEntries.size() == 0 || closeDialog) 364 return false; 359 if (m_missingEntries.size() == 0 || m_closeDialog) 360 { 361 Close(); 362 return; 363 } 365 364 366 365 if (m_nMaxCount > 0) 367 366 { 368 367 m_missingIter = m_missingEntries.begin(); 368 369 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 370 mainStack->AddScreen(this); 371 369 372 if (!doLoad()) 370 return false;373 return; 371 374 } 372 else373 return false;374 375 return true;376 375 } 377 376 378 377 bool ImportIconsWizard::doLoad() … … 386 385 enableControls(STATE_DISABLED); 387 386 if (!m_strMatches.isEmpty()) 388 387 askSubmit(m_strMatches); 388 Close(); 389 389 return false; 390 390 } 391 391 else … … 720 720 } 721 721 } 722 722 723 void ImportIconsWizard::Cancel() 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
37 37 ~ImportIconsWizard(); 38 38 39 39 bool Create(void); 40 void Run(void); 40 41 // bool keyPressEvent(QKeyEvent *); 41 42 void customEvent(QEvent *event); 43 void Cancel(void); 42 44 43 45 struct SearchEntry //! search entry results 44 46 { … … 135 137 */ 136 138 bool checkAndDownload(const QString& url, const QString& localChanId); 137 139 138 /*! \brief attempt the inital load of the TV channel information139 * \return true if successful140 */141 bool initialLoad(QString name="");142 143 140 /*! \brief attempts to move the iteration on one/more than one 144 141 * \return true if we can go again or false if we can not 145 142 */ … … 171 168 172 169 void startDialog(); 173 170 171 bool m_closeDialog; //!< Set to true when we want dialog to close 172 174 173 MythScreenStack *m_popupStack; 175 174 MythUIProgressDialog *m_progressDialog; 176 175