add enabled flag
authorkirilma <kirilma@localhost>
Wed, 5 May 2010 13:59:24 +0000 (13:59 +0000)
committerkirilma <kirilma@localhost>
Wed, 5 May 2010 13:59:24 +0000 (13:59 +0000)
src/mvc/delegate.cpp
src/mvc/delegate.h

index f0ed965..d9d6fa2 100644 (file)
@@ -135,6 +135,9 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, cons
         }
 
         // draw Controls
+        foreach(Control* c, mControls.values()) {
+            c->setEnabled(false);
+        }
         if(event->isFavourite())
             mControls[FavouriteControlOn]->paint(painter, option.rect);
         else
@@ -341,6 +344,7 @@ Delegate::Control::Control(ControlId aControlId, const QString &aImageName, cons
     : mId(aControlId)
     , mImage(new QImage(aImageName))
     , mDrawPoint(QPoint(0,0))
+    , mEnabled(false)
 {
     QPoint p;
     if (prev_control == NULL) {
@@ -355,6 +359,7 @@ Delegate::Control::Control(ControlId aControlId, const QString &aImageName, cons
 void Delegate::Control::paint(QPainter* painter, const QRect rect)
 {
     painter->drawImage(drawPoint(rect),*image());
+    setEnabled(true);
 }
 
 void Delegate::defineControls()
index 67ea55b..1772198 100644 (file)
@@ -53,6 +53,8 @@ class Delegate : public QItemDelegate
                 }
                 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
                 {
@@ -65,6 +67,7 @@ class Delegate : public QItemDelegate
                 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