]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/mvc/delegate.h
Time conflict warning
[toast/confclerk.git] / src / mvc / delegate.h
index a11cfabda8b9084796478d7000150a398e0ed084..98bef422711466300b172132b24acbe7814b8379 100644 (file)
@@ -14,9 +14,13 @@ class Delegate : public QItemDelegate
         enum ControlId
         {
             ControlNone = 0,
         enum ControlId
         {
             ControlNone = 0,
-            FavouriteControl,
-            AlarmControl,
-            MapControl
+            FavouriteControlOn,
+            FavouriteControlOff,
+            AlarmControlOn,
+            AlarmControlOff,
+            MapControl,
+            WarningControlOn,
+            WarningControlOff
         };
 
         class Control
         };
 
         class Control
@@ -29,9 +33,12 @@ class Delegate : public QItemDelegate
                 { }
                 inline QImage *image() const { return mImage; }
                 inline void setDrawPoint(const QPoint &aPoint) { mDrawPoint = aPoint; }
                 { }
                 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
                 {
                 }
                 inline QRect drawRect(const QRect &aRect) const // helper for determining if Control was clicked
                 {
@@ -57,6 +64,14 @@ class Delegate : public QItemDelegate
         bool isLast( const QModelIndex &index ) const;
         bool isExpanded( const QModelIndex &index ) const;
         void defineControls();
         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<QTreeView> mViewPtr;
 
     private:
         QPointer<QTreeView> mViewPtr;