2009-04-03 19:30:25 +00:00
|
|
|
/*
|
2014-01-29 18:37:45 +00:00
|
|
|
Copyright 2006-2014 The QElectroTech Team
|
2009-04-03 19:30:25 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifndef QET_PROJECT_H
|
|
|
|
#define QET_PROJECT_H
|
|
|
|
#include <QtCore>
|
|
|
|
#include <QtXml>
|
|
|
|
#include "nameslist.h"
|
|
|
|
#include "elementslocation.h"
|
|
|
|
#include "borderproperties.h"
|
|
|
|
#include "conductorproperties.h"
|
2010-12-20 02:45:36 +00:00
|
|
|
#include "titleblockproperties.h"
|
2012-01-08 17:04:34 +00:00
|
|
|
#include "templatescollection.h"
|
2013-04-11 06:55:00 +00:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
class Diagram;
|
|
|
|
class ElementsCollection;
|
|
|
|
class ElementsCategory;
|
|
|
|
class ElementDefinition;
|
|
|
|
class ElementsLocation;
|
2012-07-13 07:21:19 +00:00
|
|
|
class QETResult;
|
2010-12-20 02:45:36 +00:00
|
|
|
class TitleBlockTemplate;
|
2009-04-03 19:30:25 +00:00
|
|
|
class XmlElementsCollection;
|
|
|
|
class MoveElementsHandler;
|
2012-01-22 10:40:37 +00:00
|
|
|
class MoveTitleBlockTemplatesHandler;
|
2013-04-11 06:55:00 +00:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This class represents a QET project. Typically saved as a .qet file, it
|
|
|
|
consists in an XML document grouping 0 to n diagrams and embedding an elements
|
|
|
|
collection. This collection enables users to export diagrams on remote
|
|
|
|
machines without wondering whether required elements are available to them.
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
class QETProject : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2009-04-03 19:30:25 +00:00
|
|
|
public:
|
|
|
|
QETProject(int = 1, QObject * = 0);
|
|
|
|
QETProject(const QString &, QObject * = 0);
|
|
|
|
QETProject(const QDomElement &, QObject * = 0);
|
|
|
|
virtual ~QETProject();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QETProject(const QETProject &);
|
|
|
|
|
|
|
|
// enums
|
|
|
|
public:
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This enum lists possible states for a particular project.
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
enum ProjectState {
|
2012-11-09 21:09:24 +00:00
|
|
|
Ok = 0, /// no error
|
|
|
|
FileOpenFailed = 1, /// file opening failed
|
|
|
|
XmlParsingFailed = 2, /// XML parsing failed
|
|
|
|
ProjectParsingRunning = 3, /// the XML content is currently being processed
|
|
|
|
ProjectParsingFailed = 4, /// the parsing of the XML content failed
|
2011-08-26 19:06:35 +00:00
|
|
|
FileOpenDiscard = 5 /// the user cancelled the file opening
|
2009-04-03 19:30:25 +00:00
|
|
|
};
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2009-04-03 19:30:25 +00:00
|
|
|
public:
|
|
|
|
ProjectState state() const;
|
|
|
|
QList<Diagram *> diagrams() const;
|
2014-02-11 05:10:16 +00:00
|
|
|
int getFolioSheetsQuantity() const; /// get the folio sheets quantity for this project
|
|
|
|
void setFolioSheetsQuantity(int); /// set the folio sheets quantity for this project
|
2011-09-08 19:03:13 +00:00
|
|
|
int folioIndex(const Diagram *) const;
|
2009-04-03 19:30:25 +00:00
|
|
|
ElementsCollection *embeddedCollection() const;
|
2012-01-08 17:04:34 +00:00
|
|
|
TitleBlockTemplatesProjectCollection *embeddedTitleBlockTemplatesCollection();
|
2009-04-03 19:30:25 +00:00
|
|
|
QString filePath();
|
|
|
|
void setFilePath(const QString &);
|
2009-07-13 00:59:46 +00:00
|
|
|
QString currentDir() const;
|
2009-04-03 19:30:25 +00:00
|
|
|
QString pathNameTitle() const;
|
|
|
|
QString title() const;
|
2010-07-18 19:16:52 +00:00
|
|
|
qreal declaredQElectroTechVersion();
|
2009-04-03 19:30:25 +00:00
|
|
|
void setTitle(const QString &);
|
2012-01-08 17:04:34 +00:00
|
|
|
QList<QString> embeddedTitleBlockTemplates();
|
2010-12-20 02:45:36 +00:00
|
|
|
const TitleBlockTemplate *getTemplateByName(const QString &template_name);
|
2010-12-19 18:14:05 +00:00
|
|
|
QDomElement getTemplateXmlDescriptionByName(const QString &);
|
2010-12-24 21:00:11 +00:00
|
|
|
bool setTemplateXmlDescription(const QString &, const QDomElement &);
|
|
|
|
void removeTemplateByName(const QString &);
|
2009-04-03 19:30:25 +00:00
|
|
|
BorderProperties defaultBorderProperties() const;
|
|
|
|
void setDefaultBorderProperties(const BorderProperties &);
|
2010-12-20 02:45:36 +00:00
|
|
|
TitleBlockProperties defaultTitleBlockProperties() const;
|
|
|
|
void setDefaultTitleBlockProperties(const TitleBlockProperties &);
|
2009-04-03 19:30:25 +00:00
|
|
|
ConductorProperties defaultConductorProperties() const;
|
|
|
|
void setDefaultConductorProperties(const ConductorProperties &);
|
2014-01-18 19:04:39 +00:00
|
|
|
QString defaultReportProperties() const;
|
|
|
|
void setDefaultReportProperties (const QString &properties);
|
2009-04-03 19:30:25 +00:00
|
|
|
QDomDocument toXml();
|
|
|
|
bool close();
|
2012-07-13 07:21:19 +00:00
|
|
|
QETResult write();
|
2009-04-03 19:30:25 +00:00
|
|
|
bool isReadOnly() const;
|
|
|
|
void setReadOnly(bool);
|
|
|
|
bool isEmpty() const;
|
|
|
|
bool ensureIntegrationCategoryExists();
|
|
|
|
ElementsCategory *integrationCategory() const;
|
|
|
|
QString integrateElement(const QString &, QString &);
|
|
|
|
QString integrateElement(const QString &, MoveElementsHandler *, QString &);
|
2012-01-22 10:40:37 +00:00
|
|
|
QString integrateTitleBlockTemplate(const TitleBlockTemplateLocation &, MoveTitleBlockTemplatesHandler *handler);
|
2009-04-03 19:30:25 +00:00
|
|
|
bool usesElement(const ElementsLocation &);
|
2012-01-23 20:36:51 +00:00
|
|
|
bool usesTitleBlockTemplate(const TitleBlockTemplateLocation &);
|
2012-01-24 07:11:19 +00:00
|
|
|
void cleanUnusedTitleBlocKTemplates();
|
2009-04-03 19:30:25 +00:00
|
|
|
void cleanUnusedElements(MoveElementsHandler *);
|
|
|
|
void cleanEmptyCategories(MoveElementsHandler *);
|
|
|
|
bool projectWasModified();
|
2012-07-07 19:45:32 +00:00
|
|
|
bool projectOptionsWereModified();
|
2009-04-03 19:30:25 +00:00
|
|
|
bool embeddedCollectionWasModified();
|
2012-07-07 19:45:32 +00:00
|
|
|
bool titleBlockTemplateCollectionWasModified();
|
2009-04-03 19:30:25 +00:00
|
|
|
bool diagramsWereModified();
|
2012-07-01 21:54:07 +00:00
|
|
|
DiagramContext projectProperties();
|
|
|
|
void setProjectProperties(const DiagramContext &);
|
2014-01-05 15:00:46 +00:00
|
|
|
QUndoStack* undoStack() {return undo_stack_;}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void componentWritten();
|
|
|
|
Diagram *addNewDiagram();
|
2014-02-06 15:19:27 +00:00
|
|
|
Diagram *addNewDiagramFolioList();
|
2009-04-03 19:30:25 +00:00
|
|
|
void removeDiagram(Diagram *);
|
|
|
|
void diagramOrderChanged(int, int);
|
2012-07-07 19:45:32 +00:00
|
|
|
void setModified(bool);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void projectFilePathChanged(QETProject *, const QString &);
|
|
|
|
void projectTitleChanged(QETProject *, const QString &);
|
|
|
|
void projectInformationsChanged(QETProject *);
|
|
|
|
void diagramAdded(QETProject *, Diagram *);
|
|
|
|
void diagramRemoved(QETProject *, Diagram *);
|
2012-07-07 19:45:32 +00:00
|
|
|
void projectModified(QETProject *, bool);
|
2012-02-06 21:21:43 +00:00
|
|
|
void projectDiagramsOrderChanged(QETProject *, int, int);
|
2012-04-28 16:45:16 +00:00
|
|
|
void elementIntegrated(QETProject *, const ElementsLocation &);
|
2012-01-23 20:36:51 +00:00
|
|
|
void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);
|
2009-04-03 19:30:25 +00:00
|
|
|
void readOnlyChanged(QETProject *, bool);
|
2014-01-18 19:04:39 +00:00
|
|
|
void reportPropertiesChanged(QString);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void updateDiagramsFolioData();
|
2012-01-08 17:04:34 +00:00
|
|
|
void updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
|
|
|
|
void removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
|
2012-01-23 20:36:51 +00:00
|
|
|
void usedTitleBlockTemplateChanged(const QString &);
|
2014-01-05 15:00:46 +00:00
|
|
|
void undoStackChanged (bool a) {if (!a) setModified(true);}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
private:
|
2012-01-08 17:04:34 +00:00
|
|
|
void setupTitleBlockTemplatesCollection();
|
2009-04-03 19:30:25 +00:00
|
|
|
ElementsCategory *rootCategory() const;
|
|
|
|
void readProjectXml();
|
|
|
|
void readDiagramsXml();
|
|
|
|
void readElementsCollectionXml();
|
2010-12-19 18:14:05 +00:00
|
|
|
void readEmbeddedTemplatesXml();
|
2012-07-01 21:54:07 +00:00
|
|
|
void readProjectPropertiesXml();
|
|
|
|
void writeProjectPropertiesXml(QDomElement &);
|
2009-04-03 19:30:25 +00:00
|
|
|
void readDefaultPropertiesXml();
|
|
|
|
void writeDefaultPropertiesXml(QDomElement &);
|
|
|
|
void addDiagram(Diagram *);
|
|
|
|
NamesList namesListForIntegrationCategory();
|
|
|
|
ElementsLocation copyElementWithHandler(ElementDefinition *, ElementsCategory *, MoveElementsHandler *, QString &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2009-04-03 19:30:25 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// File path this project is saved to
|
2009-04-03 19:30:25 +00:00
|
|
|
QString file_path_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Current state of the project
|
2009-04-03 19:30:25 +00:00
|
|
|
ProjectState state_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// XML document representing the project
|
2009-04-03 19:30:25 +00:00
|
|
|
QDomDocument document_root_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Diagrams carried by the project
|
2009-04-03 19:30:25 +00:00
|
|
|
QList<Diagram *> diagrams_;
|
2014-02-11 05:10:16 +00:00
|
|
|
/// Folio List Sheets quantity for this project.
|
2014-02-10 13:58:30 +00:00
|
|
|
int folioSheetsQuantity;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Embedded elements collection
|
2009-04-03 19:30:25 +00:00
|
|
|
XmlElementsCollection *collection_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Project title
|
2009-04-03 19:30:25 +00:00
|
|
|
QString project_title_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// QElectroTech version declared in the XML document at opening time
|
2010-07-18 19:16:52 +00:00
|
|
|
qreal project_qet_version_;
|
2012-07-07 19:45:32 +00:00
|
|
|
/// Whether options were modified
|
|
|
|
bool modified_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Whether the project is read only
|
2009-04-03 19:30:25 +00:00
|
|
|
bool read_only_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Filepath for which this project is considered read only
|
2009-04-03 19:30:25 +00:00
|
|
|
QString read_only_file_path_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Name of the category used when automatically integrating elements within the embedded collection
|
2009-04-03 19:30:25 +00:00
|
|
|
static QString integration_category_name;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Default dimensions and properties for new diagrams created within the project
|
2009-04-03 19:30:25 +00:00
|
|
|
BorderProperties default_border_properties_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Default conductor properties for new diagrams created within the project
|
2009-04-03 19:30:25 +00:00
|
|
|
ConductorProperties default_conductor_properties_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Default title block properties for new diagrams created within the project
|
2010-12-20 02:45:36 +00:00
|
|
|
TitleBlockProperties default_titleblock_properties_;
|
2014-01-18 19:04:39 +00:00
|
|
|
/// Default report properties
|
|
|
|
QString default_report_properties_;
|
2012-01-08 17:04:34 +00:00
|
|
|
/// Embedded title block templates collection
|
|
|
|
TitleBlockTemplatesProjectCollection titleblocks_;
|
2012-07-01 21:54:07 +00:00
|
|
|
/// project-wide variables that will be made available to child diagrams
|
|
|
|
DiagramContext project_properties_;
|
2014-01-05 15:00:46 +00:00
|
|
|
/// undo stack for this project
|
|
|
|
QUndoStack *undo_stack_;
|
2009-04-03 19:30:25 +00:00
|
|
|
};
|
2012-02-06 21:21:43 +00:00
|
|
|
Q_DECLARE_METATYPE(QETProject *)
|
2009-04-03 19:30:25 +00:00
|
|
|
#endif
|