source: src/gui/tabcontainer.cpp @ e6ab8a2

qt5
Last change on this file since e6ab8a2 was e6ab8a2, checked in by Philipp Spitzer <philipp@…>, 11 years ago

Removed the ability to show "pictures" (maps) of rooms and maps of conferences.
The XML file does not contain picture/map/image information of conferences or rooms.
We left the room.picture definition in the database SQL because there is no "drop column"
in sqlite.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
4 *
5 * This file is part of ConfClerk.
6 *
7 * ConfClerk is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * ConfClerk is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * ConfClerk.  If not, see <http://www.gnu.org/licenses/>.
19 */
20#include "tabcontainer.h"
21
22#include <QFile>
23#include <QMessageBox>
24#include <QTimer>
25
26#include <treeview.h>
27#include <delegate.h>
28
29#include "eventdialog.h"
30#include "room.h"
31#include "errormessage.h"
32
33#include "conflictsdialog.h"
34
35TabContainer::TabContainer(QWidget *aParent)
36    : QWidget(aParent)
37{
38    setupUi(this);
39
40    treeView->setHeaderHidden(true);
41    treeView->setRootIsDecorated(false);
42    treeView->setIndentation(0);
43    treeView->setAnimated(true);
44    treeView->setModel(new EventModel());
45    treeView->setItemDelegate(new Delegate(treeView));
46
47    connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTreeView(const QDate &)));
48
49    connect(treeView, SIGNAL(eventHasChanged(int,bool)), SIGNAL(eventHasChanged(int,bool)));
50    connect(treeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
51    connect(treeView, SIGNAL(requestForConflicts(const QModelIndex &)), SLOT(displayConflicts(const QModelIndex &)));
52
53    // day navigator is hidden by default
54    dayNavigator->hide();
55}
56
57void TabContainer::updateTreeView(const QDate &aDate)
58{
59    int active_id = Conference::activeConference();
60    dayNavigator->show();
61    if (active_id > 0) {
62        loadEvents(aDate, active_id);
63    } else {
64        static_cast<EventModel*>(treeView->model())->clearModel();
65    }
66}
67
68void TabContainer::itemClicked(const QModelIndex &aIndex)
69{
70    // have to handle only events, not time-groups
71    if(!aIndex.parent().isValid()) // time-group
72        return;
73
74    EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
75#ifdef N810
76    dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
77#endif
78    connect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
79    dialog.exec();
80    disconnect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
81}
82
83void TabContainer::displayConflicts(const QModelIndex &aIndex)
84{
85    ConflictsDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
86#ifdef N810
87    dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
88#endif
89    connect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
90    dialog.exec();
91    disconnect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
92}
93
94void TabContainer::updateTreeViewModel(int aEventId, bool aReloadModel)
95{
96    if(aReloadModel)
97    {
98        // requires special handling
99        // eg. in case of favourities - some favourities may have changed
100        // and so we need to reload them
101        int confId = Conference::activeConference();
102        QDate startDate = Conference::getById(confId).start();
103        QDate endDate = Conference::getById(confId).end();
104        dayNavigator->setDates(startDate, endDate);
105        updateTreeView( Conference::getById(confId).start() );
106    }
107    else
108    {
109        // just update event in the question
110        static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
111    }
112}
113
114void TabContainer::setDates(const QDate &aStart, const QDate &aEnd)
115{
116    dayNavigator->setDates(aStart, aEnd);
117}
118
119void TabContainer::clearModel()
120{
121    static_cast<EventModel*>(treeView->model())->clearModel();
122}
123
Note: See TracBrowser for help on using the repository browser.