LibrePCB Developers Documentation
Project Class Referencefinal

The Project class represents a whole (opened) project with all its content. More...

#include <project.h>

+ Inheritance diagram for Project:
+ Collaboration diagram for Project:

Signals

void attributesChanged () override
 This signal is emitted when the value of attributes has changed. More...
 
void schematicAdded (int newIndex)
 This signal is emitted after a schematic was added to the project. More...
 
void schematicRemoved (int oldIndex)
 This signal is emitted after a schematic was removed from the project. More...
 
void boardAdded (int newIndex)
 This signal is emitted after a board was added to the project. More...
 
void boardRemoved (int oldIndex)
 This signal is emitted after a board was removed from the project. More...
 
- Signals inherited from AttributeProvider
virtual void attributesChanged ()=0
 This signal is emitted when the value of attributes has changed. More...
 

Public Member Functions

 Project ()=delete
 
 Project (const Project &other)=delete
 
 Project (std::unique_ptr< TransactionalDirectory > directory, const QString &filename)
 The constructor to open an existing project with all its content. More...
 
 ~Project () noexcept
 The destructor will close the whole project (without saving!) More...
 
FilePath getFilepath () const noexcept
 Get the filepath of the project file (*.lpp) More...
 
FilePath getPath () const noexcept
 Get the path to the project directory. More...
 
const TransactionalDirectorygetDirectory () const noexcept
 
TransactionalDirectorygetDirectory () noexcept
 
StrokeFontPoolgetStrokeFonts () const noexcept
 Get the StrokeFontPool which contains all stroke fonts of the project. More...
 
const UuidgetUuid () const noexcept
 Get the UUID of the project. More...
 
const ElementNamegetName () const noexcept
 Get the name of the project. More...
 
const QString & getAuthor () const noexcept
 Get the author of the project. More...
 
const QString & getVersion () const noexcept
 Get the version of the project. More...
 
const QDateTime & getCreated () const noexcept
 Get the date and time when the project was created. More...
 
const QDateTime & getLastModified () const noexcept
 Get the date and time when the project was last modified. More...
 
const AttributeListgetAttributes () const noexcept
 Get the list of attributes. More...
 
ProjectSettingsgetSettings () const noexcept
 Get the ProjectSettings object which contains all project settings. More...
 
ProjectLibrarygetLibrary () const noexcept
 Get the ProjectLibrary object which contains all library elements used in this project. More...
 
ErcMsgListgetErcMsgList () const noexcept
 Get the ERC messages list. More...
 
CircuitgetCircuit () const noexcept
 Get the Circuit object. More...
 
void setUuid (const Uuid &newUuid) noexcept
 Set the project's UUID. More...
 
void setName (const ElementName &newName) noexcept
 Set the name of the project. More...
 
void setAuthor (const QString &newAuthor) noexcept
 Set the author of the project. More...
 
void setVersion (const QString &newVersion) noexcept
 Set the version of the project. More...
 
void setCreated (const QDateTime &newCreated) noexcept
 Set the creation date/time. More...
 
void updateLastModified () noexcept
 Update the last modified date/time. More...
 
void setAttributes (const AttributeList &newAttributes) noexcept
 Set all project attributes. More...
 
SchematicLayerProvidergetLayers () noexcept
 
const SchematicLayerProvidergetLayers () const noexcept
 
int getSchematicIndex (const Schematic &schematic) const noexcept
 Get the page index of a specific schematic. More...
 
const QList< Schematic * > & getSchematics () const noexcept
 Get all schematics. More...
 
SchematicgetSchematicByIndex (int index) const noexcept
 Get the schematic page at a specific index. More...
 
SchematicgetSchematicByUuid (const Uuid &uuid) const noexcept
 Get the schematic page with a specific UUID. More...
 
SchematicgetSchematicByName (const QString &name) const noexcept
 Get the schematic page with a specific name. More...
 
SchematiccreateSchematic (const ElementName &name)
 Create a new schematic (page) More...
 
void addSchematic (Schematic &schematic, int newIndex=-1)
 Add an existing schematic to this project. More...
 
void removeSchematic (Schematic &schematic, bool deleteSchematic=false)
 Remove a schematic from this project. More...
 
int getBoardIndex (const Board &board) const noexcept
 Get the index of a specific board. More...
 
const QList< Board * > & getBoards () const noexcept
 Get all boards. More...
 
BoardgetBoardByIndex (int index) const noexcept
 Get the board at a specific index. More...
 
BoardgetBoardByUuid (const Uuid &uuid) const noexcept
 Get the board with a specific UUID. More...
 
