[svn-upgrade] new version fosdem-schedule (0.4.1+svn262+ds)
[debian/fosdem-schedule.git] / src / mvc / delegate.h
index 227cccc66fa4cf8b5c2d5c1eb23619ffd94f40fe..177219885d7fe3657bb4b7d2a05c31d339929b21 100644 (file)
@@ -43,13 +43,19 @@ class Delegate : public QItemDelegate
         class Control
         {
             public:
-                Control(ControlId aControlId, const QString &aImageName)
-                    : mId(aControlId)
-                    , mImage(new QImage(aImageName))
-                    , mDrawPoint(QPoint(0,0))
-                { }
+                Control(ControlId aControlId, const QString &aImageName, const Control* prev_control);
+
                 inline QImage *image() const { return mImage; }
                 inline void setDrawPoint(const QPoint &aPoint) { mDrawPoint = aPoint; }
+                inline QRect drawRect(const QRect &aRect) const // helper for determining if Control was clicked
+                {
+                    return QRect(drawPoint(aRect), drawPoint(aRect)+QPoint(mImage->size().width(),mImage->size().height()));
+                }
+                void paint(QPainter* painter, const QRect rect);
+
+                bool enabled() const { return mEnabled; }
+                void setEnabled(bool v) { mEnabled = v; }
+            private:
                 inline QPoint drawPoint(const QRect &aRect = QRect()) const // for painter to draw Control
                 {
                     if(aRect == QRect()) // null rectangle
@@ -57,14 +63,11 @@ class Delegate : public QItemDelegate
                     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
-                {
-                    return QRect(drawPoint(aRect), drawPoint(aRect)+QPoint(mImage->size().width(),mImage->size().height()));
-                }
-            private:
+
                 ControlId mId;
                 QImage *mImage;
                 QPoint mDrawPoint; // relative 'start-drawing' position (may hold negative values)
+                bool mEnabled;
         };
 
         Delegate(QTreeView *aParent); // the delegate 'owner' has to be specified in the constructor - it's used to obtain visualRect of selected item/index