source: src/gui/tabcontainer.cpp @ bb6f7d6

qt5
Last change on this file since bb6f7d6 was bb6f7d6, checked in by pavelpa <pavelpa@…>, 12 years ago

search tab - header is hidden in case no conf exists in the DB

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include "tabcontainer.h"
2
3#include <QFile>
4#include <QMessageBox>
5#include <QTimer>
6
7#include <treeview.h>
8#include <delegate.h>
9
10#include "eventdialog.h"
11#include "mapwindow.h"
12
13#include "conflictsdialog.h"
14
15TabContainer::TabContainer(QWidget *aParent)
16    : QWidget(aParent)
17{
18    setupUi(this);
19
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));
26
27    connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTreeView(const QDate &)));
28
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 &)));
33
34    // day navigator is hidden by default
35    dayNavigator->hide();
36}
37
38void TabContainer::updateTreeView(const QDate &aDate)
39{
40    dayNavigator->show();
41    loadEvents( aDate, Conference::activeConference() );
42    treeView->reset();
43}
44
45void TabContainer::itemClicked(const QModelIndex &aIndex)
46{
47    // have to handle only events, not time-groups
48    if(!aIndex.parent().isValid()) // time-group
49        return;
50
51    EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
52    connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
53    dialog.exec();
54    disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
55}
56
57void TabContainer::displayMap(const QModelIndex &aIndex)
58{
59    Event *event = static_cast<Event*>(aIndex.internalPointer());
60
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");
66
67    QString roomName;
68    if(mapPath.contains("not-available", Qt::CaseInsensitive))
69        roomName = QString("Map is not available: %1").arg(event->room());
70    else
71        roomName = event->room();
72
73    QPixmap map(mapPath);
74    MapWindow window(map,roomName,this);
75    window.exec();
76}
77
78void TabContainer::displayConflicts(const QModelIndex &aIndex)
79{
80    ConflictsDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
81    connect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
82    dialog.exec();
83    disconnect(&dialog, SIGNAL(eventHasChanged(int)), this, SIGNAL(eventHasChanged(int)));
84}
85
86void TabContainer::updateTreeViewModel(int aEventId)
87{
88    static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
89}
90
91void TabContainer::setDates(const QDate &aStart, const QDate &aEnd)
92{
93    dayNavigator->setDates(aStart, aEnd);
94}
95
Note: See TracBrowser for help on using the repository browser.