From 72a926e9adbf5eb1a69daafe3d4c24b6129979da Mon Sep 17 00:00:00 2001
From: Matthew V <matteofichtner@hotmail.com>
Date: Sun, 15 Mar 2015 02:06:29 +0300
Subject: [PATCH] fix for ticket 789

---
 icons/trashGray.png   | Bin 0 -> 1592 bytes
 qt-ui/diveplanner.cpp |  4 ++++
 qt-ui/models.cpp      | 15 +++++++++++++++
 qt-ui/models.h        |  3 +++
 subsurface.qrc        |  7 ++++---
 5 files changed, 26 insertions(+), 3 deletions(-)
 create mode 100644 icons/trashGray.png

diff --git a/icons/trashGray.png b/icons/trashGray.png
new file mode 100644
index 0000000..c9e3b8d
Binary files /dev/null and b/icons/trashGray.png differ
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 7831cc6..8dd6ca9 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -634,12 +634,16 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const
 		case REMOVE:
 			if (rowCount() > 1)
 				return p.entered ? trashIcon() : QVariant();
+            else
+                return p.entered ? trashIconGray() : QVariant();
 		}
 	} else if (role == Qt::SizeHintRole) {
 		switch (index.column()) {
 		case REMOVE:
 			if (rowCount() > 1)
 				return p.entered ? trashIcon().size() : QVariant();
+            else
+                return p.entered ? trashIconGray().size() : QVariant();
 		}
 	} else if (role == Qt::FontRole) {
 		if (divepoints.at(index.row()).entered) {
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index fec7d02..c7ffe1f 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -71,6 +71,20 @@ const QPixmap &trashIcon()
 	return *trashIconPixmap;
 }
 
+static QPixmap *trashIconGrayPixmap;
+
+// initialize the gray trash icon if necessary
+static void initTrashIconGray()
+{
+    if (!trashIconGrayPixmap)
+        trashIconGrayPixmap = new QPixmap(QIcon(":trashGray").pixmap(defaultIconMetrics().sz_small));
+}
+
+const QPixmap &trashIconGray()
+{
+    return *trashIconGrayPixmap;
+}
+
 CylindersModel::CylindersModel(QObject *parent) : changed(false),
 	rows(0)
 {
@@ -433,6 +447,7 @@ WeightModel::WeightModel(QObject *parent) : CleanerTableModel(parent),
 	setHeaderDataStrings(QStringList() << tr("") << tr("Type") << tr("Weight"));
 
 	initTrashIcon();
+    initTrashIconGray();
 }
 
 weightsystem_t *WeightModel::weightSystemAt(const QModelIndex &index)
diff --git a/qt-ui/models.h b/qt-ui/models.h
index 0123ce1..97ae4bd 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -92,6 +92,9 @@ private:
 /* Retrieve the trash icon pixmap, common to most table models */
 const QPixmap &trashIcon();
 
+/* Retrieve the gray trash icon pixmap for rows that are not allowed to remove. */
+const QPixmap &trashIconGray();
+
 /* Encapsulation of the Cylinder Model, that presents the
  * Current cylinders that are used on a dive. */
 class CylindersModel : public CleanerTableModel {
diff --git a/subsurface.qrc b/subsurface.qrc
index 2b07313..22b9c60 100644
--- a/subsurface.qrc
+++ b/subsurface.qrc
@@ -72,8 +72,9 @@
         <file>icons/ostc3.png</file>
         <file>icons/suunto_vyper.png</file>
         <file alias="facebook">icons/facebook.png</file>
-	<file alias="filter-reset">icons/edit-undo.svg</file>
-	<file alias="filter-hide">icons/go-top.svg</file>
-	<file alias="filter-close">icons/process-stop.svg</file>
+        <file alias="filter-reset">icons/edit-undo.svg</file>
+        <file alias="filter-hide">icons/go-top.svg</file>
+        <file alias="filter-close">icons/process-stop.svg</file>
+        <file alias="trashGray">icons/trashGray.png</file>
     </qresource>
 </RCC>
--
libgit2 0.21.0

