source: src/gui/tabcontainer.cpp

Last change on this file was ffb6be7, checked in by gregor herrmann <gregor@…>, 4 months ago

Bump copyright years.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011-2021 Philipp Spitzer, gregor herrmann, Stefan Stahl
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(treeView, SIGNAL(eventChanged(int,bool)), SIGNAL(eventChanged(int,bool)));
48    connect(treeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
49    connect(treeView, SIGNAL(requestForConflicts(const QModelIndex &)), SLOT(displayConflicts(const QModelIndex &)));
50}
51
52void TabContainer::updateTreeView(const QDate &aDate)
53{
54    int active_id = Conference::activeConference();
55    if (active_id > 0) {
56        loadEvents(aDate, active_id);
57    } else {
58        static_cast<EventModel*>(treeView->model())->clearModel();
59    }
60}
61
62void TabContainer::itemClicked(const QModelIndex &aIndex)
63{
64    // have to handle only events, not time-groups
65    if(!aIndex.parent().isValid()) // time-group
66        return;
67
68    EventDialog dialog(Conference::activeConference(), static_cast<Event*>(aIndex.internalPointer())->id(),this);
69#ifdef N810
70    dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
71#endif
72    connect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
73    dialog.exec();
74    disconnect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
75}
76
77void TabContainer::displayConflicts(const QModelIndex &aIndex)
78{
79    Event* event = static_cast<Event*>(aIndex.internalPointer());
80    ConflictsDialog dialog(event->id(), event->conferenceId(), this);
81#ifdef N810
82    dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
83#endif
84    connect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
85    dialog.exec();
86    disconnect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
87}
88
89
90void TabContainer::redisplayEvent(int aEventId) {
91    static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
92}
93
94
95void TabContainer::redisplayDate(const QDate& curDate) {
96    updateTreeView(curDate);
97}
98
99
100void TabContainer::clearModel()
101{
102    static_cast<EventModel*>(treeView->model())->clearModel();
103}
104
Note: See TracBrowser for help on using the repository browser.