From 05afe5fb1267dff4b5ebbcc8c4c89571ebb08a73 Mon Sep 17 00:00:00 2001 From: pavelpa Date: Tue, 26 Jan 2010 19:17:47 +0000 Subject: [PATCH] implemented 'tab container' widget, which groups daynavigator with treeview - moved functionality from mainwindow to tabcontainer - TODO: 'search' tab not done yet --- src/app/app.pro | 2 +- src/app/main.cpp | 4 + src/gui/gui.pro | 3 + src/gui/mainwindow.cpp | 240 ++++++--------------------------------- src/gui/mainwindow.h | 10 -- src/gui/mainwindow.ui | 87 +++----------- src/gui/tabcontainer.cpp | 180 +++++++++++++++++++++++++++++ src/gui/tabcontainer.h | 48 ++++++++ src/gui/tabcontainer.ui | 80 +++++++++++++ src/sql/sqlengine.h | 6 +- 10 files changed, 370 insertions(+), 290 deletions(-) create mode 100644 src/gui/tabcontainer.cpp create mode 100644 src/gui/tabcontainer.h create mode 100644 src/gui/tabcontainer.ui diff --git a/src/app/app.pro b/src/app/app.pro index 6b1ea4c..67f6bab 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -6,7 +6,7 @@ QT += sql xml # module dependencies LIBS += -L$$DESTDIR -lgui -lmvc -lsql -INCLUDEPATH += ../gui +INCLUDEPATH += ../gui ../sql DEPENDPATH += . ../gui TARGETDEPS += $$DESTDIR/libmvc.a $$DESTDIR/libgui.a $$DESTDIR/libsql.a maemo { diff --git a/src/app/main.cpp b/src/app/main.cpp index 6711834..43728cb 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -5,6 +5,8 @@ #include #endif /* MAEMO */ +#include + int main(int argc, char *argv[]) { Q_INIT_RESOURCE(icons); @@ -13,6 +15,8 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); QApplication::setWindowIcon(QIcon(":/icons/fosdem.png")); + SqlEngine::initialize(); // creates DB connection + QWidget *window; #ifdef MAEMO // if the app is run with two cmd-line arguments diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 50def41..82a215e 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -28,6 +28,7 @@ FORMS += mainwindow.ui \ importschedulewidget.ui \ about.ui \ eventdialog.ui \ + tabcontainer.ui \ mapwindow.ui HEADERS += mainwindow.h \ @@ -35,6 +36,7 @@ HEADERS += mainwindow.h \ importschedulewidget.h \ eventdialog.h \ tabwidget.h \ + tabcontainer.h \ mapwindow.h SOURCES += mainwindow.cpp \ @@ -42,6 +44,7 @@ SOURCES += mainwindow.cpp \ importschedulewidget.cpp \ eventdialog.cpp \ tabwidget.cpp \ + tabcontainer.cpp \ mapwindow.cpp maemo { diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index d7d3fec..3a260f4 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include @@ -14,13 +14,14 @@ #include #include -#include #include "ui_about.h" -#include "eventdialog.h" +#include #include "daynavigatorwidget.h" #include "importschedulewidget.h" #include "mapwindow.h" +#include + MainWindow::MainWindow(int aEventId, QWidget *aParent) : QMainWindow(aParent) { @@ -29,7 +30,7 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent) // create "SQLITE" DB instance/connection // opens DB connection (needed for EventModel) mSqlEngine = new SqlEngine(this); - mSqlEngine->initialize(); + //mSqlEngine->initialize(); importScheduleWidget->setSqlEngine(mSqlEngine); // Sanity check for existence of any Conference in the DB @@ -48,37 +49,15 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent) setWindowTitle(confs[0].title()); } + dayTabContainer->setType(TabContainer::EContainerTypeDay); + favsTabContainer->setType(TabContainer::EContainerTypeFavs); + tracksTabContainer->setType(TabContainer::EContainerTypeTracks); + nowTabContainer->setType(TabContainer::EContainerTypeNow); + roomsTabContainer->setType(TabContainer::EContainerTypeRooms); + connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int))); - connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &))); - connect(trackDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTracksView(const QDate &))); - connect(favouriteDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateFavouritesView(const QDate &))); connect(searchDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateSearchView(const QDate &))); - connect(roomDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateRoomView(const QDate &))); - - // DAY EVENTS View - dayTreeView->setHeaderHidden(true); - dayTreeView->setRootIsDecorated(false); - dayTreeView->setIndentation(0); - dayTreeView->setAnimated(true); - dayTreeView->setModel(new EventModel()); - dayTreeView->setItemDelegate(new Delegate(dayTreeView)); - - // FAVOURITIES View - favTreeView->setHeaderHidden(true); - favTreeView->setRootIsDecorated(false); - favTreeView->setIndentation(0); - favTreeView->setAnimated(true); - favTreeView->setModel(new EventModel()); - favTreeView->setItemDelegate(new Delegate(favTreeView)); - - // TRACKS View - trackTreeView->setHeaderHidden(true); - trackTreeView->setRootIsDecorated(false); - trackTreeView->setIndentation(0); - trackTreeView->setAnimated(true); - trackTreeView->setModel(new EventModel()); - trackTreeView->setItemDelegate(new Delegate(trackTreeView)); // SEARCH EVENTS View searchTreeView->setHeaderHidden(true); @@ -88,80 +67,37 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent) searchTreeView->setModel(new EventModel()); searchTreeView->setItemDelegate(new Delegate(searchTreeView)); - // NOW View - nowTreeView->setHeaderHidden(true); - nowTreeView->setRootIsDecorated(false); - nowTreeView->setIndentation(0); - nowTreeView->setAnimated(true); - nowTreeView->setModel(new EventModel()); - nowTreeView->setItemDelegate(new Delegate(nowTreeView)); - - // NOW View refresh timer - QTimer *timer = new QTimer( this ); - connect( timer, SIGNAL(timeout()), SLOT(timerUpdateNowView()) ); - timer->start( 30000); // 30 seconds timer - - // ROOMS View - roomTreeView->setHeaderHidden(true); - roomTreeView->setRootIsDecorated(false); - roomTreeView->setIndentation(0); - roomTreeView->setAnimated(true); - roomTreeView->setModel(new EventModel()); - roomTreeView->setItemDelegate(new Delegate(roomTreeView)); - // event details have changed - connect(dayTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); - connect(favTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); - connect(trackTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); + connect(dayTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); + connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); + connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); + connect(roomsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); + connect(nowTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); + connect(searchTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); - connect(nowTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); - connect(roomTreeView, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); // event clicked - connect(dayTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); - connect(favTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); - connect(trackTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); connect(searchTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); - connect(nowTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); - connect(roomTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); - // request for map to be displayed - connect(dayTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); - connect(favTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); - connect(trackTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); - connect(searchTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); - connect(nowTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); - connect(roomTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); - // request for warning to be displayed - connect(dayTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &))); - connect(favTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &))); - connect(trackTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &))); - connect(searchTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &))); - connect(nowTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &))); - connect(roomTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &))); + // event search button clicked connect(searchButton, SIGNAL(clicked()), SLOT(searchClicked())); connect(searchAgainButton, SIGNAL(clicked()), SLOT(searchAgainClicked())); + // event conference map button clicked connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked())); // - connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(tabHasChanged(int))); connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp())); - if(!Conference::getAll().count()) // no conference(s) in the DB - { - dayNavigator->hide(); // hide DayNavigatorWidget - trackDayNavigator->hide(); - roomDayNavigator->hide(); - } - else + if(Conference::getAll().count()) // no conference(s) in the DB { QDate aStartDate = Conference::getById(AppSettings::confId()).start(); QDate aEndDate = Conference::getById(AppSettings::confId()).end(); - dayNavigator->setDates(aStartDate, aEndDate); - trackDayNavigator->setDates(aStartDate, aEndDate); - favouriteDayNavigator->setDates(aStartDate, aEndDate); searchDayNavigator->setDates(aStartDate, aEndDate); - roomDayNavigator->setDates(aStartDate, aEndDate); + // + dayTabContainer->setDates(aStartDate, aEndDate); + tracksTabContainer->setDates(aStartDate, aEndDate); + roomsTabContainer->setDates(aStartDate, aEndDate); + favsTabContainer->setDates(aStartDate, aEndDate); // conferenceTitle->setText(Conference::getById(AppSettings::confId()).title()); conferenceSubtitle->setText(Conference::getById(AppSettings::confId()).subtitle()); @@ -214,11 +150,12 @@ void MainWindow::scheduleImported(int aConfId) AppSettings::setConfId(confs[0].id()); // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates - QDate aStartDate = Conference::getById(AppSettings::confId()).start(); - QDate aEndDate = Conference::getById(AppSettings::confId()).end(); - dayNavigator->setDates(aStartDate, aEndDate); - trackDayNavigator->setDates(aStartDate, aEndDate); - roomDayNavigator->setDates(aStartDate, aEndDate); + QDate startDate = Conference::getById(AppSettings::confId()).start(); + QDate endDate = Conference::getById(AppSettings::confId()).end(); + dayTabContainer->setDates(startDate, endDate); + tracksTabContainer->setDates(startDate, endDate); + roomsTabContainer->setDates(startDate, endDate); + favsTabContainer->setDates(startDate, endDate); } } @@ -230,27 +167,6 @@ void MainWindow::aboutApp() dialog.exec(); } -void MainWindow::updateDayView(const QDate &aDate) -{ - static_cast(dayTreeView->model())->loadEvents(aDate,AppSettings::confId()); - dayTreeView->reset(); - dayNavigator->show(); -} - -void MainWindow::updateTracksView(const QDate &aDate) -{ - static_cast(trackTreeView->model())->loadEventsByTrack(aDate, AppSettings::confId()); - trackTreeView->reset(); - trackDayNavigator->show(); -} - -void MainWindow::updateFavouritesView(const QDate &aDate) -{ - static_cast(favTreeView->model())->loadFavEvents(aDate,AppSettings::confId()); - favTreeView->reset(); - favouriteDayNavigator->show(); -} - void MainWindow::updateSearchView(const QDate &aDate) { qDebug() << "MainWindow::updateSearchView(), aDate: " << aDate.toString() ; @@ -270,52 +186,6 @@ void MainWindow::updateSearchView(const QDate &aDate) } } -void MainWindow::updateNowView() -{ - EventModel *model = static_cast(nowTreeView->model()); - model->loadNowEvents(AppSettings::confId()); - nowTreeView->reset(); - nowTreeView->setAllExpanded(true); -} - -void MainWindow::updateRoomView(const QDate &aDate) -{ - static_cast(roomTreeView->model())->loadEventsByRoom(aDate, AppSettings::confId()); - roomTreeView->reset(); - roomDayNavigator->show(); -} - -void MainWindow::itemClicked(const QModelIndex &aIndex) -{ - // have to handle only events, not time-groups - if(!aIndex.parent().isValid()) // time-group - return; - - EventDialog dialog(static_cast(aIndex.internalPointer())->id(),this); - dialog.exec(); -} - -void MainWindow::displayMap(const QModelIndex &aIndex) -{ - Event *event = static_cast(aIndex.internalPointer()); - - // room names are stored in lower-case format - // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png" - QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room().toLower().remove(".")); - if(!QFile::exists(mapPath)) - mapPath = QString(":/maps/rooms/not-available.png"); - - QString roomName; - if(mapPath.contains("not-available", Qt::CaseInsensitive)) - roomName = QString("Map is not available: %1").arg(event->room()); - else - roomName = event->room(); - - QPixmap map(mapPath); - MapWindow window(map,roomName,this); - window.exec(); -} - void MainWindow::searchClicked() { QHash columns; @@ -347,12 +217,10 @@ void MainWindow::searchAgainClicked() //searchAgainButton->hide(); searchVerticalWidget->hide(); searchTreeView->hide(); - } void MainWindow::conferenceMapClicked() { - QString mapPath = QString(":/maps/campus.png"); if(!QFile::exists(mapPath)) mapPath = QString(":/maps/rooms/not-available.png"); @@ -364,50 +232,14 @@ void MainWindow::conferenceMapClicked() window.exec(); } -void MainWindow::displayWarning(const QModelIndex &aIndex) -{ - Q_UNUSED(aIndex); - - QMessageBox::warning( - this, - tr("Time Conflict Warning"), - tr("This event happens at the same time than another one of your favourites.") ); -} - void MainWindow::eventHasChanged(int aEventId) { - static_cast(dayTreeView->model())->updateModel(aEventId); - - // we need to reload favourites, because some favourite could be deleted - //static_cast(favTreeView->model())->updateModel(aEventId); - QDate aStartDate = Conference::getById(AppSettings::confId()).start(); - QDate aEndDate = Conference::getById(AppSettings::confId()).end(); - favouriteDayNavigator->setDates(aStartDate, aEndDate); - updateFavouritesView( Conference::getById(AppSettings::confId()).start() ); + dayTabContainer->updateTreeViewModel(aEventId); + favsTabContainer->updateTreeViewModel(aEventId); + tracksTabContainer->updateTreeViewModel(aEventId); + nowTabContainer->updateTreeViewModel(aEventId); + roomsTabContainer->updateTreeViewModel(aEventId); - static_cast(trackTreeView->model())->updateModel(aEventId); static_cast(searchTreeView->model())->updateModel(aEventId); - static_cast(nowTreeView->model())->updateModel(aEventId); - static_cast(roomTreeView->model())->updateModel(aEventId); } -void MainWindow::tabHasChanged(int aIndex) -{ - Q_UNUSED(aIndex); - - // TODO: only if it changed to favourities tab - updateFavouritesView(favouriteDayNavigator->getCurrentDate()); - // TODO: only if it changed to now tab - updateNowView(); -} - -void MainWindow::timerUpdateNowView() -{ - QWidget * pCurrentWidget = tabWidget->widget(tabWidget->currentIndex()); - - if( pCurrentWidget != NULL ) - { - if( pCurrentWidget == tab ) - updateNowView(); - } -} diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 6986e15..0f425a3 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -18,21 +18,11 @@ public: private slots: void scheduleImported(int aConfId); void aboutApp(); - void updateDayView(const QDate &aDate); - void updateTracksView(const QDate &aDate); - void updateFavouritesView(const QDate &aDate); void updateSearchView(const QDate &aDate); - void updateNowView(); - void updateRoomView(const QDate &aDate); - void itemClicked(const QModelIndex &aIndex); - void displayMap(const QModelIndex &aIndex); - void displayWarning(const QModelIndex &aIndex); void searchClicked(); void searchAgainClicked(); void conferenceMapClicked(); - void tabHasChanged(int aIndex); void eventHasChanged(int aEventId); - void timerUpdateNowView(); private: SqlEngine *mSqlEngine; }; diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui index 2f2fa81..7f25a2f 100644 --- a/src/gui/mainwindow.ui +++ b/src/gui/mainwindow.ui @@ -5,8 +5,8 @@ 0 0 - 935 - 514 + 903 + 498 @@ -31,32 +31,7 @@ - - - - - - - - 0 - 0 - - - - - - - - - 16777215 - 16777215 - - - - - - - + @@ -65,15 +40,8 @@ Favourites - - - - - - - - - + + @@ -83,21 +51,7 @@ - - - - - - - - - 16777215 - 16777215 - - - - - + @@ -338,24 +292,7 @@ - - - QLayout::SetDefaultConstraint - - - - - - - - - 16777215 - 16777215 - - - - - + @@ -519,13 +456,13 @@ - + Now - + @@ -559,6 +496,12 @@
importschedulewidget.h
1 + + TabContainer + QWidget +
tabcontainer.h
+ 1 +
diff --git a/src/gui/tabcontainer.cpp b/src/gui/tabcontainer.cpp new file mode 100644 index 0000000..6035e84 --- /dev/null +++ b/src/gui/tabcontainer.cpp @@ -0,0 +1,180 @@ +#include "tabcontainer.h" + +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "eventdialog.h" +#include "mapwindow.h" + +TabContainer::TabContainer(QWidget *aParent) + : QWidget(aParent) + , mType(EContainerTypeNone) +{ + setupUi(this); + + searchAgainButton->hide(); + + treeView->setHeaderHidden(true); + treeView->setRootIsDecorated(false); + treeView->setIndentation(0); + treeView->setAnimated(true); + treeView->setModel(new EventModel()); + treeView->setItemDelegate(new Delegate(treeView)); + + connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTreeView(const QDate &))); + + connect(treeView, SIGNAL(eventHasChanged(int)), SIGNAL(eventHasChanged(int))); + connect(treeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); + connect(treeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); + connect(treeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &))); + + if(!Conference::getAll().count()) // no conference(s) in the DB + { + dayNavigator->hide(); // hide DayNavigatorWidget + } + else + { + QDate aStartDate = Conference::getById(AppSettings::confId()).start(); + QDate aEndDate = Conference::getById(AppSettings::confId()).end(); + dayNavigator->setDates(aStartDate, aEndDate); + } +} + +void TabContainer::setType(TabContainer::Type aType) +{ + mType = aType; + if(aType == EContainerTypeNow) + { + QTimer *timer = new QTimer( this ); + connect( timer, SIGNAL(timeout()), SLOT(timerUpdateTreeView()) ); + timer->start( 30000); // 30 seconds timer + } +} + +void TabContainer::updateTreeView(const QDate &aDate) +{ + switch(mType) + { + case EContainerTypeDay: + { + static_cast(treeView->model())->loadEvents(aDate,AppSettings::confId()); + } + break; + case EContainerTypeFavs: + { + static_cast(treeView->model())->loadFavEvents(aDate,AppSettings::confId()); + } + break; + case EContainerTypeTracks: + { + static_cast(treeView->model())->loadEventsByTrack(aDate, AppSettings::confId()); + } + break; + case EContainerTypeRooms: + { + static_cast(treeView->model())->loadEventsByRoom(aDate, AppSettings::confId()); + } + break; + case EContainerTypeNow: + { + static_cast(treeView->model())->loadNowEvents(AppSettings::confId()); + treeView->setAllExpanded(true); + } + break; + case EContainerTypeNone: + default: + { + qDebug() << "Container type not specified"; + } + } + treeView->reset(); + dayNavigator->show(); +} + +void TabContainer::itemClicked(const QModelIndex &aIndex) +{ + // have to handle only events, not time-groups + if(!aIndex.parent().isValid()) // time-group + return; + + EventDialog dialog(static_cast(aIndex.internalPointer())->id(),this); + dialog.exec(); +} + +void TabContainer::displayMap(const QModelIndex &aIndex) +{ + Event *event = static_cast(aIndex.internalPointer()); + + // room names are stored in lower-case format + // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png" + QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room().toLower().remove(".")); + if(!QFile::exists(mapPath)) + mapPath = QString(":/maps/rooms/not-available.png"); + + QString roomName; + if(mapPath.contains("not-available", Qt::CaseInsensitive)) + roomName = QString("Map is not available: %1").arg(event->room()); + else + roomName = event->room(); + + QPixmap map(mapPath); + MapWindow window(map,roomName,this); + window.exec(); +} + +void TabContainer::displayWarning(const QModelIndex &aIndex) +{ + Q_UNUSED(aIndex); + + QMessageBox::warning( + this, + tr("Time Conflict Warning"), + tr("This event happens at the same time than another one of your favourites.") ); +} + +void TabContainer::updateTreeViewModel(int aEventId) +{ + switch(mType) + { + case EContainerTypeFavs: + { + // requires special handling + // we need to reload favourites, because some favourite could be deleted + //static_cast(favTreeView->model())->updateModel(aEventId); + QDate aStartDate = Conference::getById(AppSettings::confId()).start(); + QDate aEndDate = Conference::getById(AppSettings::confId()).end(); + dayNavigator->setDates(aStartDate, aEndDate); + updateTreeView( Conference::getById(AppSettings::confId()).start() ); + } + break; + case EContainerTypeDay: + case EContainerTypeNone: + default: + { + static_cast(treeView->model())->updateModel(aEventId); + } + } +} + +void TabContainer::setDates(const QDate &aStart, const QDate &aEnd) +{ + dayNavigator->setDates(aStart, aEnd); +} + +void TabContainer::timerUpdateTreeView() +{ + if(mType == EContainerTypeNow) + { + updateTreeView(QDate()); + } +} + diff --git a/src/gui/tabcontainer.h b/src/gui/tabcontainer.h new file mode 100644 index 0000000..527c58b --- /dev/null +++ b/src/gui/tabcontainer.h @@ -0,0 +1,48 @@ +#ifndef TABCONTAINER_H +#define TABCONTAINER_H + +#include +#include "ui_tabcontainer.h" + +class TabContainer : public QWidget, Ui::TabContainer +{ + Q_OBJECT +public: + + // type of the container + // specifies the type of the data that treeView holds + enum Type + { + EContainerTypeNone = 0, + EContainerTypeDay, + EContainerTypeFavs, + EContainerTypeTracks, + EContainerTypeRooms, + EContainerTypeSearch, + EContainerTypeNow + }; + + TabContainer(QWidget *aParent = NULL); + ~TabContainer() {} + void setType(TabContainer::Type aType); + +signals: + void eventHasChanged(int aEventId); + +public slots: + void updateTreeViewModel(int aEventId); + void setDates(const QDate &aStart, const QDate &aEnd); + +private slots: + void updateTreeView(const QDate &aDate); + void timerUpdateTreeView(); + void itemClicked(const QModelIndex &aIndex); + void displayMap(const QModelIndex &aIndex); + void displayWarning(const QModelIndex &aIndex); + +private: + TabContainer::Type mType; +}; + +#endif /* TABCONTAINER_H */ + diff --git a/src/gui/tabcontainer.ui b/src/gui/tabcontainer.ui new file mode 100644 index 0000000..ff1966e --- /dev/null +++ b/src/gui/tabcontainer.ui @@ -0,0 +1,80 @@ + + TabContainer + + + + 0 + 0 + 568 + 292 + + + + Form + + + + + + true + + + + 0 + 0 + + + + Search again + + + S + + + + :/icons/search.png:/icons/search.png + + + + 24 + 24 + + + + Qt::ToolButtonIconOnly + + + + + + + + + + + 0 + 0 + + + + + + + + + DayNavigatorWidget + QWidget +
daynavigatorwidget.h
+ 1 +
+ + TreeView + QTreeView +
../mvc/treeview.h
+
+
+ + + + +
diff --git a/src/sql/sqlengine.h b/src/sql/sqlengine.h index 0ac9fa3..d52ceb3 100644 --- a/src/sql/sqlengine.h +++ b/src/sql/sqlengine.h @@ -12,7 +12,7 @@ class SqlEngine : public QObject public: SqlEngine(QObject *aParent = NULL); ~SqlEngine(); - void initialize(); + static void initialize(); void addConferenceToDB(QHash &aConference); void addEventToDB(QHash &aEvent); void addPersonToDB(QHash &aPerson); @@ -22,8 +22,8 @@ class SqlEngine : public QObject // search Events for .... int searchEvent(int conferenceId, const QHash &columns, const QString &keyword); private: - QString login(const QString &aDatabaseType, const QString &aDatabaseName); - bool createTables(QSqlDatabase &aDatabase); + static QString login(const QString &aDatabaseType, const QString &aDatabaseName); + static bool createTables(QSqlDatabase &aDatabase); bool execQuery(QSqlDatabase &aDatabase, const QString &aQuery); }; -- 2.39.5