11
11
12
12
TagSelectorDialog::TagSelectorDialog (QWidget *parent,
13
13
CodeFile::FileType type) :
14
- QDialog(parent),
15
- ui(new Ui::TagSelectorDialog) {
14
+ QDialog(parent), ui(new Ui::TagSelectorDialog) {
16
15
ui->setupUi (this );
17
16
18
17
filterModel.setParent (ui->tagListView );
19
18
model.setParent (this );
20
- setupTagTreeView (type);
19
+ setupTagView (type);
21
20
connect (ui->tagFilterBox , &QLineEdit::textChanged,
22
21
this , [this ](const QString &input) {
23
22
filterModel.setFilterRegularExpression (input);
24
23
});
25
24
26
25
connect (ui->tagListView ->selectionModel (),
27
26
&QItemSelectionModel::selectionChanged,
28
- this ,
29
- &TagSelectorDialog::checkOK);
27
+ this , &TagSelectorDialog::checkOK);
30
28
31
29
connect (ui->tagListView ->selectionModel (),
32
30
&QItemSelectionModel::selectionChanged,
33
- this ,
34
- &TagSelectorDialog::showDetails);
31
+ this , &TagSelectorDialog::showDetails);
35
32
36
33
selectButton = new QPushButton (tr (" Select" ), this );
37
34
ui->buttonBox ->removeButton (ui->buttonBox ->button (QDialogButtonBox::Ok));
@@ -46,15 +43,15 @@ TagSelectorDialog::~TagSelectorDialog() {
46
43
delete ui;
47
44
}
48
45
49
- void TagSelectorDialog::setupTagTreeView (
46
+ void TagSelectorDialog::setupTagView (
50
47
CodeFile::FileType type = CodeFile::ItemTag) {
51
48
model.setParent (ui->tagListView );
52
49
filterModel.setSourceModel (&model);
53
50
filterModel.setFilterCaseSensitivity (Qt::CaseInsensitive);
54
51
filterModel.setFilterRole (Qt::DisplayRole);
55
52
ui->tagListView ->setModel (&filterModel);
56
53
57
- QString tagStr = QStringLiteral (" tag/" );
54
+ QString && tagStr = QStringLiteral (" tag/" );
58
55
switch (type) {
59
56
case CodeFile::BlockTag:
60
57
tagStr += QStringLiteral (" block" );
@@ -80,22 +77,22 @@ void TagSelectorDialog::setupTagTreeView(
80
77
break ;
81
78
}
82
79
83
- auto tagStrSplited = tagStr.split (' /' );
80
+ auto && tagStrSplited = tagStr.split (' /' );
84
81
std::transform (tagStrSplited.cbegin (), tagStrSplited.cend (),
85
82
tagStrSplited.begin (), [](const QString &str) -> QString {
86
83
return str + ' s' ;
87
84
});
88
- auto tagDir = tagStrSplited.join (' /' );
85
+ const QString & tagDir = tagStrSplited.join (' /' );
89
86
90
- auto fileIDList = Glhp::fileIdList (QDir::currentPath (), tagDir);
87
+ const auto & fileIDList = Glhp::fileIdList (QDir::currentPath (), tagDir);
91
88
for (const auto &id : fileIDList) {
92
89
model.appendRow (new QStandardItem (id));
93
90
}
94
91
95
- MCRTagInfo = Game::getInfo (tagStr);
92
+ m_tagInfo = Game::getInfo (tagStr);
96
93
97
- auto tagIter = MCRTagInfo .constBegin ();
98
- while ((tagIter != MCRTagInfo .constEnd ())) {
94
+ auto tagIter = m_tagInfo .constBegin ();
95
+ while ((tagIter != m_tagInfo .constEnd ())) {
99
96
auto *item = new QStandardItem (
100
97
QStringLiteral (" minecraft:" ) + tagIter.key ());
101
98
model.appendRow (item);
@@ -104,34 +101,31 @@ void TagSelectorDialog::setupTagTreeView(
104
101
}
105
102
106
103
QString TagSelectorDialog::getInternalSelectedID () {
107
- auto indexes = ui->tagListView ->selectionModel ()->selectedIndexes ();
104
+ const auto indexes = ui->tagListView ->selectionModel ()->selectedIndexes ();
108
105
109
106
if (indexes.isEmpty ()) return QString ();
110
107
111
- QStandardItem *item =
108
+ const QStandardItem *item =
112
109
model.itemFromIndex (filterModel.mapToSource (indexes[0 ]));
113
110
auto id = item->text ();
114
111
return id;
115
112
}
116
113
117
114
QString TagSelectorDialog::getSelectedID () {
118
- const auto &&internalID = getInternalSelectedID ();
119
- const auto &id = internalID;
120
-
121
- return ' #' + id;
115
+ return ' #' + getInternalSelectedID ();
122
116
}
123
117
124
118
void TagSelectorDialog::checkOK () {
125
119
selectButton->setEnabled (!getInternalSelectedID ().isEmpty ());
126
120
}
127
121
128
122
void TagSelectorDialog::showDetails () {
129
- auto id = getInternalSelectedID ();
123
+ QString && id = getInternalSelectedID ();
130
124
131
125
if (!id.isEmpty ()) {
132
126
Glhp::removePrefix (id, " minecraft:" _QL1);
133
- if (MCRTagInfo .contains (id)) {
134
- const auto details = MCRTagInfo [id].toString ();
127
+ if (m_tagInfo .contains (id)) {
128
+ const auto details = m_tagInfo [id].toString ();
135
129
ui->tagDetailsLabel ->setText (details);
136
130
return ;
137
131
}
0 commit comments