#include "daynavigatorwidget.h"
#include "mapwindow.h"
+const int confId = 1;
+
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
actTreeView->setModel(new EventModel());
actTreeView->setItemDelegate(new Delegate(actTreeView));
- // event double clicked
- connect(dayTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &)));
- connect(favTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &)));
- connect(actTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &)));
+ // event clicked
+ connect(dayTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
+ connect(favTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
+ connect(actTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
// request for map to be displayed
connect(dayTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
connect(favTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
// TESTING: load some 'fav' data
if(Conference::getAll().count()) // no conference(s) in the DB
{
- int confId = 1;
static_cast<EventModel*>(favTreeView->model())->loadFavEvents(Conference::getById(confId).start(),confId);
favTreeView->reset();
}
}
else
{
- int confId = 1;
QDate aStartDate = Conference::getById(confId).start();
QDate aEndDate = Conference::getById(confId).end();
dayNavigator->setDates(aStartDate, aEndDate);
if(Conference::getAll().count())
{
- int confId = 1;
// 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
QDate aStartDate = Conference::getById(confId).start();
QDate aEndDate = Conference::getById(confId).end();
void MainWindow::updateDayView(const QDate &aDate)
{
- int confId = 1;
static_cast<EventModel*>(dayTreeView->model())->loadEvents(aDate,confId);
dayTreeView->reset();
dayNavigator->show();
void MainWindow::updateTab(const int aIndex)
{
- int confId = 1;
switch(aIndex)
{
case 0://index 0 of tabWidget: dayViewTab
}
};
-
-
}
void MainWindow::updateActivitiesDayView(const QDate &aDate)
{
- int confId = 1;
static_cast<EventModel*>(actTreeView->model())->loadEventsByActivities(aDate,confId);
actTreeView->reset();
activityDayNavigator->show();
void MainWindow::updateFavouritesDayView(const QDate &aDate)
{
- int confId = 1;
static_cast<EventModel*>(favTreeView->model())->loadFavEvents(aDate,confId);
favTreeView->reset();
favouriteDayNavigator->show();
}
-void MainWindow::itemDoubleClicked(const QModelIndex &aIndex)
+void MainWindow::itemClicked(const QModelIndex &aIndex)
{
// have to handle only events, not time-groups
if(!aIndex.parent().isValid()) // time-group
QModelIndex index = currentIndex();
QPoint point = aEvent->pos();
- testForControlClicked(index,point);
-
- // pass the event to the Base class, so item clicks/events are handled correctly
- QTreeView::mouseReleaseEvent(aEvent);
+ // test whether we have handled the mouse event
+ if(!testForControlClicked(index,point))
+ {
+ // pass the event to the Base class, so item clicks/events are handled correctly
+ QTreeView::mouseReleaseEvent(aEvent);
+ }
}
-void TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint)
+// returns bool if some Control was clicked
+bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint)
{
+ bool handled = false;
+
if(!aIndex.isValid())
- return;
+ return handled;
QRect rect = visualRect(aIndex); // visual QRect of selected/clicked item in the list
Delegate *delegate = static_cast<Delegate*>(itemDelegate(aIndex));
event.update("favourite");
// since the Favourite icon has changed, update TreeView accordingly
static_cast<EventModel*>(model())->emitDataChangedSignal(aIndex,aIndex);
+ handled = true;
}
break;
case Delegate::AlarmControlOn:
event.update("alarm");
// since the Alarm icon has changed, update TreeView accordingly
static_cast<EventModel*>(model())->emitDataChangedSignal(aIndex,aIndex);
-
+ handled = true;
}
break;
case Delegate::MapControl:
// handle Alarm Control clicked
qDebug() << "MAP CLICKED: " << qVariantValue<QString>(aIndex.data());
emit(requestForMap(aIndex));
+ handled = true;
}
break;
case Delegate::ControlNone:
default:
{
// item was clicked, but not a control
+ handled = false;
}
};
+
+ return handled;
}