LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Workspace Class Referencefinal

The Workspace class represents a workspace with all its data (library, projects, settings, ...) More...

#include <workspace.h>

Inherits QObject.

+ Collaboration diagram for Workspace:

Signals

void libraryAdded (const FilePath &libDir)
 
void libraryRemoved (const FilePath &libDir)
 

Public Member Functions

 Workspace ()=delete
 
 Workspace (const Workspace &other)=delete
 
 Workspace (const FilePath &wsPath)
 Constructor to open an existing workspace. More...
 
 ~Workspace () noexcept
 
const FilePathgetPath () const
 Get the filepath to the workspace directory. More...
 
const FilePathgetProjectsPath () const
 Get the filepath to the "projects" directory in the workspace. More...
 
const FilePathgetMetadataPath () const
 Get the filepath to the version directory (v#) in the workspace. More...
 
const FilePathgetLibrariesPath () const
 Get the filepath to the "v#/libraries" directory in the workspace. More...
 
ProjectTreeModelgetProjectTreeModel () const noexcept
 
RecentProjectsModelgetRecentProjectsModel () const noexcept
 
FavoriteProjectsModelgetFavoriteProjectsModel () const noexcept
 
WorkspaceSettingsgetSettings () const
 Get the workspace settings. More...
 
QSharedPointer< library::LibrarygetLibrary (const Uuid &uuid, bool local=true, bool remote=true) const noexcept
 Get the (highest version) library of a given UUID. More...
 
const QMap< QString,
QSharedPointer
< library::Library > > 
getLocalLibraries () const noexcept
 Get all local libraries (located in "workspace/v#/libraries/local") More...
 
const QMap< QString,
QSharedPointer
< library::Library > > 
getRemoteLibraries () const noexcept
 Get all remote libraries (located in "workspace/v#/libraries/remote") More...
 
void addLocalLibrary (const QString &libDirName)
 Add a new local library. More...
 
void addRemoteLibrary (const QString &libDirName)
 Add a new remote library. More...
 
void removeLocalLibrary (const QString &libDirName, bool rmDir=true)
 Remove a local library. More...
 
void removeRemoteLibrary (const QString &libDirName, bool rmDir=true)
 Remove a remote library. More...
 
WorkspaceLibraryDbgetLibraryDb () const
 Get the workspace library database. More...
 
void setLastRecentlyUsedProject (const FilePath &filepath) noexcept
 setLastRecentlyUsedProject More...
 
bool isFavoriteProject (const FilePath &filepath) const noexcept
 Check whether a project is in the favorite project list or not. More...
 
void addFavoriteProject (const FilePath &filepath) noexcept
 Add a project to the favorite projects list. More...
 
void removeFavoriteProject (const FilePath &filepath) noexcept
 Remove a project from the favorite projects list. More...
 
Workspaceoperator= (const Workspace &rhs)=delete
 

Static Public Member Functions

static bool isValidWorkspacePath (const FilePath &path) noexcept
 Check whether a filepath points to a valid workspace directory or not. More...
 
static QList< VersiongetFileFormatVersionsOfWorkspace (const FilePath &path) noexcept
 getFileFormatVersionsOfWorkspace More...
 
static tl::optional< VersiongetHighestFileFormatVersionOfWorkspace (const FilePath &path) noexcept
 getHighestFileFormatVersionOfWorkspace More...
 
static void createNewWorkspace (const FilePath &path)
 Create a new workspace. More...
 
static FilePath getMostRecentlyUsedWorkspacePath () noexcept
 Get the most recently used workspace path. More...
 
static void setMostRecentlyUsedWorkspacePath (const FilePath &path) noexcept
 Set the most recently used workspace path. More...
 
static FilePath chooseWorkspacePath () noexcept
 Let the user choose a workspace path (with a directory chooser dialog) More...
 
static Version FILE_FORMAT_VERSION () noexcept
 Current workspace file format version (constant) More...
 

Private Attributes

FilePath mPath
 a FilePath object which represents the workspace directory More...
 
FilePath mProjectsPath
 the directory "projects" More...
 
FilePath mMetadataPath
 the subdirectory of the current file format version More...
 
FilePath mLibrariesPath
 the directory "v#/libraries" More...
 
DirectoryLock mLock
 to lock the version directory (#mVersionPath) More...
 
QScopedPointer< WorkspaceSettingsmWorkspaceSettings
 the WorkspaceSettings object More...
 
QMap< QString, QSharedPointer
< library::Library > > 
mLocalLibraries
 all local libraries More...
 
QMap< QString, QSharedPointer
< library::Library > > 
mRemoteLibraries
 all remote libraries More...
 
QScopedPointer
< WorkspaceLibraryDb
mLibraryDb
 the library database More...
 
QScopedPointer< ProjectTreeModelmProjectTreeModel
 a tree model for the whole projects directory More...
 
QScopedPointer
< RecentProjectsModel
mRecentProjectsModel
 a list model of all recent projects More...
 
QScopedPointer
< FavoriteProjectsModel
mFavoriteProjectsModel
 a list model of all favorite projects More...
 

Detailed Description

The Workspace class represents a workspace with all its data (library, projects, settings, ...)

To access the settings of the workspace, use the method getSettings().

Author
ubruhin
Date
2014-06-23

Constructor & Destructor Documentation

Workspace ( )
delete
Workspace ( const Workspace other)
delete
Workspace ( const FilePath wsPath)
explicit

Constructor to open an existing workspace.

Parameters
wsPathThe filepath to the workspace directory
Exceptions
ExceptionIf the workspace could not be opened, this constructor throws an exception.

+ Here is the call graph for this function:

~Workspace ( )
noexcept

The destructor

Member Function Documentation

const FilePath& getPath ( ) const
inline

Get the filepath to the workspace directory.

+ Here is the caller graph for this function:

const FilePath& getProjectsPath ( ) const
inline

Get the filepath to the "projects" directory in the workspace.

const FilePath& getMetadataPath ( ) const
inline

Get the filepath to the version directory (v#) in the workspace.

const FilePath& getLibrariesPath ( ) const
inline

Get the filepath to the "v#/libraries" directory in the workspace.

+ Here is the caller graph for this function:

ProjectTreeModel & getProjectTreeModel ( ) const
noexcept
RecentProjectsModel & getRecentProjectsModel ( ) const
noexcept
FavoriteProjectsModel & getFavoriteProjectsModel ( ) const
noexcept
WorkspaceSettings& getSettings ( ) const
inline

Get the workspace settings.

+ Here is the caller graph for this function:

QSharedPointer< library::Library > getLibrary ( const Uuid uuid,
bool  local = true,
bool  remote = true 
) const
noexcept

Get the (highest version) library of a given UUID.

Parameters
uuidThe uuid of the library
localIf true, local libraries are searched
remoteIf true, remote libraries are searched
Returns
The library with the highest version (nullptr if not installed)

+ Here is the caller graph for this function:

const QMap<QString, QSharedPointer<library::Library> > getLocalLibraries ( ) const
inlinenoexcept

Get all local libraries (located in "workspace/v#/libraries/local")

Returns
A list of all local libraries

+ Here is the caller graph for this function:

const QMap<QString, QSharedPointer<library::Library> > getRemoteLibraries ( ) const
inlinenoexcept

Get all remote libraries (located in "workspace/v#/libraries/remote")

Returns
A list of all remote libraries

+ Here is the caller graph for this function:

void addLocalLibrary ( const QString &  libDirName)

Add a new local library.

Parameters
libDirNameThe name of the (existing) local library directory
Exceptions
Exceptionon error

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void addRemoteLibrary ( const QString &  libDirName)

Add a new remote library.

Parameters
libDirNameThe name of the (existing) remote library directory
Exceptions
Exceptionon error

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void removeLocalLibrary ( const QString &  libDirName,
bool  rmDir = true 
)

Remove a local library.

Parameters
libDirNameThe name of the (existing) local library directory
rmDirIt true, the library's directory will be removed
Exceptions
Exceptionon error

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void removeRemoteLibrary ( const QString &  libDirName,
bool  rmDir = true 
)

Remove a remote library.

Parameters
libDirNameThe name of the (existing) remote library directory
rmDirIt true, the library's directory will be removed
Exceptions
Exceptionon error

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WorkspaceLibraryDb& getLibraryDb ( ) const
inline

Get the workspace library database.

+ Here is the caller graph for this function:

void setLastRecentlyUsedProject ( const FilePath filepath)
noexcept

setLastRecentlyUsedProject

Parameters
filepath
bool isFavoriteProject ( const FilePath filepath) const
noexcept

Check whether a project is in the favorite project list or not.

Parameters
filepathThe filepath to a *.lpp project file
Returns
True if the specified project is in the favorites list, false otherwise
void addFavoriteProject ( const FilePath filepath)
noexcept

Add a project to the favorite projects list.

Parameters
filepathThe filepath to a *.lpp project file
void removeFavoriteProject ( const FilePath filepath)
noexcept

Remove a project from the favorite projects list.

Parameters
filepathThe filepath to a *.lpp project file
Workspace& operator= ( const Workspace rhs)
delete
bool isValidWorkspacePath ( const FilePath path)
staticnoexcept

Check whether a filepath points to a valid workspace directory or not.

Parameters
pathA path to a directory
Returns
True if the path is a valid workspace directory, false otherwise

+ Here is the caller graph for this function:

QList< Version > getFileFormatVersionsOfWorkspace ( const FilePath path)
staticnoexcept

getFileFormatVersionsOfWorkspace

Parameters
path
Returns

+ Here is the call graph for this function:

tl::optional< Version > getHighestFileFormatVersionOfWorkspace ( const FilePath path)
staticnoexcept

getHighestFileFormatVersionOfWorkspace

Parameters
path
Returns

+ Here is the caller graph for this function:

void createNewWorkspace ( const FilePath path)
static

Create a new workspace.

Parameters
pathA path to a directory where to create the new workspace
Exceptions
Exceptionon error.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

FilePath getMostRecentlyUsedWorkspacePath ( )
staticnoexcept

Get the most recently used workspace path.

Returns
The filepath to the last recently used workspace (may be invalid)

+ Here is the caller graph for this function:

void setMostRecentlyUsedWorkspacePath ( const FilePath path)
staticnoexcept

Set the most recently used workspace path.

Parameters
pathThe filepath to the workspace directory

+ Here is the caller graph for this function:

FilePath chooseWorkspacePath ( )
staticnoexcept

Let the user choose a workspace path (with a directory chooser dialog)

Returns
The choosen filepath (is invalid on error or user cancel)

+ Here is the call graph for this function:

static Version FILE_FORMAT_VERSION ( )
inlinestaticnoexcept

Current workspace file format version (constant)

Warning
Don't change this value unless you know exactly what you're doing!
Returns
File format version

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void libraryAdded ( const FilePath libDir)
signal

+ Here is the caller graph for this function:

void libraryRemoved ( const FilePath libDir)
signal

+ Here is the caller graph for this function:

Member Data Documentation

FilePath mPath
private

a FilePath object which represents the workspace directory

FilePath mProjectsPath
private

the directory "projects"

FilePath mMetadataPath
private

the subdirectory of the current file format version

FilePath mLibrariesPath
private

the directory "v#/libraries"

DirectoryLock mLock
private

to lock the version directory (#mVersionPath)

QScopedPointer<WorkspaceSettings> mWorkspaceSettings
private

the WorkspaceSettings object

QMap<QString, QSharedPointer<library::Library> > mLocalLibraries
private

all local libraries

QMap<QString, QSharedPointer<library::Library> > mRemoteLibraries
private

all remote libraries

QScopedPointer<WorkspaceLibraryDb> mLibraryDb
private

the library database

QScopedPointer<ProjectTreeModel> mProjectTreeModel
private

a tree model for the whole projects directory

QScopedPointer<RecentProjectsModel> mRecentProjectsModel
private

a list model of all recent projects

QScopedPointer<FavoriteProjectsModel> mFavoriteProjectsModel
private

a list model of all favorite projects


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