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 f0ed96518d5c732650eedcf32913ffce88945499..d9d6fa210d0d4bdf890a316a589fb4e54ff3fba8 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 67ea55ba6e32331ddf3e0c95d372cb1f296369a1..177219885d7fe3657bb4b7d2a05c31d339929b21 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