X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/blobdiff_plain/680a4da6eaddcd82c4702df65c7bf6708769fab6..699d5b8b1b53e8b3866150d59799d8cd96a53d63:/src/mvc/delegate.h diff --git a/src/mvc/delegate.h b/src/mvc/delegate.h index 63c74dc..98bef42 100644 --- a/src/mvc/delegate.h +++ b/src/mvc/delegate.h @@ -18,7 +18,9 @@ class Delegate : public QItemDelegate FavouriteControlOff, AlarmControlOn, AlarmControlOff, - MapControl + MapControl, + WarningControlOn, + WarningControlOff }; class Control @@ -31,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 { @@ -59,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;