2021-06-18 19:06:11 +02:00
|
|
|
// Copyright (C) 2021 Jakub Melka
|
|
|
|
//
|
|
|
|
// This file is part of Pdf4Qt.
|
|
|
|
//
|
|
|
|
// Pdf4Qt is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// with the written consent of the copyright owner, any later version.
|
|
|
|
//
|
|
|
|
// Pdf4Qt 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 Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#ifndef STATISTICSGRAPHWIDGET_H
|
|
|
|
#define STATISTICSGRAPHWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
2021-06-20 18:17:32 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2021-06-18 19:06:11 +02:00
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class StatisticsGraphWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace pdfplugin
|
|
|
|
{
|
|
|
|
|
|
|
|
class StatisticsGraphWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-06-19 18:57:02 +02:00
|
|
|
|
|
|
|
struct StatisticsItem
|
|
|
|
{
|
|
|
|
bool operator==(const StatisticsItem&) const = default;
|
|
|
|
|
|
|
|
qreal portion;
|
|
|
|
QColor color;
|
|
|
|
QStringList texts;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Statistics
|
|
|
|
{
|
|
|
|
bool operator==(const Statistics&) const = default;
|
|
|
|
|
|
|
|
QString title;
|
|
|
|
QStringList headers;
|
|
|
|
std::vector<StatisticsItem> items;
|
|
|
|
};
|
|
|
|
|
2021-06-18 19:06:11 +02:00
|
|
|
explicit StatisticsGraphWidget(QWidget* parent);
|
|
|
|
virtual ~StatisticsGraphWidget() override;
|
|
|
|
|
2021-06-20 18:17:32 +02:00
|
|
|
virtual QSize sizeHint() const override;
|
|
|
|
virtual QSize minimumSizeHint() const override;
|
|
|
|
|
2021-06-19 18:57:02 +02:00
|
|
|
void setStatistics(Statistics statistics);
|
|
|
|
|
2021-06-20 18:17:32 +02:00
|
|
|
protected:
|
|
|
|
virtual void paintEvent(QPaintEvent* event) override;
|
|
|
|
|
2021-06-18 19:06:11 +02:00
|
|
|
private:
|
|
|
|
Ui::StatisticsGraphWidget* ui;
|
2021-06-19 18:57:02 +02:00
|
|
|
|
|
|
|
struct GeometryHint
|
|
|
|
{
|
|
|
|
QMargins margins;
|
|
|
|
int colorRectangleWidth = 0;
|
|
|
|
int linesWidthLeft = 0;
|
|
|
|
int linesWidthRight = 0;
|
2021-06-20 18:17:32 +02:00
|
|
|
int markerSize = 0;
|
|
|
|
int normalLineWidth = 0;
|
|
|
|
int selectedLineWidth = 0;
|
|
|
|
int colorRectangeLeftMargin = 0;
|
2021-06-19 18:57:02 +02:00
|
|
|
|
|
|
|
int titleWidth = 0;
|
|
|
|
int titleHeight = 0;
|
|
|
|
int textHeight = 0;
|
2021-06-20 18:17:32 +02:00
|
|
|
int textMargin = 0;
|
|
|
|
int textLineHeight = 0;
|
2021-06-19 18:57:02 +02:00
|
|
|
|
|
|
|
std::vector<int> textWidths;
|
|
|
|
|
2021-06-20 18:17:32 +02:00
|
|
|
QSize minimalWidgetSize;
|
2021-06-19 18:57:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
GeometryHint getGeometryHint() const;
|
|
|
|
|
|
|
|
QFont getTitleFont() const;
|
|
|
|
QFont getHeaderFont() const;
|
|
|
|
QFont getTextFont() const;
|
|
|
|
|
|
|
|
Statistics m_statistics;
|
2021-06-20 18:17:32 +02:00
|
|
|
std::vector<QRect> m_colorBoxes;
|
|
|
|
size_t m_selectedColorBox = -1;
|
2021-06-18 19:06:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace pdfplugin
|
|
|
|
|
|
|
|
#endif // STATISTICSGRAPHWIDGET_H
|