The title block template editor now opens templates as read-only if needed.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1476 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-01-23 07:22:07 +00:00
parent 0473244284
commit 6d5570404a

View File

@@ -119,7 +119,7 @@ bool QETTitleBlockTemplateEditor::edit(const TitleBlockTemplateLocation &locatio
opened_from_file_ = false;
location_ = location;
updateEditorTitle();
setReadOnly(location.isReadOnly());
editCopyOf(tb_template_orig);
return(true);
}
@@ -152,7 +152,7 @@ bool QETTitleBlockTemplateEditor::edit(QETProject *project, const QString &templ
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 @@ bool QETTitleBlockTemplateEditor::edit(const QString &file_path) {
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::updateEditorTitle() {
*/
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 @@ bool QETTitleBlockTemplateEditor::saveAs(const TitleBlockTemplateLocation &locat
opened_from_file_ = false;
location_ = location;
undo_stack_ -> setClean();
updateEditorTitle();
setReadOnly(false);
return(true);
}
@@ -549,7 +550,7 @@ bool QETTitleBlockTemplateEditor::saveAs(const QString &filepath) {
opened_from_file_ = true;
filepath_ = filepath;
undo_stack_ -> setClean();
updateEditorTitle();
setReadOnly(false);
return(true);
}
@@ -598,19 +599,20 @@ void QETTitleBlockTemplateEditor::openFromFile() {
bool QETTitleBlockTemplateEditor::save() {
if (opened_from_file_) {
if (!filepath_.isEmpty()) {
QFileInfo file_path_info(filepath_);
if (file_path_info.isWritable()) {
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());
}
}
return(saveAsFile());
} else {
if (location_.isValid()) {
if (!location_.isReadOnly()) {
return(saveAs(location_));
} else {
return(saveAs());
}
}
return(saveAs());
}
}
/**