mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-08 17:05:43 -05:00
fix multi-group categories, fix qt5 builds
This commit is contained in:
@@ -17,10 +17,10 @@
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_TopBar">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
<enum>QFrame::Shape::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
<enum>QFrame::Shadow::Plain</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
@@ -48,7 +48,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -85,6 +85,9 @@
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -92,12 +95,56 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="SpeciesChartView" name="chartView_SpeciesDistribution">
|
||||
<property name="renderHints">
|
||||
<set>QPainter::Antialiasing</set>
|
||||
<widget class="QFrame" name="frame_speciesDistribution">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Shadow::Plain</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_speciesDistribution">
|
||||
<property name="topMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_speciesDistributionGroup">
|
||||
<property name="text">
|
||||
<string>Group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NoScrollComboBox" name="comboBox_speciesDistributionGroup">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>8</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_speciesDistribution">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="SpeciesChartView" name="chartView_SpeciesDistribution" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabLevels">
|
||||
@@ -120,10 +167,10 @@
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
<enum>QFrame::Shape::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
<enum>QFrame::Shadow::Plain</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
@@ -142,7 +189,7 @@
|
||||
<item>
|
||||
<widget class="NoScrollComboBox" name="comboBox_Group">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
<enum>QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>8</number>
|
||||
@@ -152,7 +199,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -199,10 +246,10 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::NoInsert</enum>
|
||||
<enum>QComboBox::InsertPolicy::NoInsert</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
<enum>QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>12</number>
|
||||
@@ -229,16 +276,16 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SpeciesChartView</class>
|
||||
<extends>QChartView</extends>
|
||||
<header>specieschartview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>NoScrollComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>noscrollwidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SpeciesChartView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>specieschartview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../resources/images.qrc"/>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef SPECIESCHARTVIEW_H
|
||||
#define SPECIESCHARTVIEW_H
|
||||
|
||||
#if __has_include(<QtCharts>)
|
||||
#include <QtCharts/QChartView>
|
||||
|
||||
class Project;
|
||||
@@ -34,4 +35,6 @@ private:
|
||||
int m_maxTextWidth = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // __has_include(<QtCharts>)
|
||||
|
||||
#endif // SPECIESCHARTVIEW_H
|
||||
|
||||
@@ -77,11 +77,13 @@ private:
|
||||
|
||||
#else
|
||||
|
||||
class Project;
|
||||
|
||||
class WildMonChart : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WildMonChart(QWidget *, const EncounterTableModel *) {};
|
||||
explicit WildMonChart(QWidget *, const EncounterTableModel *, Project *) {};
|
||||
~WildMonChart() {};
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifdef QT_CHARTS_LIB
|
||||
|
||||
#include "specieschartview.h"
|
||||
|
||||
#include "project.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
SpeciesChartView::SpeciesChartView(QWidget *parent)
|
||||
@@ -98,3 +98,5 @@ void SpeciesChartView::paintEvent(QPaintEvent *event)
|
||||
painter.drawPixmap(iconRect, entry.icon);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // QT_CHARTS_LIB
|
||||
|
||||
@@ -35,6 +35,7 @@ WildMonChart::WildMonChart(QWidget *parent, const EncounterTableModel *table, Pr
|
||||
connect(ui->groupBox_Species, &QGroupBox::clicked, this, &WildMonChart::refreshLevelDistributionChart);
|
||||
connect(ui->comboBox_Species, &QComboBox::currentTextChanged, this, &WildMonChart::refreshLevelDistributionChart);
|
||||
connect(ui->comboBox_Group, &QComboBox::currentTextChanged, this, &WildMonChart::refreshLevelDistributionChart);
|
||||
connect(ui->comboBox_speciesDistributionGroup, &QComboBox::currentTextChanged, this, &WildMonChart::refreshSpeciesDistributionChart);
|
||||
|
||||
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &WildMonChart::limitChartAnimation);
|
||||
|
||||
@@ -82,10 +83,14 @@ void WildMonChart::clearTableData() {
|
||||
|
||||
const QSignalBlocker blocker1(ui->comboBox_Species);
|
||||
const QSignalBlocker blocker2(ui->comboBox_Group);
|
||||
const QSignalBlocker blocker3(ui->comboBox_speciesDistributionGroup);
|
||||
ui->comboBox_Species->clear();
|
||||
ui->comboBox_Group->clear();
|
||||
ui->comboBox_Group->setEnabled(false);
|
||||
ui->comboBox_speciesDistributionGroup->clear();
|
||||
ui->comboBox_speciesDistributionGroup->setEnabled(false);
|
||||
ui->label_Group->setEnabled(false);
|
||||
ui->label_speciesDistributionGroup->setEnabled(false);
|
||||
}
|
||||
|
||||
// Extract all the data from the table that we need for the charts
|
||||
@@ -150,20 +155,27 @@ void WildMonChart::readTable() {
|
||||
// Populate combo boxes
|
||||
const QSignalBlocker blocker1(ui->comboBox_Species);
|
||||
const QSignalBlocker blocker2(ui->comboBox_Group);
|
||||
const QSignalBlocker blocker3(ui->comboBox_speciesDistributionGroup);
|
||||
ui->comboBox_Species->clear();
|
||||
ui->comboBox_Species->addItems(getSpeciesNamesAlphabetical());
|
||||
ui->comboBox_Group->clear();
|
||||
ui->comboBox_Group->addItems(this->groupNames);
|
||||
ui->comboBox_speciesDistributionGroup->clear();
|
||||
ui->comboBox_speciesDistributionGroup->addItems(this->groupNames);
|
||||
bool enableGroupSelection = usesGroupLabels();
|
||||
ui->comboBox_Group->setEnabled(enableGroupSelection);
|
||||
ui->comboBox_speciesDistributionGroup->setEnabled(enableGroupSelection);
|
||||
ui->label_Group->setEnabled(enableGroupSelection);
|
||||
ui->label_speciesDistributionGroup->setEnabled(enableGroupSelection);
|
||||
}
|
||||
|
||||
void WildMonChart::refresh() {
|
||||
const QSignalBlocker blocker1(ui->comboBox_Species);
|
||||
const QSignalBlocker blocker2(ui->comboBox_Group);
|
||||
const QSignalBlocker blocker3(ui->comboBox_speciesDistributionGroup);
|
||||
const QString oldSpecies = ui->comboBox_Species->currentText();
|
||||
const QString oldGroup = ui->comboBox_Group->currentText();
|
||||
const QString oldSpeciesGroup = ui->comboBox_speciesDistributionGroup->currentText();
|
||||
|
||||
readTable();
|
||||
|
||||
@@ -174,6 +186,9 @@ void WildMonChart::refresh() {
|
||||
index = ui->comboBox_Group->findText(oldGroup);
|
||||
if (index >= 0) ui->comboBox_Group->setCurrentIndex(index);
|
||||
|
||||
index = ui->comboBox_speciesDistributionGroup->findText(oldSpeciesGroup);
|
||||
if (index >= 0) ui->comboBox_speciesDistributionGroup->setCurrentIndex(index);
|
||||
|
||||
refreshSpeciesDistributionChart();
|
||||
refreshLevelDistributionChart();
|
||||
}
|
||||
@@ -235,14 +250,13 @@ struct SpeciesFrequency
|
||||
};
|
||||
|
||||
QChart* WildMonChart::createSpeciesDistributionChart() {
|
||||
const QString groupName = ui->comboBox_speciesDistributionGroup->currentText();
|
||||
QList<QBarSet*> barSets;
|
||||
QStringList categories;
|
||||
QList<SpeciesFrequency> speciesList;
|
||||
|
||||
for (const auto &species : getSpeciesNamesAlphabetical()) {
|
||||
for (auto groupName : this->groupNamesReversed) {
|
||||
speciesList.append({species, getSpeciesFrequency(species, groupName) * 100.0});
|
||||
}
|
||||
speciesList.append({species, getSpeciesFrequency(species, groupName) * 100.0});
|
||||
}
|
||||
|
||||
std::sort(speciesList.begin(), speciesList.end(), [](const auto &a, const auto &b) {
|
||||
@@ -251,8 +265,10 @@ QChart* WildMonChart::createSpeciesDistributionChart() {
|
||||
|
||||
auto *set = new QBarSet("Encounter Rates");
|
||||
for (const auto &entry : speciesList) {
|
||||
set->append(entry.frequency);
|
||||
categories.append(entry.name);
|
||||
if (entry.frequency > 0.0) {
|
||||
set->append(entry.frequency);
|
||||
categories.append(entry.name);
|
||||
}
|
||||
}
|
||||
|
||||
barSets.append(set);
|
||||
@@ -359,7 +375,7 @@ QChart* WildMonChart::createLevelDistributionChart() {
|
||||
levelRange = getLevelRange(species, groupName);
|
||||
} else {
|
||||
// Species box is inactive, we display data for all species in the table.
|
||||
for (const auto &species : this->speciesInLegendOrder)
|
||||
for (const auto &species : getSpeciesNamesAlphabetical())
|
||||
barSets.append(createLevelDistributionBarSet(species, groupName, false));
|
||||
levelRange = this->groupedLevelRanges.value(groupName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user