2 * Copyright (C) 2010 Ixonos Plc.
3 * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
5 * This file is part of ConfClerk.
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)
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
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/>.
20 #include "tabcontainer.h"
23 #include <QMessageBox>
29 #include "eventdialog.h"
31 #include "errormessage.h"
33 #include "conflictsdialog.h"
35 TabContainer::TabContainer(QWidget *aParent)
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));
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 &)));
52 void TabContainer::updateTreeView(const QDate &aDate)
54 int active_id = Conference::activeConference();
56 loadEvents(aDate, active_id);
58 static_cast<EventModel*>(treeView->model())->clearModel();
62 void TabContainer::itemClicked(const QModelIndex &aIndex)
64 // have to handle only events, not time-groups
65 if(!aIndex.parent().isValid()) // time-group
68 EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
70 dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
72 connect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
74 disconnect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
77 void TabContainer::displayConflicts(const QModelIndex &aIndex)
79 ConflictsDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
81 dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
83 connect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
85 disconnect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
89 void TabContainer::redisplayEvent(int aEventId, bool aReloadModel) {
90 /* if (aReloadModel) updateTreeView(dayNavigator->curDate());
91 else */ static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
95 void TabContainer::redisplayDate(const QDate& curDate) {
96 updateTreeView(curDate);
100 void TabContainer::clearModel()
102 static_cast<EventModel*>(treeView->model())->clearModel();