conflicts refactoring
authorpavelpa <pavelpa@localhost>
Tue, 26 Jan 2010 20:12:21 +0000 (20:12 +0000)
committerpavelpa <pavelpa@localhost>
Tue, 26 Jan 2010 20:12:21 +0000 (20:12 +0000)
 - has to be finished

src/icons.qrc
src/icons/exclamation-iconOff.png [deleted file]
src/icons/exclamation-iconOn.png [deleted file]
src/icons/exclamation.png [new file with mode: 0644]
src/mvc/delegate.cpp
src/mvc/delegate.h
src/mvc/treeview.cpp

index 808d862..192f8bc 100644 (file)
@@ -8,8 +8,7 @@
         <file>icons/compassBig.png</file>
         <file>icons/favourite-offBig.png</file>
         <file>icons/favourite-onBig.png</file>
-        <file>icons/exclamation-iconOn.png</file>
-        <file>icons/exclamation-iconOff.png</file>
+        <file>icons/exclamation.png</file>
         <file>icons/info.png</file>
         <file>icons/search.png</file>
     </qresource>
diff --git a/src/icons/exclamation-iconOff.png b/src/icons/exclamation-iconOff.png
deleted file mode 100644 (file)
index dc56ba8..0000000
Binary files a/src/icons/exclamation-iconOff.png and /dev/null differ
diff --git a/src/icons/exclamation-iconOn.png b/src/icons/exclamation-iconOn.png
deleted file mode 100644 (file)
index 91065fb..0000000
Binary files a/src/icons/exclamation-iconOn.png and /dev/null differ
diff --git a/src/icons/exclamation.png b/src/icons/exclamation.png
new file mode 100644 (file)
index 0000000..91065fb
Binary files /dev/null and b/src/icons/exclamation.png differ
index 8e25929..79d94db 100644 (file)
@@ -65,8 +65,7 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, cons
         //int spacer = (fmSmall.boundingRect("999").width() < SPACER) ? SPACER : fmSmall.boundingRect("999").width();
 
         //Time conflicts are colored differently
-        if ((static_cast<Event*>(index.internalPointer())->isFavourite())
-            && (hasTimeConflict(index, index.parent())))
+        if(hasTimeConflict(index, index.parent()))
         {
             bkgrColor = Qt::yellow;
         }
@@ -134,16 +133,9 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, cons
         painter->drawImage(mControls[MapControl]->drawPoint(option.rect),*mControls[MapControl]->image());
         // Time conflict
         //if(static_cast<Event*>(index.internalPointer())->hasTimeConflict())
-        if(bkgrColor == Qt::yellow)
-        {
-            painter->drawImage(mControls[WarningControlOn]->drawPoint(option.rect),*mControls[WarningControlOn]->image());
-            mControls[WarningControlOn]->hasConflict=true;
-        }
-        else
-        {
-            painter->drawImage(mControls[WarningControlOff]->drawPoint(option.rect),*mControls[WarningControlOff]->image());
-            mControls[WarningControlOn]->hasConflict=false;
-        }
+
+        if(hasTimeConflict(index, index.parent()))
+            painter->drawImage(mControls[WarningControl]->drawPoint(option.rect),*mControls[WarningControl]->image());
 
         // draw texts
         Event *event = static_cast<Event*>(index.internalPointer());
@@ -315,18 +307,16 @@ Delegate::ControlId Delegate::whichControlClicked(const QModelIndex &aIndex, con
     while (i.hasNext())
     {
         ControlId id = i.next();
-        if((mControls[id]->drawRect(static_cast<QTreeView*>(parent())->visualRect(aIndex)).contains(aPoint))
-            && (id != WarningControlOn) && (id != WarningControlOff))
-        {
-            return id;
-        }
-        else if ((mControls[id]->drawRect(static_cast<QTreeView*>(parent())->visualRect(aIndex)).contains(aPoint))
-            && (mControls[id]->hasConflict))
+        if(mControls[id]->drawRect(static_cast<QTreeView*>(parent())->visualRect(aIndex)).contains(aPoint))
         {
-            qDebug() << "tengo conflicto";
-            return id;
+            if(id == WarningControl)
+            {
+                if(mControls[id]->hasConflict)
+                    return id;
+            }
+            else
+                return id;
         }
-
     }
 
     return ControlNone;
@@ -380,21 +370,13 @@ void Delegate::defineControls()
     mControls.insert(MapControl,control);
 #endif
 
-    // WARNING ICONs
-    // on
-    control = new Control(WarningControlOn,QString(":icons/exclamation-iconOn.png"));
+    // WARNING ICON
+    control = new Control(WarningControl,QString(":icons/exclamation.png"));
     p = mControls[MapControl]->drawPoint();
     control->hasConflict = false;
     p.setX(p.x()-control->image()->width()-SPACER);
     control->setDrawPoint(p);
-    mControls.insert(WarningControlOn,control);
-    // off
-    control = new Control(WarningControlOff,QString(":icons/exclamation-iconOff.png"));
-    p = mControls[MapControl]->drawPoint();
-    control->hasConflict = false;
-    p.setX(p.x()-control->image()->width()-SPACER);
-    control->setDrawPoint(p);
-    mControls.insert(WarningControlOff,control);
+    mControls.insert(WarningControl,control);
 }
 
 bool Delegate::isPointFromRect(const QPoint &aPoint, const QRect &aRect) const
@@ -456,3 +438,4 @@ bool Delegate::hasTimeConflict(const QModelIndex &index, const QModelIndex &pare
     }
     return false;
 }
+
index d8cc1a4..42cce94 100644 (file)
@@ -19,8 +19,7 @@ class Delegate : public QItemDelegate
             AlarmControlOn,
             AlarmControlOff,
             MapControl,
-            WarningControlOn,
-            WarningControlOff
+            WarningControl
         };
 
         class Control
index 8e32690..d18c873 100644 (file)
@@ -100,8 +100,7 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
                 handled = true;
             }
         break;
-        case Delegate::WarningControlOff:
-        case Delegate::WarningControlOn:
+        case Delegate::WarningControl:
         {
 
             qDebug() << "WARNING CLICKED: " << qVariantValue<QString>(aIndex.data());