From fbc1646730b1555048ddabc78dbdaf294d5b7db5 Mon Sep 17 00:00:00 2001 From: korrco Date: Mon, 18 Jan 2010 17:15:45 +0000 Subject: [PATCH] activities tab implemented - need to fit gui, functionality works fine --- src/gui/mainwindow.cpp | 40 ++++++++++++++++++++++++++++++++++------ src/gui/mainwindow.h | 2 +- src/mvc/eventmodel.cpp | 8 ++++---- src/orm/ormrecord.h | 1 + 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index eab5120..d068c74 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -36,7 +36,7 @@ MainWindow::MainWindow(QWidget *parent) connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &))); connect(activityDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateActivitiesDayView(const QDate &))); - connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(updateView(int))); + //connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(updateView(int))); // DAY EVENTS View dayTreeView->setHeaderHidden(true); @@ -53,6 +53,15 @@ MainWindow::MainWindow(QWidget *parent) favTreeView->setAnimated(true); favTreeView->setModel(new EventModel()); favTreeView->setItemDelegate(new Delegate(favTreeView)); + + //ACTIVITIES View + activityDayTreeView->setHeaderHidden(true); + activityDayTreeView->setRootIsDecorated(false); + activityDayTreeView->setIndentation(0); + activityDayTreeView->setAnimated(true); + activityDayTreeView->setModel(new EventModel()); + activityDayTreeView->setItemDelegate(new Delegate(activityDayTreeView)); + // TESTING: load some 'fav' data if(Conference::getAll().count()) // no conference(s) in the DB { @@ -62,15 +71,21 @@ MainWindow::MainWindow(QWidget *parent) } if(!Conference::getAll().count()) // no conference(s) in the DB + { dayNavigator->hide(); // hide DayNavigatorWidget + activityDayNavigator->hide(); + } else { int confId = 1; - dayNavigator->setDates(Conference::getById(confId).start(),Conference::getById(confId).end()); + QDate aStartDate = Conference::getById(confId).start(); + QDate aEndDate = Conference::getById(confId).end(); + dayNavigator->setDates(aStartDate, aEndDate); + activityDayNavigator->setDates(aStartDate, aEndDate); } - connect(static_cast(dayTreeView->model()), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), SLOT(updateFavView())); - connect(static_cast(favTreeView->model()), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), SLOT(updateFavViewComplete())); + connect(static_cast(favTreeView->model()), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), SLOT(updateFavView())); +/* connect(static_cast(favTreeView->model()), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), SLOT(updateFavViewComplete()));*/ } MainWindow::~MainWindow() @@ -137,14 +152,18 @@ void MainWindow::updateFavView() static_cast(favTreeView->model())->loadFavEvents(Conference::getById(confId).start(),confId); favTreeView->reset(); //Necessary reset: // if favourite event unselected as favourite is the only one in its time, and reset is not produced, crashed + + dayNavigator->show(); } +/* void MainWindow::updateFavViewComplete() { int confId = 1; updateFavView(); updateDayView(Conference::getById(confId).start()); } +*/ void MainWindow::updateActivitiesDayView(const QDate &aDate) { @@ -156,9 +175,18 @@ void MainWindow::updateActivitiesDayView(const QDate &aDate) void MainWindow::updateView(int tabIndex) { - //TODO korinpa: skraslit ! aj pre ine taby + //TODO korinpa: change to enum or names ? qDebug() << "updateView index: " << tabIndex; - if (tabIndex == 2) + if (tabIndex == 0) + { + QDate date = dayNavigator->getCurrentDate(); + updateDayView(date); + } + else if (tabIndex == 1) + { + updateFavView(); + } + else if (tabIndex == 2) { QDate date = activityDayNavigator->getCurrentDate(); updateActivitiesDayView(date); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index eae7f5e..4c1c483 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -20,7 +20,7 @@ private slots: void aboutApp(); void updateDayView(const QDate &aDate); void updateFavView(); - void updateFavViewComplete(); + /*void updateFavViewComplete();*/ void updateActivitiesDayView(const QDate &aDate); void updateView(int tabIndex); private: diff --git a/src/mvc/eventmodel.cpp b/src/mvc/eventmodel.cpp index 1c0d295..d41aab8 100644 --- a/src/mvc/eventmodel.cpp +++ b/src/mvc/eventmodel.cpp @@ -185,10 +185,10 @@ void EventModel::loadEventsByActivities(const QDate &aDate, int aConferenceId) { clearModel(); if(Conference::getAll().count()) - { - qDebug() << "Loading Conference Data (by Activities): [" << Conference::getById(aConferenceId).title() << "] " << aDate; - mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId); - } + { + qDebug() << "Loading Conference Data (by Activities): [" << Conference::getById(aConferenceId).title() << "] " << aDate; + mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId); + } createActivityGroups(); } diff --git a/src/orm/ormrecord.h b/src/orm/ormrecord.h index 3590075..ae848ea 100644 --- a/src/orm/ormrecord.h +++ b/src/orm/ormrecord.h @@ -139,6 +139,7 @@ QList OrmRecord::load(QSqlQuery query) { if (!query.exec()) { + qDebug() << "Error: " << query.lastError().driverText() << "; Type: " << query.lastError().type(); throw new OrmSqlException(query.lastError().text()); } } -- 2.30.2