BoardgetBoardByName (const QString &name) const noexcept
 Get the board with a specific name. More...
 
BoardcreateBoard (const ElementName &name)
 Create a new board. More...
 
BoardcreateBoard (const Board &other, const ElementName &name)
 Create a new board as a copy of an existing board. More...
 
void addBoard (Board &board, int newIndex=-1)
 Add an existing board to this project. More...
 
void removeBoard (Board &board, bool deleteBoard=false)
 Remove a board from this project. More...
 
void save ()
 Save the project to the transactional file system. More...
 
QString getUserDefinedAttributeValue (const QString &key) const noexcept override
 Get the value of a user defined attribute (if available) More...
 
QString getBuiltInAttributeValue (const QString &key) const noexcept override
 Get the value of a built-in attribute (if available) More...
 
bool operator== (const Project &rhs) noexcept
 
bool operator!= (const Project &rhs) noexcept
 
- Public Member Functions inherited from AttributeProvider
 AttributeProvider () noexcept
 
 AttributeProvider (const AttributeProvider &other)=delete
 
AttributeProvideroperator= (const AttributeProvider &rhs)=delete
 
virtual ~AttributeProvider () noexcept
 
QString getAttributeValue (const QString &key) const noexcept
 Get the value of an attribute which can be used in texts (like "{{NAME}}") More...
 
virtual QVector< const AttributeProvider * > getAttributeProviderParents () const noexcept
 Get all parent attribute providers (fallback if attribute not found) More...
 

Static Public Member Functions

static Projectcreate (std::unique_ptr< TransactionalDirectory > directory, const QString &filename)
 
static bool isFilePathInsideProjectDirectory (const FilePath &fp) noexcept
 
static bool isProjectFile (const FilePath &file) noexcept
 
static bool isProjectDirectory (const FilePath &dir) noexcept
 
static Version getProjectFileFormatVersion (const FilePath &dir)
 

Private Member Functions

 Project (std::unique_ptr< TransactionalDirectory > directory, const QString &filename, bool create)
 The constructor to create or open a project with all its content. More...
 

Private Attributes

std::unique_ptr< TransactionalDirectorymDirectory
 Project root directory. More...
 
QString mFilename
 Name of the *.lpp project file. More...
 
QScopedPointer< StrokeFontPoolmStrokeFontPool
 All fonts from ./resources/fontobene/. More...
 
Uuid mUuid
 The project's UUID. More...
 
ElementName mName
 The project name. More...
 
QString mAuthor
 Author (optional). More...
 
QString mVersion
 Version (arbitrary string, optional). More...
 
QDateTime mCreated
 Date/time of project creation. More...
 
QDateTime mLastModified
 Date/time of last modification. More...
 
AttributeList mAttributes
 User-defined attributes in the specified order. More...
 
QScopedPointer< ProjectSettingsmProjectSettings
 All project specific settings. More...
 
QScopedPointer< ProjectLibrarymProjectLibrary
 Ehe library which contains all elements needed in this project. More...
 
QScopedPointer< ErcMsgListmErcMsgList
 
QScopedPointer< CircuitmCircuit
 
QList< Schematic * > mSchematics
 All schematics of this project. More...
 
QList< Schematic * > mRemovedSchematics
 All removed schematics of this project. More...
 
QScopedPointer< SchematicLayerProvidermSchematicLayerProvider
 All schematic layers of this project. More...
 
QList< Board * > mBoards
 All boards of this project. More...
 
QList< Board * > mRemovedBoards
 All removed boards of this project. More...
 

Detailed Description

The Project class represents a whole (opened) project with all its content.

This class represents a whole project with all the content of its directory:

  • circuit, schematics and boards
  • the project's library
  • project settings
  • and much more...

The constructor of the librepcb::Project class needs the filepath to a project file. Then the project will be opened. A new project can be created with the static method create(). The destructor will close the project (without saving). Use the method save() to write the whole project to the harddisc.

Note
!! A detailed description about projects is available here: Project Specification !!

Constructor & Destructor Documentation

◆ Project() [1/4]

Project ( )
delete
+ Here is the caller graph for this function:

◆ Project() [2/4]

Project ( const Project other)
delete

◆ Project() [3/4]

Project ( std::unique_ptr< TransactionalDirectory directory,
const QString &  filename 
)
inline

The constructor to open an existing project with all its content.

Parameters
directoryThe directory which contains the project.
filenameThe filename of the *.lpp project file.
Exceptions
ExceptionIf the project could not be opened successfully
+ Here is the call graph for this function:

◆ ~Project()

~Project ( )
noexcept

