From 07ae23af712746b964906f0f1e785bdb13201399 Mon Sep 17 00:00:00 2001 From: timkoma Date: Wed, 27 Jan 2010 15:06:21 +0000 Subject: [PATCH] refactoring of the TABS --- src/app/app.pro | 2 +- src/gui/dayviewtabcontainer.cpp | 15 +++ src/gui/dayviewtabcontainer.h | 16 +++ src/gui/favtabcontainer.cpp | 28 ++++ src/gui/favtabcontainer.h | 27 ++++ src/gui/gui.pro | 117 +++++++++++------ src/gui/mainwindow.cpp | 7 - src/gui/mainwindow.ui | 226 ++++++++++++++++++-------------- src/gui/nowtabcontainer.cpp | 28 ++++ src/gui/nowtabcontainer.h | 27 ++++ src/gui/roomstabcontainer.cpp | 17 +++ src/gui/roomstabcontainer.h | 25 ++++ src/gui/searchhead.cpp | 21 +++ src/gui/searchhead.h | 26 ++++ src/gui/searchhead.ui | 150 +++++++++++++++++++++ src/gui/searchtabcontainer.cpp | 102 ++++++++++++++ src/gui/searchtabcontainer.h | 26 ++++ src/gui/tabcontainer.cpp | 151 +-------------------- src/gui/tabcontainer.h | 38 +++--- src/gui/tabcontainer.ui | 202 ++++------------------------ src/gui/trackstabcontainer.cpp | 11 ++ src/gui/trackstabcontainer.h | 25 ++++ 22 files changed, 796 insertions(+), 491 deletions(-) create mode 100644 src/gui/dayviewtabcontainer.cpp create mode 100644 src/gui/dayviewtabcontainer.h create mode 100644 src/gui/favtabcontainer.cpp create mode 100644 src/gui/favtabcontainer.h create mode 100644 src/gui/nowtabcontainer.cpp create mode 100644 src/gui/nowtabcontainer.h create mode 100644 src/gui/roomstabcontainer.cpp create mode 100644 src/gui/roomstabcontainer.h create mode 100644 src/gui/searchhead.cpp create mode 100644 src/gui/searchhead.h create mode 100644 src/gui/searchhead.ui create mode 100644 src/gui/searchtabcontainer.cpp create mode 100644 src/gui/searchtabcontainer.h create mode 100644 src/gui/trackstabcontainer.cpp create mode 100644 src/gui/trackstabcontainer.h diff --git a/src/app/app.pro b/src/app/app.pro index 67f6bab..bd1d96f 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 ../sql +INCLUDEPATH += ../gui ../sql ../mvc ../orm DEPENDPATH += . ../gui TARGETDEPS += $$DESTDIR/libmvc.a $$DESTDIR/libgui.a $$DESTDIR/libsql.a maemo { diff --git a/src/gui/dayviewtabcontainer.cpp b/src/gui/dayviewtabcontainer.cpp new file mode 100644 index 0000000..1514bbf --- /dev/null +++ b/src/gui/dayviewtabcontainer.cpp @@ -0,0 +1,15 @@ + +#include "dayviewtabcontainer.h" + +DayViewTabContainer::DayViewTabContainer(QWidget *aParent) : TabContainer( aParent ) +{ +} + +DayViewTabContainer::~DayViewTabContainer() +{ +} + +void DayViewTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) +{ + static_cast(treeView->model())->loadEvents( aDate, aConferenceId ); +} diff --git a/src/gui/dayviewtabcontainer.h b/src/gui/dayviewtabcontainer.h new file mode 100644 index 0000000..cfbbbc7 --- /dev/null +++ b/src/gui/dayviewtabcontainer.h @@ -0,0 +1,16 @@ + +#ifndef DAYVIEWTABCONTAINER_H_ +#define DAYVIEWTABCONTAINER_H_ + +#include "tabcontainer.h" + +class DayViewTabContainer: public TabContainer { + Q_OBJECT +public: + DayViewTabContainer(QWidget *aParent); + virtual ~DayViewTabContainer(); +protected: + virtual void loadEvents(const QDate &aDate, const int aConferenceId ); +}; + +#endif /* DAYVIEWTABCONTAINER_H_ */ diff --git a/src/gui/favtabcontainer.cpp b/src/gui/favtabcontainer.cpp new file mode 100644 index 0000000..4a8e98f --- /dev/null +++ b/src/gui/favtabcontainer.cpp @@ -0,0 +1,28 @@ +/* + * favtabcontainer.cpp + * + * Created on: Jan 27, 2010 + * Author: maemo + */ + +#include "favtabcontainer.h" + +FavTabContainer::FavTabContainer(QWidget *aParent) : TabContainer( aParent ) +{ +} + +void FavTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) +{ + static_cast(treeView->model())->loadFavEvents( aDate, aConferenceId ); +} + +void FavTabContainer::updateTreeViewModel(int aEventId) +{ + // 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() ); +} diff --git a/src/gui/favtabcontainer.h b/src/gui/favtabcontainer.h new file mode 100644 index 0000000..06140f0 --- /dev/null +++ b/src/gui/favtabcontainer.h @@ -0,0 +1,27 @@ +/* + * favtabcontainer.h + * + * Created on: Jan 27, 2010 + * Author: maemo + */ + +#ifndef FAVTABCONTAINER_H_ +#define FAVTABCONTAINER_H_ + +#include "tabcontainer.h" + +class FavTabContainer: public TabContainer +{ + Q_OBJECT +public: + FavTabContainer(QWidget *aParent); + virtual ~FavTabContainer(){} + +public slots: + virtual void updateTreeViewModel(int aEventId); + +protected: + virtual void loadEvents( const QDate &aDate, const int aConferenceId ); +}; + +#endif /* FAVTABCONTAINER_H_ */ diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 82a215e..7fec1d3 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -3,53 +3,90 @@ TEMPLATE = lib TARGET = gui DESTDIR = ../bin CONFIG += static -QT += sql xml +QT += sql \ + xml # module dependencies -LIBS += -L$$DESTDIR -lmvc -lorm -lsql -INCLUDEPATH += ../orm ../mvc ../sql ../app -DEPENDPATH += . ../orm ../mvc ../sql -TARGETDEPS += $$DESTDIR/liborm.a $$DESTDIR/libmvc.a $$DESTDIR/libsql.a -maemo { - LIBS += -L$$DESTDIR -lqalarm +LIBS += -L$$DESTDIR \ + -lmvc \ + -lorm \ + -lsql +INCLUDEPATH += ../orm \ + ../mvc \ + ../sql \ + ../app +DEPENDPATH += . \ + ../orm \ + ../mvc \ + ../sql +TARGETDEPS += $$DESTDIR/liborm.a \ + $$DESTDIR/libmvc.a \ + $$DESTDIR/libsql.a +maemo { + LIBS += -L$$DESTDIR \ + -lqalarm INCLUDEPATH += ../alarm - DEPENDPATH += ../alarm - TARGETDEPS += $$DESTDIR/libqalarm.a + DEPENDPATH += ../alarm + TARGETDEPS += $$DESTDIR/libqalarm.a } - # A shamelessly long list of sources, headers and forms. # Please note that resources MUST be added to the app module # (which means they need to be added to the test module as well, # but I am sure you can live with that for the time being). - -FORMS += mainwindow.ui \ - daynavigatorwidget.ui \ - importschedulewidget.ui \ - about.ui \ - eventdialog.ui \ - tabcontainer.ui \ - mapwindow.ui - -HEADERS += mainwindow.h \ - daynavigatorwidget.h \ - importschedulewidget.h \ - eventdialog.h \ - tabwidget.h \ - tabcontainer.h \ - mapwindow.h - -SOURCES += mainwindow.cpp \ - daynavigatorwidget.cpp \ - importschedulewidget.cpp \ - eventdialog.cpp \ - tabwidget.cpp \ - tabcontainer.cpp \ - mapwindow.cpp - -maemo { - FORMS += alarmdialog.ui - HEADERS += alarmdialog.h - SOURCES += alarmdialog.cpp +FORMS += searchhead.ui \ + mainwindow.ui \ + daynavigatorwidget.ui \ + importschedulewidget.ui \ + about.ui \ + eventdialog.ui \ + tabcontainer.ui \ + mapwindow.ui +HEADERS += roomstabcontainer.h \ + nowtabcontainer.h \ + trackstabcontainer.h \ + favtabcontainer.h \ + searchtabcontainer.h \ + searchhead.h \ + dayviewtabcontainer.h \ + mainwindow.h \ + daynavigatorwidget.h \ + importschedulewidget.h \ + eventdialog.h \ + tabwidget.h \ + tabcontainer.h \ + mapwindow.h +SOURCES += roomstabcontainer.cpp \ + nowtabcontainer.cpp \ + trackstabcontainer.cpp \ + favtabcontainer.cpp \ + searchtabcontainer.cpp \ + searchhead.cpp \ + dayviewtabcontainer.cpp \ + mainwindow.cpp \ + daynavigatorwidget.cpp \ + importschedulewidget.cpp \ + eventdialog.cpp \ + tabwidget.cpp \ + tabcontainer.cpp \ + mapwindow.cpp +maemo { + FORMS += searchhead.ui \ + alarmdialog.ui + HEADERS += roomstabcontainer.h \ + nowtabcontainer.h \ + trackstabcontainer.h \ + favtabcontainer.h \ + searchtabcontainer.h \ + searchhead.h \ + dayviewtabcontainer.h \ + alarmdialog.h + SOURCES += roomstabcontainer.cpp \ + nowtabcontainer.cpp \ + trackstabcontainer.cpp \ + favtabcontainer.cpp \ + searchtabcontainer.cpp \ + searchhead.cpp \ + dayviewtabcontainer.cpp \ + alarmdialog.cpp } - diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 660de2b..0016b4b 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -43,13 +43,6 @@ 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); - searchTabContainer->setType(TabContainer::EContainerTypeSearch); - connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int))); // event details have changed diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui index 63e4e05..2ab2b7c 100644 --- a/src/gui/mainwindow.ui +++ b/src/gui/mainwindow.ui @@ -1,7 +1,8 @@ - + + MainWindow - - + + 0 0 @@ -9,182 +10,189 @@ 498 - + 400 300 - + MainWindow - - - - - - 0 + + + + + + 3 - - + + Day View - - - + + + - - + + Favourites - - - + + + - - + + Tracks - - - + + + - - + + Search - + - + + + + 0 + 0 + + + - - + + Rooms - - - + + + - - + + Conference - - - + + + - - + + 75 true - + Conference Name - + Qt::AlignCenter - + true - - + + Conference Subtitle - + Qt::AlignCenter - + true - - + + Qt::Horizontal - - - - + + + + 75 true true - + When: - - - + + + 75 true true - + Where: - - - + + + DATE (FROM - TO) - - - + + + CITY, CAMPUS - - - + + + MAP - - + + :/icons/compassBig.png:/icons/compassBig.png - + true - - - + + + Qt::Horizontal - + 40 20 @@ -192,9 +200,9 @@ - - - + + + @@ -202,16 +210,16 @@ - - + + Qt::Horizontal - - - + + + 0 0 @@ -219,11 +227,11 @@ - - + + Qt::Vertical - + 20 40 @@ -235,13 +243,13 @@ - - + + Now - - - + + + @@ -249,7 +257,7 @@ - + @@ -265,14 +273,38 @@ 1 - TabContainer + SearchTabContainer QWidget -
tabcontainer.h
- 1 +
searchtabcontainer.h
+
+ + DayViewTabContainer + QWidget +
dayviewtabcontainer.h
+
+ + FavTabContainer + QWidget +
favtabcontainer.h
+
+ + TracksTabContainer + QWidget +
trackstabcontainer.h
+
+ + RoomsTabContainer + QWidget +
roomstabcontainer.h
+
+ + NowTabContainer + QWidget +
nowtabcontainer.h
- +
diff --git a/src/gui/nowtabcontainer.cpp b/src/gui/nowtabcontainer.cpp new file mode 100644 index 0000000..249ad64 --- /dev/null +++ b/src/gui/nowtabcontainer.cpp @@ -0,0 +1,28 @@ +/* + * nowtabcontainer.cpp + * + * Created on: Jan 27, 2010 + * Author: maemo + */ + +#include +#include "nowtabcontainer.h" + +NowTabContainer::NowTabContainer( QWidget *aParent ) : TabContainer( aParent ) +{ + QTimer *timer = new QTimer( this ); + connect( timer, SIGNAL(timeout()), SLOT(timerUpdateTreeView()) ); + timer->start( 30000); // 30 seconds timer +} + +void NowTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) +{ + Q_UNUSED( aDate ); + static_cast(treeView->model())->loadNowEvents( aConferenceId ); + treeView->setAllExpanded(true); +} + +void NowTabContainer::timerUpdateTreeView() +{ + updateTreeView( QDate() ); +} diff --git a/src/gui/nowtabcontainer.h b/src/gui/nowtabcontainer.h new file mode 100644 index 0000000..a7112fa --- /dev/null +++ b/src/gui/nowtabcontainer.h @@ -0,0 +1,27 @@ +/* + * nowtabcontainer.h + * + * Created on: Jan 27, 2010 + * Author: maemo + */ + +#ifndef NOWTABCONTAINER_H_ +#define NOWTABCONTAINER_H_ + +#include "tabcontainer.h" + +class NowTabContainer: public TabContainer +{ + Q_OBJECT +public: + NowTabContainer( QWidget *aParent ); + virtual ~NowTabContainer() { } + +protected: + virtual void loadEvents( const QDate &aDate, const int aConferenceId ); + +private slots: + void timerUpdateTreeView(); +}; + +#endif /* NOWTABCONTAINER_H_ */ diff --git a/src/gui/roomstabcontainer.cpp b/src/gui/roomstabcontainer.cpp new file mode 100644 index 0000000..e5f7af2 --- /dev/null +++ b/src/gui/roomstabcontainer.cpp @@ -0,0 +1,17 @@ +/* + * roomstabcontainer.cpp + * + * Created on: Jan 27, 2010 + * Author: maemo + */ + +#include "roomstabcontainer.h" + +RoomsTabContainer::RoomsTabContainer( QWidget *aParent ) : TabContainer( aParent ) +{ +} + +void RoomsTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) +{ + static_cast(treeView->model())->loadEventsByRoom( aDate, aConferenceId ); +} diff --git a/src/gui/roomstabcontainer.h b/src/gui/roomstabcontainer.h new file mode 100644 index 0000000..7c1e59c --- /dev/null +++ b/src/gui/roomstabcontainer.h @@ -0,0 +1,25 @@ +/* + * roomstabcontainer.h + * + * Created on: Jan 27, 2010 + * Author: maemo + */ + +#ifndef ROOMSTABCONTAINER_H_ +#define ROOMSTABCONTAINER_H_ + +#include "tabcontainer.h" + +class RoomsTabContainer: public TabContainer +{ + Q_OBJECT +public: + RoomsTabContainer( QWidget *aParent ); + virtual ~RoomsTabContainer() {} + +protected: + virtual void loadEvents( const QDate &aDate, const int aConferenceId ); + +}; + +#endif /* ROOMSTABCONTAINER_H_ */ diff --git a/src/gui/searchhead.cpp b/src/gui/searchhead.cpp new file mode 100644 index 0000000..1390feb --- /dev/null +++ b/src/gui/searchhead.cpp @@ -0,0 +1,21 @@ + +#include "searchhead.h" + +SearchHead::SearchHead(QWidget *parent) + : QWidget(parent) +{ + setupUi(this); + connect( searchButton, SIGNAL(clicked()), SLOT(searchButtonClicked())); +} + +SearchHead::~SearchHead() +{ + +} + + +void SearchHead::searchButtonClicked() +{ + qDebug() << "SearchHead::searchButtonClicked()"; + emit( searchClicked() ); +} diff --git a/src/gui/searchhead.h b/src/gui/searchhead.h new file mode 100644 index 0000000..8ab2d69 --- /dev/null +++ b/src/gui/searchhead.h @@ -0,0 +1,26 @@ +#ifndef SEARCHHEAD_H +#define SEARCHHEAD_H + +#include +#include +#include "ui_searchhead.h" + +class SearchHead : public QWidget, public Ui::SearchHeadClass +{ + Q_OBJECT + +public: + SearchHead(QWidget *parent = 0); + ~SearchHead(); + +signals: + void searchClicked(); + +private slots: + void searchButtonClicked(); + +//private: + //Ui::SearchHeadClass ui; +}; + +#endif // SEARCHHEAD_H diff --git a/src/gui/searchhead.ui b/src/gui/searchhead.ui new file mode 100644 index 0000000..c5beae5 --- /dev/null +++ b/src/gui/searchhead.ui @@ -0,0 +1,150 @@ + + + SearchHeadClass + + + + 0 + 0 + 371 + 88 + + + + + 0 + 0 + + + + + 10 + 10 + + + + SearchHead + + + + 9 + + + + + + + Title + + + true + + + + + + + Abstract + + + + + + + Speaker + + + + + + + Tag + + + + + + + Room + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + true + + + type a keyword to search + + + + + + + + 0 + 0 + + + + Search + + + + :/icons/search.png:/icons/search.png + + + false + + + true + + + true + + + false + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + + + + diff --git a/src/gui/searchtabcontainer.cpp b/src/gui/searchtabcontainer.cpp new file mode 100644 index 0000000..64d989f --- /dev/null +++ b/src/gui/searchtabcontainer.cpp @@ -0,0 +1,102 @@ + +#include + +#include "searchtabcontainer.h" +#include "searchhead.h" + + +SearchTabContainer::SearchTabContainer(QWidget *aParent) : TabContainer( aParent ) +{ + header = new SearchHead(this); + header->setObjectName(QString::fromUtf8("header")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + //sizePolicy.setHeightForWidth(TabContainer::sizePolicy().hasHeightForWidth()); + sizePolicy.setHeightForWidth(header->sizePolicy().hasHeightForWidth()); + header->setSizePolicy(sizePolicy); + header->setMinimumSize(QSize(10, 10)); + + verticalLayout->insertWidget(0,header); + + header->show(); + + searchAgainButton = new QToolButton(this); + searchAgainButton->setObjectName(QString::fromUtf8("button")); + QIcon icon; + icon.addPixmap(QPixmap(QString::fromUtf8(":/icons/search.png")), QIcon::Normal, QIcon::Off); + searchAgainButton->setIcon(icon); + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Minimum); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(searchAgainButton->sizePolicy().hasHeightForWidth()); + searchAgainButton->setSizePolicy(sizePolicy1); + + verticalLayout_2->insertWidget(0,searchAgainButton); + + searchAgainButton->show(); + + connect( header, SIGNAL(searchClicked()), SLOT(searchButtonClicked())); + connect( searchAgainButton, SIGNAL(clicked()), SLOT(searchAgainClicked())); +} + +SearchTabContainer::~SearchTabContainer() +{ +} + +void SearchTabContainer::searchButtonClicked() +{ + qDebug() << "SearchTab::searchButtonClicked()"; + + QHash columns; + + SearchHead *searchHeader = static_cast(header); + if( searchHeader->searchTitle->isChecked() ) + columns.insertMulti("EVENT", "title"); + if( searchHeader->searchAbstract->isChecked() ) + columns.insertMulti("EVENT", "abstract"); + if( searchHeader->searchTag->isChecked() ) + columns.insertMulti("EVENT", "tag"); + if( searchHeader->searchSpeaker->isChecked() ) + columns["PERSON"] = "name"; + if( searchHeader->searchRoom->isChecked() ) + columns["ROOM"] = "name"; + + QString keyword = searchHeader->searchEdit->text().replace( QString("%"), QString("\\%") ); + qDebug() << "\nKeyword to search: " << keyword; + SqlEngine::searchEvent( AppSettings::confId(), columns, keyword ); + + QDate startDate = Conference::getById(AppSettings::confId()).start(); + QDate endDate = Conference::getById(AppSettings::confId()).end(); + dayNavigator->setDates(startDate, endDate); + updateTreeView( Conference::getById(AppSettings::confId()).start() ); +} + +void SearchTabContainer::searchAgainClicked() +{ + qDebug() << "SearchTab::searchAgainClicked()"; + header->show(); + searchAgainButton->hide(); + dayNavigator->hide(); + treeView->hide(); +} + +void SearchTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) +{ + int eventsCount = static_cast(treeView->model())->loadSearchResultEvents( aDate, aConferenceId ); + if( eventsCount || + //TODO: this is not good test + dayNavigator->getCurrentDate() != Conference::getById( aConferenceId ).start() + ){ + searchAgainButton->show(); + dayNavigator->show(); + treeView->show(); + header->hide(); + } + else{ + treeView->hide(); + searchAgainButton->hide(); + dayNavigator->hide(); + header->show(); + } +} diff --git a/src/gui/searchtabcontainer.h b/src/gui/searchtabcontainer.h new file mode 100644 index 0000000..bcfdc7b --- /dev/null +++ b/src/gui/searchtabcontainer.h @@ -0,0 +1,26 @@ + +#ifndef SEARCHTAB_H_ +#define SEARCHTAB_H_ + +#include + +#include "tabcontainer.h" +#include "searchhead.h" + +class SearchTabContainer: public TabContainer { + Q_OBJECT +public: + SearchTabContainer(QWidget *aParent); + virtual ~SearchTabContainer(); +protected: + virtual void loadEvents( const QDate &aDate, const int aConferenceId ); +private slots: + void searchButtonClicked(); + void searchAgainClicked(); + +private: + SearchHead *header; + QToolButton *searchAgainButton; +}; + +#endif /* SEARCHTAB_H_ */ diff --git a/src/gui/tabcontainer.cpp b/src/gui/tabcontainer.cpp index 3d3cc7b..f2e3fff 100644 --- a/src/gui/tabcontainer.cpp +++ b/src/gui/tabcontainer.cpp @@ -4,13 +4,7 @@ #include #include -#include -#include - -#include - #include -#include #include #include "eventdialog.h" @@ -18,13 +12,9 @@ TabContainer::TabContainer(QWidget *aParent) : QWidget(aParent) - , mType(EContainerTypeNone) { setupUi(this); - searchAgainButton->hide(); - searchHead->hide(); - treeView->setHeaderHidden(true); treeView->setRootIsDecorated(false); treeView->setIndentation(0); @@ -39,9 +29,6 @@ TabContainer::TabContainer(QWidget *aParent) connect(treeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); connect(treeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &))); - connect(searchButton, SIGNAL(clicked()), SLOT(searchClicked())); - connect(searchAgainButton, SIGNAL(clicked()), SLOT(searchAgainClicked())); - if(!Conference::getAll().count()) // no conference(s) in the DB { dayNavigator->hide(); // hide DayNavigatorWidget @@ -54,79 +41,11 @@ TabContainer::TabContainer(QWidget *aParent) } } -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 - } - if(aType == EContainerTypeSearch) - { - searchHead->show(); - } -} - 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 EContainerTypeSearch: - { - treeView->reset(); - int eventsCount = static_cast(treeView->model())->loadSearchResultEvents(aDate,AppSettings::confId()); - if( eventsCount || - dayNavigator->getCurrentDate() != Conference::getById(AppSettings::confId()).start() ){ - searchAgainButton->show(); - dayNavigator->show(); - treeView->show(); - searchHead->hide(); - } - else{ - treeView->hide(); - searchAgainButton->hide(); - dayNavigator->hide(); - searchHead->show(); - } - } - break; - case EContainerTypeNone: - default: - { - qDebug() << "Container type not specified"; - } - } - treeView->reset(); dayNavigator->show(); + loadEvents( aDate, AppSettings::confId() ); + treeView->reset(); } void TabContainer::itemClicked(const QModelIndex &aIndex) @@ -174,26 +93,7 @@ void TabContainer::displayWarning(const QModelIndex &aIndex) 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); - } - } + static_cast(treeView->model())->updateModel(aEventId); } void TabContainer::setDates(const QDate &aStart, const QDate &aEnd) @@ -201,50 +101,5 @@ void TabContainer::setDates(const QDate &aStart, const QDate &aEnd) dayNavigator->setDates(aStart, aEnd); } -void TabContainer::timerUpdateTreeView() -{ - if(mType == EContainerTypeNow) - { - updateTreeView(QDate()); - } -} -void TabContainer::searchClicked() -{ - if(mType == EContainerTypeSearch) - { - QHash columns; - - if( searchTitle->isChecked() ) - columns.insertMulti("EVENT", "title"); - if( searchAbstract->isChecked() ) - columns.insertMulti("EVENT", "abstract"); - if( searchTag->isChecked() ) - columns.insertMulti("EVENT", "tag"); - if( searchSpeaker->isChecked() ) - columns["PERSON"] = "name"; - if( searchRoom->isChecked() ) - columns["ROOM"] = "name"; - - QString keyword = searchEdit->text().replace( QString("%"), QString("\\%") ); - qDebug() << "\nKeyword to search: " << keyword; - SqlEngine::searchEvent( AppSettings::confId(), columns, keyword ); - - QDate startDate = Conference::getById(AppSettings::confId()).start(); - QDate endDate = Conference::getById(AppSettings::confId()).end(); - dayNavigator->setDates(startDate, endDate); - updateTreeView( Conference::getById(AppSettings::confId()).start() ); - } -} - -void TabContainer::searchAgainClicked() -{ - if(mType == EContainerTypeSearch) - { - searchHead->show(); - searchAgainButton->hide(); - dayNavigator->hide(); - treeView->hide(); - } -} diff --git a/src/gui/tabcontainer.h b/src/gui/tabcontainer.h index 47748a0..8c682fe 100644 --- a/src/gui/tabcontainer.h +++ b/src/gui/tabcontainer.h @@ -4,46 +4,38 @@ #include #include "ui_tabcontainer.h" -class TabContainer : public QWidget, Ui::TabContainer +#include +#include +#include +#include + +class TabContainer : public QWidget, public Ui::TabContainer { Q_OBJECT public: - // type of the container - // specifies the type of the data that treeView holds - enum Type + TabContainer(QWidget *aParent = NULL); + virtual ~TabContainer() {} + +protected: + virtual void loadEvents( const QDate &aDate, const int aConferenceId ) { - EContainerTypeNone = 0, - EContainerTypeDay, - EContainerTypeFavs, - EContainerTypeTracks, - EContainerTypeRooms, - EContainerTypeSearch, - EContainerTypeNow + Q_UNUSED(aDate); + Q_UNUSED(aConferenceId); }; - TabContainer(QWidget *aParent = NULL); - ~TabContainer() {} - void setType(TabContainer::Type aType); - signals: void eventHasChanged(int aEventId); public slots: - void updateTreeViewModel(int aEventId); + virtual void updateTreeViewModel(int aEventId); void setDates(const QDate &aStart, const QDate &aEnd); -private slots: +protected slots: void updateTreeView(const QDate &aDate); - void timerUpdateTreeView(); void itemClicked(const QModelIndex &aIndex); void displayMap(const QModelIndex &aIndex); void displayWarning(const QModelIndex &aIndex); - void searchClicked(); - void searchAgainClicked(); - -private: - TabContainer::Type mType; }; #endif /* TABCONTAINER_H */ diff --git a/src/gui/tabcontainer.ui b/src/gui/tabcontainer.ui index 4da6b10..4f194da 100644 --- a/src/gui/tabcontainer.ui +++ b/src/gui/tabcontainer.ui @@ -1,7 +1,8 @@ - + + TabContainer - - + + 0 0 @@ -9,191 +10,42 @@ 292 - + + + 0 + 0 + + + Form - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - QLayout::SetDefaultConstraint - - - - - - - true - - - type a keyword to search - - - - - - - - 0 - 0 - - - - Search - - - - :/icons/search.png:/icons/search.png - - - false - - - true - - - true - - - false - - - - - - - - - - - Title - - - true - - - - - - - Abstract - - - - - - - Speaker - - - - - - - Tag - - - - - - - Room - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - + + + 0 + + + - + - - + + - - - true - - - + + + 0 0 - - Search again - - - S - - - - :/icons/search.png:/icons/search.png - - + - 24 - 24 + 10 + 10 - - Qt::ToolButtonIconOnly - - - - - - - - 0 - 0 - - @@ -214,7 +66,7 @@ - + diff --git a/src/gui/trackstabcontainer.cpp b/src/gui/trackstabcontainer.cpp new file mode 100644 index 0000000..eea8f2b --- /dev/null +++ b/src/gui/trackstabcontainer.cpp @@ -0,0 +1,11 @@ + +#include "trackstabcontainer.h" + +TracksTabContainer::TracksTabContainer( QWidget *aParent ) : TabContainer( aParent ) +{ +} + +void TracksTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) +{ + static_cast(treeView->model())->loadEventsByTrack( aDate, aConferenceId ); +} diff --git a/src/gui/trackstabcontainer.h b/src/gui/trackstabcontainer.h new file mode 100644 index 0000000..46cfd9f --- /dev/null +++ b/src/gui/trackstabcontainer.h @@ -0,0 +1,25 @@ +/* + * trackstabcontainer.h + * + * Created on: Jan 27, 2010 + * Author: maemo + */ + +#ifndef TRACKSTABCONTAINER_H_ +#define TRACKSTABCONTAINER_H_ + +#include "tabcontainer.h" + +class TracksTabContainer: public TabContainer +{ + Q_OBJECT +public: + TracksTabContainer( QWidget *aParent ); + virtual ~TracksTabContainer() {} + +protected: + virtual void loadEvents( const QDate &aDate, const int aConferenceId ); + +}; + +#endif /* TRACKSTABCONTAINER_H_ */ -- 2.39.5