1 /* 2 SPDX-FileCopyrightText: 2010 Nicolas Ternisien <nicolas.ternisien@gmail.com> 3 4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 5 */ 6 7 #ifndef CHART_WIDGET_H 8 #define CHART_WIDGET_H 9 10 #include <QColor> 11 #include <QList> 12 #include <QString> 13 #include <QWidget> 14 15 class QLabel; 16 class QWidget; 17 18 #include "base.h" 19 20 class Chart : public QWidget 21 { 22 Q_OBJECT 23 public: 24 explicit Chart(QWidget *parent = nullptr); 25 26 void setMemoryInfos(t_memsize *memoryInfos); 27 void setFreeMemoryLabel(QLabel *freeMemoryLabel); 28 29 static QString formattedUnit(t_memsize value); 30 31 protected: 32 bool drawChart(t_memsize total, const QList<t_memsize> &used, const QList<QColor> &colors, const QList<QString> &texts); 33 34 t_memsize *memoryInfos = nullptr; 35 36 QLabel *mFreeMemoryLabel = nullptr; 37 }; 38 39 class ChartWidget : public QWidget 40 { 41 public: 42 /** 43 * Initialize the list view item and task. 44 */ 45 ChartWidget(const QString &title, const QString &hint, Chart *chartImplementation, QWidget *parent = nullptr); 46 47 void setMemoryInfos(t_memsize *memoryInfos); 48 void refresh(); 49 50 private: 51 QLabel *titleLabel = nullptr; 52 53 Chart *chart = nullptr; 54 55 QLabel *mFreeMemoryLabel = nullptr; 56 }; 57 58 #endif // CHART_WIDGET_H 59