From: pavelpa Date: Wed, 27 Jan 2010 21:08:37 +0000 (+0000) Subject: 'conflict' dialog now contains list of events in conflict with given eventId X-Git-Tag: 0.5.0~167 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/d49254dfd400b8c543966a2979580db43a1fc867 'conflict' dialog now contains list of events in conflict with given eventId --- diff --git a/src/gui/conflictdialogcontainer.cpp b/src/gui/conflictdialogcontainer.cpp index b09eda7..b83bb8f 100644 --- a/src/gui/conflictdialogcontainer.cpp +++ b/src/gui/conflictdialogcontainer.cpp @@ -8,19 +8,7 @@ ConflictDialogContainer::ConflictDialogContainer(QWidget *aParent) void ConflictDialogContainer::loadEvents( const QDate &aDate, const int aConferenceId ) { - static_cast(treeView->model())->loadEventsByRoom( aDate, aConferenceId ); - //treeView->setAllExpanded(true); -} - -void ConflictDialogContainer::updateTreeViewModel(int 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() ); + static_cast(treeView->model())->loadConflictEvents( mEventId, aConferenceId ); + dayNavigator->hide(); } diff --git a/src/gui/conflictdialogcontainer.h b/src/gui/conflictdialogcontainer.h index 2f5c538..44b34b2 100644 --- a/src/gui/conflictdialogcontainer.h +++ b/src/gui/conflictdialogcontainer.h @@ -11,11 +11,13 @@ public: ConflictDialogContainer(QWidget *aParent); virtual ~ConflictDialogContainer(){} -public slots: - virtual void updateTreeViewModel(int aEventId); + void setEventId(int aEventId) { mEventId = aEventId; } protected: virtual void loadEvents( const QDate &aDate, const int aConferenceId ); + +private: + int mEventId; }; #endif /* CONFLICTDIALOGCONTAINER_H */ diff --git a/src/gui/conflictsdialog.cpp b/src/gui/conflictsdialog.cpp index 070dc9d..674375e 100644 --- a/src/gui/conflictsdialog.cpp +++ b/src/gui/conflictsdialog.cpp @@ -1,12 +1,14 @@ #include "conflictsdialog.h" -ConflictsDialog::ConflictsDialog(QWidget *aParent) +ConflictsDialog::ConflictsDialog(int aEventId, QWidget *aParent) : QDialog(aParent) { setupUi(this); connect(container, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int))); connect(container, SIGNAL(eventHasChanged(int)), container, SLOT(updateTreeViewModel(int))); + container->setEventId(aEventId); + int confId = Conference::activeConference(); QDate startDate = Conference::getById(confId).start(); QDate endDate = Conference::getById(confId).end(); diff --git a/src/gui/conflictsdialog.h b/src/gui/conflictsdialog.h index 40114ab..cd28c7c 100644 --- a/src/gui/conflictsdialog.h +++ b/src/gui/conflictsdialog.h @@ -8,7 +8,7 @@ class ConflictsDialog : public QDialog, Ui::ConflictsDialog { Q_OBJECT public: - ConflictsDialog(QWidget *aParent = NULL); + ConflictsDialog(int aEventId, QWidget *aParent = NULL); ~ConflictsDialog(); signals: void eventHasChanged(int aEventId); diff --git a/src/gui/favtabcontainer.cpp b/src/gui/favtabcontainer.cpp index 341dd9f..80bd6bb 100644 --- a/src/gui/favtabcontainer.cpp +++ b/src/gui/favtabcontainer.cpp @@ -12,6 +12,8 @@ void FavTabContainer::loadEvents( const QDate &aDate, const int 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); diff --git a/src/gui/tabcontainer.cpp b/src/gui/tabcontainer.cpp index a733824..8f30a96 100644 --- a/src/gui/tabcontainer.cpp +++ b/src/gui/tabcontainer.cpp @@ -33,7 +33,7 @@ TabContainer::TabContainer(QWidget *aParent) if(!Conference::getAll().count()) // no conference(s) in the DB { - dayNavigator->hide(); // hide DayNavigatorWidget + dayNavigator->hide(); } else { @@ -85,9 +85,7 @@ void TabContainer::displayMap(const QModelIndex &aIndex) void TabContainer::displayConflicts(const QModelIndex &aIndex) { - Q_UNUSED(aIndex); - - ConflictsDialog dialog; + ConflictsDialog dialog(static_cast(aIndex.internalPointer())->id(),this); connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int))); dialog.exec(); disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int))); diff --git a/src/mvc/event.cpp b/src/mvc/event.cpp index d587a36..ba7bbc4 100644 --- a/src/mvc/event.cpp +++ b/src/mvc/event.cpp @@ -68,6 +68,16 @@ QList Event::nowEvents(int conferenceId, QString orderBy) return load(query); } +QList Event::conflictEvents(int aEventId, int conferenceId) +{ + QSqlQuery query; + query.prepare( selectQuery() + QString("WHERE id IN ( SELECT conflict_event FROM event_conflict WHERE xid_event = :id AND xid_conference = :conf ) ORDER BY %1").arg("start")); + query.bindValue(":id", aEventId); + query.bindValue(":conf", conferenceId); + + return load(query); +} + QList Event::getFavByDate(const QDate& date, int conferenceId) { QSqlQuery query; diff --git a/src/mvc/event.h b/src/mvc/event.h index 822694d..8d55cef 100644 --- a/src/mvc/event.h +++ b/src/mvc/event.h @@ -27,6 +27,7 @@ public: static QList nowEvents(int conferenceId, QString orderBy); // get events scheduled NOW static QList getByTrack(int id); static QList getByDateAndRoom(const QDate& date, int conferenceId); + static QList conflictEvents(int aEventId, int conferenceId); public: int id() const { return value("id").toInt(); } int conferenceId() const { return value("xid_conference").toInt(); } diff --git a/src/mvc/eventmodel.cpp b/src/mvc/eventmodel.cpp index c64c758..23568a1 100644 --- a/src/mvc/eventmodel.cpp +++ b/src/mvc/eventmodel.cpp @@ -274,6 +274,18 @@ void EventModel::loadNowEvents(int aConferenceId) createTimeGroups(); } +void EventModel::loadConflictEvents(int aEventId, int aConferenceId) +{ + clearModel(); + // check for existence of the conference in the DB + if(Conference::getAll().count()) + { + qDebug() << "Loading Conference Data: [" << Conference::getById(aConferenceId).title() << "] in conflict with " << aEventId; + mEvents = Event::conflictEvents(aEventId, aConferenceId); + } + createTimeGroups(); +} + void EventModel::updateModel(int aEventId) { for(int i=0; i