File r897759.diff of Package kdepim4

Subject: kalarm: disabled from enabled alarm colour when highlighted in alarm list
From: wstephenson@suse.de
Bug: 
Patch-upstream: 897759
--- kalarm/alarmlistdelegate.cpp	(revision 897758)
+++ kalarm/alarmlistdelegate.cpp	(revision 897759)
@@ -19,46 +19,57 @@
  */
 
 #include "kalarm.h"
-
-#include <QAbstractProxyModel>
-#include <QMouseEvent>
-#include <QApplication>
-
-#include <kdebug.h>
+#include "alarmlistdelegate.moc"
 
 #include "resources/kcalendar.h"
 #include "alarmlistview.h"
 #include "alarmresources.h"
 #include "eventlistmodel.h"
 #include "functions.h"
-#include "alarmlistdelegate.moc"
+
+#include <kcolorscheme.h>
+#include <kdebug.h>
+
+#include <QAbstractProxyModel>
+#include <QMouseEvent>
+#include <QApplication>
 
 
 void AlarmListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
 {
-	if (index.isValid()  &&  index.column() == EventListModel::TimeColumn)
+	QStyleOptionViewItem opt = option;
+	if (index.isValid())
 	{
-		QString str = index.data(Qt::DisplayRole).toString();
-		// Need to pad out spacing to align times without leading zeroes
-		int i = str.indexOf(" ~");    // look for indicator that leading zeroes are omitted
-		if (i >= 0)
+		if (opt.state & QStyle::State_Selected
+		&&  !index.data(EventListModel::EnabledRole).toBool())
+		{
+			// Make the text colour for selected disabled alarms
+			// distinguishable from enabled alarms.
+			KColorScheme::adjustForeground(opt.palette, KColorScheme::InactiveText, QPalette::HighlightedText, KColorScheme::Selection);
+		}
+		if (index.column() == EventListModel::TimeColumn)
 		{
-			QStyleOptionViewItem opt = option;
-			QVariant value;
-			value = index.data(Qt::ForegroundRole);
-			if (value.isValid())
-				opt.palette.setColor(QPalette::Text, value.value<QColor>());
-			int digitWidth = opt.fontMetrics.width("0");
-			QString date = str.left(i + 1);
-			int w = opt.fontMetrics.width(date) + digitWidth;
-			drawDisplay(painter, opt, opt.rect, date);
-			QRect rect(opt.rect);
-			rect.setLeft(rect.left() + w);
-			drawDisplay(painter, opt, rect, str.mid(i + 2));
-			return;
+			QString str = index.data(Qt::DisplayRole).toString();
+			// Need to pad out spacing to align times without leading zeroes
+			int i = str.indexOf(" ~");    // look for indicator that leading zeroes are omitted
+			if (i >= 0)
+			{
+				QVariant value;
+				value = index.data(Qt::ForegroundRole);
+				if (value.isValid())
+					opt.palette.setColor(QPalette::Text, value.value<QColor>());
+				int digitWidth = opt.fontMetrics.width("0");
+				QString date = str.left(i + 1);
+				int w = opt.fontMetrics.width(date) + digitWidth;
+				drawDisplay(painter, opt, opt.rect, date);
+				QRect rect(opt.rect);
+				rect.setLeft(rect.left() + w);
+				drawDisplay(painter, opt, rect, str.mid(i + 2));
+				return;
+			}
 		}
 	}
-	QItemDelegate::paint(painter, option, index);
+	QItemDelegate::paint(painter, opt, index);
 }
 
 QSize AlarmListDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
--- kalarm/eventlistmodel.cpp	(revision 897758)
+++ kalarm/eventlistmodel.cpp	(revision 897759)
@@ -144,6 +144,8 @@ QVariant EventListModel::data(const QMod
 			break;   // use the default for normal active alarms
 		case StatusRole:
 			return event->category();
+		case EnabledRole:
+			return event->enabled();
 		default:
 			break;
 	}
--- kalarm/Changelog	(revision 897758)
+++ kalarm/Changelog	(revision 897759)
@@ -1,6 +1,7 @@
 KAlarm Change Log
 
-=== Version 2.0.7 --- 15 December 2008 ===
+=== Version 2.0.7 --- 16 December 2008 ===
+- Distinguish disabled from enabled alarm colour when highlighted in alarm list.
 - Fix crash if KAlarm is activated again while restoring from previous session.
 - Fix kalarmautostart crash on logout while kalarmautostart is still running.
 - Fix failure to update alarms in KOrganizer when Kontact is running.
--- kalarm/eventlistmodel.h	(revision 897758)
+++ kalarm/eventlistmodel.h	(revision 897759)
@@ -50,7 +50,8 @@ class EventListModel : public QAbstractT
 		enum {   // additional roles
 			StatusRole = Qt::UserRole,  // return ACTIVE/ARCHIVED
 			ValueRole,                  // return numeric value
-			SortRole                    // return the value to use for sorting
+			SortRole,                   // return the value to use for sorting
+			EnabledRole                 // return true for enabled alarm, false for disabled
 		};
 
 		static EventListModel* alarms();
Index: kalarm/alarmlistdelegate.cpp
===================================================================
Index: kalarm/eventlistmodel.cpp
===================================================================
Index: kalarm/Changelog
===================================================================
Index: kalarm/eventlistmodel.h
===================================================================
openSUSE Build Service is sponsored by