#include <conference.h>
#include <QDialog>
+#include <QMessageBox>
#include "ui_about.h"
#include "eventdialog.h"
#include "daynavigatorwidget.h"
#include "importscheduledialog.h"
#include "mapwindow.h"
+
const int confId = 1;
MainWindow::MainWindow(int aEventId, QWidget *aParent)
connect(favTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
connect(trackTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
connect(searchTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
+ // request for warning to be displayed
+ connect(dayTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
+ connect(favTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
+ connect(trackTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
+ connect(searchTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
// event search button clicked
connect(searchButton, SIGNAL(clicked()), SLOT(searchClicked()));
updateSearchView( Conference::getById(confId).start() );
}
+void MainWindow::displayWarning(const QModelIndex &aIndex)
+{
+ QMessageBox::warning(
+ this,
+ tr("Time Conflict Warning"),
+ tr("This event happens at the same time than another one of your favourites.") );
+}
void updateSearchView(const QDate &aDate);
void itemClicked(const QModelIndex &aIndex);
void displayMap(const QModelIndex &aIndex);
+ void displayWarning(const QModelIndex &aIndex);
void searchClicked();
private:
SqlEngine *mSqlEngine;
// Time conflict
//if(static_cast<Event*>(index.internalPointer())->hasTimeConflict())
if(bkgrColor == Qt::yellow)
+ {
painter->drawImage(mControls[WarningControlOn]->drawPoint(option.rect),*mControls[WarningControlOn]->image());
+ mControls[WarningControlOn]->hasConflict=true;
+ }
else
+ {
painter->drawImage(mControls[WarningControlOff]->drawPoint(option.rect),*mControls[WarningControlOff]->image());
+ mControls[WarningControlOn]->hasConflict=false;
+ }
// draw texts
Event *event = static_cast<Event*>(index.internalPointer());
while (i.hasNext())
{
ControlId id = i.next();
- if(mControls[id]->drawRect(static_cast<QTreeView*>(parent())->visualRect(aIndex)).contains(aPoint))
+ if((mControls[id]->drawRect(static_cast<QTreeView*>(parent())->visualRect(aIndex)).contains(aPoint))
+ && (id != WarningControlOn) && (id != WarningControlOff))
+ {
+ return id;
+ }
+ else
+ {
+ if ((mControls[id]->drawRect(static_cast<QTreeView*>(parent())->visualRect(aIndex)).contains(aPoint))
+ && (mControls[id]->hasConflict))
+ {
return id;
+ }
+ }
}
return ControlNone;
// on
control = new Control(WarningControlOn,QString(":icons/exclamation-iconOn.png"));
p = mControls[MapControl]->drawPoint();
+ control->hasConflict = false;
p.setX(p.x()-control->image()->width()-SPACER);
control->setDrawPoint(p);
mControls.insert(WarningControlOn,control);
// off
control = new Control(WarningControlOff,QString(":icons/exclamation-iconOff.png"));
p = mControls[MapControl]->drawPoint();
+ control->hasConflict = false;
p.setX(p.x()-control->image()->width()-SPACER);
control->setDrawPoint(p);
mControls.insert(WarningControlOff,control);
{
return QRect(drawPoint(aRect), drawPoint(aRect)+QPoint(mImage->size().width(),mImage->size().height()));
}
+ bool hasConflict;
private:
ControlId mId;
QImage *mImage;
handled = true;
}
break;
- case Delegate::WarningControlOn:
case Delegate::WarningControlOff:
+ case Delegate::WarningControlOn:
{
+
+ qDebug() << "WARNING CLICKED: " << qVariantValue<QString>(aIndex.data());
// TODO: implement
+ emit(requestForWarning(aIndex));
handled = true;
}
break;
void handleItemClicked(const QModelIndex &index);
signals:
void requestForMap(const QModelIndex &aIndex);
+ void requestForWarning(const QModelIndex &aIndex);
};
#endif /* TREEVIEW_H */