- Timestamp:
- 04/15/10 14:50:23 (13 years ago)
- Branches:
- master, qt5
- Children:
- 2eda137
- Parents:
- d97bcab
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gui/mainwindow.cpp
rd97bcab r04acaf9 51 51 setupUi(this); 52 52 53 saved_title = windowTitle(); 54 53 55 #ifdef N810 54 56 tabWidget->setTabText(1,"Favs"); … … 99 101 setWindowTitle(Conference::getById(confId).title()); 100 102 101 if(confCount==1) // don't have to show 'selectConference' widget, if there is only one conference in the DB102 selectConferenceWidget->hide();103 else103 QList<Conference> confs = Conference::getAll(); 104 QListIterator<Conference> i(confs); 105 while(i.hasNext()) 104 106 { 105 // have to fill comboBox with available conferences 106 QList<Conference> confs = Conference::getAll(); 107 QListIterator<Conference> i(confs); 108 while(i.hasNext()) 109 { 110 Conference conf = i.next(); 111 selectConference->addItem(conf.title(),conf.id()); 112 } 113 int idx = selectConference->findText(Conference::getById(Conference::activeConference()).title()); 114 selectConference->setCurrentIndex(idx); 107 Conference conf = i.next(); 108 selectConference->addItem(conf.title(),conf.id()); 115 109 } 110 int idx = selectConference->findText(Conference::getById(Conference::activeConference()).title()); 111 selectConference->setCurrentIndex(idx); 116 112 connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int))); 113 conferenceChanged(idx); 117 114 } 118 115 else … … 155 152 selectConference->setCurrentIndex(idx); 156 153 157 if(confCount>1) 158 selectConferenceWidget->show(); 154 selectConferenceWidget->show(); 159 155 160 156 conferenceChanged(idx); … … 169 165 // should not happen 170 166 qWarning() << __PRETTY_FUNCTION__ << "removed non-existent item:" << title; 167 // this happens when you remove the only conference (the list is not ptoperly inited in this case) 168 // now make sure that conferencet 169 if (selectConference->count() > 0) { 170 selectConference->setCurrentIndex(0); 171 conferenceChanged(0); 172 } else { 173 conferenceChanged(-1); 174 } 171 175 } else { 172 176 // will it signal "changed"? … … 238 242 } 239 243 244 void MainWindow::unsetConference() 245 { 246 dayTabContainer->clearModel(); 247 tracksTabContainer->clearModel(); 248 roomsTabContainer->clearModel(); 249 favsTabContainer->clearModel(); 250 searchTabContainer->clearModel(); 251 searchTabContainer->searchAgainClicked(); 252 nowTabContainer->clearModel(); 253 254 conferenceHeader->hide(); 255 setWindowTitle(saved_title); 256 } 257 240 258 void MainWindow::conferenceChanged(int aIndex) 241 259 { 242 Conference::getById(Conference::activeConference()).update("active",0); 243 Conference::getById(selectConference->itemData(aIndex).toInt()).update("active",1); 260 if (aIndex < 0) { 261 // no conferences left? reset all views 262 unsetConference(); 263 return; 264 } 265 266 try { 267 Conference::getById(Conference::activeConference()).update("active",0); 268 Conference::getById(selectConference->itemData(aIndex).toInt()).update("active",1); 269 } catch (OrmException& e) { 270 // cannon set an active conference 271 unsetConference(); 272 return; 273 } 244 274 245 275 initTabs(); -
src/gui/mainwindow.h
rd97bcab r04acaf9 43 43 void fillAndShowConferenceHeader(); 44 44 void initTabs(); 45 void unsetConference(); 46 47 QString saved_title; 45 48 }; 46 49 -
src/gui/tabcontainer.cpp
rd97bcab r04acaf9 56 56 void TabContainer::updateTreeView(const QDate &aDate) 57 57 { 58 int active_id = Conference::activeConference(); 58 59 dayNavigator->show(); 59 loadEvents( aDate, Conference::activeConference() ); 60 treeView->reset(); 60 if (active_id > 0) { 61 loadEvents(aDate, active_id); 62 } else { 63 static_cast<EventModel*>(treeView->model())->clearModel(); 64 } 61 65 } 62 66 … … 133 137 } 134 138 139 void TabContainer::clearModel() 140 { 141 static_cast<EventModel*>(treeView->model())->clearModel(); 142 } 143 -
src/gui/tabcontainer.h
rd97bcab r04acaf9 36 36 virtual ~TabContainer() {} 37 37 38 void clearModel(); 38 39 protected: 39 40 virtual void loadEvents( const QDate &aDate, const int aConferenceId ) -
src/mvc/eventmodel.cpp
rd97bcab r04acaf9 25 25 26 26 EventModel::EventModel() 27 { 28 mEvents.clear(); 29 } 27 { } 30 28 31 29 void EventModel::createTimeGroups() … … 63 61 64 62 mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex; 63 64 reset(); 65 65 } 66 66 … … 200 200 void EventModel::clearModel() 201 201 { 202 for(int i = 0;i < mGroups.count();i++){ 203 QModelIndex idx = index(i, 0); 204 Group group = mGroups[i]; 205 beginRemoveRows(idx, 0, group.mChildCount - 1); 206 /*bool ok =*/ removeRows(0, group.mChildCount, idx); 207 endRemoveRows(); 208 //qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok; 209 } 202 qDebug() << __PRETTY_FUNCTION__ << this << mEvents.count(); 203 mGroups.clear(); 210 204 mEvents.clear(); 205 mParents.clear(); 206 207 reset(); 211 208 } 212 209 -
src/mvc/eventmodel.h
rd97bcab r04acaf9 42 42 void loadEventsByRoom(const QDate &aDate, int aConferenceId); 43 43 void loadConflictEvents(int aEventId, int aConferenceId); // loads events in conflict 44 void clearModel(); 44 45 45 46 private: … … 63 64 void createTrackGroups(); 64 65 void createTrackGroupsNew(); 65 void clearModel();66 66 void createRoomGroups(); 67 67
Note: See TracChangeset
for help on using the changeset viewer.