LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_EDITOR_LIBRARYOVERVIEWWIDGET_H
21 #define LIBREPCB_LIBRARY_EDITOR_LIBRARYOVERVIEWWIDGET_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../common/editorwidgetbase.h"
27 
28 #include <QtCore>
29 #include <QtWidgets>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 namespace library {
36 
37 class Library;
38 
39 namespace editor {
40 
41 class LibraryListEditorWidget;
42 
43 namespace Ui {
44 class LibraryOverviewWidget;
45 }
46 
47 /*******************************************************************************
48  * Class LibraryOverviewWidget
49  ******************************************************************************/
50 
58  Q_OBJECT
59 
60 public:
61  // Constructors / Destructor
62  LibraryOverviewWidget() = delete;
63  LibraryOverviewWidget(const LibraryOverviewWidget& other) = delete;
64  LibraryOverviewWidget(const Context& context, QSharedPointer<Library> lib,
65  QWidget* parent = nullptr) noexcept;
66  ~LibraryOverviewWidget() noexcept;
67 
68  // Operator Overloadings
70 
71 public slots:
72  bool save() noexcept override;
73 
74 signals:
76  void editPackageCategoryTriggered(const FilePath& fp);
77  void editSymbolTriggered(const FilePath& fp);
78  void editPackageTriggered(const FilePath& fp);
79  void editComponentTriggered(const FilePath& fp);
80  void editDeviceTriggered(const FilePath& fp);
81  void removeElementTriggered(const FilePath& fp);
82 
83 private: // Methods
84  void updateMetadata() noexcept;
85  QString commitMetadata() noexcept;
86  bool isInterfaceBroken() const noexcept override { return false; }
87  bool runChecks(LibraryElementCheckMessageList& msgs) const override;
88  template <typename MessageType>
89  void fixMsg(const MessageType& msg);
90  template <typename MessageType>
91  bool fixMsgHelper(std::shared_ptr<const LibraryElementCheckMessage> msg,
92  bool applyFix);
94  std::shared_ptr<const LibraryElementCheckMessage> msg,
95  bool applyFix) override;
96  void updateElementLists() noexcept;
97  template <typename ElementType>
98  void updateElementList(QListWidget& listWidget, const QIcon& icon) noexcept;
99  void openContextMenuAtPos(const QPoint& pos) noexcept;
100  bool removeSelectedItem(const QString& itemName,
101  const FilePath& itemPath) noexcept;
102 
103  // Event Handlers
104  void btnIconClicked() noexcept;
105  void lstCmpCatDoubleClicked(const QModelIndex& index) noexcept;
106  void lstPkgCatDoubleClicked(const QModelIndex& index) noexcept;
107  void lstSymDoubleClicked(const QModelIndex& index) noexcept;
108  void lstPkgDoubleClicked(const QModelIndex& index) noexcept;
109  void lstCmpDoubleClicked(const QModelIndex& index) noexcept;
110  void lstDevDoubleClicked(const QModelIndex& index) noexcept;
111 
112 private: // Data
113  QSharedPointer<Library> mLibrary;
114  QScopedPointer<Ui::LibraryOverviewWidget> mUi;
116  QByteArray mIcon;
117 };
118 
119 /*******************************************************************************
120  * End of File
121  ******************************************************************************/
122 
123 } // namespace editor
124 } // namespace library
125 } // namespace librepcb
126 
127 #endif // LIBREPCB_LIBRARY_EDITOR_LIBRARYOVERVIEWWIDGET_H
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
The LibraryOverviewWidget class.
Definition: libraryoverviewwidget.h:57
The Library class represents a library directory.
Definition: library.h:49
void lstPkgCatDoubleClicked(const QModelIndex &index) noexcept
Definition: libraryoverviewwidget.cpp:407
void lstCmpCatDoubleClicked(const QModelIndex &index) noexcept
Definition: libraryoverviewwidget.cpp:397
void lstCmpDoubleClicked(const QModelIndex &index) noexcept
Definition: libraryoverviewwidget.cpp:437
QSharedPointer< Library > mLibrary
Definition: libraryoverviewwidget.h:113
LibraryOverviewWidget & operator=(const LibraryOverviewWidget &rhs)=delete
QScopedPointer< Ui::LibraryOverviewWidget > mUi
Definition: libraryoverviewwidget.h:114
void updateElementLists() noexcept
Definition: libraryoverviewwidget.cpp:251
void lstDevDoubleClicked(const QModelIndex &index) noexcept
Definition: libraryoverviewwidget.cpp:447
The LibraryListEditorWidget class.
Definition: librarylisteditorwidget.h:57
QString commitMetadata() noexcept
Definition: libraryoverviewwidget.cpp:180
QByteArray mIcon
Definition: libraryoverviewwidget.h:116
void lstPkgDoubleClicked(const QModelIndex &index) noexcept
Definition: libraryoverviewwidget.cpp:427
void updateElementList(QListWidget &listWidget, const QIcon &icon) noexcept
Definition: libraryoverviewwidget.cpp:264
void editComponentCategoryTriggered(const FilePath &fp)
bool runChecks(LibraryElementCheckMessageList &msgs) const override
Definition: libraryoverviewwidget.cpp:212
void editPackageCategoryTriggered(const FilePath &fp)
void updateMetadata() noexcept
Definition: libraryoverviewwidget.cpp:159
bool fixMsgHelper(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix)
Definition: libraryoverviewwidget.cpp:233
bool removeSelectedItem(const QString &itemName, const FilePath &itemPath) noexcept
Definition: libraryoverviewwidget.cpp:348
void btnIconClicked() noexcept
Definition: libraryoverviewwidget.cpp:383
bool save() noexceptoverride
Definition: libraryoverviewwidget.cpp:137
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
bool isInterfaceBroken() const noexceptoverride
Definition: libraryoverviewwidget.h:86
QScopedPointer< LibraryListEditorWidget > mDependenciesEditorWidget
Definition: libraryoverviewwidget.h:115
~LibraryOverviewWidget() noexcept
Definition: libraryoverviewwidget.cpp:130
void openContextMenuAtPos(const QPoint &pos) noexcept
Definition: libraryoverviewwidget.cpp:313
bool processCheckMessage(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix) override
Definition: libraryoverviewwidget.cpp:244
void lstSymDoubleClicked(const QModelIndex &index) noexcept
Definition: libraryoverviewwidget.cpp:417
The EditorWidgetBase class.
Definition: editorwidgetbase.h:66