From: pavelpa Date: Thu, 28 Jan 2010 14:47:21 +0000 (+0000) Subject: some performance optimizations X-Git-Tag: 0.5.0~150 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/872aeaa10875e45f50a9973cad7b17d9f85f83aa some performance optimizations - favourities reloaded only if they have really changed - otherwise only event in the question is updated --- diff --git a/src/gui/eventdialog.cpp b/src/gui/eventdialog.cpp index 12838a5..91c9262 100644 --- a/src/gui/eventdialog.cpp +++ b/src/gui/eventdialog.cpp @@ -66,13 +66,13 @@ void EventDialog::favouriteClicked() qDebug() << " FAVOURITE [" << event.id() << "] -> " << event.isFavourite(); - // since the Favourite icon has changed, update TreeViews accordingly - // all TreeViews have to listen on this signal - emit(eventHasChanged(event.id())); - // have to emit 'eventHasChanged' signal on all events in conflict for(int i=0; i(treeView->model())->loadFavEvents( aDate, aConferenceId ); } -void FavTabContainer::updateTreeViewModel(int aEventId) -{ - Q_UNUSED(aEventId); - - // requires special handling - // we need to reload favourites, because some favourite could be deleted - //static_cast(favTreeView->model())->updateModel(aEventId); - int confId = Conference::activeConference(); - QDate startDate = Conference::getById(confId).start(); - QDate endDate = Conference::getById(confId).end(); - dayNavigator->setDates(startDate, endDate); - updateTreeView( Conference::getById(confId).start() ); -} - diff --git a/src/gui/favtabcontainer.h b/src/gui/favtabcontainer.h index 233757c..55fed4e 100644 --- a/src/gui/favtabcontainer.h +++ b/src/gui/favtabcontainer.h @@ -11,9 +11,6 @@ public: FavTabContainer(QWidget *aParent); virtual ~FavTabContainer(){} -public slots: - virtual void updateTreeViewModel(int aEventId); - protected: virtual void loadEvents( const QDate &aDate, const int aConferenceId ); }; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 130204e..8283787 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -31,12 +31,12 @@ MainWindow::MainWindow(int aEventId, QWidget *aParent) connect(importScheduleWidget, SIGNAL(scheduleImported(int)), SLOT(scheduleImported(int))); // event details have changed - connect(dayTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); - connect(favsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); - connect(tracksTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); - connect(roomsTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); - connect(nowTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); - connect(searchTabContainer, SIGNAL(eventHasChanged(int)), SLOT(eventHasChanged(int))); + connect(dayTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); + connect(favsTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); + connect(tracksTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); + connect(roomsTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); + connect(nowTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); + connect(searchTabContainer, SIGNAL(eventHasChanged(int,bool)), SLOT(eventHasChanged(int,bool))); // event conference map button clicked connect(showMapButton, SIGNAL(clicked()), SLOT(conferenceMapClicked())); @@ -104,10 +104,10 @@ void MainWindow::conferenceMapClicked() window.exec(); } -void MainWindow::eventHasChanged(int aEventId) +void MainWindow::eventHasChanged(int aEventId, bool aReloadModel) { dayTabContainer->updateTreeViewModel(aEventId); - favsTabContainer->updateTreeViewModel(aEventId); + favsTabContainer->updateTreeViewModel(aEventId,aReloadModel); tracksTabContainer->updateTreeViewModel(aEventId); nowTabContainer->updateTreeViewModel(aEventId); roomsTabContainer->updateTreeViewModel(aEventId); @@ -137,8 +137,8 @@ void MainWindow::initTabs() dayTabContainer->setDates(startDate, endDate); tracksTabContainer->setDates(startDate, endDate); roomsTabContainer->setDates(startDate, endDate); - //favsTabContainer->setDates(startDate, endDate); - //searchTabContainer->setDates(startDate, endDate); + favsTabContainer->setDates(startDate, endDate); + searchTabContainer->setDates(startDate, endDate); searchTabContainer->searchAgainClicked(); nowTabContainer->updateTreeView(QDate::currentDate()); } diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index e5678c3..a02a193 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -17,7 +17,7 @@ private slots: void scheduleImported(int aConfId); void aboutApp(); void conferenceMapClicked(); - void eventHasChanged(int aEventId); + void eventHasChanged(int aEventId, bool aReloadModel); private: void fillAndShowConferenceHeader(); void initTabs(); diff --git a/src/gui/tabcontainer.cpp b/src/gui/tabcontainer.cpp index 7a5da45..6e71ba2 100644 --- a/src/gui/tabcontainer.cpp +++ b/src/gui/tabcontainer.cpp @@ -26,7 +26,7 @@ TabContainer::TabContainer(QWidget *aParent) connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTreeView(const QDate &))); - connect(treeView, SIGNAL(eventHasChanged(int)), SIGNAL(eventHasChanged(int))); + connect(treeView, SIGNAL(eventHasChanged(int,bool)), SIGNAL(eventHasChanged(int,bool))); connect(treeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &))); connect(treeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &))); connect(treeView, SIGNAL(requestForConflicts(const QModelIndex &)), SLOT(displayConflicts(const QModelIndex &))); @@ -49,9 +49,9 @@ void TabContainer::itemClicked(const QModelIndex &aIndex) return; EventDialog dialog(static_cast(aIndex.internalPointer())->id(),this); - connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int))); + connect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool))); dialog.exec(); - disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int))); + disconnect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool))); } void TabContainer::displayMap(const QModelIndex &aIndex) @@ -78,14 +78,29 @@ void TabContainer::displayMap(const QModelIndex &aIndex) void TabContainer::displayConflicts(const QModelIndex &aIndex) { ConflictsDialog dialog(static_cast(aIndex.internalPointer())->id(),this); - connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int))); + connect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool))); dialog.exec(); - disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int))); + disconnect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool))); } -void TabContainer::updateTreeViewModel(int aEventId) +void TabContainer::updateTreeViewModel(int aEventId, bool aReloadModel) { - static_cast(treeView->model())->updateModel(aEventId); + if(aReloadModel) + { + // requires special handling + // eg. in case of favourities - some favourities may have changed + // and so we need to reload them + int confId = Conference::activeConference(); + QDate startDate = Conference::getById(confId).start(); + QDate endDate = Conference::getById(confId).end(); + dayNavigator->setDates(startDate, endDate); + updateTreeView( Conference::getById(confId).start() ); + } + else + { + // just update event in the question + static_cast(treeView->model())->updateModel(aEventId); + } } void TabContainer::setDates(const QDate &aStart, const QDate &aEnd) diff --git a/src/gui/tabcontainer.h b/src/gui/tabcontainer.h index c6c0c1f..3ecc779 100644 --- a/src/gui/tabcontainer.h +++ b/src/gui/tabcontainer.h @@ -25,10 +25,10 @@ protected: }; signals: - void eventHasChanged(int aEventId); + void eventHasChanged(int aEventId, bool aReloadModel); public slots: - virtual void updateTreeViewModel(int aEventId); + virtual void updateTreeViewModel(int aEventId, bool aReloadModel = false); void setDates(const QDate &aStart, const QDate &aEnd); protected slots: diff --git a/src/mvc/treeview.cpp b/src/mvc/treeview.cpp index 36f1f69..f907830 100644 --- a/src/mvc/treeview.cpp +++ b/src/mvc/treeview.cpp @@ -64,13 +64,13 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP conflicts = Event::conflictEvents(event.id(),Conference::activeConference()); } - // since the Favourite icon has changed, update TreeViews accordingly - // all TreeViews have to listen on this signal - emit(eventHasChanged(event.id())); - // have to emit 'eventHasChanged' signal on all events in conflict for(int i=0; i