@@ -34,46 +34,37 @@ ShortcutsDialog::ShortcutsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::
34
34
connect (ui->tblShortcuts , SIGNAL (itemSelectionChanged ()), this , SLOT (syncTextfield ()));
35
35
connect (ui->shortcutEdit , SIGNAL (askForSave ()), this , SLOT (updateShortcut ()));
36
36
connect (this , SIGNAL (rejected ()), this , SLOT (rejectedSlot ()));
37
- connect (ui->bntClearFilter , SIGNAL (released ()), this , SLOT (on_btnClearFilter ()));
38
37
connect (ui->filterEdit , SIGNAL (textChanged (const QString &)), this , SLOT (on_FilterTextChanged (const QString &)));
39
38
}
40
39
41
40
void ShortcutsDialog::showShortcutsFiltered (const QString & actionName)
42
41
{
43
42
QMap<QString, Configuration::Shortcut> shorcutsToShow;
44
43
filterShortcutsByName (actionName, shorcutsToShow);
45
- renderShortcuts (shorcutsToShow);
46
- }
47
-
48
- void ShortcutsDialog::filterShortcutsByName (const QString & nameFilter, QMap<QString, Configuration::Shortcut> & mapToFill)
49
- {
50
- for (QMap<QString, Configuration::Shortcut>::iterator i = Config ()->Shortcuts .begin ();
51
- i != Config ()->Shortcuts .end ();
52
- ++i)
53
- {
54
- if (i.value ().Name .contains (nameFilter, Qt::CaseInsensitive) || nameFilter == QString ())
55
- {
56
- mapToFill.insert (i.value ().Name , i.value ());
57
- }
58
- }
59
- }
60
-
61
- void ShortcutsDialog::renderShortcuts (QMap<QString, Configuration::Shortcut> & shortcuts)
62
- {
63
44
ui->tblShortcuts ->clearContents ();
64
- ui->tblShortcuts ->setRowCount (shortcuts .count ());
45
+ ui->tblShortcuts ->setRowCount (shorcutsToShow .count ());
65
46
currentRow = 0 ;
66
47
67
48
int row = 0 ;
68
- for (QMap<QString, Configuration::Shortcut>::const_iterator it = shortcuts.begin (); it != shortcuts.end ();
69
- ++it, row++)
49
+ for (auto shortcut : shorcutsToShow)
70
50
{
71
- QTableWidgetItem* shortcutName = new QTableWidgetItem (it. value () .Name );
72
- QTableWidgetItem* shortcutKey = new QTableWidgetItem (it. value () .Hotkey .toString (QKeySequence::NativeText));
51
+ QTableWidgetItem* shortcutName = new QTableWidgetItem (shortcut .Name );
52
+ QTableWidgetItem* shortcutKey = new QTableWidgetItem (shortcut .Hotkey .toString (QKeySequence::NativeText));
73
53
ui->tblShortcuts ->setItem (row, 0 , shortcutName);
74
54
ui->tblShortcuts ->setItem (row, 1 , shortcutKey);
55
+ row++;
56
+ }
57
+ ui->tblShortcuts ->setSortingEnabled (true );}
58
+
59
+ void ShortcutsDialog::filterShortcutsByName (const QString & nameFilter, QMap<QString, Configuration::Shortcut> & mapToFill)
60
+ {
61
+ for (auto shortcut : Config ()->Shortcuts )
62
+ {
63
+ if (shortcut.Name .contains (nameFilter, Qt::CaseInsensitive) || nameFilter == QString ())
64
+ {
65
+ mapToFill.insert (shortcut.Name , shortcut);
66
+ }
75
67
}
76
- ui->tblShortcuts ->setSortingEnabled (true );
77
68
}
78
69
79
70
void ShortcutsDialog::updateShortcut ()
@@ -163,11 +154,11 @@ void ShortcutsDialog::syncTextfield()
163
154
if (indexes.count () < 1 )
164
155
return ;
165
156
currentRow = indexes.at (0 ).row ();
166
- for (QMap<QString, Configuration::Shortcut>::iterator i = Config ()->Shortcuts . begin (); i != Config ()-> Shortcuts . end (); ++i )
157
+ for (auto shortcut : Config ()->Shortcuts )
167
158
{
168
- if (i. value () .Name == ui->tblShortcuts ->item (currentRow, 0 )->text ())
159
+ if (shortcut .Name == ui->tblShortcuts ->item (currentRow, 0 )->text ())
169
160
{
170
- currentShortcut = i. value () ;
161
+ currentShortcut = shortcut ;
171
162
break ;
172
163
}
173
164
}
@@ -192,12 +183,6 @@ void ShortcutsDialog::rejectedSlot()
192
183
Config ()->readShortcuts ();
193
184
}
194
185
195
- void ShortcutsDialog::on_btnClearFilter ()
196
- {
197
- ui->filterEdit ->clear ();
198
- showShortcutsFiltered (QString ());
199
- }
200
-
201
186
void ShortcutsDialog::on_FilterTextChanged (const QString & actionName)
202
187
{
203
188
showShortcutsFiltered (actionName);
0 commit comments