forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sc_importWidget.hpp
98 lines (78 loc) · 2.36 KB
/
sc_importWidget.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// ==========================================================================
// Dedmonwakeen's Raid DPS/TPS Simulator.
// Send questions to [email protected]
// ==========================================================================
#ifndef SC_IMPORTWIDGET_HPP
#define SC_IMPORTWIDGET_HPP
// Workaround for "combaseapi.h(229): error C2187: syntax error: 'identifier' was unexpected here" when using
// /permissive- Qt includes the 8.1 SDK which is unfortunately not /permissive- compliant
#if defined( _WIN32 ) && !defined( _WIN32_WINNT_WINTHRESHOLD )
struct IUnknown;
#endif
#include <QDebug>
#include <QFile>
#include <QMap>
#include <QSettings>
#include <QStandardItemModel>
#include <QVector>
#include <QtWidgets/QtWidgets>
class BattleNetImportWidget : public QWidget
{
Q_OBJECT
using RealmDataModel = QMap<QString, QStandardItemModel *>;
// Simple horizontal layout for the widget
QHBoxLayout* m_layout;
// Components
QLabel* m_regionLabel;
QComboBox* m_regionCombo;
QLabel* m_realmLabel;
QComboBox* m_realmCombo;
QLabel* m_characterLabel;
QLineEdit* m_character;
QLabel* m_specializationLabel;
QComboBox* m_specializationCombo;
QPushButton* m_importButton;
// Data
RealmDataModel m_realmModels;
QSettings m_settings;
public:
BattleNetImportWidget( QWidget* parent = nullptr );
QLineEdit* characterWidget() const
{
return m_character;
}
// Accessors that sanitize the input to a form simc understands
QString region() const
{
return m_regionCombo->currentText().toLower();
}
QString realm() const
{
return m_realmCombo->currentData( Qt::UserRole ).toString();
}
QString character() const
{
return m_character->displayText();
}
QString specialization() const
{
return m_specializationCombo->currentData( Qt::DisplayRole ).toString().toLower();
}
bool validateInput() const;
signals:
void importTriggeredOut( const QString&, const QString&, const QString&, const QString& );
void armoryRegionChangedOut( const QString& );
public slots:
void armoryRegionChangedIn( const QString& );
private slots:
void returnPressed();
void buttonClicked();
void realmIndexChanged( int );
private:
void parseRealmListFile( QFile& file );
void loadRealmData();
void populateSpecialization();
void populateRegion();
void selectRegion( const QString& );
};
#endif /* SC_IMPORTWIDGET_HPP */