QElectroTech  0.70
Public Member Functions | Static Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
TitleBlockTemplatesFilesCollection Class Reference

#include <templatescollection.h>

Public Member Functions

 TitleBlockTemplatesFilesCollection (const QString &, QObject *=nullptr)
 
 ~TitleBlockTemplatesFilesCollection () override
 
QString path (const QString &=QString()) const
 
QStringList templates () override
 
TitleBlockTemplategetTemplate (const QString &) override
 
QDomElement getTemplateXmlDescription (const QString &) override
 
bool setTemplateXmlDescription (const QString &, const QDomElement &) override
 
void removeTemplate (const QString &) override
 
TitleBlockTemplateLocation location (const QString &=QString()) override
 
bool hasFilePath () override
 
QString filePath () override
 
bool isReadOnly (const QString &=QString()) const override
 
- Public Member Functions inherited from TitleBlockTemplatesCollection
 TitleBlockTemplatesCollection (QObject *parent)
 
 ~TitleBlockTemplatesCollection () override
 
virtual QString title () const
 
virtual void setTitle (const QString &)
 
virtual QString protocol () const
 
virtual void setProtocol (const QString &)
 
virtual QET::QetCollection collection () const
 TitleBlockTemplatesCollection::collection. More...
 
virtual void setCollection (QET::QetCollection)
 TitleBlockTemplatesCollection::setCollection Set the storage of this collection. More...
 
virtual QETProjectparentProject ()
 
virtual QList< TitleBlockTemplateLocationtemplatesLocations ()
 

Static Public Member Functions

static QString toTemplateName (const QString &)
 
static QString toFileName (const QString &)
 

Private Slots

void fileSystemChanged (const QString &str)
 

Private Member Functions

 TitleBlockTemplatesFilesCollection (const TitleBlockTemplatesFilesCollection &)
 

Private Attributes

QFileSystemWatcher watcher_
 File System Watcher object to track the files changes made outside the application. More...
 
QDir dir_
 Collection real directory. More...
 

Additional Inherited Members

- Signals inherited from TitleBlockTemplatesCollection
void changed (TitleBlockTemplatesCollection *, const QString &=QString())
 
void aboutToRemove (TitleBlockTemplatesCollection *, const QString &)
 
- Protected Attributes inherited from TitleBlockTemplatesCollection
QString title_
 Human-readable title for this collection. More...
 
QString protocol_
 Protocol used to designate this collection. More...
 
QET::QetCollection m_collection
 
QHash< QString, TitleBlockTemplate * > titleblock_templates_
 Already parsed embedded titleblock templates. More...
 

Detailed Description

This classe represents a simple abastraction layer for a file-based title block templates directory.

Definition at line 124 of file templatescollection.h.

Constructor & Destructor Documentation

◆ TitleBlockTemplatesFilesCollection() [1/2]

TitleBlockTemplatesFilesCollection::TitleBlockTemplatesFilesCollection ( const QString &  path,
QObject *  parent = nullptr 
)

Constructor

Parameters
pathPath of the directory containing the collection
parentParent QObject

Definition at line 355 of file templatescollection.cpp.

References dir_, fileSystemChanged(), and watcher_.

◆ ~TitleBlockTemplatesFilesCollection()

TitleBlockTemplatesFilesCollection::~TitleBlockTemplatesFilesCollection ( )
override

Destructor

Definition at line 373 of file templatescollection.cpp.

◆ TitleBlockTemplatesFilesCollection() [2/2]

TitleBlockTemplatesFilesCollection::TitleBlockTemplatesFilesCollection ( const TitleBlockTemplatesFilesCollection )
private

Member Function Documentation

◆ filePath()

QString TitleBlockTemplatesFilesCollection::filePath ( )
overridevirtual
Returns
The filesystem path where this files collection is actually stored.

Implements TitleBlockTemplatesCollection.

Definition at line 501 of file templatescollection.cpp.

References dir_.

◆ fileSystemChanged

void TitleBlockTemplatesFilesCollection::fileSystemChanged ( const QString &  str)
privateslot

Handle the changes occuring on the file system.

Parameters
strPath of the directory that changed.

Definition at line 542 of file templatescollection.cpp.

References TitleBlockTemplatesCollection::changed(), and dir_.

Referenced by TitleBlockTemplatesFilesCollection().

◆ getTemplate()

