porymap/include/ui/wildmonchart.h

99 lines
2.5 KiB
C
Raw Normal View History

2024-08-21 18:06:30 +01:00
#ifndef WILDMONCHART_H
#define WILDMONCHART_H
#include "encountertablemodel.h"
#include <QWidget>
#if __has_include(<QtCharts>)
#include <QtCharts>
2024-08-21 18:06:30 +01:00
namespace Ui {
class WildMonChart;
}
class WildMonChart : public QWidget
{
Q_OBJECT
public:
2024-08-22 04:28:33 +01:00
explicit WildMonChart(QWidget *parent, const EncounterTableModel *table);
2024-08-21 18:06:30 +01:00
~WildMonChart();
2024-08-23 21:00:42 +01:00
virtual void closeEvent(QCloseEvent *event) override;
2024-08-21 18:06:30 +01:00
public slots:
2024-08-22 04:28:33 +01:00
void setTable(const EncounterTableModel *table);
2024-08-27 04:53:08 +01:00
void clearTable();
void refresh();
2024-08-21 18:06:30 +01:00
private:
Ui::WildMonChart *ui;
2024-08-22 04:28:33 +01:00
const EncounterTableModel *table;
QStringList groupNames;
2024-08-23 20:00:00 +01:00
QStringList groupNamesReversed;
QStringList speciesInLegendOrder;
QMap<int, QString> tableIndexToGroupName;
2024-08-23 17:06:50 +01:00
struct LevelRange {
int min;
int max;
};
QMap<QString, LevelRange> groupedLevelRanges;
struct Summary {
double speciesFrequency = 0.0;
QMap<int, double> levelFrequencies;
};
typedef QMap<QString, Summary> GroupedData;
QMap<QString, GroupedData> speciesToGroupedData;
2024-08-23 18:15:48 +01:00
QMap<QString, QColor> speciesToColor;
2024-08-23 20:00:00 +01:00
QStringList getSpeciesNamesAlphabetical() const;
double getSpeciesFrequency(const QString&, const QString&) const;
QMap<int, double> getLevelFrequencies(const QString &, const QString &) const;
2024-08-23 18:15:48 +01:00
LevelRange getLevelRange(const QString &, const QString &) const;
bool usesGroupLabels() const;
void clearTableData();
void readTable();
2024-08-27 04:53:08 +01:00
QChart* createSpeciesDistributionChart();
QChart* createLevelDistributionChart();
QBarSet* createLevelDistributionBarSet(const QString &, const QString &, bool);
2024-08-27 04:53:08 +01:00
void refreshSpeciesDistributionChart();
void refreshLevelDistributionChart();
void saveSpeciesColors(const QList<QBarSet*> &);
void applySpeciesColors(const QList<QBarSet*> &);
2024-08-23 18:15:48 +01:00
QChart::ChartTheme currentTheme() const;
void updateTheme();
2024-08-27 23:20:29 +01:00
void limitChartAnimation(QChart*);
2024-08-23 21:32:37 +01:00
void showHelpDialog();
2024-08-21 18:06:30 +01:00
};
#else
// As of writing our static Qt build for Windows doesn't include the QtCharts module, so we dummy the class out here.
// The charts module is additionally excluded from Windows in porymap.pro
#define DISABLE_CHARTS_MODULE
class WildMonChart : public QWidget
{
Q_OBJECT
public:
explicit WildMonChart(QWidget *, const EncounterTableModel *) {};
~WildMonChart() {};
public slots:
void setTable(const EncounterTableModel *) {};
void clearTable() {};
void refresh() {};
};
#endif // __has_include(<QtCharts>)
2024-08-21 18:06:30 +01:00
#endif // WILDMONCHART_H