LibrePCB Developers Documentation
|
The WorkspaceLibraryDb class. More...
#include <workspacelibrarydb.h>
Inherits QObject.
Classes | |
struct | Part |
Signals | |
void | scanStarted () |
void | scanLibraryListUpdated (int libraryCount) |
void | scanProgressUpdate (int percent) |
void | scanSucceeded (int elementCount) |
void | scanFailed (QString errorMsg) |
void | scanFinished () |
Public Member Functions | |
WorkspaceLibraryDb ()=delete | |
WorkspaceLibraryDb (const WorkspaceLibraryDb &other)=delete | |
WorkspaceLibraryDb (const FilePath &librariesPath) | |
Constructor to open the library database of an existing workspace. | |
~WorkspaceLibraryDb () noexcept | |
const FilePath & | getFilePath () const noexcept |
Get the file path of the SQLite database. | |
bool | isScanInProgress () const noexcept |
Check if there is currently a library scan in progress. | |
int | getScanProgressPercent () const noexcept |
Get the current progress of the library rescan. | |
template<typename ElementType > | |
QMultiMap< Version, FilePath > | getAll (const std::optional< Uuid > &uuid=std::nullopt, const FilePath &lib=FilePath()) const |
Get elements, optionally matching some criteria. | |
template<typename ElementType > | |
FilePath | getLatest (const Uuid &uuid) const |
Get an element of a specific UUID and the highest version. | |
template<typename ElementType > | |
QList< Uuid > | find (const QString &keyword) const |
Find elements by keyword. | |
QList< Uuid > | findDevicesOfParts (const QString &keyword) const |
Find parts by keyword. | |
QList< Part > | findPartsOfDevice (const Uuid &device, const QString &keyword) const |
Find parts of device by keyword. | |
template<typename ElementType > | |
bool | getTranslations (const FilePath &elemDir, const QStringList &localeOrder, QString *name=nullptr, QString *description=nullptr, QString *keywords=nullptr) const |
Get translations of a specific element. | |
template<typename ElementType > | |
bool | getMetadata (const FilePath elemDir, Uuid *uuid=nullptr, Version *version=nullptr, bool *deprecated=nullptr) const |
Get metadata of a specific element. | |
bool | getLibraryMetadata (const FilePath libDir, QPixmap *icon=nullptr, QString *manufacturer=nullptr) const |
Get additional metadata of a specific library. | |
template<typename ElementType > | |
bool | getCategoryMetadata (const FilePath catDir, std::optional< Uuid > *parent=nullptr) const |
Get additional metadata of a specific category. | |
bool | getDeviceMetadata (const FilePath &devDir, Uuid *cmpUuid=nullptr, Uuid *pkgUuid=nullptr) const |
Get additional metadata of a specific device. | |
template<typename ElementType > | |
QSet< Uuid > | getChilds (const std::optional< Uuid > &parent) const |
Get children categories of a specific category. | |
template<typename ElementType > | |
QSet< Uuid > | getByCategory (const std::optional< Uuid > &category, int limit=-1) const |
Get elements of a specific category. | |
template<typename ElementType > | |
QSet< Uuid > | getGenerated (const QString &generatedBy) const |
Get elements generated by a given "generated_by" identifier. | |
template<typename ElementType > | |
ResourceList | getResources (const FilePath elemDir) const |
Get resources of a specific library element. | |
QSet< Uuid > | getComponentDevices (const Uuid &component) const |
Get all devices of a specific component. | |
QList< Part > | getDeviceParts (const Uuid &device) const |
Get all parts of a specific device. | |
void | startLibraryRescan () noexcept |
Rescan the whole library directory and update the SQLite database. | |
WorkspaceLibraryDb & | operator= (const WorkspaceLibraryDb &rhs)=delete |
template<> | |
QList< Uuid > | find (const QString &keyword) const |
Private Member Functions | |
QMultiMap< Version, FilePath > | getAll (const QString &elementsTable, const std::optional< Uuid > &uuid, const FilePath &lib) const |
FilePath | getLatestVersionFilePath (const QMultiMap< Version, FilePath > &list) const noexcept |
QList< Uuid > | find (const QString &elementsTable, const QString &keyword) const |
bool | getTranslations (const QString &elementsTable, const FilePath &elemDir, const QStringList &localeOrder, QString *name, QString *description, QString *keywords) const |
bool | getMetadata (const QString &elementsTable, const FilePath elemDir, Uuid *uuid, Version *version, bool *deprecated) const |
bool | getCategoryMetadata (const QString &categoriesTable, const FilePath catDir, std::optional< Uuid > *parent) const |
AttributeList | getPartAttributes (int partId) const |
QSet< Uuid > | getChilds (const QString &categoriesTable, const std::optional< Uuid > &categoryUuid) const |
QSet< Uuid > | getByCategory (const QString &elementsTable, const QString &categoryTable, const std::optional< Uuid > &category, int limit) const |
QSet< Uuid > | getGenerated (const QString &elementsTable, const QString &generatedBy) const |
ResourceList | getResources (const QString &elementsTable, const FilePath &elemDir) const |
int | getDbVersion () const noexcept |
Static Private Member Functions | |
static QSet< Uuid > | getUuidSet (QSqlQuery &query) |
template<typename ElementType > | |
static QString | getTable () noexcept |
template<typename ElementType > | |
static QString | getCategoryTable () noexcept |
Private Attributes | |
const FilePath | mLibrariesPath |
Path to workspace libraries directory. | |
const FilePath | mFilePath |
Path to the SQLite database file. | |
QScopedPointer< SQLiteDatabase > | mDb |
The SQLite database. | |
QScopedPointer< WorkspaceLibraryScanner > | mLibraryScanner |
Static Private Attributes | |
static const int | sCurrentDbVersion = 7 |
The WorkspaceLibraryDb class.
|
delete |
|
delete |
|
explicit |
|
noexcept |
|
inlinenoexcept |
Get the file path of the SQLite database.
|
inlinenoexcept |
Check if there is currently a library scan in progress.
|
noexcept |
Get the current progress of the library rescan.
|
inline |
Get elements, optionally matching some criteria.
ElementType | Type of the library element. |
uuid | If not nullopt, only elements with this UUID are returned. |
lib | If valid, only elements from this library are returned. Attention: Must not be used when ElementType is Library! |
Get an element of a specific UUID and the highest version.
uuid | The UUID of the element to get. |
template QList< Uuid > find< Device > | ( | const QString & | keyword | ) | const |
Find elements by keyword.
keyword | Keyword to search for. Note that the translations for all languages will be taken into account. |
QList< Uuid > findDevicesOfParts | ( | const QString & | keyword | ) | const |
Find parts by keyword.
keyword | Keyword to search for. |
QList< WorkspaceLibraryDb::Part > findPartsOfDevice | ( | const Uuid & | device, |
const QString & | keyword | ||
) | const |
Find parts of device by keyword.
device | Device to search for parts. |
keyword | Keyword to search for. |
|
inline |
Get translations of a specific element.
ElementType | Type of the library element. |
elemDir | Library element directory. If it does not exist, all translations will be set to an empty string. |
localeOrder | Locale order (highest priority first). |
name | If not nullptr, name will be written here. Set to an empty string if the requested data does not exist. |
description | If not nullptr, desc. will be written here. Set to an empty string if the requested data does not exist. |
keywords | If not nullptr, keywords will be written here. Set to an empty string if the requested data does not exist. |
true | If the element and corresponding translations were found in the database. |
false | If the element was not found or contains no translations ar all. |
|
inline |
Get metadata of a specific element.
ElementType | Type of the library element. |
elemDir | Library element directory. |
uuid | If not nullptr and the element was found, its UUID will be written here. |
version | If not nullptr and the element was found, its version will be written here. |
deprecated | If not nullptr and the element was found, its deprecation flag will be written here. |
true | If the element was found in the database. |
false | If the element was not found. |
bool getLibraryMetadata | ( | const FilePath | libDir, |
QPixmap * | icon = nullptr , |
||
QString * | manufacturer = nullptr |
||
) | const |
Get additional metadata of a specific library.
libDir | Library directory. |
icon | If not nullptr and the library was found, its icon will be written here. |
manufacturer | If not nullptr and the library was found, its manufacturer name will be written here (may be empty). |
true | If the library was found in the database. |
false | If the library was not found. |
|
inline |
Get additional metadata of a specific category.
ElementType | Type of the library element. |
catDir | Category directory. |
parent | If not nullptr and the category was found, its parent will be written here. |
true | If the category was found in the database. |
false | If the category was not found. |
bool getDeviceMetadata | ( | const FilePath & | devDir, |
Uuid * | cmpUuid = nullptr , |
||
Uuid * | pkgUuid = nullptr |
||
) | const |
Get additional metadata of a specific device.
devDir | Device directory. |
pkgUuid | If not nullptr and the device was found, its package UUID will be written here. |
cmpUuid | If not nullptr and the device was found, its component UUID will be written here. |
true | If the device was found in the database. |
false | If the device was not found. |
|
inline |
Get children categories of a specific category.
ElementType | Type of the category. |
parent | Category to get the children of. If nullopt, all root categories, and categories with inexistent parent will be returned (this ensures that all elements are discoverable by getByCategory()). |
|
inline |
Get elements of a specific category.
ElementType | Type of the library element. |
category | Category to get the elements of. If nullopt, all elements with no category at all, or with only inexistent categories are returned. |
limit | If not -1, the number of results is limited to this value. This can be used for performance reasons, for example if you only want to know if there are any elements in the given category, the limit can be set to 1, which is much faster than retrieving all results. |
|
inline |
Get elements generated by a given "generated_by" identifier.
ElementType | Type of the library element. |
generatedBy | The "generated_by" identifier. Must be non-empty, otherwise no results are returned. |
|
inline |
Get resources of a specific library element.
ElementType | Type of the library element. |
elemDir | Library element directory. |
Get all devices of a specific component.
component | Component UUID to get the devices of. |
QList< WorkspaceLibraryDb::Part > getDeviceParts | ( | const Uuid & | device | ) | const |
Get all parts of a specific device.
device | Device UUID to get the parts of. |
|
noexcept |
Rescan the whole library directory and update the SQLite database.
|
delete |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
private |
|
privatenoexcept |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
privatenoexcept |
|
staticprivatenoexcept |
|
staticprivatenoexcept |
QList< Uuid > find | ( | const QString & | keyword | ) | const |
|
private |
The SQLite database.
|
private |
|
staticprivate |