The destructor will close the whole project (without saving!)

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Project() [4/4]

Project ( std::unique_ptr< TransactionalDirectory directory,
const QString &  filename,
bool  create 
)
explicitprivate

The constructor to create or open a project with all its content.

Parameters
directoryThe directory which contains the project.
filenameThe filename of the *.lpp project file.
createTrue if the specified project does not exist already and must be created.
Exceptions
ExceptionIf the project could not be created/opened successfully
Todo:
Remove interactive message boxes, should be done at a higher layer!
+ Here is the call graph for this function:

Member Function Documentation

◆ getFilepath()

FilePath getFilepath ( ) const
inlinenoexcept

Get the filepath of the project file (*.lpp)

Returns
The absolute filepath
+ Here is the caller graph for this function:

◆ getPath()

FilePath getPath ( ) const
inlinenoexcept

Get the path to the project directory.

Returns
The filepath to the project directory
+ Here is the caller graph for this function:

◆ getDirectory() [1/2]

const TransactionalDirectory& getDirectory ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getDirectory() [2/2]

TransactionalDirectory& getDirectory ( )
inlinenoexcept

◆ getStrokeFonts()

StrokeFontPool& getStrokeFonts ( ) const
inlinenoexcept

Get the StrokeFontPool which contains all stroke fonts of the project.

Returns
A reference to the librepcb::StrokeFontPool object
+ Here is the caller graph for this function:

◆ getUuid()

const Uuid& getUuid ( ) const
inlinenoexcept

Get the UUID of the project.

Returns
The project UUID

◆ getName()

const ElementName& getName ( ) const
inlinenoexcept

Get the name of the project.

Returns
The name of the project
+ Here is the caller graph for this function:

◆ getAuthor()

const QString& getAuthor ( ) const
inlinenoexcept

Get the author of the project.

Returns
The author of the project

◆ getVersion()

const QString& getVersion ( ) const
inlinenoexcept

Get the version of the project.

Returns
The version of the project (arbitrary string)
+ Here is the caller graph for this function:

◆ getCreated()

const QDateTime& getCreated ( ) const
inlinenoexcept

Get the date and time when the project was created.

Returns
The local date and time of creation

◆ getLastModified()

const QDateTime& getLastModified ( ) const
inlinenoexcept

Get the date and time when the project was last modified.

Returns
The local date and time of last modification
Todo:
Dynamically determine the datetime of the last modification from version control system, file attributes or something like that.

◆ getAttributes()

const AttributeList& getAttributes ( ) const
inlinenoexcept

Get the list of attributes.

Returns
All attributes in a specific order

◆ getSettings()

ProjectSettings& getSettings ( ) const
inlinenoexcept

Get the ProjectSettings object which contains all project settings.

Returns
A reference to the ProjectSettings object
+ Here is the caller graph for this function:

◆ getLibrary()

ProjectLibrary& getLibrary ( ) const
inlinenoexcept

Get the ProjectLibrary object which contains all library elements used in this project.

Returns
A reference to the ProjectLibrary object
+ Here is the caller graph for this function:

◆ getErcMsgList()

ErcMsgList& getErcMsgList ( ) const
inlinenoexcept

Get the ERC messages list.

Returns
A reference to the ErcMsgList object
+ Here is the caller graph for this function:

◆ getCircuit()

Circuit& getCircuit ( ) const
inlinenoexcept

Get the Circuit object.

Returns
A reference to the Circuit object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUuid()

void setUuid ( const Uuid newUuid)
noexcept

Set the project's UUID.

Warning
Only call this right after instantiating a new Project object, not some time later! Not intended to be accessible by the UI.
Parameters
newUuidThe new UUID.
+ Here is the caller graph for this function:

◆ setName()

void setName ( const ElementName newName)
noexcept

Set the name of the project.

Parameters
newNameThe new name
+ Here is the caller graph for this function:

◆ setAuthor()

void setAuthor ( const QString &  newAuthor)
noexcept

Set the author of the project.

Parameters
newAuthorThe new author
+ Here is the caller graph for this function:

◆ setVersion()

void setVersion ( const QString &  newVersion)
noexcept

Set the version of the project.

Parameters
newVersionThe new version (can be an arbitrary string)
+ Here is the caller graph for this function:

◆ setCreated()

void setCreated ( const QDateTime &  newCreated)
noexcept

Set the creation date/time.

Parameters
newCreatedThe new date/time of creation.
+ Here is the caller graph for this function:

◆ updateLastModified()

void updateLastModified ( )
noexcept

Update the last modified date/time.

