LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
libraryelementcheckmessage.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_LIBRARYELEMENTCHECKMESSAGE_H
21 #define LIBREPCB_LIBRARY_LIBRARYELEMENTCHECKMESSAGE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include <QtCore>
27 #include <QtWidgets>
28 
29 #include <memory>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 namespace library {
36 
37 /*******************************************************************************
38  * Class LibraryElementCheckMessage
39  ******************************************************************************/
40 
45  Q_DECLARE_TR_FUNCTIONS(LibraryElementCheckMessage)
46 
47 public:
49  enum class Severity {
50  Hint = 0,
51  Warning = 1,
52  Error = 2,
53  };
54 
55  // Constructors / Destructor
56  LibraryElementCheckMessage() = delete;
57 
58  // Getters
59  Severity getSeverity() const noexcept { return mSeverity; }
60  const QPixmap& getSeverityPixmap() const noexcept { return mSeverityPixmap; }
61  const QString& getMessage() const noexcept { return mMessage; }
62  const QString& getDescription() const noexcept { return mDescription; }
63 
64  // General Methods
65  template <typename T>
66  T* as() noexcept {
67  return dynamic_cast<T*>(this);
68  }
69  template <typename T>
70  const T* as() const noexcept {
71  return dynamic_cast<const T*>(this);
72  }
73 
74  // Static Methods
75  static QPixmap getSeverityPixmap(Severity severity) noexcept;
76 
77  // Operator Overloads
78  bool operator==(const LibraryElementCheckMessage& rhs) const noexcept;
79  bool operator!=(const LibraryElementCheckMessage& rhs) const noexcept;
80  bool operator<(const LibraryElementCheckMessage& rhs) const noexcept;
81 
82 protected: // Methods
84  LibraryElementCheckMessage(Severity severity, const QString& msg,
85  const QString& description) noexcept;
86  virtual ~LibraryElementCheckMessage() noexcept;
87 
88 protected: // Data
90  QPixmap mSeverityPixmap;
91  QString mMessage;
92  QString mDescription;
93 };
94 
95 typedef QVector<std::shared_ptr<const LibraryElementCheckMessage>>
97 
98 /*******************************************************************************
99  * End of File
100  ******************************************************************************/
101 
102 } // namespace library
103 } // namespace librepcb
104 
105 #endif // LIBREPCB_LIBRARY_LIBRARYELEMENTCHECKMESSAGE_H
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
The LibraryElementCheckMessage class.
Definition: libraryelementcheckmessage.h:44
QPixmap mSeverityPixmap
Definition: libraryelementcheckmessage.h:90
T * as() noexcept
Definition: libraryelementcheckmessage.h:66
bool operator==(const LibraryElementCheckMessage &rhs) const noexcept
Definition: libraryelementcheckmessage.cpp:72
const QString & getMessage() const noexcept
Definition: libraryelementcheckmessage.h:61
Severity
Message severity type (higher numer = higher severity)
Definition: libraryelementcheckmessage.h:49
Severity mSeverity
Definition: libraryelementcheckmessage.h:89
QString mMessage
Definition: libraryelementcheckmessage.h:91
QString mDescription
Definition: libraryelementcheckmessage.h:92
Severity getSeverity() const noexcept
Definition: libraryelementcheckmessage.h:59
bool operator!=(const LibraryElementCheckMessage &rhs) const noexcept
Definition: libraryelementcheckmessage.cpp:80
bool operator<(const LibraryElementCheckMessage &rhs) const noexcept
Definition: libraryelementcheckmessage.cpp:85
const QPixmap & getSeverityPixmap() const noexcept
Definition: libraryelementcheckmessage.h:60
const QString & getDescription() const noexcept
Definition: libraryelementcheckmessage.h:62
virtual ~LibraryElementCheckMessage() noexcept
Definition: libraryelementcheckmessage.cpp:51
const T * as() const noexcept
Definition: libraryelementcheckmessage.h:70