1 #include "tabcontainer.h"
10 #include "eventdialog.h"
11 #include "mapwindow.h"
13 TabContainer::TabContainer(QWidget *aParent)
18 treeView->setHeaderHidden(true);
19 treeView->setRootIsDecorated(false);
20 treeView->setIndentation(0);
21 treeView->setAnimated(true);
22 treeView->setModel(new EventModel());
23 treeView->setItemDelegate(new Delegate(treeView));
25 connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTreeView(const QDate &)));
27 connect(treeView, SIGNAL(eventHasChanged(int)), SIGNAL(eventHasChanged(int)));
28 connect(treeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
29 connect(treeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
30 connect(treeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
32 if(!Conference::getAll().count()) // no conference(s) in the DB
34 dayNavigator->hide(); // hide DayNavigatorWidget
38 QDate aStartDate = Conference::getById(AppSettings::confId()).start();
39 QDate aEndDate = Conference::getById(AppSettings::confId()).end();
40 dayNavigator->setDates(aStartDate, aEndDate);
44 void TabContainer::updateTreeView(const QDate &aDate)
47 loadEvents( aDate, AppSettings::confId() );
51 void TabContainer::itemClicked(const QModelIndex &aIndex)
53 // have to handle only events, not time-groups
54 if(!aIndex.parent().isValid()) // time-group
57 EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
58 connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
60 disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
63 void TabContainer::displayMap(const QModelIndex &aIndex)
65 Event *event = static_cast<Event*>(aIndex.internalPointer());
67 // room names are stored in lower-case format
68 // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png"
69 QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room().toLower().remove("."));
70 if(!QFile::exists(mapPath))
71 mapPath = QString(":/maps/rooms/not-available.png");
74 if(mapPath.contains("not-available", Qt::CaseInsensitive))
75 roomName = QString("Map is not available: %1").arg(event->room());
77 roomName = event->room();
80 MapWindow window(map,roomName,this);
84 void TabContainer::displayWarning(const QModelIndex &aIndex)
90 tr("Time Conflict Warning"),
91 tr("This event happens at the same time than another one of your favourites.") );
94 void TabContainer::updateTreeViewModel(int aEventId)
96 static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
99 void TabContainer::setDates(const QDate &aStart, const QDate &aEnd)
101 dayNavigator->setDates(aStart, aEnd);