+ Here is the caller graph for this function:

◆ setAttributes()

void setAttributes ( const AttributeList newAttributes)
noexcept

Set all project attributes.

Parameters
newAttributesThe new list of attributes
+ Here is the caller graph for this function:

◆ getLayers() [1/2]

SchematicLayerProvider& getLayers ( )
inlinenoexcept
+ Here is the caller graph for this function:

◆ getLayers() [2/2]

const SchematicLayerProvider& getLayers ( ) const
inlinenoexcept
+ Here is the call graph for this function:

◆ getSchematicIndex()

int getSchematicIndex ( const Schematic schematic) const
noexcept

Get the page index of a specific schematic.

Returns
the schematic index (-1 if the schematic does not exist)
+ Here is the caller graph for this function:

◆ getSchematics()

const QList<Schematic*>& getSchematics ( ) const
inlinenoexcept

Get all schematics.

Returns
A QList with all schematics
+ Here is the caller graph for this function:

◆ getSchematicByIndex()

Schematic* getSchematicByIndex ( int  index) const
inlinenoexcept

Get the schematic page at a specific index.

Parameters
indexThe page index (zero is the first)
Returns
A pointer to the specified schematic, or nullptr if index is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSchematicByUuid()

Schematic * getSchematicByUuid ( const Uuid uuid) const
noexcept

Get the schematic page with a specific UUID.

Parameters
uuidThe schematic UUID
Returns
A pointer to the specified schematic, or nullptr if uuid is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSchematicByName()

Schematic * getSchematicByName ( const QString &  name) const
noexcept

Get the schematic page with a specific name.

Parameters
nameThe schematic name
Returns
A pointer to the specified schematic, or nullptr if name is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createSchematic()

Schematic * createSchematic ( const ElementName name)

Create a new schematic (page)

Parameters
nameThe schematic page name
Returns
A pointer to the new schematic
Exceptions
ExceptionThis method throws an exception on error.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSchematic()

void addSchematic ( Schematic schematic,
int  newIndex = -1 
)

Add an existing schematic to this project.

Parameters
schematicThe schematic to add
newIndexThe desired index in the list (after inserting it)
Exceptions
ExceptionOn error
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeSchematic()

void removeSchematic ( Schematic schematic,
bool  deleteSchematic = false 
)

Remove a schematic from this project.

Parameters
schematicThe schematic to remove
deleteSchematicIf true, the schematic object will be deleted (Set this to true only when called from ctor or dtor!!)
Exceptions
ExceptionOn error
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBoardIndex()

int getBoardIndex ( const Board board) const
noexcept

Get the index of a specific board.

Returns
the board index (-1 if the board does not exist)
+ Here is the caller graph for this function:

◆ getBoards()

const QList<Board*>& getBoards ( ) const
inlinenoexcept

Get all boards.

Returns
A QList with all boards
+ Here is the caller graph for this function:

◆ getBoardByIndex()

Board* getBoardByIndex ( int  index) const
inlinenoexcept

Get the board at a specific index.

Parameters
indexThe board index (zero is the first)
Returns
A pointer to the specified board, or nullptr if index is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBoardByUuid()

Board * getBoardByUuid ( const Uuid uuid) const
noexcept

Get the board with a specific UUID.

Parameters
uuidThe board UUID
Returns
A pointer to the specified board, or nullptr if uuid is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBoardByName()

Board * getBoardByName ( const QString &  name) const
noexcept

Get the board with a specific name.

Parameters
nameThe board name
Returns
A pointer to the specified board, or nullptr if name is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createBoard() [1/2]

Board * createBoard ( const ElementName name)

Create a new board.

Parameters
nameThe board name
Returns
A pointer to the new board
Exceptions
ExceptionThis method throws an exception on error.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createBoard() [2/2]

Board * createBoard ( const Board other,
const ElementName name 
)

Create a new board as a copy of an existing board.

Parameters
otherThe board to copy
nameThe board name
Returns
A pointer to the new board
Exceptions
ExceptionThis method throws an exception on error.
+ Here is the call graph for this function:

◆ addBoard()

void addBoard ( Board board,
int  newIndex = -1 
)

Add an existing board to this project.

Parameters
boardThe board to add
newIndexThe desired index in the list (after inserting it)
Exceptions
ExceptionOn error
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeBoard()

void removeBoard ( Board board,
bool  deleteBoard = false 
)

Remove a board from this project.

Parameters
boardThe board to remove
deleteBoardIf true, the board object will be deleted (Set this to true only when called from ctor or dtor!!)
Exceptions
ExceptionOn error
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

void save ( )

