X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/blobdiff_plain/5d228166c667e2deaa6294071bf2935cb01b302f..1825f8254c4aaa2fe261356b7b0a9091ac471b46:/src/gui/tabcontainer.cpp
diff --git a/src/gui/tabcontainer.cpp b/src/gui/tabcontainer.cpp
index 68d7d64..da29115 100644
--- a/src/gui/tabcontainer.cpp
+++ b/src/gui/tabcontainer.cpp
@@ -1,3 +1,22 @@
+/*
+ * Copyright (C) 2010 Ixonos Plc.
+ * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
+ *
+ * This file is part of ConfClerk.
+ *
+ * ConfClerk is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * ConfClerk is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ConfClerk. If not, see .
+ */
#include "tabcontainer.h"
#include
@@ -8,7 +27,8 @@
#include
#include "eventdialog.h"
-#include "mapwindow.h"
+#include "room.h"
+#include "errormessage.h"
#include "conflictsdialog.h"
@@ -24,11 +44,10 @@ TabContainer::TabContainer(QWidget *aParent)
treeView->setModel(new EventModel());
treeView->setItemDelegate(new Delegate(treeView));
- connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTreeView(const QDate &)));
+ // connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTreeView(const QDate &)));
connect(treeView, SIGNAL(eventHasChanged(int,bool)), SIGNAL(eventHasChanged(int,bool)));
connect(treeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
- connect(treeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
connect(treeView, SIGNAL(requestForConflicts(const QModelIndex &)), SLOT(displayConflicts(const QModelIndex &)));
// day navigator is hidden by default
@@ -37,9 +56,13 @@ TabContainer::TabContainer(QWidget *aParent)
void TabContainer::updateTreeView(const QDate &aDate)
{
+ int active_id = Conference::activeConference();
dayNavigator->show();
- loadEvents( aDate, Conference::activeConference() );
- treeView->reset();
+ if (active_id > 0) {
+ loadEvents(aDate, active_id);
+ } else {
+ static_cast(treeView->model())->clearModel();
+ }
}
void TabContainer::itemClicked(const QModelIndex &aIndex)
@@ -57,27 +80,6 @@ void TabContainer::itemClicked(const QModelIndex &aIndex)
disconnect(&dialog, SIGNAL(eventHasChanged(int,bool)), this, SIGNAL(eventHasChanged(int,bool)));
}
-void TabContainer::displayMap(const QModelIndex &aIndex)
-{
- Event *event = static_cast(aIndex.internalPointer());
-
- // room names are stored in lower-case format
- // room names are stored without dots in the name, eg. "aw.1124.png" -> "aw1124.png"
- QString mapPath = QString(":/maps/rooms/%1.png").arg(event->room().toLower().remove("."));
- if(!QFile::exists(mapPath))
- mapPath = QString(":/maps/rooms/not-available.png");
-
- QString roomName;
- if(mapPath.contains("not-available", Qt::CaseInsensitive))
- roomName = QString("Map is not available: %1").arg(event->room());
- else
- roomName = event->room();
-
- QPixmap map(mapPath);
- MapWindow window(map,roomName,this);
- window.exec();
-}
-
void TabContainer::displayConflicts(const QModelIndex &aIndex)
{
ConflictsDialog dialog(static_cast(aIndex.internalPointer())->id(),this);
@@ -94,13 +96,13 @@ void TabContainer::updateTreeViewModel(int aEventId, bool aReloadModel)
if(aReloadModel)
{
// requires special handling
- // eg. in case of favourities - some favourities may have changed
+ // eg. in case of favourites - some favourites may have changed
// and so we need to reload them
int confId = Conference::activeConference();
QDate startDate = Conference::getById(confId).start();
QDate endDate = Conference::getById(confId).end();
dayNavigator->setDates(startDate, endDate);
- updateTreeView( Conference::getById(confId).start() );
+ updateTreeView(dayNavigator->curDate());
}
else
{
@@ -109,8 +111,19 @@ void TabContainer::updateTreeViewModel(int aEventId, bool aReloadModel)
}
}
+
+void TabContainer::setCurDate(const QDate& curDate) {
+ updateTreeView(curDate);
+}
+
+
void TabContainer::setDates(const QDate &aStart, const QDate &aEnd)
{
dayNavigator->setDates(aStart, aEnd);
}
+void TabContainer::clearModel()
+{
+ static_cast(treeView->model())->clearModel();
+}
+