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);
53 dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
55 connect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
57 disconnect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
60 void TabContainer::displayMap(const QModelIndex &aIndex)
62 Event *event = static_cast<Event*>(aIndex.internalPointer());
64 // room names are stored in lower-case format
65 // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png"
66 QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room().toLower().remove("."));
67 if(!QFile::exists(mapPath))
68 mapPath = QString(":/maps/rooms/not-available.png");
71 if(mapPath.contains("not-available", Qt::CaseInsensitive))
72 roomName = QString("Map is not available: %1").arg(event->room());
74 roomName = event->room();
77 MapWindow window(map,roomName,this);
81 void TabContainer::displayConflicts(const QModelIndex &aIndex)
83 ConflictsDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
85 dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
87 connect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
89 disconnect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
92 void TabContainer::updateTreeViewModel(int aEventId, bool aReloadModel)
96 // requires special handling
97 // eg. in case of favourities - some favourities may have changed
98 // and so we need to reload them
99 int confId = Conference::activeConference();
100 QDate startDate = Conference::getById(confId).start();
101 QDate endDate = Conference::getById(confId).end();
102 dayNavigator->setDates(startDate, endDate);
103 updateTreeView( Conference::getById(confId).start() );
107 // just update event in the question
108 static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
112 void TabContainer::setDates(const QDate &aStart, const QDate &aEnd)
114 dayNavigator->setDates(aStart, aEnd);