Save the project to the transactional file system.

Exceptions
ExceptionIf an error occurred.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserDefinedAttributeValue()

QString getUserDefinedAttributeValue ( const QString &  key) const
overridevirtualnoexcept

Get the value of a user defined attribute (if available)

Parameters
keyThe attribute name (e.g. "NAME" for "{{NAME}}")
Returns
The value of the attribute (empty string if not found)

Reimplemented from AttributeProvider.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBuiltInAttributeValue()

QString getBuiltInAttributeValue ( const QString &  key) const
overridevirtualnoexcept

Get the value of a built-in attribute (if available)

Parameters
keyThe attribute name (e.g. "NAME" for "{{NAME}}")
Returns
The value of the attribute (empty string if not found)

Reimplemented from AttributeProvider.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator==()

bool operator== ( const Project rhs)
inlinenoexcept

◆ operator!=()

bool operator!= ( const Project rhs)
inlinenoexcept

◆ create()

static Project* create ( std::unique_ptr< TransactionalDirectory directory,
const QString &  filename 
)
inlinestatic
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFilePathInsideProjectDirectory()

bool isFilePathInsideProjectDirectory ( const FilePath fp)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isProjectFile()

bool isProjectFile ( const FilePath file)
staticnoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isProjectDirectory()

bool isProjectDirectory ( const FilePath dir)
staticnoexcept
+ Here is the caller graph for this function:

◆ getProjectFileFormatVersion()

Version getProjectFileFormatVersion ( const FilePath dir)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attributesChanged

void attributesChanged ( )
overridesignal

This signal is emitted when the value of attributes has changed.

All derived classes must emit this signal when some attributes have changed their values (only attributes which can be fetched with getAttributeValue(), inclusive all attributes from all "parent" classes).

+ Here is the caller graph for this function:

◆ schematicAdded

void schematicAdded ( int  newIndex)
signal

This signal is emitted after a schematic was added to the project.

Parameters
newIndexThe index of the added schematic
+ Here is the caller graph for this function:

◆ schematicRemoved

void schematicRemoved ( int  oldIndex)
signal

This signal is emitted after a schematic was removed from the project.

Parameters
oldIndexThe index of the removed schematic
+ Here is the caller graph for this function:

◆ boardAdded

void boardAdded ( int  newIndex)
signal

This signal is emitted after a board was added to the project.

Parameters
newIndexThe index of the added board
+ Here is the caller graph for this function:

◆ boardRemoved

void boardRemoved ( int  oldIndex)
signal

This signal is emitted after a board was removed from the project.

Parameters
oldIndexThe index of the removed board
+ Here is the caller graph for this function:

Member Data Documentation

◆ mDirectory

std::unique_ptr<TransactionalDirectory> mDirectory
private

Project root directory.

◆ mFilename

QString mFilename
private

Name of the *.lpp project file.

◆ mStrokeFontPool

QScopedPointer<StrokeFontPool> mStrokeFontPool
private

All fonts from ./resources/fontobene/.

◆ mUuid

Uuid mUuid
private

The project's UUID.

◆ mName

ElementName mName
private

The project name.

◆ mAuthor

QString mAuthor
private

Author (optional).

◆ mVersion

QString mVersion
private

Version (arbitrary string, optional).

◆ mCreated

QDateTime mCreated
private

Date/time of project creation.

◆ mLastModified

QDateTime mLastModified
private

Date/time of last modification.

◆ mAttributes

AttributeList mAttributes
private

User-defined attributes in the specified order.

◆ mProjectSettings

QScopedPointer<ProjectSettings> mProjectSettings
private

All project specific settings.

◆ mProjectLibrary

QScopedPointer<ProjectLibrary> mProjectLibrary
private

Ehe library which contains all elements needed in this project.

◆ mErcMsgList

QScopedPointer<ErcMsgList> mErcMsgList
private

A list which contains all electrical rule check (ERC) messages

◆ mCircuit

QScopedPointer<Circuit> mCircuit
private

The whole circuit of this project (contains all netclasses, netsignals, component instances, ...)

◆ mSchematics

QList<Schematic*> mSchematics
private

All schematics of this project.

◆ mRemovedSchematics

QList<Schematic*> mRemovedSchematics
private

All removed schematics of this project.

◆ mSchematicLayerProvider

QScopedPointer<SchematicLayerProvider> mSchematicLayerProvider
private

All schematic layers of this project.

◆ mBoards

QList<Board*> mBoards
private

All boards of this project.

◆ mRemovedBoards

QList<Board*> mRemovedBoards
private

All removed boards of this project.


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