Ticket #5875: mythui_mythweather.4.diff
File mythui_mythweather.4.diff, 10.2 KB (added by , 15 years ago) |
---|
-
mythweather/mythweather/weather.cpp
24 24 m_paused = false; 25 25 26 26 m_firstRun = true; 27 m_firstSetup = true; 27 28 28 29 if (!srcMan) 29 30 { … … 94 95 m_pauseText->Hide(); 95 96 } 96 97 97 setupScreens();98 99 98 return true; 100 99 } 101 100 … … 105 104 m_screens.clear(); 106 105 // it points to an element of screens, which was just deleted; 107 106 m_currScreen = NULL; 107 108 // Refresh sources 109 m_srcMan->clearSources(); 110 m_srcMan->findScriptsDB(); 111 m_srcMan->setupSources(); 108 112 109 113 MSqlQuery db(MSqlQuery::InitCon()); 110 114 QString query = … … 120 124 121 125 if (!db.size()) 122 126 { 123 m_srcMan->clearSources(); 124 m_srcMan->findScripts(); 127 if (m_firstSetup) 128 { 129 // If no screens exist, run the setup 130 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 125 131 126 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 132 ScreenSetup *ssetup = new ScreenSetup(mainStack, "weatherscreensetup", 133 m_srcMan); 127 134 128 ScreenSetup *ssetup = new ScreenSetup(mainStack, "weatherscreensetup", 129 m_srcMan); 135 connect(ssetup, SIGNAL(Exiting()), this, SLOT(setupScreens())); 130 136 131 if (ssetup->Create()) 132 mainStack->AddScreen(ssetup); 133 134 m_srcMan->clearSources(); 135 m_srcMan->findScriptsDB(); 136 m_srcMan->setupSources(); 137 m_srcMan->startTimers(); 138 m_srcMan->doUpdate(); 137 if (ssetup->Create()) 138 { 139 mainStack->AddScreen(ssetup); 140 } 141 142 m_firstSetup = false; 143 } 144 else 145 { 146 Close(); 147 } 139 148 } 140 141 // re-execute 142 if (!db.exec()) 149 else 143 150 { 144 VERBOSE(VB_IMPORTANT, db.lastError().text()); 145 return; 146 } 151 while (db.next()) 152 { 153 int id = db.value(0).toInt(); 154 QString container = db.value(1).toString(); 155 units_t units = db.value(2).toUInt(); 156 uint draworder = db.value(3).toUInt(); 147 157 148 while (db.next()) 149 { 150 int id = db.value(0).toInt(); 151 QString container = db.value(1).toString(); 152 units_t units = db.value(2).toUInt(); 153 uint draworder = db.value(3).toUInt(); 158 ScreenListInfo *screenListInfo = m_allScreens[container]; 154 159 155 ScreenListInfo *screenListInfo = m_allScreens[container]; 160 WeatherScreen *ws = WeatherScreen::loadScreen(m_weatherStack, screenListInfo, id); 161 if (!ws->Create()) 162 continue; 156 163 157 WeatherScreen *ws = WeatherScreen::loadScreen(m_weatherStack, screenListInfo, id);158 if (!ws->Create())159 continue;160 161 ws->setUnits(units);162 ws->setInUse(true);163 m_screens.insert(draworder, ws);164 connect(ws, SIGNAL(screenReady(WeatherScreen *)), this,165 SLOT(screenReady(WeatherScreen *)));166 m_srcMan-> connectScreen(id, ws);164 ws->setUnits(units); 165 ws->setInUse(true); 166 m_screens.insert(draworder, ws); 167 connect(ws, SIGNAL(screenReady(WeatherScreen *)), this, 168 SLOT(screenReady(WeatherScreen *))); 169 m_srcMan->connectScreen(id, ws); 170 } 171 172 m_srcMan->startTimers(); 173 m_srcMan->doUpdate(); 167 174 } 168 175 } 169 176 … … 292 299 mainStack->AddScreen(ssetup); 293 300 294 301 m_firstRun = true; 295 m_srcMan->clearSources();296 m_srcMan->findScriptsDB();297 m_srcMan->setupSources();298 302 setupScreens(); 299 m_srcMan->startTimers();300 m_srcMan->doUpdate();301 303 } 302 304 303 305 void Weather::cursorRight() 304 306 { 305 307 WeatherScreen *ws = nextScreen(); 306 if (ws ->canShowScreen())308 if (ws && ws->canShowScreen()) 307 309 { 308 310 hideScreen(); 309 311 showScreen(ws); … … 314 316 void Weather::cursorLeft() 315 317 { 316 318 WeatherScreen *ws = prevScreen(); 317 if (ws ->canShowScreen())319 if (ws && ws->canShowScreen()) 318 320 { 319 321 hideScreen(); 320 322 showScreen(ws); -
mythweather/mythweather/weather.h
29 29 30 30 bool UpdateData(); 31 31 32 public slots: 33 void setupScreens(); 34 32 35 private slots: 33 36 void update_timeout() {} 34 37 void nextpage_timeout(); … … 40 43 void screenReady(WeatherScreen *ws); 41 44 42 45 private: 43 void setupScreens();44 46 WeatherScreen *nextScreen(); 45 47 WeatherScreen *prevScreen(); 46 48 void showScreen(WeatherScreen *ws); … … 59 61 QTimer *m_nextpage_Timer; 60 62 61 63 bool m_gotDataHook; 64 65 bool m_firstSetup; 62 66 63 67 bool m_createdSrcMan; 64 68 SourceManager *m_srcMan; -
mythweather/mythweather/weatherSetup.cpp
497 497 498 498 menuPopup->SetReturnEvent(this, "options"); 499 499 500 menuPopup->AddButton(tr("Move Up"), selected);501 menuPopup->AddButton(tr("Move Down"), selected);502 menuPopup->AddButton(tr("Remove"), selected);503 menuPopup->AddButton(tr("Change Location"), selected);500 menuPopup->AddButton(tr("Move Up"), qVariantFromValue(selected)); 501 menuPopup->AddButton(tr("Move Down"), qVariantFromValue(selected)); 502 menuPopup->AddButton(tr("Remove"), qVariantFromValue(selected)); 503 menuPopup->AddButton(tr("Change Location"), qVariantFromValue(selected)); 504 504 if (si->hasUnits) 505 menuPopup->AddButton(tr("Change Units"), selected);506 menuPopup->AddButton(tr("Cancel"), selected);505 menuPopup->AddButton(tr("Change Units"), qVariantFromValue(selected)); 506 menuPopup->AddButton(tr("Cancel"), qVariantFromValue(selected)); 507 507 508 508 } 509 509 else if (GetFocusWidget() == m_inactiveList) … … 572 572 573 573 menuPopup->SetReturnEvent(this, "units"); 574 574 575 menuPopup->AddButton(tr("English Units"), si);576 menuPopup->AddButton(tr("SI Units"), si);575 menuPopup->AddButton(tr("English Units"), qVariantFromValue(si)); 576 menuPopup->AddButton(tr("SI Units"), qVariantFromValue(si)); 577 577 } 578 578 579 579 void ScreenSetup::deleteScreen() 580 580 { 581 582 581 if (m_activeList->GetItemCurrent()) 583 582 delete m_activeList->GetItemCurrent(); 584 583 … … 602 601 603 602 if (resultid == "options") 604 603 { 605 MythUIButtonListItem *item = (MythUIButtonListItem *)dce->GetResultData();604 MythUIButtonListItem *item = qVariantValue<MythUIButtonListItem *>(dce->GetData()); 606 605 ScreenListInfo *si = (ScreenListInfo *) item->getData(); 607 606 608 607 if (buttonnum == 0) … … 629 628 } 630 629 else if (resultid == "units") 631 630 { 632 ScreenListInfo *si = (ScreenListInfo *)dce->GetResultData(); 633 if (buttonnum == 0) 631 if (buttonnum > -1) 634 632 { 635 si->units = ENG_UNITS; 633 ScreenListInfo *si = qVariantValue<ScreenListInfo *>(dce->GetData()); 634 if (buttonnum == 0) 635 { 636 si->units = ENG_UNITS; 637 } 638 else if (buttonnum == 1) 639 { 640 si->units = SI_UNITS; 641 } 642 doLocationDialog(si); 636 643 } 637 else if (buttonnum == 1)638 {639 si->units = SI_UNITS;640 }641 doLocationDialog(si);642 644 } 643 645 else if (resultid == "location") 644 646 { 645 ScreenListInfo *si = (ScreenListInfo *)dce->GetResultData();647 ScreenListInfo *si = qVariantValue<ScreenListInfo *>(dce->GetData()); 646 648 Q3DictIterator<TypeListInfo> it(si->types); 647 649 for (; it.current(); ++it) 648 650 { … … 807 809 808 810 void SourceSetup::updateSpinboxUpdate() 809 811 { 810 SourceListInfo *si = 811 (SourceListInfo *) m_sourceList->GetItemCurrent()->getData(); 812 si->update_timeout = m_updateSpinbox->GetItemCurrent()->text().toInt(); 812 if (m_sourceList->GetItemCurrent()) 813 { 814 SourceListInfo *si = 815 (SourceListInfo *) m_sourceList->GetItemCurrent()->getData(); 816 si->update_timeout = m_updateSpinbox->GetItemCurrent()->text().toInt(); 817 } 813 818 } 814 819 815 820 void SourceSetup::retrieveSpinboxUpdate() 816 821 { 817 SourceListInfo *si = 818 (SourceListInfo *) m_sourceList->GetItemCurrent()->getData(); 819 si->retrieve_timeout = m_retrieveSpinbox->GetItemCurrent()->text().toInt(); 822 if (m_sourceList->GetItemCurrent()) 823 { 824 SourceListInfo *si = 825 (SourceListInfo *) m_sourceList->GetItemCurrent()->getData(); 826 si->retrieve_timeout = m_retrieveSpinbox->GetItemCurrent()->text().toInt(); 827 } 820 828 } 821 829 822 830 void SourceSetup::sourceListItemSelected(MythUIButtonListItem *item) … … 998 1006 } 999 1007 1000 1008 DialogCompletionEvent *dce = 1001 new DialogCompletionEvent("location", 0, "", m_screenListInfo);1009 new DialogCompletionEvent("location", 0, "", qVariantFromValue(m_screenListInfo)); 1002 1010 QApplication::postEvent(m_retScreen, dce); 1003 1011 1004 1012 Close(); -
mythweather/mythweather/main.cpp
63 63 Weather *weather = new Weather(mainStack, "mythweather", srcMan); 64 64 65 65 if (weather->Create()) 66 { 66 67 mainStack->AddScreen(weather); 68 weather->setupScreens(); 69 } 67 70 } 68 71 69 72 int mythplugin_run() -
mythweather/mythweather/weatherUtils.h
38 38 bool multiLoc; 39 39 }; 40 40 41 Q_DECLARE_METATYPE(ScreenListInfo *); 42 41 43 typedef QMap<QString, ScreenListInfo *> ScreenListMap; 42 44 43 45 ScreenListMap loadScreens();