Ticket #9009: mythui_mythgame.diff
File mythui_mythgame.diff, 6.6 KB (added by , 14 years ago) |
---|
-
mythplugins/mythgame/mythgame/gamehandler.cpp
15 15 16 16 #define LOC_ERR QString("MythGame:GAMEHANDLER Error: ") 17 17 #define LOC QString("MythGame:GAMEHANDLER: ") 18 #include <mythprogressdialog.h> 18 19 19 20 static QList<GameHandler*> *handlers = NULL; 20 21 … … 393 394 int counter = 0; 394 395 MSqlQuery query(MSqlQuery::InitCon()); 395 396 396 MythProgressDialog *progressDlg = 397 new MythProgressDialog( 398 QObject::tr("Updating %1(%2) ROM database") 399 .arg(handler->SystemName()).arg(handler->GameType()), 400 m_GameMap.size()); 397 QString message = QObject::tr("Updating %1(%2) ROM database") 398 .arg(handler->SystemName()) 399 .arg(handler->GameType()); 401 400 401 CreateProgress(message); 402 403 if (m_progressDlg) 404 m_progressDlg->SetTotal(m_GameMap.size()); 405 402 406 GameScanMap::Iterator iter; 403 407 404 408 QString GameName, Genre, Country, CRC32, Year, Plot; … … 490 494 promptForRemoval( iter.value().Rom() , iter.value().RomPath() ); 491 495 } 492 496 493 progressDlg->setProgress(++counter); 497 if (m_progressDlg) 498 m_progressDlg->SetProgress(++counter); 494 499 } 495 500 496 progressDlg->Close(); 497 progressDlg->deleteLater(); 501 if (m_progressDlg) 502 { 503 m_progressDlg->Close(); 504 m_progressDlg = NULL; 498 505 } 506 } 499 507 500 508 void GameHandler::VerifyGameDB(GameHandler *handler) 501 509 { … … 512 520 MythDB::DBError("GameHandler::VerifyGameDB - " 513 521 "select", query); 514 522 515 MythProgressDialog *progressDlg = new MythProgressDialog( 516 QObject::tr("Verifying %1 files").arg(handler->SystemName()), 517 query.size()); 523 QString message = QObject::tr("Verifying %1 files") 524 .arg(handler->SystemName()); 518 525 526 CreateProgress(message); 527 528 if (m_progressDlg) 529 m_progressDlg->SetTotal(query.size()); 530 519 531 // For every file we know about, check to see if it still exists. 520 532 if (query.isActive() && query.size() > 0) 521 533 { … … 539 551 GameName,RomPath); 540 552 } 541 553 } 542 progressDlg->setProgress(++counter); 554 if (m_progressDlg) 555 m_progressDlg->SetProgress(++counter); 543 556 } 544 557 } 545 progressDlg->Close(); 546 progressDlg->deleteLater(); 558 559 if (m_progressDlg) 560 { 561 m_progressDlg->Close(); 562 m_progressDlg = NULL; 547 563 } 564 } 548 565 549 566 // Recurse through the directory and gather a count on how many files there are to process. 550 567 // This is used for the progressbar info. … … 632 649 } 633 650 634 651 void GameHandler::buildFileList(QString directory, GameHandler *handler, 635 MythProgressDialog *pdial,int* filecount)652 int* filecount) 636 653 { 637 654 QDir RomDir(directory); 638 655 … … 657 674 658 675 if (Info.isDir()) 659 676 { 660 buildFileList(Info.filePath(), handler, pdial,filecount);677 buildFileList(Info.filePath(), handler, filecount); 661 678 continue; 662 679 } 663 680 else … … 688 705 .arg(handler->SystemName()).arg(RomName)); 689 706 690 707 *filecount = *filecount + 1; 691 pdial->setProgress(*filecount); 708 if (m_progressDlg) 709 m_progressDlg->SetProgress(*filecount); 692 710 693 711 } 694 712 } … … 715 733 else 716 734 maxcount = 100; 717 735 718 MythProgressDialog *pdial = new MythProgressDialog(719 QObject::tr("Scanning for %1 game(s)...").arg(handler->SystemName()),720 maxcount);721 pdial->setProgress(0);722 723 736 if (handler->GameType() == "PC") 724 737 { 738 // Busy Dialog here? 725 739 m_GameMap[handler->SystemCmdLine()] = 726 740 GameScan(handler->SystemCmdLine(), 727 741 handler->SystemCmdLine(), … … 730 744 handler->SystemCmdLine().left(handler->SystemCmdLine().lastIndexOf(QRegExp("/")))); 731 745 732 746 733 pdial->setProgress(maxcount);747 m_progressDlg->SetProgress(maxcount); 734 748 VERBOSE(VB_GENERAL, LOC + QString("PC Game %1").arg(handler->SystemName())); 735 736 749 } 737 750 else 738 751 { 752 QString message = QObject::tr("Scanning for %1 game(s)...") 753 .arg(handler->SystemName()); 754 CreateProgress(message); 755 756 if (m_progressDlg) 757 m_progressDlg->SetTotal(maxcount); 758 739 759 int filecount = 0; 740 buildFileList(handler->SystemRomPath(), handler, pdial, &filecount); 760 buildFileList(handler->SystemRomPath(), handler, &filecount); 761 762 if (m_progressDlg) 763 { 764 m_progressDlg->Close(); 765 m_progressDlg = NULL; 741 766 } 767 } 742 768 743 769 VerifyGameDB(handler); 744 770 … … 754 780 } 755 781 else 756 782 handler->setRebuild(false); 757 758 759 pdial->Close();760 pdial->deleteLater();761 783 } 762 784 763 785 void GameHandler::processAllGames(void) … … 935 957 handlers->append(handler); 936 958 } 937 959 960 void GameHandler::CreateProgress(QString message) 961 { 962 if (m_progressDlg) 963 return; 964 965 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); 966 967 m_progressDlg = new MythUIProgressDialog(message, popupStack, 968 "gameprogress"); 969 970 if (m_progressDlg->Create()) 971 { 972 popupStack->AddScreen(m_progressDlg, false); 973 } 974 else 975 { 976 delete m_progressDlg; 977 m_progressDlg = NULL; 978 } 979 } -
mythplugins/mythgame/mythgame/gamehandler.h
10 10 #include "rom_metadata.h" 11 11 #include "rominfo.h" 12 12 13 class MythUIProgressDialog; 13 14 class MythMainWindow; 14 15 class GameHandler; 15 16 class QObject; … … 79 80 80 81 static int buildFileCount(QString directory, GameHandler *handler); 81 82 void buildFileList(QString directory, GameHandler *handler, 82 MythProgressDialog *pdial,int* filecount);83 int* filecount); 83 84 84 85 void processGames(GameHandler *); 85 86 static void processAllGames(void); … … 124 125 bool m_KeepAll; 125 126 126 127 private: 128 void CreateProgress(QString message); 129 127 130 static GameHandler *newInstance; 131 MythUIProgressDialog *m_progressDlg; 128 132 }; 129 133 130 134 #endif