implement for cleaning all views in the tabs
clean the models when no active conference found
fix cleaning model and signalling views
+ saved_title = windowTitle();
+
#ifdef N810
tabWidget->setTabText(1,"Favs");
//tabWidget->setTabText(2,"Day");
#ifdef N810
tabWidget->setTabText(1,"Favs");
//tabWidget->setTabText(2,"Day");
fillAndShowConferenceHeader();
setWindowTitle(Conference::getById(confId).title());
fillAndShowConferenceHeader();
setWindowTitle(Conference::getById(confId).title());
- if(confCount==1) // don't have to show 'selectConference' widget, if there is only one conference in the DB
- selectConferenceWidget->hide();
- else
+ QList<Conference> confs = Conference::getAll();
+ QListIterator<Conference> i(confs);
+ while(i.hasNext())
- // have to fill comboBox with available conferences
- QList<Conference> confs = Conference::getAll();
- QListIterator<Conference> i(confs);
- while(i.hasNext())
- {
- Conference conf = i.next();
- selectConference->addItem(conf.title(),conf.id());
- }
- int idx = selectConference->findText(Conference::getById(Conference::activeConference()).title());
- selectConference->setCurrentIndex(idx);
+ Conference conf = i.next();
+ selectConference->addItem(conf.title(),conf.id());
+ int idx = selectConference->findText(Conference::getById(Conference::activeConference()).title());
+ selectConference->setCurrentIndex(idx);
connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int)));
connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int)));
+ conferenceChanged(idx);
int idx = selectConference->findText(conf.title());
selectConference->setCurrentIndex(idx);
int idx = selectConference->findText(conf.title());
selectConference->setCurrentIndex(idx);
- if(confCount>1)
- selectConferenceWidget->show();
+ selectConferenceWidget->show();
conferenceChanged(idx);
}
conferenceChanged(idx);
}
if (idx == -1) {
// should not happen
qWarning() << __PRETTY_FUNCTION__ << "removed non-existent item:" << title;
if (idx == -1) {
// should not happen
qWarning() << __PRETTY_FUNCTION__ << "removed non-existent item:" << title;
+ // this happens when you remove the only conference (the list is not ptoperly inited in this case)
+ // now make sure that conferencet
+ if (selectConference->count() > 0) {
+ selectConference->setCurrentIndex(0);
+ conferenceChanged(0);
+ } else {
+ conferenceChanged(-1);
+ }
} else {
// will it signal "changed"?
selectConference->removeItem(idx);
} else {
// will it signal "changed"?
selectConference->removeItem(idx);
nowTabContainer->updateTreeView(QDate::currentDate());
}
nowTabContainer->updateTreeView(QDate::currentDate());
}
+void MainWindow::unsetConference()
+{
+ dayTabContainer->clearModel();
+ tracksTabContainer->clearModel();
+ roomsTabContainer->clearModel();
+ favsTabContainer->clearModel();
+ searchTabContainer->clearModel();
+ searchTabContainer->searchAgainClicked();
+ nowTabContainer->clearModel();
+
+ conferenceHeader->hide();
+ setWindowTitle(saved_title);
+}
+
void MainWindow::conferenceChanged(int aIndex)
{
void MainWindow::conferenceChanged(int aIndex)
{
- Conference::getById(Conference::activeConference()).update("active",0);
- Conference::getById(selectConference->itemData(aIndex).toInt()).update("active",1);
+ if (aIndex < 0) {
+ // no conferences left? reset all views
+ unsetConference();
+ return;
+ }
+
+ try {
+ Conference::getById(Conference::activeConference()).update("active",0);
+ Conference::getById(selectConference->itemData(aIndex).toInt()).update("active",1);
+ } catch (OrmException& e) {
+ // cannon set an active conference
+ unsetConference();
+ return;
+ }
initTabs();
fillAndShowConferenceHeader();
initTabs();
fillAndShowConferenceHeader();
private:
void fillAndShowConferenceHeader();
void initTabs();
private:
void fillAndShowConferenceHeader();
void initTabs();
+ void unsetConference();
+
+ QString saved_title;
};
#endif /* MAINWINDOW_H */
};
#endif /* MAINWINDOW_H */
void TabContainer::updateTreeView(const QDate &aDate)
{
void TabContainer::updateTreeView(const QDate &aDate)
{
+ int active_id = Conference::activeConference();
- loadEvents( aDate, Conference::activeConference() );
- treeView->reset();
+ if (active_id > 0) {
+ loadEvents(aDate, active_id);
+ } else {
+ static_cast<EventModel*>(treeView->model())->clearModel();
+ }
}
void TabContainer::itemClicked(const QModelIndex &aIndex)
}
void TabContainer::itemClicked(const QModelIndex &aIndex)
dayNavigator->setDates(aStart, aEnd);
}
dayNavigator->setDates(aStart, aEnd);
}
+void TabContainer::clearModel()
+{
+ static_cast<EventModel*>(treeView->model())->clearModel();
+}
+
TabContainer(QWidget *aParent = NULL);
virtual ~TabContainer() {}
TabContainer(QWidget *aParent = NULL);
virtual ~TabContainer() {}
protected:
virtual void loadEvents( const QDate &aDate, const int aConferenceId )
{
protected:
virtual void loadEvents( const QDate &aDate, const int aConferenceId )
{
const QString EventModel::COMMA_SEPARATOR = ", ";
EventModel::EventModel()
const QString EventModel::COMMA_SEPARATOR = ", ";
EventModel::EventModel()
void EventModel::createTimeGroups()
{
void EventModel::createTimeGroups()
{
}
mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
}
mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
}
void EventModel::createTrackGroups() {
}
void EventModel::createTrackGroups() {
void EventModel::clearModel()
{
void EventModel::clearModel()
{
- for(int i = 0;i < mGroups.count();i++){
- QModelIndex idx = index(i, 0);
- Group group = mGroups[i];
- beginRemoveRows(idx, 0, group.mChildCount - 1);
- /*bool ok =*/ removeRows(0, group.mChildCount, idx);
- endRemoveRows();
- //qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok;
- }
+ qDebug() << __PRETTY_FUNCTION__ << this << mEvents.count();
+ mGroups.clear();
+ mParents.clear();
+
+ reset();
}
void EventModel::loadEvents(const QDate &aDate, int aConferenceId)
}
void EventModel::loadEvents(const QDate &aDate, int aConferenceId)
void loadNowEvents(int aConferenceId); // loads Now events from the DB
void loadEventsByRoom(const QDate &aDate, int aConferenceId);
void loadConflictEvents(int aEventId, int aConferenceId); // loads events in conflict
void loadNowEvents(int aConferenceId); // loads Now events from the DB
void loadEventsByRoom(const QDate &aDate, int aConferenceId);
void loadConflictEvents(int aEventId, int aConferenceId); // loads events in conflict
void createTimeGroups();
void createTrackGroups();
void createTrackGroupsNew();
void createTimeGroups();
void createTrackGroups();
void createTrackGroupsNew();
void createRoomGroups();
public slots:
void createRoomGroups();
public slots: