LibrePCB Developers Documentation
Loading...
Searching...
No Matches
editortoolbox.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_EDITORTOOLBOX_H
21#define LIBREPCB_EDITOR_EDITORTOOLBOX_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
28
29#include <QtCore>
30#include <QtWidgets>
31
32#include <optional>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class ComponentInstance;
40class Workspace;
41class WorkspaceLibraryDb;
42
43namespace editor {
44
45class MenuBuilder;
46
47/*******************************************************************************
48 * Class EditorToolbox
49 ******************************************************************************/
50
55class EditorToolbox final {
56 Q_DECLARE_TR_FUNCTIONS(EditorToolbox)
57
58public:
59 // Constructors / Destructor
60 EditorToolbox() = delete;
61 EditorToolbox(const EditorToolbox& other) = delete;
62 ~EditorToolbox() = delete;
63
64 // Operator Overloadings
65 EditorToolbox& operator=(const EditorToolbox& rhs) = delete;
66
67 // Static Methods
68
75 static QString toSingleLine(const QString& s) noexcept;
76
83 static QString toMultiLine(const QString& s) noexcept;
84
92 static QString cleanKeywords(const QString& userInput) noexcept;
93
101 static QIcon svgIcon(const QString& file) noexcept;
102
108 static void removeFormLayoutRow(QLabel& label) noexcept;
109
115 static void deleteLayoutItemRecursively(QLayoutItem* item) noexcept;
116
135 static bool startToolBarTabFocusCycle(QToolBar& toolBar,
136 QWidget& returnFocusToWidget) noexcept;
137
151 const WorkspaceLibraryDb& db, const ComponentInstance& cmp,
152 const std::optional<Uuid>& filterDev = std::nullopt) noexcept;
153
168 static void addResourcesToMenu(const Workspace& ws, MenuBuilder& mb,
169 const ComponentInstance& cmp,
170 const std::optional<Uuid>& filterDev,
171 QPointer<QWidget> editor,
172 QMenu& root) noexcept;
173
174private:
184 static bool removeFormLayoutRow(QLayout& layout, QLabel& label) noexcept;
185
191 static void hideLayoutItem(QLayoutItem& item) noexcept;
192
201 static void searchAndOpenDatasheet(const Workspace& ws, const QString& mpn,
202 const QString& manufacturer,
203 QPointer<QWidget> parent) noexcept;
204};
205
206/*******************************************************************************
207 * End of File
208 ******************************************************************************/
209
210} // namespace editor
211} // namespace librepcb
212
213#endif
The ComponentInstance class.
Definition componentinstance.h:54
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The WorkspaceLibraryDb class.
Definition workspacelibrarydb.h:58
The EditorToolbox class provides some useful general purpose methods for editors (i....
Definition editortoolbox.h:55
static QString toSingleLine(const QString &s) noexcept
Escape newlines to convert a multi-line to a single-line string.
Definition editortoolbox.cpp:116
static bool startToolBarTabFocusCycle(QToolBar &toolBar, QWidget &returnFocusToWidget) noexcept
Set the focus to the first widget of a toolbar and iterate through.
Definition editortoolbox.cpp:163
static QIcon svgIcon(const QString &file) noexcept
Load a SVG QIcon which is properly colorized.
Definition editortoolbox.cpp:135
static void removeFormLayoutRow(QLabel &label) noexcept
Remove (hide) a whole row in a QFormLayout.
Definition editortoolbox.cpp:139
static void hideLayoutItem(QLayoutItem &item) noexcept
Helper for removeFormLayoutRow()
Definition editortoolbox.cpp:365
EditorToolbox & operator=(const EditorToolbox &rhs)=delete
static QString toMultiLine(const QString &s) noexcept
Replace newlines to convert a single-line to a multi-line string.
Definition editortoolbox.cpp:120
static void searchAndOpenDatasheet(const Workspace &ws, const QString &mpn, const QString &manufacturer, QPointer< QWidget > parent) noexcept
Helper for addResourcesToMenu()
Definition editortoolbox.cpp:377
static void deleteLayoutItemRecursively(QLayoutItem *item) noexcept
Delete a QLayout item with all its children.
Definition editortoolbox.cpp:149
EditorToolbox(const EditorToolbox &other)=delete
static void addResourcesToMenu(const Workspace &ws, MenuBuilder &mb, const ComponentInstance &cmp, const std::optional< Uuid > &filterDev, QPointer< QWidget > editor, QMenu &root) noexcept
Add relevant resources of a component instance to a context menu.
Definition editortoolbox.cpp:249
static QString cleanKeywords(const QString &userInput) noexcept
Clean/normalize comma-separated keywords from user input.
Definition editortoolbox.cpp:124
static ResourceList getComponentResources(const WorkspaceLibraryDb &db, const ComponentInstance &cmp, const std::optional< Uuid > &filterDev=std::nullopt) noexcept
Collect all relevant resources for a given component instance.
Definition editortoolbox.cpp:185
Helper to easily create a QMenu.
Definition menubuilder.h:42
Definition occmodel.cpp:77