QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
templatescollection.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef TITLEBLOCK_SLASH_TEMPLATES_COLLECTION_H
19#define TITLEBLOCK_SLASH_TEMPLATES_COLLECTION_H
20#define TITLEBLOCKS_FILE_EXTENSION ".titleblock"
21#include "../qet.h"
22#include "templatelocation.h"
23
24#include <QtCore>
25#include <QtXml>
27class QETProject;
28
35class TitleBlockTemplatesCollection : public QObject {
36 Q_OBJECT
37
38 // Constructors, destructor
39 public:
40 TitleBlockTemplatesCollection(QObject *parent);
42 private:
44
45 // methods
46 public:
47 virtual QStringList templates() = 0;
48 virtual TitleBlockTemplate *getTemplate(const QString &) = 0;
49 virtual QDomElement getTemplateXmlDescription(const QString &) = 0;
50 virtual bool setTemplateXmlDescription(const QString &, const QDomElement &) = 0;
51 virtual void removeTemplate(const QString &) = 0;
52 virtual TitleBlockTemplateLocation location(const QString & = QString()) = 0;
53 virtual bool hasFilePath() = 0;
54 virtual QString filePath() = 0;
55 virtual bool isReadOnly(const QString & = QString()) const = 0;
56 virtual QString title() const;
57 virtual void setTitle(const QString &);
58 virtual QString protocol() const;
59 virtual void setProtocol(const QString &);
60 virtual QET::QetCollection collection () const;
61 virtual void setCollection (QET::QetCollection);
62 virtual QETProject *parentProject();
63 virtual QList<TitleBlockTemplateLocation> templatesLocations();
64
65 signals:
66 void changed(TitleBlockTemplatesCollection *, const QString & = QString());
68
69 // attributes
70 protected:
72 QString title_;
74 QString protocol_;
77 QHash<QString, TitleBlockTemplate *> titleblock_templates_;
78};
79
85 Q_OBJECT
86
87 // Constructors, destructor
88 public:
89 TitleBlockTemplatesProjectCollection(QETProject *, QObject *parent = nullptr);
91 private:
93
94 // methods
95 public:
96 QString title() const override;
97 QString protocol() const override;
98 QETProject *parentProject() override;
99 QStringList templates() override;
100 TitleBlockTemplate *getTemplate(const QString &) override;
101 QDomElement getTemplateXmlDescription(const QString &) override;
102 bool setTemplateXmlDescription(const QString &, const QDomElement &) override;
103 void removeTemplate(const QString &) override;
104 TitleBlockTemplateLocation location(const QString & = QString()) override;
105 bool hasFilePath() override;
106 QString filePath() override;
107 bool isReadOnly(const QString & = QString()) const override;
108 virtual void fromXml(const QDomElement &);
109 virtual void deleteUnusedTitleBlocKTemplates();
110
111 // attributes
112 private:
116 QDomDocument xml_document_;
118 QHash<QString, QDomElement> titleblock_templates_xml_;
119};
120
126 Q_OBJECT
127
128 // Constructors, destructor
129 public:
130 TitleBlockTemplatesFilesCollection(const QString &, QObject * = nullptr);
132 private:
134
135 // methods
136 public:
137 QString path(const QString & = QString()) const;
138 QStringList templates() override;
139 TitleBlockTemplate *getTemplate(const QString &) override;
140 QDomElement getTemplateXmlDescription(const QString &) override;
141 bool setTemplateXmlDescription(const QString &, const QDomElement &) override;
142 void removeTemplate(const QString &) override;
143 TitleBlockTemplateLocation location(const QString & = QString()) override;
144 bool hasFilePath() override;
145 QString filePath() override;
146 bool isReadOnly(const QString & = QString()) const override;
147
148 static QString toTemplateName(const QString &);
149 static QString toFileName(const QString &);
150
151 private slots:
152 void fileSystemChanged(const QString &str);
153
154 // attributes
155 private:
157 QFileSystemWatcher watcher_;
159 QDir dir_;
160};
161#endif
Definition qetproject.h:62
The TitleBlockTemplate class This class represents an title block template for an electric diagram....
Definition titleblocktemplate.h:37
Definition templatelocation.h:29
Definition templatescollection.h:35
virtual QString protocol() const
Definition templatescollection.cpp:63
virtual bool isReadOnly(const QString &=QString()) const =0
QET::QetCollection m_collection
Definition templatescollection.h:75
virtual QDomElement getTemplateXmlDescription(const QString &)=0
virtual TitleBlockTemplateLocation location(const QString &=QString())=0
TitleBlockTemplatesCollection(const TitleBlockTemplatesCollection &)
virtual bool hasFilePath()=0
virtual void setTitle(const QString &)
TitleBlockTemplatesCollection::setTitle.
Definition templatescollection.cpp:55
virtual bool setTemplateXmlDescription(const QString &, const QDomElement &)=0
virtual void removeTemplate(const QString &)=0
void changed(TitleBlockTemplatesCollection *, const QString &=QString())
virtual void setCollection(QET::QetCollection)
TitleBlockTemplatesCollection::setCollection Set the storage of this collection.
Definition templatescollection.cpp:90
virtual QETProject * parentProject()
Definition templatescollection.cpp:98
virtual QET::QetCollection collection() const
TitleBlockTemplatesCollection::collection.
Definition templatescollection.cpp:80
~TitleBlockTemplatesCollection() override
Definition templatescollection.cpp:39
virtual QString filePath()=0
virtual QStringList templates()=0
virtual QString title() const
Definition templatescollection.cpp:46
QString title_
Human-readable title for this collection.
Definition templatescollection.h:72
void aboutToRemove(TitleBlockTemplatesCollection *, const QString &)
virtual void setProtocol(const QString &)
Definition templatescollection.cpp:72
virtual QList< TitleBlockTemplateLocation > templatesLocations()
Definition templatescollection.cpp:108
virtual TitleBlockTemplate * getTemplate(const QString &)=0
QString protocol_
Protocol used to designate this collection.
Definition templatescollection.h:74
QHash< QString, TitleBlockTemplate * > titleblock_templates_
Already parsed embedded titleblock templates.
Definition templatescollection.h:77
Definition templatescollection.h:125
QDir dir_
Collection real directory.
Definition templatescollection.h:159
QFileSystemWatcher watcher_
File System Watcher object to track the files changes made outside the application.
Definition templatescollection.h:157
bool hasFilePath() override
Definition templatescollection.cpp:516
void removeTemplate(const QString &) override
Definition templatescollection.cpp:491
static QString toTemplateName(const QString &)
Definition templatescollection.cpp:549
void fileSystemChanged(const QString &str)
Definition templatescollection.cpp:567
bool isReadOnly(const QString &=QString()) const override
Definition templatescollection.cpp:534
QString filePath() override
Definition templatescollection.cpp:524
bool setTemplateXmlDescription(const QString &, const QDomElement &) override
Definition templatescollection.cpp:470
static QString toFileName(const QString &)
Definition templatescollection.cpp:559
TitleBlockTemplate * getTemplate(const QString &) override
Definition templatescollection.cpp:425
QString path(const QString &=QString()) const
Definition templatescollection.cpp:399
QDomElement getTemplateXmlDescription(const QString &) override
Definition templatescollection.cpp:443
QStringList templates() override
Definition templatescollection.cpp:411
TitleBlockTemplatesFilesCollection(const TitleBlockTemplatesFilesCollection &)
~TitleBlockTemplatesFilesCollection() override
Definition templatescollection.cpp:392
TitleBlockTemplateLocation location(const QString &=QString()) override
Definition templatescollection.cpp:508
Definition templatescollection.h:84
QHash< QString, QDomElement > titleblock_templates_xml_
XML descriptions of embedded titleblock templates.
Definition templatescollection.h:118
TitleBlockTemplatesProjectCollection(const TitleBlockTemplatesProjectCollection &)
TitleBlockTemplateLocation location(const QString &=QString()) override
Definition templatescollection.cpp:301
virtual void deleteUnusedTitleBlocKTemplates()
Definition templatescollection.cpp:358
TitleBlockTemplate * getTemplate(const QString &) override
Definition templatescollection.cpp:205
QDomDocument xml_document_
Parent QDomDocument for stored QDomElements.
Definition templatescollection.h:116
~TitleBlockTemplatesProjectCollection() override
Definition templatescollection.cpp:132
QETProject * parentProject() override
Definition templatescollection.cpp:187
QDomElement getTemplateXmlDescription(const QString &) override
Definition templatescollection.cpp:231
bool isReadOnly(const QString &=QString()) const override
Definition templatescollection.cpp:328
bool setTemplateXmlDescription(const QString &, const QDomElement &) override
Definition templatescollection.cpp:249
bool hasFilePath() override
Definition templatescollection.cpp:309
void removeTemplate(const QString &) override
Definition templatescollection.cpp:286
QETProject * project_
Parent project.
Definition templatescollection.h:114
QString title() const override
Definition templatescollection.cpp:139
QStringList templates() override
Definition templatescollection.cpp:195
QString protocol() const override
Definition templatescollection.cpp:172
virtual void fromXml(const QDomElement &)
Definition templatescollection.cpp:340
QString filePath() override
Definition templatescollection.cpp:318
QetCollection
Enum used to specify the origin of a collection of thing (title block, element etc....
Definition qet.h:148