LibrePCB Developers Documentation
addlibrarywidget.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_WORKSPACE_ADDLIBRARYWIDGET_H
21 #define LIBREPCB_WORKSPACE_ADDLIBRARYWIDGET_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
28 
29 #include <QtCore>
30 #include <QtWidgets>
31 
32 #include <memory>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class Repository;
40 
41 namespace workspace {
42 class Workspace;
43 }
44 
45 namespace library {
46 namespace manager {
47 
48 class LibraryDownload;
49 
50 namespace Ui {
51 class AddLibraryWidget;
52 }
53 
54 /*******************************************************************************
55  * Class AddLibraryWidget
56  ******************************************************************************/
57 
61 class AddLibraryWidget final : public QWidget {
62  Q_OBJECT
63 
64 public:
65  // Constructors / Destructor
66  AddLibraryWidget() noexcept;
67  AddLibraryWidget(const AddLibraryWidget& other) = delete;
68  explicit AddLibraryWidget(workspace::Workspace& ws) noexcept;
69  ~AddLibraryWidget() noexcept;
70 
71  // General Methods
72  void updateRepositoryLibraryList() noexcept;
73 
74  // Operator Overloadings
75  AddLibraryWidget& operator=(const AddLibraryWidget& rhs) = delete;
76 
77 signals:
78  void libraryAdded(const FilePath& libDir);
79 
80 private: // Methods
81  void localLibraryNameLineEditTextChanged(QString name) noexcept;
82  void downloadZipUrlLineEditTextChanged(QString urlStr) noexcept;
83  void createLocalLibraryButtonClicked() noexcept;
84  void downloadZippedLibraryButtonClicked() noexcept;
85  void downloadZipFinished(bool success, const QString& errMsg) noexcept;
86  void repositoryLibraryListReceived(const QJsonArray& libs) noexcept;
87  void errorWhileFetchingLibraryList(const QString& errorMsg) noexcept;
88  void clearRepositoryLibraryList() noexcept;
89  void repoLibraryDownloadCheckedChanged(bool checked) noexcept;
90  void downloadLibrariesFromRepositoryButtonClicked() noexcept;
91 
92  static QString getTextOrPlaceholderFromQLineEdit(QLineEdit* edit,
93  bool isFilename) noexcept;
94 
95 private: // Data
97  QScopedPointer<Ui::AddLibraryWidget> mUi;
98  QScopedPointer<LibraryDownload> mManualLibraryDownload;
99  QList<std::shared_ptr<Repository>> mRepositories;
100 };
101 
102 /*******************************************************************************
103  * End of File
104  ******************************************************************************/
105 
106 } // namespace manager
107 } // namespace library
108 } // namespace librepcb
109 
110 #endif // LIBREPCB_WORKSPACE_ADDLIBRARYWIDGET_H
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:62
workspace::Workspace & mWorkspace
Definition: addlibrarywidget.h:96
Definition: mainwindow.h:10
Definition: airwiresbuilder.cpp:32
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
The AddLibraryWidget class.
Definition: addlibrarywidget.h:61
QScopedPointer< Ui::AddLibraryWidget > mUi
Definition: addlibrarywidget.h:97
QList< std::shared_ptr< Repository > > mRepositories
Definition: addlibrarywidget.h:99
QScopedPointer< LibraryDownload > mManualLibraryDownload
Definition: addlibrarywidget.h:98