From dfacacfdce6b5744acd8eb14843a6ef239c886b8 Mon Sep 17 00:00:00 2001 From: blacksun Date: Sun, 21 Dec 2014 13:17:35 +0000 Subject: [PATCH] Read only is no more managed for each diagram but for the whole project git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3565 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/diagram.cpp | 24 ++++++++---------------- sources/diagram.h | 33 +++++++++++++-------------------- sources/diagramview.cpp | 1 - sources/qetproject.cpp | 23 ++++++++++------------- 4 files changed, 31 insertions(+), 50 deletions(-) diff --git a/sources/diagram.cpp b/sources/diagram.cpp index bdd2a043e..610accbb6 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -54,8 +54,7 @@ Diagram::Diagram(QETProject *project) : draw_grid_ (true), use_border_ (true), draw_terminals_ (true), - draw_colored_conductors_ (true), - read_only_ (false) + draw_colored_conductors_ (true) { setProject(project); qgi_manager_ = new QGIManager(this); @@ -1246,20 +1245,13 @@ qreal Diagram::declaredQElectroTechVersion(bool fallback_to_project) const { } /** - @return true si le schema est en lecture seule -*/ -bool Diagram::isReadOnly() const { - return(read_only_); -} - -/** - @param read_only true pour passer le schema en lecture seule, false sinon -*/ -void Diagram::setReadOnly(bool read_only) { - if (read_only_ != read_only) { - read_only_ = read_only; - emit(readOnlyChanged(read_only_)); - } + * @brief Diagram::isReadOnly + * @return true if this diagram is read only. + * This method is same has call Diagram::project() -> isReadOnly() + */ +bool Diagram::isReadOnly() const +{ + return project_ -> isReadOnly(); } /** diff --git a/sources/diagram.h b/sources/diagram.h index b9b08aadd..1ec2184c5 100644 --- a/sources/diagram.h +++ b/sources/diagram.h @@ -97,7 +97,6 @@ class Diagram : public QGraphicsScene bool use_border_; bool draw_terminals_; bool draw_colored_conductors_; - bool read_only_; QString m_conductors_autonum_name; @@ -120,14 +119,11 @@ class Diagram : public QGraphicsScene // methods related to parent project QETProject *project() const; - void setProject(QETProject *); - int folioIndex() const; - qreal declaredQElectroTechVersion(bool = true) const; - void showMe() {emit showDiagram(this);} - - // methods related to read only mode - bool isReadOnly() const; - void setReadOnly(bool); + void setProject(QETProject *); + int folioIndex() const; + qreal declaredQElectroTechVersion(bool = true) const; + void showMe() {emit showDiagram(this);} + bool isReadOnly() const; // methods related to conductor creation void setConductor(bool); @@ -213,17 +209,14 @@ class Diagram : public QGraphicsScene void invertSelection(); signals: - void showDiagram (Diagram *); - void written(); - void readOnlyChanged(bool); - void usedTitleBlockTemplateChanged(const QString &); - void diagramTitleChanged(Diagram *, const QString &); - /// Signal emitted when users wish to locate an element from the diagram within elements collection - void findElementRequired(const ElementsLocation &); - /// Signal emitted when users wish to edit an element from the diagram - void editElementRequired(const ElementsLocation &); - void reportPropertiesChanged(QString); - void XRefPropertiesChanged(); + void showDiagram (Diagram *); + void written(); + void usedTitleBlockTemplateChanged(const QString &); + void diagramTitleChanged(Diagram *, const QString &); + void findElementRequired(const ElementsLocation &); /// Signal emitted when users wish to locate an element from the diagram within elements collection + void editElementRequired(const ElementsLocation &); /// Signal emitted when users wish to edit an element from the diagram + void reportPropertiesChanged(QString); + void XRefPropertiesChanged(); }; Q_DECLARE_METATYPE(Diagram *) diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 0ae4a9d39..1f378a3e7 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -86,7 +86,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : connect(scene, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*))); connect(scene, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); - connect(scene, SIGNAL(readOnlyChanged(bool)), this, SLOT(applyReadOnly())); connect(&(scene -> border_and_titleblock), SIGNAL(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect())); connect(&(scene -> border_and_titleblock), SIGNAL(displayChanged()), this, SLOT(adjustSceneRect())); connect(&(scene -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle())); diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index f29f518fc..193039581 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -607,19 +607,16 @@ bool QETProject::isReadOnly() const { } /** - @param read_only true pour passer le projet (schemas et collection) - en mode Read Only, false sinon. -*/ -void QETProject::setReadOnly(bool read_only) { - if (read_only_ != read_only) { - // memorise le fichier pour lequel ce projet est en lecture seule - read_only_file_path_ = file_path_; - - // applique le nouveau mode aux schemas - foreach(Diagram *diagram, diagrams()) { - diagram -> setReadOnly(read_only); - } - + * @brief QETProject::setReadOnly + * Set this project to read only if @read_only = true + * @param read_only + */ +void QETProject::setReadOnly(bool read_only) +{ + if (read_only_ != read_only) + { + //keep the file to which this project is read-only + read_only_file_path_ = file_path_; read_only_ = read_only; emit(readOnlyChanged(this, read_only)); }