LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
categorytreelabeltextbuilder.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_CATEGORYTREELABELTEXTBUILDER_H
21 #define LIBREPCB_LIBRARY_EDITOR_CATEGORYTREELABELTEXTBUILDER_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include <librepcb/common/uuid.h>
29 
30 #include <QtCore>
31 #include <QtWidgets>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 namespace workspace {
39 class WorkspaceLibraryDb;
40 }
41 
42 namespace library {
43 namespace editor {
44 
45 /*******************************************************************************
46  * Class CategoryTreeLabelTextBuilder
47  ******************************************************************************/
48 
55 template <typename ElementType>
57  Q_DECLARE_TR_FUNCTIONS(CategoryTreeLabelTextBuilder)
58 
59 public:
60  // Constructors / Destructor
63  delete;
65  const QStringList& localeOrder,
66  QLabel& label) noexcept;
68 
69  // Setters
70  void setHighlightLastLine(bool highlight) noexcept {
71  mHighlightLastLine = highlight;
72  }
73  void setEndlessRecursionUuid(const Uuid& uuid) noexcept {
74  mEndlessRecursionUuid = uuid;
75  }
76  void setOneLine(bool oneLine) noexcept { mOneLine = oneLine; }
77  void setText(const QString& text) noexcept;
78  void setErrorText(const QString& error) noexcept;
79 
80  // General Methods
81  bool updateText(const tl::optional<Uuid>& category,
82  const QString& lastLine = QString()) noexcept;
83 
84  // Operator Overloadings
85  CategoryTreeLabelTextBuilder& operator =(
86  const CategoryTreeLabelTextBuilder& rhs) = delete;
87 
88 private: // Methods
89  bool updateText(const QList<Uuid>& uuids, const QString& lastLine) noexcept;
90  void setText(const QStringList& lines) noexcept;
91  FilePath getLatestCategory(const Uuid& category) const;
92  QList<Uuid> getCategoryParents(const Uuid& category) const;
93 
94 private: // Data
95  const workspace::WorkspaceLibraryDb& mDb;
96  const QStringList& mLocaleOrder;
97  QLabel& mLabel;
99  tl::optional<Uuid> mEndlessRecursionUuid;
100  bool mOneLine;
101 };
102 
107 
108 /*******************************************************************************
109  * End of File
110  ******************************************************************************/
111 
112 } // namespace editor
113 } // namespace library
114 } // namespace librepcb
115 
116 #endif // LIBREPCB_LIBRARY_EDITOR_CATEGORYTREELABELTEXTBUILDER_H
The CategoryTreeLabelTextBuilder class.
Definition: categorytreelabeltextbuilder.h:56
bool mOneLine
Definition: categorytreelabeltextbuilder.h:100
The ComponentCategory class.
Definition: componentcategory.h:43
void setErrorText(const QString &error) noexcept
Definition: categorytreelabeltextbuilder.cpp:72
bool updateText(const tl::optional< Uuid > &category, const QString &lastLine=QString()) noexcept
Definition: categorytreelabeltextbuilder.cpp:83
const QStringList & mLocaleOrder
Definition: categorytreelabeltextbuilder.h:96
QLabel & mLabel
Definition: categorytreelabeltextbuilder.h:97
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
QList< Uuid > getCategoryParents(const Uuid &category) const
void setText(const QString &text) noexcept
Definition: categorytreelabeltextbuilder.cpp:65
FilePath getLatestCategory(const Uuid &category) const
void setOneLine(bool oneLine) noexcept
Definition: categorytreelabeltextbuilder.h:76
~CategoryTreeLabelTextBuilder() noexcept
Definition: categorytreelabeltextbuilder.cpp:57
bool mHighlightLastLine
Definition: categorytreelabeltextbuilder.h:98
const workspace::WorkspaceLibraryDb & mDb
Definition: categorytreelabeltextbuilder.h:95
void setHighlightLastLine(bool highlight) noexcept
Definition: categorytreelabeltextbuilder.h:70
The WorkspaceLibraryDb class.
Definition: workspacelibrarydb.h:52
tl::optional< Uuid > mEndlessRecursionUuid
Definition: categorytreelabeltextbuilder.h:99
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
void setEndlessRecursionUuid(const Uuid &uuid) noexcept
Definition: categorytreelabeltextbuilder.h:73
The PackageCategory class.
Definition: packagecategory.h:43