[qet] [1476] The title block template editor now opens templates as read-only if needed .

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


Revision: 1476
Author:   xavier
Date:     2012-01-23 08:22:07 +0100 (Mon, 23 Jan 2012)
Log Message:
-----------
The title block template editor now opens templates as read-only if needed.

Modified Paths:
--------------
    branches/0.3/sources/titleblock/qettemplateeditor.cpp

Modified: branches/0.3/sources/titleblock/qettemplateeditor.cpp
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.cpp	2012-01-23 07:21:09 UTC (rev 1475)
+++ branches/0.3/sources/titleblock/qettemplateeditor.cpp	2012-01-23 07:22:07 UTC (rev 1476)
@@ -119,7 +119,7 @@
 	
 	opened_from_file_ = false;
 	location_ = location;
-	updateEditorTitle();
+	setReadOnly(location.isReadOnly());
 	editCopyOf(tb_template_orig);
 	return(true);
 }
@@ -152,7 +152,7 @@
 	opened_from_file_ = false;
 	location_.setParentCollection(project -> embeddedTitleBlockTemplatesCollection());
 	location_.setName(template_name);
-	updateEditorTitle();
+	setReadOnly(project -> isReadOnly());
 	return(editCopyOf(tb_template_orig));
 }
 
@@ -175,10 +175,10 @@
 		return(false);
 	}
 	
+	QFileInfo file_path_info(file_path);
 	filepath_ = file_path;
 	opened_from_file_ = true;
-	updateEditorTitle();
-	
+	setReadOnly(!file_path_info.isWritable());
 	return(true);
 }
 
@@ -509,6 +509,7 @@
 */
 void QETTitleBlockTemplateEditor::updateActions() {
 	/// TODO complete this method
+	save_ -> setEnabled(!read_only_);
 	merge_cells_ -> setEnabled(!read_only_);
 	split_cell_ -> setEnabled(!read_only_);
 }
@@ -533,7 +534,7 @@
 	opened_from_file_ = false;
 	location_ = location;
 	undo_stack_ -> setClean();
-	updateEditorTitle();
+	setReadOnly(false);
 	return(true);
 }
 
@@ -549,7 +550,7 @@
 	opened_from_file_ = true;
 	filepath_ = filepath;
 	undo_stack_ -> setClean();
-	updateEditorTitle();
+	setReadOnly(false);
 	return(true);
 }
 
@@ -598,18 +599,19 @@
 bool QETTitleBlockTemplateEditor::save() {
 	if (opened_from_file_) {
 		if (!filepath_.isEmpty()) {
-			return(saveAs(filepath_));
-		} else {
-			// Actually, this should never happen since opened_from_file_ is always set
-			// along with a valid path. There is a dedicated menu item to call this.s
-			return(saveAsFile());
+			QFileInfo file_path_info(filepath_);
+			if (file_path_info.isWritable()) {
+				return(saveAs(filepath_));
+			}
 		}
+		return(saveAsFile());
 	} else {
 		if (location_.isValid()) {
-			return(saveAs(location_));
-		} else {
-			return(saveAs());
+			if (!location_.isReadOnly()) {
+				return(saveAs(location_));
+			}
 		}
+		return(saveAs());
 	}
 }
 


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