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
This commit is contained in:
blacksun
2014-12-21 13:17:35 +00:00
parent a5b1a92beb
commit dfacacfdce
4 changed files with 31 additions and 50 deletions

View File

@@ -54,8 +54,7 @@ Diagram::Diagram(QETProject *project) :
draw_grid_ (true), draw_grid_ (true),
use_border_ (true), use_border_ (true),
draw_terminals_ (true), draw_terminals_ (true),
draw_colored_conductors_ (true), draw_colored_conductors_ (true)
read_only_ (false)
{ {
setProject(project); setProject(project);
qgi_manager_ = new QGIManager(this); 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 * @brief Diagram::isReadOnly
* @return true if this diagram is read only.
* This method is same has call Diagram::project() -> isReadOnly()
*/ */
bool Diagram::isReadOnly() const { bool Diagram::isReadOnly() const
return(read_only_); {
} return project_ -> isReadOnly();
/**
@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_));
}
} }
/** /**

View File

@@ -97,7 +97,6 @@ class Diagram : public QGraphicsScene
bool use_border_; bool use_border_;
bool draw_terminals_; bool draw_terminals_;
bool draw_colored_conductors_; bool draw_colored_conductors_;
bool read_only_;
QString m_conductors_autonum_name; QString m_conductors_autonum_name;
@@ -124,10 +123,7 @@ class Diagram : public QGraphicsScene
int folioIndex() const; int folioIndex() const;
qreal declaredQElectroTechVersion(bool = true) const; qreal declaredQElectroTechVersion(bool = true) const;
void showMe() {emit showDiagram(this);} void showMe() {emit showDiagram(this);}
// methods related to read only mode
bool isReadOnly() const; bool isReadOnly() const;
void setReadOnly(bool);
// methods related to conductor creation // methods related to conductor creation
void setConductor(bool); void setConductor(bool);
@@ -215,13 +211,10 @@ class Diagram : public QGraphicsScene
signals: signals:
void showDiagram (Diagram *); void showDiagram (Diagram *);
void written(); void written();
void readOnlyChanged(bool);
void usedTitleBlockTemplateChanged(const QString &); void usedTitleBlockTemplateChanged(const QString &);
void diagramTitleChanged(Diagram *, 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 locate an element from the diagram within elements collection
void findElementRequired(const ElementsLocation &); void editElementRequired(const ElementsLocation &); /// Signal emitted when users wish to edit an element from the diagram
/// Signal emitted when users wish to edit an element from the diagram
void editElementRequired(const ElementsLocation &);
void reportPropertiesChanged(QString); void reportPropertiesChanged(QString);
void XRefPropertiesChanged(); void XRefPropertiesChanged();
}; };

View File

@@ -86,7 +86,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
connect(scene, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*))); connect(scene, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
connect(scene, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); 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(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect()));
connect(&(scene -> border_and_titleblock), SIGNAL(displayChanged()), 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())); connect(&(scene -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));

View File

@@ -607,19 +607,16 @@ bool QETProject::isReadOnly() const {
} }
/** /**
@param read_only true pour passer le projet (schemas et collection) * @brief QETProject::setReadOnly
en mode Read Only, false sinon. * Set this project to read only if @read_only = true
* @param read_only
*/ */
void QETProject::setReadOnly(bool read_only) { void QETProject::setReadOnly(bool read_only)
if (read_only_ != read_only) { {
// memorise le fichier pour lequel ce projet est en lecture seule if (read_only_ != read_only)
{
//keep the file to which this project is read-only
read_only_file_path_ = file_path_; read_only_file_path_ = file_path_;
// applique le nouveau mode aux schemas
foreach(Diagram *diagram, diagrams()) {
diagram -> setReadOnly(read_only);
}
read_only_ = read_only; read_only_ = read_only;
emit(readOnlyChanged(this, read_only)); emit(readOnlyChanged(this, read_only));
} }