TitleBlockTemplate * TitleBlockTemplatesFilesCollection::getTemplate ( const QString &  template_name)
overridevirtual
Returns
the template which name is template_name, or 0 if the template could not be loaded.

Implements TitleBlockTemplatesCollection.

Definition at line 403 of file templatescollection.cpp.

References path(), templates(), and QET::TitleBlockTemplate.

◆ getTemplateXmlDescription()

QDomElement TitleBlockTemplatesFilesCollection::getTemplateXmlDescription ( const QString &  template_name)
overridevirtual
Parameters
template_nameName of a template (which has to already exist)
Returns
the XML description for the template_name template, or a null QDomElement if no such template exists.

Implements TitleBlockTemplatesCollection.

Definition at line 421 of file templatescollection.cpp.

References path().

◆ hasFilePath()

bool TitleBlockTemplatesFilesCollection::hasFilePath ( )
overridevirtual
Returns
always true since a files collection is always stored on a filesystem.

Implements TitleBlockTemplatesCollection.

Definition at line 494 of file templatescollection.cpp.

◆ isReadOnly()

bool TitleBlockTemplatesFilesCollection::isReadOnly ( const QString &  template_name = QString()) const
overridevirtual
Parameters
template_nameEither an empty QString to know whether the collection itself is read only, or a specific template name.
Returns
true if the specified template is read only, false otherwise

Implements TitleBlockTemplatesCollection.

Definition at line 510 of file templatescollection.cpp.

References dir_, and toFileName().

◆ location()

TitleBlockTemplateLocation TitleBlockTemplatesFilesCollection::location ( const QString &  template_name = QString())
overridevirtual
Parameters
template_nameName of a template supposed to be contained within this collection.
Returns

Implements TitleBlockTemplatesCollection.

Definition at line 486 of file templatescollection.cpp.

◆ path()

QString TitleBlockTemplatesFilesCollection::path ( const QString &  template_name = QString()) const
Returns
the canonical path of the directory hosting this collection.

Definition at line 379 of file templatescollection.cpp.

References dir_, and toFileName().

Referenced by getTemplate(), getTemplateXmlDescription(), and setTemplateXmlDescription().

◆ removeTemplate()

void TitleBlockTemplatesFilesCollection::removeTemplate ( const QString &  template_name)
overridevirtual

◆ setTemplateXmlDescription()

bool TitleBlockTemplatesFilesCollection::setTemplateXmlDescription ( const QString &  template_name,
const QDomElement &  xml_element 
)
overridevirtual

Set the XML description of the template_name template to xml_element.

Parameters
template_nameName of a template (which does not have to already exist)
xml_elementXML element describing the template

Implements TitleBlockTemplatesCollection.

Definition at line 448 of file templatescollection.cpp.

References TitleBlockTemplatesCollection::changed(), path(), and QET::writeXmlFile().

◆ templates()

QStringList TitleBlockTemplatesFilesCollection::templates ( )
overridevirtual
Returns
the list of templates contained in this collection

Implements TitleBlockTemplatesCollection.

Definition at line 390 of file templatescollection.cpp.

References dir_, and TITLEBLOCKS_FILE_EXTENSION.

Referenced by getTemplate().

◆ toFileName()

QString TitleBlockTemplatesFilesCollection::toFileName ( const QString &  template_name)
static
Parameters
template_nameA template name
Returns
the file name for template_name

Definition at line 534 of file templatescollection.cpp.

References TITLEBLOCKS_FILE_EXTENSION.

Referenced by isReadOnly(), path(), and removeTemplate().

◆ toTemplateName()

QString TitleBlockTemplatesFilesCollection::toTemplateName ( const QString &  file_name)
static
Parameters
file_nameA file name
Returns
the template name for file_name

Definition at line 524 of file templatescollection.cpp.

References TITLEBLOCKS_FILE_EXTENSION.

Member Data Documentation

◆ dir_

QDir TitleBlockTemplatesFilesCollection::dir_
private

Collection real directory.

Definition at line 158 of file templatescollection.h.

Referenced by filePath(), fileSystemChanged(), isReadOnly(), path(), removeTemplate(), templates(), and TitleBlockTemplatesFilesCollection().

◆ watcher_

QFileSystemWatcher TitleBlockTemplatesFilesCollection::watcher_
private

File System Watcher object to track the files changes made outside the application.

Definition at line 156 of file templatescollection.h.

Referenced by TitleBlockTemplatesFilesCollection().


The documentation for this class was generated from the following files: