[qet] [1475] The panel now reflects whether title block templates are read-only.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 1475
Author:   xavier
Date:     2012-01-23 08:21:09 +0100 (Mon, 23 Jan 2012)
Log Message:
-----------
The panel now reflects whether title block templates are read-only.

Modified Paths:
--------------
    branches/0.3/sources/elementspanelwidget.cpp

Modified: branches/0.3/sources/elementspanelwidget.cpp
===================================================================
--- branches/0.3/sources/elementspanelwidget.cpp	2012-01-23 07:20:07 UTC (rev 1474)
+++ branches/0.3/sources/elementspanelwidget.cpp	2012-01-23 07:21:09 UTC (rev 1475)
@@ -371,20 +371,21 @@
 		prj_move_diagram_up   -> setEnabled(is_writable && diagram_position > 0);
 		prj_move_diagram_down -> setEnabled(is_writable && diagram_position < project_diagrams_count - 1);
 		setElementsActionEnabled(false);
-	} else if (
-		elements_panel -> selectedItemIsATitleBlockTemplatesDirectory() ||
-		elements_panel -> selectedItemIsATitleBlockTemplate()
-	) {
+	} else if (elements_panel -> selectedItemIsATitleBlockTemplatesDirectory()) {
 		QTreeWidgetItem *item = elements_panel -> currentItem();
 		TitleBlockTemplateLocation location = elements_panel -> locationForTitleBlockTemplate(item);
-		bool is_writable;
-		if (location.isValid()) {
-			is_writable = !location.parentCollection() -> isReadOnly();
-			tbt_add    -> setEnabled(is_writable);
-			tbt_edit   -> setEnabled(is_writable);
-			tbt_remove -> setEnabled(is_writable);
-		}
+		tbt_add    -> setEnabled(!location.isReadOnly());
+		tbt_edit   -> setEnabled(false); // would not make sense
+		tbt_remove -> setEnabled(false); // would not make sense
 		setElementsActionEnabled(false);
+	} else if (elements_panel -> selectedItemIsATitleBlockTemplate()) {
+		QTreeWidgetItem *item = elements_panel -> currentItem();
+		TitleBlockTemplateLocation location = elements_panel -> locationForTitleBlockTemplate(item);
+		tbt_add    -> setEnabled(false); // would not make sense
+		tbt_edit   -> setEnabled(true); // the tbt editor has a read-only mode
+		// deleting a tbt requires its parent collection to be writable
+		tbt_remove -> setEnabled(location.parentCollection() && !(location.parentCollection() -> isReadOnly()));
+		setElementsActionEnabled(false);
 	}
 }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/