PDF4QT/Pdf4QtViewerPlugins/ObjectInspectorPlugin/statisticsgraphwidget.h

107 lines
2.6 KiB
C
Raw Normal View History

2021-06-18 19:06:11 +02:00
// Copyright (C) 2021 Jakub Melka
//
2021-08-10 19:22:56 +02:00
// This file is part of PDF4QT.
2021-06-18 19:06:11 +02:00
//
2021-08-10 19:22:56 +02:00
// PDF4QT is free software: you can redistribute it and/or modify
2021-06-18 19:06:11 +02:00
// 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.
//
2021-08-10 19:22:56 +02:00
// PDF4QT is distributed in the hope that it will be useful,
2021-06-18 19:06:11 +02:00
// 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
2021-08-10 19:22:56 +02:00
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
2021-06-18 19:06:11 +02:00
#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