From 8fc142a1406bb7bd19cdb2cdbe41faba86fb8aad Mon Sep 17 00:00:00 2001 From: xavier Date: Sun, 7 Mar 2010 18:33:41 +0000 Subject: [PATCH] Correction : le mode lecture seule est desormais active ou desactive si besoin apres un "Enregistrer sous" git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@884 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/editor/qetelementeditor.cpp | 29 +++++++++++++++++++++++++++++ sources/editor/qetelementeditor.h | 18 ------------------ 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/sources/editor/qetelementeditor.cpp b/sources/editor/qetelementeditor.cpp index 9a579022e..7dd009f78 100644 --- a/sources/editor/qetelementeditor.cpp +++ b/sources/editor/qetelementeditor.cpp @@ -89,6 +89,35 @@ QETElementEditor::~QETElementEditor() { editors_.clear(); } +/** + @param el Le nouvel emplacement de l'element edite +*/ +void QETElementEditor::setLocation(const ElementsLocation &el) { + location_ = el; + opened_from_file = false; + // modifie le mode lecture seule si besoin + ElementsCollectionItem *item = QETApp::collectionItem(location_); + bool must_be_read_only = item && !item -> isWritable(); + if (isReadOnly() != must_be_read_only) { + setReadOnly(must_be_read_only); + } + slot_updateTitle(); +} + +/** + @param fn Le nouveau nom de fichier de l'element edite +*/ +void QETElementEditor::setFileName(const QString &fn) { + filename_ = fn; + opened_from_file = true; + // modifie le mode lecture seule si besoin + bool must_be_read_only = !QFileInfo(filename_).isWritable(); + if (isReadOnly() != must_be_read_only) { + setReadOnly(must_be_read_only); + } + slot_updateTitle(); +} + /** Met en place les actions */ diff --git a/sources/editor/qetelementeditor.h b/sources/editor/qetelementeditor.h index d8d418caa..ee17b17dc 100644 --- a/sources/editor/qetelementeditor.h +++ b/sources/editor/qetelementeditor.h @@ -219,15 +219,6 @@ inline OrientationSet QETElementEditor::orientations() const { return(ce_scene -> orientations()); } -/** - @param el Le nouvel emplacement de l'element edite -*/ -inline void QETElementEditor::setLocation(const ElementsLocation &el) { - location_ = el; - opened_from_file = false; - slot_updateTitle(); -} - /** @return l'emplacement de l'element edite */ @@ -235,15 +226,6 @@ inline ElementsLocation QETElementEditor::location() const { return(location_); } -/** - @param fn Le nouveau nom de fichier de l'element edite -*/ -inline void QETElementEditor::setFileName(const QString &fn) { - filename_ = fn; - opened_from_file = true; - slot_updateTitle(); -} - /** @return le nom de fichier de l'element edite */