| 1 | #cxx . . $ `<file>/src/CommandDialog.cpp`/include "ScopedAssign.h"cxx . . $ `<file>/src/ScopedAssign.h`/ |
| 2 | #include "CommandDialog.h"cxx . . $ `<file>/src/CommandDialog.h`/ |
| 3 | #include <QStandardItemModel> |
| 4 | |
| 5 | |
| 6 | enum CommandColumnscxx . . $ CommandColumns# { |
| 7 | ICONcxx . . $ ICON. = 0, NAMEcxx . . $ NAME., DESCRIPTIONcxx . . $ DESCRIPTION., SOURCEcxx . . $ SOURCE., MAXcxx . . $ MAX. |
| 8 | }; |
| 9 | |
| 10 | |
| 11 | CommandDialogcxx . . $ CommandDialog#::CommandDialogcxx . . $ CommandDialog#CommandDialog(ff9122897d541ead).(QListcxx . . $ QList#<CommandRefcxx . . $ CommandRef#>& commands, QWidgetcxx . . $ QWidget#* parent) |
| 12 | : QDialogcxx . . $ QDialog#QDialog(872e7b0c281abd8d).(parent), commandscxx . . $ CommandDialog#commands.(commands) |
| 13 | { |
| 14 | setupUicxx . . $ Ui_CommandDialog#setupUi(d194de0c0f68c28b).(this); |
| 15 | |
| 16 | connectcxx . . $ QObject#connect(835f87066c895669).(btnAddcxx . . $ Ui_CommandDialog#btnAdd., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &CommandDialogcxx . . $ CommandDialog#::onAddButtonClickedcxx . . $ CommandDialog#onAddButtonClicked(49f6e7a06ebc5aa8).); |
| 17 | connectcxx . . $ QObject#connect(835f87066c895669).(btnRemovecxx . . $ Ui_CommandDialog#btnRemove., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &CommandDialogcxx . . $ CommandDialog#::onRemoveButtonClickedcxx . . $ CommandDialog#onRemoveButtonClicked(49f6e7a06ebc5aa8).); |
| 18 | |
| 19 | connectcxx . . $ QObject#connect(835f87066c895669).(okButtoncxx . . $ Ui_CommandDialog#okButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &CommandDialogcxx . . $ CommandDialog#::acceptcxx . . $ CommandDialog#accept(49f6e7a06ebc5aa8).); |
| 20 | connectcxx . . $ QObject#connect(835f87066c895669).(cancelButtoncxx . . $ Ui_CommandDialog#cancelButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &CommandDialogcxx . . $ CommandDialog#::rejectcxx . . $ CommandDialog#reject(49f6e7a06ebc5aa8).); |
| 21 | |
| 22 | refreshcxx . . $ CommandDialog#refresh(49f6e7a06ebc5aa8).(); |
| 23 | } |
| 24 | |
| 25 | void CommandDialogcxx . . $ CommandDialog#::refreshcxx . . $ CommandDialog#refresh(49f6e7a06ebc5aa8).() |
| 26 | { |
| 27 | for (const auto& command : commandscxx . . $ CommandDialog#commands.) { |
| 28 | createItemcxx . . $ CommandDialog#createItem(b126dc7c1de90089).(); |
| 29 | writeCommandcxx . . $ CommandDialog#writeCommand(add488b42c51f376).(command); |
| 30 | } |
| 31 | twCommandscxx . . $ Ui_CommandDialog#twCommands.->resizeColumnsToContentscxx . . $ QTableView#resizeColumnsToContents(49f6e7a06ebc5aa8).(); |
| 32 | } |
| 33 | |
| 34 | void CommandDialogcxx . . $ CommandDialog#::onAddButtonClickedcxx . . $ CommandDialog#onAddButtonClicked(49f6e7a06ebc5aa8).() |
| 35 | { |
| 36 | auto sa = ScopedAssigncxx . . $ ScopedAssign#ScopedAssign(c294a3505e7ed828).(userModecxx . . $ CommandDialog#userMode., false); |
| 37 | createCommandcxx . . $ CommandDialog#createCommand(49f6e7a06ebc5aa8).(); |
| 38 | twCommandscxx . . $ Ui_CommandDialog#twCommands.->resizeColumnsToContentscxx . . $ QTableView#resizeColumnsToContents(49f6e7a06ebc5aa8).(); |
| 39 | } |
| 40 | |
| 41 | void CommandDialogcxx . . $ CommandDialog#::onRemoveButtonClickedcxx . . $ CommandDialog#onRemoveButtonClicked(49f6e7a06ebc5aa8).() |
| 42 | { |
| 43 | if (twCommandscxx . . $ Ui_CommandDialog#twCommands.->currentRowcxx . . $ QTableWidget#currentRow(455f465bc33b4cdf).() == -1) return; |
| 44 | |
| 45 | auto sa = ScopedAssigncxx . . $ ScopedAssign#ScopedAssign(c294a3505e7ed828).(userModecxx . . $ CommandDialog#userMode., false); |
| 46 | twCommandscxx . . $ Ui_CommandDialog#twCommands.->removeRowcxx . . $ QTableWidget#removeRow(d4f767463ce0a6b3).(twCommandscxx . . $ Ui_CommandDialog#twCommands.->currentRowcxx . . $ QTableWidget#currentRow(455f465bc33b4cdf).()); |
| 47 | } |
| 48 | |
| 49 | int CommandDialogcxx . . $ CommandDialog#::createItemcxx . . $ CommandDialog#createItem(b126dc7c1de90089).() |
| 50 | { |
| 51 | int row = twCommandscxx . . $ Ui_CommandDialog#twCommands.->rowCountcxx . . $ QTableWidget#rowCount(455f465bc33b4cdf).(); |
| 52 | twCommandscxx . . $ Ui_CommandDialog#twCommands.->setRowCountcxx . . $ QTableWidget#setRowCount(d4f767463ce0a6b3).(row + 1); |
| 53 | twCommandscxx . . $ Ui_CommandDialog#twCommands.->selectRowcxx . . $ QTableView#selectRow(d4f767463ce0a6b3).(row); |
| 54 | |
| 55 | for (auto column : {ICONcxx . . $ ICON., NAMEcxx . . $ NAME., DESCRIPTIONcxx . . $ DESCRIPTION., SOURCEcxx . . $ SOURCE.}) { |
| 56 | auto* item = new QTableWidgetItemcxx . . $ QTableWidgetItem#(); |
| 57 | item->setFlagscxx . . $ QTableWidgetItem#setFlags(dc1db7281029bd82).(Qtcxx . . $ Qt/::ItemIsSelectablecxx . . $ Qt/ItemIsSelectable. |cxx . . $ Qt/`operator|`(bcda3d535fff4cd0). Qtcxx . . $ Qt/::ItemIsEnabledcxx . . $ Qt/ItemIsEnabled. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). Qtcxx . . $ Qt/::ItemIsEditablecxx . . $ Qt/ItemIsEditable.); |
| 58 | twCommandscxx . . $ Ui_CommandDialog#twCommands.->setItemcxx . . $ QTableWidget#setItem(786223559052ea9b).(row, column, item); |
| 59 | } |
| 60 | |
| 61 | return row; |
| 62 | } |
| 63 | |
| 64 | void CommandDialogcxx . . $ CommandDialog#::createCommandcxx . . $ CommandDialog#createCommand(49f6e7a06ebc5aa8).() |
| 65 | { |
| 66 | // get next available command name |
| 67 | QStringcxx . . $ QString# cmdName = {cxx . . $ QString#QString(ced63f7c635d850d).}; |
| 68 | bool found = false; |
| 69 | do { |
| 70 | cmdName =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#(trcxx . . $ CommandDialog#tr(75d9f1c324b4579d).("Command_%1")).argcxx . . $ QString#arg(64ab2ed17cc11715).(countercxx . . $ CommandDialog#counter.++); |
| 71 | found = false; |
| 72 | for (auto& command : commandscxx . . $ CommandDialog#commands.) { |
| 73 | if (command.namecxx . . $ CommandRef#name. ==cxx . . $ `operator==`(5bc2975d2d751687). cmdName) { |
| 74 | found = true; |
| 75 | break; |
| 76 | } |
| 77 | } |
| 78 | } while (found); |
| 79 | |
| 80 | int index = createItemcxx . . $ CommandDialog#createItem(b126dc7c1de90089).(); |
| 81 | writeCommandcxx . . $ CommandDialog#writeCommand(add488b42c51f376).({cmdName, {}, {}, ":/icons/gear.png", index}); |
| 82 | } |
| 83 | |
| 84 | void CommandDialogcxx . . $ CommandDialog#::writeCommandcxx . . $ CommandDialog#writeCommand(add488b42c51f376).(const CommandRefcxx . . $ CommandRef#& command) |
| 85 | { |
| 86 | auto* item0 = twCommandscxx . . $ Ui_CommandDialog#twCommands.->itemcxx . . $ QTableWidget#item(e78ccbf9c1467f73).(command.indexcxx . . $ CommandRef#index., ICONcxx . . $ ICON.); |
| 87 | item0->setTextcxx . . $ QTableWidgetItem#setText(3520e46b33348bf6).(command.iconcxx . . $ CommandRef#icon.); |
| 88 | |
| 89 | auto* item1 = twCommandscxx . . $ Ui_CommandDialog#twCommands.->itemcxx . . $ QTableWidget#item(e78ccbf9c1467f73).(command.indexcxx . . $ CommandRef#index., NAMEcxx . . $ NAME.); |
| 90 | item1->setTextcxx . . $ QTableWidgetItem#setText(3520e46b33348bf6).(command.namecxx . . $ CommandRef#name.); |
| 91 | |
| 92 | auto* item2 = twCommandscxx . . $ Ui_CommandDialog#twCommands.->itemcxx . . $ QTableWidget#item(e78ccbf9c1467f73).(command.indexcxx . . $ CommandRef#index., DESCRIPTIONcxx . . $ DESCRIPTION.); |
| 93 | item2->setTextcxx . . $ QTableWidgetItem#setText(3520e46b33348bf6).(command.descriptioncxx . . $ CommandRef#description.); |
| 94 | |
| 95 | auto* item3 = twCommandscxx . . $ Ui_CommandDialog#twCommands.->itemcxx . . $ QTableWidget#item(e78ccbf9c1467f73).(command.indexcxx . . $ CommandRef#index., SOURCEcxx . . $ SOURCE.); |
| 96 | item3->setTextcxx . . $ QTableWidgetItem#setText(3520e46b33348bf6).(command.sourcecxx . . $ CommandRef#source.); |
| 97 | } |
| 98 | |
| 99 | void CommandDialogcxx . . $ CommandDialog#::acceptcxx . . $ CommandDialog#accept(49f6e7a06ebc5aa8).() |
| 100 | { |
| 101 | commandscxx . . $ CommandDialog#commands..clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 102 | for (int row = 0; row < twCommandscxx . . $ Ui_CommandDialog#twCommands.->rowCountcxx . . $ QTableWidget#rowCount(455f465bc33b4cdf).(); ++row) { |
| 103 | auto icon = twCommandscxx . . $ Ui_CommandDialog#twCommands.->itemcxx . . $ QTableWidget#item(e78ccbf9c1467f73).(row, ICONcxx . . $ ICON.)->textcxx . . $ QTableWidgetItem#text(6ef7b6c27b00b43d).(); |
| 104 | auto name = twCommandscxx . . $ Ui_CommandDialog#twCommands.->itemcxx . . $ QTableWidget#item(e78ccbf9c1467f73).(row, NAMEcxx . . $ NAME.)->textcxx . . $ QTableWidgetItem#text(6ef7b6c27b00b43d).(); |
| 105 | auto description = twCommandscxx . . $ Ui_CommandDialog#twCommands.->itemcxx . . $ QTableWidget#item(e78ccbf9c1467f73).(row, DESCRIPTIONcxx . . $ DESCRIPTION.)->textcxx . . $ QTableWidgetItem#text(6ef7b6c27b00b43d).(); |
| 106 | auto source = twCommandscxx . . $ Ui_CommandDialog#twCommands.->itemcxx . . $ QTableWidget#item(e78ccbf9c1467f73).(row, SOURCEcxx . . $ SOURCE.)->textcxx . . $ QTableWidgetItem#text(6ef7b6c27b00b43d).(); |
| 107 | const CommandRefcxx . . $ CommandRef# command{name, description, source, icon, row}; |
| 108 | commandscxx . . $ CommandDialog#commands..appendcxx . . $ QList#append(77d9f17553126ecb).(command); |
| 109 | } |
| 110 | donecxx . . $ QDialog#done(d4f767463ce0a6b3).(QDialogcxx . . $ QDialog#::Acceptedcxx . . $ QDialog#Accepted.); |
| 111 | } |
| 112 | |
| 113 | void CommandDialogcxx . . $ CommandDialog#::rejectcxx . . $ CommandDialog#reject(49f6e7a06ebc5aa8).() |
| 114 | { |
| 115 | donecxx . . $ QDialog#done(d4f767463ce0a6b3).(QDialogcxx . . $ QDialog#::Rejectedcxx . . $ QDialog#Rejected.); |
| 116 | } |