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 if(!Conference::getAll().count()) // no conference(s) in the DB
36 dayNavigator->hide(); // hide DayNavigatorWidget
40 QDate aStartDate = Conference::getById(Conference::activeConference()).start();
41 QDate aEndDate = Conference::getById(Conference::activeConference()).end();
42 dayNavigator->setDates(aStartDate, aEndDate);
46 void TabContainer::updateTreeView(const QDate &aDate)
49 loadEvents( aDate, Conference::activeConference() );
53 void TabContainer::itemClicked(const QModelIndex &aIndex)
55 // have to handle only events, not time-groups
56 if(!aIndex.parent().isValid()) // time-group
59 EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
60 connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
62 disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
65 void TabContainer::displayMap(const QModelIndex &aIndex)
67 Event *event = static_cast<Event*>(aIndex.internalPointer());
69 // room names are stored in lower-case format
70 // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png"
71 QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room().toLower().remove("."));
72 if(!QFile::exists(mapPath))
73 mapPath = QString(":/maps/rooms/not-available.png");
76 if(mapPath.contains("not-available", Qt::CaseInsensitive))
77 roomName = QString("Map is not available: %1").arg(event->room());
79 roomName = event->room();
82 MapWindow window(map,roomName,this);
86 void TabContainer::displayConflicts(const QModelIndex &aIndex)
90 ConflictsDialog dialog;
91 connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
93 disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
96 void TabContainer::updateTreeViewModel(int aEventId)
98 static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
101 void TabContainer::setDates(const QDate &aStart, const QDate &aEnd)
103 dayNavigator->setDates(aStart, aEnd);