void ConflictDialogContainer::loadEvents( const QDate &aDate, const int aConferenceId )
{
- static_cast<EventModel*>(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<EventModel*>(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<EventModel*>(treeView->model())->loadConflictEvents( mEventId, aConferenceId );
+ dayNavigator->hide();
}
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 */
#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();
{
Q_OBJECT
public:
- ConflictsDialog(QWidget *aParent = NULL);
+ ConflictsDialog(int aEventId, QWidget *aParent = NULL);
~ConflictsDialog();
signals:
void eventHasChanged(int aEventId);
void FavTabContainer::updateTreeViewModel(int aEventId)
{
+ Q_UNUSED(aEventId);
+
// requires special handling
// we need to reload favourites, because some favourite could be deleted
//static_cast<EventModel*>(favTreeView->model())->updateModel(aEventId);
if(!Conference::getAll().count()) // no conference(s) in the DB
{
- dayNavigator->hide(); // hide DayNavigatorWidget
+ dayNavigator->hide();
}
else
{
void TabContainer::displayConflicts(const QModelIndex &aIndex)
{
- Q_UNUSED(aIndex);
-
- ConflictsDialog dialog;
+ ConflictsDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
dialog.exec();
disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
return load(query);
}
+QList<Event> 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> Event::getFavByDate(const QDate& date, int conferenceId)
{
QSqlQuery query;
static QList<Event> nowEvents(int conferenceId, QString orderBy); // get events scheduled NOW
static QList<Event> getByTrack(int id);
static QList<Event> getByDateAndRoom(const QDate& date, int conferenceId);
+ static QList<Event> conflictEvents(int aEventId, int conferenceId);
public:
int id() const { return value("id").toInt(); }
int conferenceId() const { return value("xid_conference").toInt(); }
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<mEvents.count(); i++)
int loadSearchResultEvents(const QDate &aDate, int aConferenceId);
void loadNowEvents(int aConferenceId); // loads Now events from the DB
void loadEventsByRoom(const QDate &aDate, int aConferenceId);
+ void loadConflictEvents(int aEventId, int aConferenceId); // loads events in conflict
private:
struct Group