X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/blobdiff_plain/05afe5fb1267dff4b5ebbcc8c4c89571ebb08a73..dc66a9113c07a4682c6036157dbc0f3708c4af82:/src/gui/tabcontainer.cpp
diff --git a/src/gui/tabcontainer.cpp b/src/gui/tabcontainer.cpp
index 6035e84..822a80b 100644
--- a/src/gui/tabcontainer.cpp
+++ b/src/gui/tabcontainer.cpp
@@ -1,28 +1,42 @@
+/*
+ * 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
#include
#include
-#include
-
-#include
-
#include
-#include
#include
#include "eventdialog.h"
-#include "mapwindow.h"
+#include "room.h"
+#include "errormessage.h"
+
+#include "conflictsdialog.h"
TabContainer::TabContainer(QWidget *aParent)
: QWidget(aParent)
- , mType(EContainerTypeNone)
{
setupUi(this);
- searchAgainButton->hide();
-
treeView->setHeaderHidden(true);
treeView->setRootIsDecorated(false);
treeView->setIndentation(0);
@@ -30,74 +44,19 @@ TabContainer::TabContainer(QWidget *aParent)
treeView->setModel(new EventModel());
treeView->setItemDelegate(new Delegate(treeView));
- connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateTreeView(const QDate &)));
-
- connect(treeView, SIGNAL(eventHasChanged(int)), SIGNAL(eventHasChanged(int)));
+ connect(treeView, SIGNAL(eventChanged(int,bool)), SIGNAL(eventChanged(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(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
-
- if(!Conference::getAll().count()) // no conference(s) in the DB
- {
- dayNavigator->hide(); // hide DayNavigatorWidget
- }
- else
- {
- QDate aStartDate = Conference::getById(AppSettings::confId()).start();
- QDate aEndDate = Conference::getById(AppSettings::confId()).end();
- dayNavigator->setDates(aStartDate, aEndDate);
- }
-}
-
-void TabContainer::setType(TabContainer::Type aType)
-{
- mType = aType;
- if(aType == EContainerTypeNow)
- {
- QTimer *timer = new QTimer( this );
- connect( timer, SIGNAL(timeout()), SLOT(timerUpdateTreeView()) );
- timer->start( 30000); // 30 seconds timer
- }
+ connect(treeView, SIGNAL(requestForConflicts(const QModelIndex &)), SLOT(displayConflicts(const QModelIndex &)));
}
void TabContainer::updateTreeView(const QDate &aDate)
{
- switch(mType)
- {
- case EContainerTypeDay:
- {
- static_cast(treeView->model())->loadEvents(aDate,AppSettings::confId());
- }
- break;
- case EContainerTypeFavs:
- {
- static_cast(treeView->model())->loadFavEvents(aDate,AppSettings::confId());
- }
- break;
- case EContainerTypeTracks:
- {
- static_cast(treeView->model())->loadEventsByTrack(aDate, AppSettings::confId());
- }
- break;
- case EContainerTypeRooms:
- {
- static_cast(treeView->model())->loadEventsByRoom(aDate, AppSettings::confId());
- }
- break;
- case EContainerTypeNow:
- {
- static_cast(treeView->model())->loadNowEvents(AppSettings::confId());
- treeView->setAllExpanded(true);
- }
- break;
- case EContainerTypeNone:
- default:
- {
- qDebug() << "Container type not specified";
- }
+ int active_id = Conference::activeConference();
+ if (active_id > 0) {
+ loadEvents(aDate, active_id);
+ } else {
+ static_cast(treeView->model())->clearModel();
}
- treeView->reset();
- dayNavigator->show();
}
void TabContainer::itemClicked(const QModelIndex &aIndex)
@@ -107,74 +66,38 @@ void TabContainer::itemClicked(const QModelIndex &aIndex)
return;
EventDialog dialog(static_cast(aIndex.internalPointer())->id(),this);
+#ifdef N810
+ dialog.setFixedWidth(static_cast(parent())->width());
+#endif
+ connect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
dialog.exec();
+ disconnect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
}
-void TabContainer::displayMap(const QModelIndex &aIndex)
+void TabContainer::displayConflicts(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();
+ ConflictsDialog dialog(static_cast(aIndex.internalPointer())->id(),this);
+#ifdef N810
+ dialog.setFixedWidth(static_cast(parent())->width());
+#endif
+ connect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
+ dialog.exec();
+ disconnect(&dialog, SIGNAL(eventChanged(int,bool)), this, SIGNAL(eventChanged(int,bool)));
}
-void TabContainer::displayWarning(const QModelIndex &aIndex)
-{
- Q_UNUSED(aIndex);
- QMessageBox::warning(
- this,
- tr("Time Conflict Warning"),
- tr("This event happens at the same time than another one of your favourites.") );
+void TabContainer::redisplayEvent(int aEventId) {
+ static_cast(treeView->model())->updateModel(aEventId);
}
-void TabContainer::updateTreeViewModel(int aEventId)
-{
- switch(mType)
- {
- case EContainerTypeFavs:
- {
- // requires special handling
- // we need to reload favourites, because some favourite could be deleted
- //static_cast(favTreeView->model())->updateModel(aEventId);
- QDate aStartDate = Conference::getById(AppSettings::confId()).start();
- QDate aEndDate = Conference::getById(AppSettings::confId()).end();
- dayNavigator->setDates(aStartDate, aEndDate);
- updateTreeView( Conference::getById(AppSettings::confId()).start() );
- }
- break;
- case EContainerTypeDay:
- case EContainerTypeNone:
- default:
- {
- static_cast(treeView->model())->updateModel(aEventId);
- }
- }
-}
-void TabContainer::setDates(const QDate &aStart, const QDate &aEnd)
-{
- dayNavigator->setDates(aStart, aEnd);
+void TabContainer::redisplayDate(const QDate& curDate) {
+ updateTreeView(curDate);
}
-void TabContainer::timerUpdateTreeView()
+
+void TabContainer::clearModel()
{
- if(mType == EContainerTypeNow)
- {
- updateTreeView(QDate());
- }
+ static_cast(treeView->model())->clearModel();
}