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 
52 template <typename ElementType>
54  Q_DECLARE_TR_FUNCTIONS(CategoryTreeLabelTextBuilder)
55 
56 public:
57  // Constructors / Destructor
60  delete;
62  const QStringList& localeOrder,
63  QLabel& label) noexcept;
65 
66  // Setters
67  void setHighlightLastLine(bool highlight) noexcept {
68  mHighlightLastLine = highlight;
69  }
70  void setEndlessRecursionUuid(const Uuid& uuid) noexcept {
71  mEndlessRecursionUuid = uuid;
72  }
73  void setOneLine(bool oneLine) noexcept { mOneLine = oneLine; }
74  void setText(const QString& text) noexcept;
75  void setErrorText(const QString& error) noexcept;
76 
77  // General Methods
78  bool updateText(const tl::optional<Uuid>& category,
79  const QString& lastLine = QString()) noexcept;
80 
81  // Operator Overloadings
82  CategoryTreeLabelTextBuilder& operator =(
83  const CategoryTreeLabelTextBuilder& rhs) = delete;
84 
85 private: // Methods
86  bool updateText(const QList<Uuid>& uuids, const QString& lastLine) noexcept;
87  void setText(const QStringList& lines) noexcept;
88  FilePath getLatestCategory(const Uuid& category) const;
89  QList<Uuid> getCategoryParents(const Uuid& category) const;
90 
91 private: // Data
92  const workspace::WorkspaceLibraryDb& mDb;
93  const QStringList& mLocaleOrder;
94  QLabel& mLabel;
96  tl::optional<Uuid> mEndlessRecursionUuid;
97  bool mOneLine;
98 };
99 
104 
105 /*******************************************************************************
106  * End of File
107  ******************************************************************************/
108 
109 } // namespace editor
110 } // namespace library
111 } // namespace librepcb
112 
113 #endif // LIBREPCB_LIBRARY_EDITOR_CATEGORYTREELABELTEXTBUILDER_H
The CategoryTreeLabelTextBuilder class.
Definition: categorytreelabeltextbuilder.h:53
bool mOneLine
Definition: categorytreelabeltextbuilder.h:97
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:93
QLabel & mLabel
Definition: categorytreelabeltextbuilder.h:94
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
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:73
~CategoryTreeLabelTextBuilder() noexcept
Definition: categorytreelabeltextbuilder.cpp:57
bool mHighlightLastLine
Definition: categorytreelabeltextbuilder.h:95
const workspace::WorkspaceLibraryDb & mDb
Definition: categorytreelabeltextbuilder.h:92
void setHighlightLastLine(bool highlight) noexcept
Definition: categorytreelabeltextbuilder.h:67
The WorkspaceLibraryDb class.
Definition: workspacelibrarydb.h:52
tl::optional< Uuid > mEndlessRecursionUuid
Definition: categorytreelabeltextbuilder.h:96
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:70
The PackageCategory class.
Definition: packagecategory.h:43