From: pavelpa Date: Tue, 26 Jan 2010 20:12:21 +0000 (+0000) Subject: conflicts refactoring X-Git-Tag: 0.5.0~182 X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/commitdiff_plain/336fa33e20b71c122b3f29d9eb65587ac57c1b4e conflicts refactoring - has to be finished --- diff --git a/src/icons.qrc b/src/icons.qrc index 808d862..192f8bc 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -8,8 +8,7 @@ icons/compassBig.png icons/favourite-offBig.png icons/favourite-onBig.png - icons/exclamation-iconOn.png - icons/exclamation-iconOff.png + icons/exclamation.png icons/info.png icons/search.png diff --git a/src/icons/exclamation-iconOff.png b/src/icons/exclamation-iconOff.png deleted file mode 100644 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 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 index 0000000..91065fb Binary files /dev/null and b/src/icons/exclamation.png differ diff --git a/src/mvc/delegate.cpp b/src/mvc/delegate.cpp index 8e25929..79d94db 100644 --- a/src/mvc/delegate.cpp +++ b/src/mvc/delegate.cpp @@ -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(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(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(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(parent())->visualRect(aIndex)).contains(aPoint)) - && (id != WarningControlOn) && (id != WarningControlOff)) - { - return id; - } - else if ((mControls[id]->drawRect(static_cast(parent())->visualRect(aIndex)).contains(aPoint)) - && (mControls[id]->hasConflict)) + if(mControls[id]->drawRect(static_cast(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; } + diff --git a/src/mvc/delegate.h b/src/mvc/delegate.h index d8cc1a4..42cce94 100644 --- a/src/mvc/delegate.h +++ b/src/mvc/delegate.h @@ -19,8 +19,7 @@ class Delegate : public QItemDelegate AlarmControlOn, AlarmControlOff, MapControl, - WarningControlOn, - WarningControlOff + WarningControl }; class Control diff --git a/src/mvc/treeview.cpp b/src/mvc/treeview.cpp index 8e32690..d18c873 100644 --- a/src/mvc/treeview.cpp +++ b/src/mvc/treeview.cpp @@ -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(aIndex.data());