|
|
|
@ -221,21 +221,33 @@ void MainWindow::showHighscore_triggered() {
|
|
|
|
|
title->setAlignment(Qt::AlignCenter);
|
|
|
|
|
//title->set
|
|
|
|
|
layout->addWidget(title);
|
|
|
|
|
QList<QPair<QString, QDateTime>> sorted_keys = highscore.keys();
|
|
|
|
|
std::sort(sorted_keys.begin(), sorted_keys.end());
|
|
|
|
|
int i = 1;
|
|
|
|
|
for (auto key = sorted_keys.end()-1; key != sorted_keys.begin()-1; key--) {
|
|
|
|
|
auto entry = highscore.find(*key);
|
|
|
|
|
struct KeyValuePair {
|
|
|
|
|
QPair<QString, QDateTime> key;
|
|
|
|
|
int value;
|
|
|
|
|
};
|
|
|
|
|
std::vector<KeyValuePair> sorted_entries;
|
|
|
|
|
|
|
|
|
|
for (auto entry = highscore.begin(); entry != highscore.end(); entry++) {
|
|
|
|
|
KeyValuePair pair;
|
|
|
|
|
pair.key = entry.key();
|
|
|
|
|
pair.value = entry.value();
|
|
|
|
|
sorted_entries.push_back(pair);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::sort(sorted_entries.begin(), sorted_entries.end(), [](const KeyValuePair& a, const KeyValuePair& b) {
|
|
|
|
|
return a.value > b.value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (unsigned long i = 1; i < sorted_entries.size()+1; i++) {
|
|
|
|
|
QHBoxLayout *entry_layout = new QHBoxLayout;
|
|
|
|
|
QLabel *entry_name = new QLabel(QString::fromStdString(std::to_string(i)) + ") <b>" + entry.key().first + "</b>");
|
|
|
|
|
QLabel *entry_name = new QLabel(QString::fromStdString(std::to_string(i)) + ") <b>" + sorted_entries[i-1].key.first + "</b>");
|
|
|
|
|
QLCDNumber *entry_score = new QLCDNumber();
|
|
|
|
|
entry_score->display(entry.value());
|
|
|
|
|
QLabel *entry_datetime = new QLabel(entry.key().second.toString(Qt::DateFormat::TextDate));
|
|
|
|
|
entry_score->display( sorted_entries[i-1].value);
|
|
|
|
|
QLabel *entry_datetime = new QLabel( sorted_entries[i-1].key.second.toString(Qt::DateFormat::TextDate));
|
|
|
|
|
entry_layout->addWidget(entry_name);
|
|
|
|
|
entry_layout->addWidget(entry_score);
|
|
|
|
|
entry_layout->addWidget(entry_datetime);
|
|
|
|
|
layout->addLayout(entry_layout);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
highscoreDial.setLayout(layout);
|
|
|
|
|
highscoreDial.exec();
|
|
|
|
|