1 #include "tabcontainer.h"
10 #include "eventdialog.h"
11 #include "mapwindow.h"
13 #include "conflictsdialog.h"
15 TabContainer::TabContainer(QWidget *aParent)
20 treeView->setHeaderHidden(true);
21 treeView->setRootIsDecorated(false);
22 treeView->setIndentation(0);
23 treeView->setAnimated(true);
24 treeView->setModel(new EventModel());
25 treeView->setItemDelegate(new Delegate(treeView));
27 connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTreeView(const QDate &)));
29 connect(treeView, SIGNAL(eventHasChanged(int,bool)), SIGNAL(eventHasChanged(int,bool)));
30 connect(treeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
31 connect(treeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
32 connect(treeView, SIGNAL(requestForConflicts(const QModelIndex &)), SLOT(displayConflicts(const QModelIndex &)));
34 // day navigator is hidden by default
38 void TabContainer::updateTreeView(const QDate &aDate)
41 loadEvents( aDate, Conference::activeConference() );
45 void TabContainer::itemClicked(const QModelIndex &aIndex)
47 // have to handle only events, not time-groups
48 if(!aIndex.parent().isValid()) // time-group
51 EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
52 connect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
54 disconnect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
57 void TabContainer::displayMap(const QModelIndex &aIndex)
59 Event *event = static_cast<Event*>(aIndex.internalPointer());
61 // room names are stored in lower-case format
62 // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png"
63 QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room().toLower().remove("."));
64 if(!QFile::exists(mapPath))
65 mapPath = QString(":/maps/rooms/not-available.png");
68 if(mapPath.contains("not-available", Qt::CaseInsensitive))
69 roomName = QString("Map is not available: %1").arg(event->room());
71 roomName = event->room();
74 MapWindow window(map,roomName,this);
78 void TabContainer::displayConflicts(const QModelIndex &aIndex)
80 ConflictsDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
81 connect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
83 disconnect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
86 void TabContainer::updateTreeViewModel(int aEventId, bool aReloadModel)
90 // requires special handling
91 // eg. in case of favourities - some favourities may have changed
92 // and so we need to reload them
93 int confId = Conference::activeConference();
94 QDate startDate = Conference::getById(confId).start();
95 QDate endDate = Conference::getById(confId).end();
96 dayNavigator->setDates(startDate, endDate);
97 updateTreeView( Conference::getById(confId).start() );
101 // just update event in the question
102 static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
106 void TabContainer::setDates(const QDate &aStart, const QDate &aEnd)
108 dayNavigator->setDates(aStart, aEnd);