X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/blobdiff_plain/92995da45a4d853eac6a4209e854f147b00e801d..699d5b8b1b53e8b3866150d59799d8cd96a53d63:/src/mvc/delegate.h diff --git a/src/mvc/delegate.h b/src/mvc/delegate.h index 657994d..98bef42 100644 --- a/src/mvc/delegate.h +++ b/src/mvc/delegate.h @@ -14,8 +14,13 @@ class Delegate : public QItemDelegate enum ControlId { ControlNone = 0, - FavouriteControl, - AlarmControl + FavouriteControlOn, + FavouriteControlOff, + AlarmControlOn, + AlarmControlOff, + MapControl, + WarningControlOn, + WarningControlOff }; class Control @@ -28,9 +33,12 @@ class Delegate : public QItemDelegate { } inline QImage *image() const { return mImage; } inline void setDrawPoint(const QPoint &aPoint) { mDrawPoint = aPoint; } - inline QPoint drawPoint(const QRect &aRect) const // for painter to draw Control + inline QPoint drawPoint(const QRect &aRect = QRect()) const // for painter to draw Control { - return QPoint(aRect.x()+aRect.width(),aRect.y()) + mDrawPoint; + if(aRect == QRect()) // null rectangle + return mDrawPoint; // returns relative drawing point + else + return QPoint(aRect.x()+aRect.width(),aRect.y()) + mDrawPoint; // returns absolute drawing point } inline QRect drawRect(const QRect &aRect) const // helper for determining if Control was clicked { @@ -56,6 +64,14 @@ class Delegate : public QItemDelegate bool isLast( const QModelIndex &index ) const; bool isExpanded( const QModelIndex &index ) const; void defineControls(); + // TODO: the better place for these methods would be 'eventmodel' + // they are used in 'paint' method and so it's better to obtain number of + // favourities/alarms once when the data has changed and not to call + // these methods which iterate over all Events in corresponding group + // every time it requires them + int numberOfFavourities(const QModelIndex &index) const; + int numberOfAlarms(const QModelIndex &index) const; + bool hasTimeConflict(const QModelIndex &index, const QModelIndex &parent) const; private: QPointer mViewPtr;