2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-04-24 15:57:45 +08:00
|
|
|
#ifndef ISSUESTABLE_H
|
|
|
|
#define ISSUESTABLE_H
|
|
|
|
|
|
|
|
#include <QTableView>
|
|
|
|
#include <vector>
|
|
|
|
#include "../common.h"
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
|
|
|
|
class IssuesModel : public QAbstractTableModel {
|
|
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit IssuesModel(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void addIssue(PCompileIssue issue);
|
|
|
|
void clearIssues();
|
|
|
|
|
|
|
|
void setErrorColor(QColor color);
|
|
|
|
void setWarningColor(QColor color);
|
2021-04-29 20:54:44 +08:00
|
|
|
PCompileIssue issue(int row);
|
2021-04-24 15:57:45 +08:00
|
|
|
private:
|
2021-09-05 19:10:54 +08:00
|
|
|
QVector<PCompileIssue> mIssues;
|
2021-04-24 15:57:45 +08:00
|
|
|
QColor mErrorColor;
|
|
|
|
QColor mWarningColor;
|
|
|
|
|
|
|
|
// QAbstractItemModel interface
|
|
|
|
public:
|
2021-06-23 22:38:02 +08:00
|
|
|
int count();
|
2021-04-24 15:57:45 +08:00
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
int columnCount(const QModelIndex &parent) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
2021-09-05 19:10:54 +08:00
|
|
|
const QVector<PCompileIssue> &issues() const;
|
2021-04-24 15:57:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IssuesTable : public QTableView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit IssuesTable(QWidget* parent = nullptr);
|
|
|
|
|
2021-09-05 19:10:54 +08:00
|
|
|
const QVector<PCompileIssue> & issues() const;
|
2021-04-24 15:57:45 +08:00
|
|
|
|
|
|
|
IssuesModel* issuesModel();
|
|
|
|
|
|
|
|
void setErrorColor(QColor color);
|
|
|
|
void setWarningColor(QColor color);
|
2021-09-05 19:10:54 +08:00
|
|
|
QString toHtml();
|
|
|
|
QString toTxt();
|
2021-04-24 15:57:45 +08:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void addIssue(PCompileIssue issue);
|
|
|
|
|
2021-04-29 20:54:44 +08:00
|
|
|
PCompileIssue issue(const QModelIndex& index);
|
|
|
|
PCompileIssue issue(const int row);
|
2021-06-23 22:38:02 +08:00
|
|
|
int count();
|
2021-04-29 20:54:44 +08:00
|
|
|
|
2021-04-24 15:57:45 +08:00
|
|
|
void clearIssues();
|
|
|
|
|
|
|
|
private:
|
|
|
|
IssuesModel * mModel;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ISSUESTABLE_H
|