LibrePCB Developers Documentation
Loading...
Searching...
No Matches
rulecheckmessagesmodel.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_RULECHECKMESSAGESMODEL_H
21#define LIBREPCB_EDITOR_RULECHECKMESSAGESMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36namespace editor {
37
38/*******************************************************************************
39 * Class RuleCheckMessagesModel
40 ******************************************************************************/
41
45class RuleCheckMessagesModel : public QObject,
46 public slint::Model<ui::RuleCheckMessageData> {
47 Q_OBJECT
48
49public:
50 // Types
51 typedef std::function<bool(const std::shared_ptr<const RuleCheckMessage>& msg,
52 bool checkOnly)>
54
55 // Constructors / Destructor
57 explicit RuleCheckMessagesModel(QObject* parent = nullptr) noexcept;
58 virtual ~RuleCheckMessagesModel() noexcept;
59
60 // General Methods
61 void clear() noexcept;
62 void setAutofixHandler(AutofixHandler handler) noexcept;
63 void setMessages(const RuleCheckMessageList& messages,
64 const QSet<SExpression>& approvals) noexcept;
65 int getUnapprovedCount() const noexcept { return mUnapprovedCount; }
66 int getErrorCount() const noexcept { return mErrorCount; }
67
68 // Implementations
69 std::size_t row_count() const override;
70 std::optional<ui::RuleCheckMessageData> row_data(
71 std::size_t i) const override;
72 void set_row_data(std::size_t i,
73 const ui::RuleCheckMessageData& data) noexcept override;
74
75 // Operator Overloadings
77
78signals:
79 void unapprovedCountChanged(int count);
80 void errorCountChanged(int count);
81 void approvalChanged(const SExpression& approval, bool approved);
82 void highlightRequested(std::shared_ptr<const RuleCheckMessage> msg,
83 bool zoomTo);
84
85private:
86 void updateCounters() noexcept;
87
93};
94
95/*******************************************************************************
96 * End of File
97 ******************************************************************************/
98
99} // namespace editor
100} // namespace librepcb
101
102#endif
The SExpression class.
Definition sexpression.h:69
The RuleCheckMessagesModel class.
Definition rulecheckmessagesmodel.h:46
void clear() noexcept
Definition rulecheckmessagesmodel.cpp:51
RuleCheckMessageList mMessages
Definition rulecheckmessagesmodel.h:89
void setMessages(const RuleCheckMessageList &messages, const QSet< SExpression > &approvals) noexcept
Definition rulecheckmessagesmodel.cpp:64
int getUnapprovedCount() const noexcept
Definition rulecheckmessagesmodel.h:65
AutofixHandler mAutofixHandler
Definition rulecheckmessagesmodel.h:88
void set_row_data(std::size_t i, const ui::RuleCheckMessageData &data) noexcept override
Definition rulecheckmessagesmodel.cpp:97
void setAutofixHandler(AutofixHandler handler) noexcept
Definition rulecheckmessagesmodel.cpp:58
std::optional< ui::RuleCheckMessageData > row_data(std::size_t i) const override
Definition rulecheckmessagesmodel.cpp:81
int getErrorCount() const noexcept
Definition rulecheckmessagesmodel.h:66
void highlightRequested(std::shared_ptr< const RuleCheckMessage > msg, bool zoomTo)
void approvalChanged(const SExpression &approval, bool approved)
QSet< SExpression > mApprovals
Definition rulecheckmessagesmodel.h:90
std::size_t row_count() const override
Definition rulecheckmessagesmodel.cpp:77
void updateCounters() noexcept
Definition rulecheckmessagesmodel.cpp:134
RuleCheckMessagesModel(const RuleCheckMessagesModel &other)=delete
int mErrorCount
Definition rulecheckmessagesmodel.h:92
std::function< bool(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly)> AutofixHandler
Definition rulecheckmessagesmodel.h:53
int mUnapprovedCount
Definition rulecheckmessagesmodel.h:91
RuleCheckMessagesModel & operator=(const RuleCheckMessagesModel &rhs)=delete
Definition occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition rulecheckmessage.h:104