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)), SIGNAL(eventHasChanged(int)));
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)), this, SIGNAL(eventHasChanged(int)));
54 disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
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)), this, SIGNAL(eventHasChanged(int)));
83 disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
86 void TabContainer::updateTreeViewModel(int aEventId)
88 static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
91 void TabContainer::setDates(const QDate &aStart, const QDate &aEnd)
93 dayNavigator->setDates(aStart, aEnd);