LibrePCB Developers Documentation
libraryoverviewwidget.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_LIBRARYOVERVIEWWIDGET_H
21#define LIBREPCB_EDITOR_LIBRARYOVERVIEWWIDGET_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../editorwidgetbase.h"
27
28#include <QtCore>
29#include <QtWidgets>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Library;
39
40namespace editor {
41
42class LibraryListEditorWidget;
43
44namespace Ui {
45class LibraryOverviewWidget;
46}
47
48/*******************************************************************************
49 * Class LibraryOverviewWidget
50 ******************************************************************************/
51
56 Q_OBJECT
57
59 QString name;
60 QPixmap pixmap;
62 };
63
64public:
65 // Constructors / Destructor
68 LibraryOverviewWidget(const Context& context, const FilePath& fp,
69 QWidget* parent = nullptr);
70 ~LibraryOverviewWidget() noexcept;
71
72 // Getters
73 Library& getLibrary() const noexcept { return *mLibrary; }
74 QSet<Feature> getAvailableFeatures() const noexcept override;
75
76 // Setters
77 void setFilter(const QString& filter) noexcept;
78
79 // Operator Overloadings
80 LibraryOverviewWidget& operator=(const LibraryOverviewWidget& rhs) = delete;
81
82public slots:
83 bool save() noexcept override;
84 bool remove() noexcept override;
85
86signals:
106
107private: // Methods
108 void setupListWidget(QListWidget* listWidget) noexcept;
109 void updateMetadata() noexcept;
110 QString commitMetadata() noexcept;
111 bool isInterfaceBroken() const noexcept override { return false; }
112 bool runChecks(RuleCheckMessageList& msgs) const override;
113 template <typename MessageType>
114 void fixMsg(const MessageType& msg);
115 template <typename MessageType>
116 bool fixMsgHelper(std::shared_ptr<const RuleCheckMessage> msg, bool applyFix);
117 bool processRuleCheckMessage(std::shared_ptr<const RuleCheckMessage> msg,
118 bool applyFix) override;
119 void ruleCheckApproveRequested(std::shared_ptr<const RuleCheckMessage> msg,
120 bool approve) noexcept override;
121 void updateElementLists() noexcept;
122 template <typename ElementType>
123 void updateElementList(QListWidget& listWidget, const QIcon& icon) noexcept;
124 QHash<QListWidgetItem*, FilePath> getElementListItemFilePaths(
125 const QList<QListWidgetItem*>& items) const noexcept;
126 void updateElementListFilter(QListWidget& listWidget) noexcept;
127 void openContextMenuAtPos(const QPoint& pos) noexcept;
128 void newItem(QListWidget* list) noexcept;
129 void editItem(QListWidget* list, const FilePath& fp) noexcept;
130 void duplicateItem(QListWidget* list, const FilePath& fp) noexcept;
131 void removeItems(
132 const QHash<QListWidgetItem*, FilePath>& selectedItemPaths) noexcept;
134 const QHash<QListWidgetItem*, FilePath>& selectedItemPaths,
135 const FilePath& libFp, const QString& libName) noexcept;
136 QList<LibraryMenuItem> getLocalLibraries() const noexcept;
137
138 // Event Handlers
139 void btnIconClicked() noexcept;
140 void lstDoubleClicked(const QModelIndex& index) noexcept;
141
142private: // Data
143 QScopedPointer<Ui::LibraryOverviewWidget> mUi;
145 std::unique_ptr<Library> mLibrary;
146 QByteArray mIcon;
148};
149
150/*******************************************************************************
151 * End of File
152 ******************************************************************************/
153
154} // namespace editor
155} // namespace librepcb
156
157#endif
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
The Library class represents a library directory.
Definition: library.h:46
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
The LibraryListEditorWidget class.
Definition: librarylisteditorwidget.h:55
The LibraryOverviewWidget class.
Definition: libraryoverviewwidget.h:55
void editPackageTriggered(const FilePath &fp)
QString mCurrentFilter
Definition: libraryoverviewwidget.h:147
void removeItems(const QHash< QListWidgetItem *, FilePath > &selectedItemPaths) noexcept
Definition: libraryoverviewwidget.cpp:619
bool save() noexcept override
Definition: libraryoverviewwidget.cpp:198
void lstDoubleClicked(const QModelIndex &index) noexcept
Definition: libraryoverviewwidget.cpp:798
void editDeviceTriggered(const FilePath &fp)
void duplicateComponentCategoryTriggered(const FilePath &fp)
void copyElementsToOtherLibrary(const QHash< QListWidgetItem *, FilePath > &selectedItemPaths, const FilePath &libFp, const QString &libName) noexcept
Definition: libraryoverviewwidget.cpp:659
void updateMetadata() noexcept
Definition: libraryoverviewwidget.cpp:288
QScopedPointer< Ui::LibraryOverviewWidget > mUi
Definition: libraryoverviewwidget.h:143
void duplicatePackageTriggered(const FilePath &fp)
void editComponentTriggered(const FilePath &fp)
void updateElementListFilter(QListWidget &listWidget) noexcept
Definition: libraryoverviewwidget.cpp:478
QList< LibraryMenuItem > getLocalLibraries() const noexcept
Definition: libraryoverviewwidget.cpp:748
void ruleCheckApproveRequested(std::shared_ptr< const RuleCheckMessage > msg, bool approve) noexcept override
Definition: libraryoverviewwidget.cpp:382
void setupListWidget(QListWidget *listWidget) noexcept
Definition: libraryoverviewwidget.cpp:238
void btnIconClicked() noexcept
Definition: libraryoverviewwidget.cpp:781
void editPackageCategoryTriggered(const FilePath &fp)
Library & getLibrary() const noexcept
Definition: libraryoverviewwidget.h:73
void editComponentCategoryTriggered(const FilePath &fp)
~LibraryOverviewWidget() noexcept
Definition: libraryoverviewwidget.cpp:166
QByteArray mIcon
Definition: libraryoverviewwidget.h:146
void updateElementLists() noexcept
Definition: libraryoverviewwidget.cpp:388
QScopedPointer< LibraryListEditorWidget > mDependenciesEditorWidget
Definition: libraryoverviewwidget.h:144
std::unique_ptr< Library > mLibrary
Definition: libraryoverviewwidget.h:145
void duplicatePackageCategoryTriggered(const FilePath &fp)
void duplicateItem(QListWidget *list, const FilePath &fp) noexcept
Definition: libraryoverviewwidget.cpp:580
void fixMsg(const MessageType &msg)
QHash< QListWidgetItem *, FilePath > getElementListItemFilePaths(const QList< QListWidgetItem * > &items) const noexcept
Definition: libraryoverviewwidget.cpp:464
QString commitMetadata() noexcept
Definition: libraryoverviewwidget.cpp:311
bool fixMsgHelper(std::shared_ptr< const RuleCheckMessage > msg, bool applyFix)
Definition: libraryoverviewwidget.cpp:364
void duplicateDeviceTriggered(const FilePath &fp)
void duplicateComponentTriggered(const FilePath &fp)
LibraryOverviewWidget(const LibraryOverviewWidget &other)=delete
bool isInterfaceBroken() const noexcept override
Definition: libraryoverviewwidget.h:111
void removeElementTriggered(const FilePath &fp)
void newItem(QListWidget *list) noexcept
Definition: libraryoverviewwidget.cpp:562
void openContextMenuAtPos(const QPoint &pos) noexcept
Definition: libraryoverviewwidget.cpp:488
void editSymbolTriggered(const FilePath &fp)
QSet< Feature > getAvailableFeatures() const noexcept override
Definition: libraryoverviewwidget.cpp:173
void duplicateSymbolTriggered(const FilePath &fp)
bool runChecks(RuleCheckMessageList &msgs) const override
Definition: libraryoverviewwidget.cpp:344
void updateElementList(QListWidget &listWidget, const QIcon &icon) noexcept
Definition: libraryoverviewwidget.cpp:401
void editItem(QListWidget *list, const FilePath &fp) noexcept
Definition: libraryoverviewwidget.cpp:600
bool remove() noexcept override
Definition: libraryoverviewwidget.cpp:221
void setFilter(const QString &filter) noexcept
Definition: libraryoverviewwidget.cpp:184
bool processRuleCheckMessage(std::shared_ptr< const RuleCheckMessage > msg, bool applyFix) override
Definition: libraryoverviewwidget.cpp:375
Definition: occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104
Definition: editorwidgetbase.h:68
Definition: libraryoverviewwidget.h:58
FilePath filepath
Definition: libraryoverviewwidget.h:61
QPixmap pixmap
Definition: libraryoverviewwidget.h:60
QString name
Definition: libraryoverviewwidget.h:59