source: src/gui/tabcontainer.cpp @ dc66a91

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

The favorite tab gets updated again after changing the favorite state.

  • Property mode set to 100644
File size: 3.1 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(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(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    ConflictsDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
80#ifdef N810
81    dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
82#endif
83    connect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
84    dialog.exec();
85    disconnect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
86}
87
88
89void TabContainer::redisplayEvent(int aEventId) {
90    static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
91}
92
93
94void TabContainer::redisplayDate(const QDate& curDate) {
95    updateTreeView(curDate);
96}
97
98
99void TabContainer::clearModel()
100{
101    static_cast<EventModel*>(treeView->model())->clearModel();
102}
103
Note: See TracBrowser for help on using the repository browser.