mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Projects are now displayed with a [Modified] tag after their properties were edited.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1901 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -105,8 +105,23 @@ QIcon ProjectMainConfigPage::icon() const {
|
|||||||
Apply the configuration after user input
|
Apply the configuration after user input
|
||||||
*/
|
*/
|
||||||
void ProjectMainConfigPage::applyProjectConf() {
|
void ProjectMainConfigPage::applyProjectConf() {
|
||||||
project_ -> setTitle(title_value_ -> text());
|
bool modified_project = false;
|
||||||
project_ -> setProjectProperties(project_variables_ -> context());
|
|
||||||
|
QString new_title = title_value_ -> text();
|
||||||
|
if (project_ -> title() != new_title) {
|
||||||
|
project_ -> setTitle(new_title);
|
||||||
|
modified_project = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DiagramContext new_properties = project_variables_ -> context();
|
||||||
|
if (project_ -> projectProperties() != new_properties) {
|
||||||
|
project_ -> setProjectProperties(new_properties);
|
||||||
|
modified_project = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modified_project) {
|
||||||
|
project_ -> setModified(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,9 +217,29 @@ QIcon ProjectNewDiagramConfigPage::icon() const {
|
|||||||
Apply the configuration after user input
|
Apply the configuration after user input
|
||||||
*/
|
*/
|
||||||
void ProjectNewDiagramConfigPage::applyProjectConf() {
|
void ProjectNewDiagramConfigPage::applyProjectConf() {
|
||||||
|
bool modified_project = false;
|
||||||
|
|
||||||
|
BorderProperties new_border_prop = border_ -> borderProperties();
|
||||||
|
if (project_ -> defaultBorderProperties() != new_border_prop) {
|
||||||
project_ -> setDefaultBorderProperties(border_ -> borderProperties());
|
project_ -> setDefaultBorderProperties(border_ -> borderProperties());
|
||||||
|
modified_project = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
TitleBlockProperties new_tbt_prop = titleblock_ -> titleBlockProperties();
|
||||||
|
if (project_ -> defaultTitleBlockProperties() != new_tbt_prop) {
|
||||||
project_ -> setDefaultTitleBlockProperties(titleblock_ -> titleBlockProperties());
|
project_ -> setDefaultTitleBlockProperties(titleblock_ -> titleBlockProperties());
|
||||||
|
modified_project = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConductorProperties new_conductor_prop = conductor_ -> conductorProperties();
|
||||||
|
if (project_ -> defaultConductorProperties() != new_conductor_prop) {
|
||||||
project_ -> setDefaultConductorProperties(conductor_ -> conductorProperties());
|
project_ -> setDefaultConductorProperties(conductor_ -> conductorProperties());
|
||||||
|
modified_project = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modified_project) {
|
||||||
|
project_ -> setModified(modified_project);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ void ProjectView::setProject(QETProject *project) {
|
|||||||
if (!project_) {
|
if (!project_) {
|
||||||
project_ = project;
|
project_ = project;
|
||||||
connect(project_, SIGNAL(projectTitleChanged(QETProject *, const QString &)), this, SLOT(updateWindowTitle()));
|
connect(project_, SIGNAL(projectTitleChanged(QETProject *, const QString &)), this, SLOT(updateWindowTitle()));
|
||||||
|
connect(project_, SIGNAL(projectModified (QETProject *, bool)), this, SLOT(updateWindowTitle()));
|
||||||
connect(project_, SIGNAL(readOnlyChanged (QETProject *, bool)), this, SLOT(adjustReadOnlyState()));
|
connect(project_, SIGNAL(readOnlyChanged (QETProject *, bool)), this, SLOT(adjustReadOnlyState()));
|
||||||
adjustReadOnlyState();
|
adjustReadOnlyState();
|
||||||
loadDiagrams();
|
loadDiagrams();
|
||||||
@@ -562,6 +563,7 @@ void ProjectView::exportProject() {
|
|||||||
@return true si l'enregistrement a reussi, false sinon
|
@return true si l'enregistrement a reussi, false sinon
|
||||||
*/
|
*/
|
||||||
bool ProjectView::save() {
|
bool ProjectView::save() {
|
||||||
|
bool result = false;
|
||||||
if (project_) {
|
if (project_) {
|
||||||
if (project_ -> filePath().isEmpty()) {
|
if (project_ -> filePath().isEmpty()) {
|
||||||
// le projet n'est pas encore enregistre dans un fichier
|
// le projet n'est pas encore enregistre dans un fichier
|
||||||
@@ -572,16 +574,15 @@ bool ProjectView::save() {
|
|||||||
if (DiagramView *current_view = currentDiagram()) {
|
if (DiagramView *current_view = currentDiagram()) {
|
||||||
if (Diagram *diagram = current_view -> diagram()) {
|
if (Diagram *diagram = current_view -> diagram()) {
|
||||||
diagram -> write();
|
diagram -> write();
|
||||||
updateWindowTitle();
|
result = true;
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// s'il n'y a pas de schema, on appelle directement la methode write()
|
// s'il n'y a pas de schema, on appelle directement la methode write()
|
||||||
project_ -> write();
|
result = project_ -> write();
|
||||||
}
|
}
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
return(false);
|
updateWindowTitle();
|
||||||
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ QETProject::QETProject(int diagrams, QObject *parent) :
|
|||||||
QObject(parent),
|
QObject(parent),
|
||||||
collection_(0),
|
collection_(0),
|
||||||
project_qet_version_(-1),
|
project_qet_version_(-1),
|
||||||
|
modified_(false),
|
||||||
read_only_(false),
|
read_only_(false),
|
||||||
titleblocks_(this)
|
titleblocks_(this)
|
||||||
{
|
{
|
||||||
@@ -69,6 +70,7 @@ QETProject::QETProject(const QString &path, QObject *parent) :
|
|||||||
QObject(parent),
|
QObject(parent),
|
||||||
collection_(0),
|
collection_(0),
|
||||||
project_qet_version_(-1),
|
project_qet_version_(-1),
|
||||||
|
modified_(false),
|
||||||
read_only_(false),
|
read_only_(false),
|
||||||
titleblocks_(this)
|
titleblocks_(this)
|
||||||
{
|
{
|
||||||
@@ -107,6 +109,7 @@ QETProject::QETProject(const QDomElement &xml_element, QObject *parent) :
|
|||||||
QObject(parent),
|
QObject(parent),
|
||||||
collection_(0),
|
collection_(0),
|
||||||
project_qet_version_(-1),
|
project_qet_version_(-1),
|
||||||
|
modified_(false),
|
||||||
read_only_(false),
|
read_only_(false),
|
||||||
titleblocks_(this)
|
titleblocks_(this)
|
||||||
{
|
{
|
||||||
@@ -264,6 +267,14 @@ QString QETProject::pathNameTitle() const {
|
|||||||
)
|
)
|
||||||
).arg(final_title);
|
).arg(final_title);
|
||||||
}
|
}
|
||||||
|
if (modified_) {
|
||||||
|
final_title = QString(
|
||||||
|
tr(
|
||||||
|
"%1 [modifi\351]",
|
||||||
|
"displayed title for a modified project - %1 is a displayable title"
|
||||||
|
)
|
||||||
|
).arg(final_title);
|
||||||
|
}
|
||||||
|
|
||||||
return(final_title);
|
return(final_title);
|
||||||
}
|
}
|
||||||
@@ -478,6 +489,8 @@ bool QETProject::write() {
|
|||||||
bool writing = QET::writeXmlFile(document_root_, file_path_, &error_message);
|
bool writing = QET::writeXmlFile(document_root_, file_path_, &error_message);
|
||||||
if (!writing) {
|
if (!writing) {
|
||||||
qDebug() << qPrintable(QString("QETProject::write() : %1 [%2]").arg(error_message).arg(QET::pointerString(this)));
|
qDebug() << qPrintable(QString("QETProject::write() : %1 [%2]").arg(error_message).arg(QET::pointerString(this)));
|
||||||
|
} else {
|
||||||
|
setModified(false);
|
||||||
}
|
}
|
||||||
return(writing);
|
return(writing);
|
||||||
}
|
}
|
||||||
@@ -834,6 +847,17 @@ void QETProject::diagramOrderChanged(int old_index, int new_index) {
|
|||||||
emit(projectDiagramsOrderChanged(this, old_index, new_index));
|
emit(projectDiagramsOrderChanged(this, old_index, new_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Mark this project as modified and emit the projectModified() signal.
|
||||||
|
*/
|
||||||
|
void QETProject::setModified(bool modified) {
|
||||||
|
if (modified_ != modified) {
|
||||||
|
modified_ = modified;
|
||||||
|
emit(projectModified(this, modified_));
|
||||||
|
emit(projectInformationsChanged(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set up signals/slots connections related to the title block templates
|
Set up signals/slots connections related to the title block templates
|
||||||
collection.
|
collection.
|
||||||
@@ -1121,6 +1145,16 @@ NamesList QETProject::namesListForIntegrationCategory() {
|
|||||||
return(names);
|
return(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return true if project options (title, project-wide properties, settings
|
||||||
|
for new diagrams, ...) were modified, false otherwise.
|
||||||
|
*/
|
||||||
|
bool QETProject::projectOptionsWereModified() {
|
||||||
|
// unlike similar methods, this method does not compare the content against
|
||||||
|
// expected values; instead, we just check whether we have been set as modified.
|
||||||
|
return(modified_);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cette methode sert a reperer un projet vide, c-a-d un projet identique a ce
|
Cette methode sert a reperer un projet vide, c-a-d un projet identique a ce
|
||||||
que l'on obtient en faisant Fichier > Nouveau.
|
que l'on obtient en faisant Fichier > Nouveau.
|
||||||
@@ -1149,6 +1183,16 @@ bool QETProject::embeddedCollectionWasModified() {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return true if the embedded title block templates collection was modified,
|
||||||
|
false otherwise.
|
||||||
|
*/
|
||||||
|
bool QETProject::titleBlockTemplateCollectionWasModified() {
|
||||||
|
// we do not expect a new project to embed any title block template (this may
|
||||||
|
// change in the future though).
|
||||||
|
return(titleblocks_.templates().count());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cette methode sert a reperer un projet vide, c-a-d un projet identique a ce
|
Cette methode sert a reperer un projet vide, c-a-d un projet identique a ce
|
||||||
que l'on obtient en faisant Fichier > Nouveau.
|
que l'on obtient en faisant Fichier > Nouveau.
|
||||||
@@ -1189,12 +1233,10 @@ void QETProject::setProjectProperties(const DiagramContext &context) {
|
|||||||
@see diagramsWereModified(), embeddedCollectionWasModified()
|
@see diagramsWereModified(), embeddedCollectionWasModified()
|
||||||
*/
|
*/
|
||||||
bool QETProject::projectWasModified() {
|
bool QETProject::projectWasModified() {
|
||||||
// il doit avoir un titre vide
|
if (projectOptionsWereModified()) return(true);
|
||||||
if (!title().isEmpty()) return(true);
|
|
||||||
|
|
||||||
// ni ses schemas ni sa collection embarquee ne doivent avoir ete modifies
|
|
||||||
if (diagramsWereModified()) return(true);
|
if (diagramsWereModified()) return(true);
|
||||||
if (embeddedCollectionWasModified()) return(true);
|
if (embeddedCollectionWasModified()) return(true);
|
||||||
|
if (titleBlockTemplateCollectionWasModified()) return(true);
|
||||||
|
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,9 @@ class QETProject : public QObject {
|
|||||||
void cleanUnusedElements(MoveElementsHandler *);
|
void cleanUnusedElements(MoveElementsHandler *);
|
||||||
void cleanEmptyCategories(MoveElementsHandler *);
|
void cleanEmptyCategories(MoveElementsHandler *);
|
||||||
bool projectWasModified();
|
bool projectWasModified();
|
||||||
|
bool projectOptionsWereModified();
|
||||||
bool embeddedCollectionWasModified();
|
bool embeddedCollectionWasModified();
|
||||||
|
bool titleBlockTemplateCollectionWasModified();
|
||||||
bool diagramsWereModified();
|
bool diagramsWereModified();
|
||||||
DiagramContext projectProperties();
|
DiagramContext projectProperties();
|
||||||
void setProjectProperties(const DiagramContext &);
|
void setProjectProperties(const DiagramContext &);
|
||||||
@@ -123,6 +125,7 @@ class QETProject : public QObject {
|
|||||||
Diagram *addNewDiagram();
|
Diagram *addNewDiagram();
|
||||||
void removeDiagram(Diagram *);
|
void removeDiagram(Diagram *);
|
||||||
void diagramOrderChanged(int, int);
|
void diagramOrderChanged(int, int);
|
||||||
|
void setModified(bool);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void projectFilePathChanged(QETProject *, const QString &);
|
void projectFilePathChanged(QETProject *, const QString &);
|
||||||
@@ -130,6 +133,7 @@ class QETProject : public QObject {
|
|||||||
void projectInformationsChanged(QETProject *);
|
void projectInformationsChanged(QETProject *);
|
||||||
void diagramAdded(QETProject *, Diagram *);
|
void diagramAdded(QETProject *, Diagram *);
|
||||||
void diagramRemoved(QETProject *, Diagram *);
|
void diagramRemoved(QETProject *, Diagram *);
|
||||||
|
void projectModified(QETProject *, bool);
|
||||||
void projectDiagramsOrderChanged(QETProject *, int, int);
|
void projectDiagramsOrderChanged(QETProject *, int, int);
|
||||||
void elementIntegrated(QETProject *, const ElementsLocation &);
|
void elementIntegrated(QETProject *, const ElementsLocation &);
|
||||||
void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);
|
void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);
|
||||||
@@ -172,6 +176,8 @@ class QETProject : public QObject {
|
|||||||
QString project_title_;
|
QString project_title_;
|
||||||
/// Version de QElectroTech declaree dans le document XML lors de son ouverture
|
/// Version de QElectroTech declaree dans le document XML lors de son ouverture
|
||||||
qreal project_qet_version_;
|
qreal project_qet_version_;
|
||||||
|
/// Whether options were modified
|
||||||
|
bool modified_;
|
||||||
/// booleen indiquant si le projet est en ReadOnly ou non
|
/// booleen indiquant si le projet est en ReadOnly ou non
|
||||||
bool read_only_;
|
bool read_only_;
|
||||||
/// Chemin du fichier pour lequel ce projet est considere comme etant en lecture seule
|
/// Chemin du fichier pour lequel ce projet est considere comme etant en lecture seule
|
||||||
|
|||||||
Reference in New Issue
Block a user