Add accelerators to EditableModelView

This commit is contained in:
Mm2PL 2024-08-26 13:25:07 +02:00
parent 6e104bde7e
commit 9a8e943e70
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9

View file

@ -41,14 +41,14 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
vbox->addLayout(buttons); vbox->addLayout(buttons);
// add // add
QPushButton *add = new QPushButton("Add"); QPushButton *add = new QPushButton("&Add");
buttons->addWidget(add); buttons->addWidget(add);
QObject::connect(add, &QPushButton::clicked, [this] { QObject::connect(add, &QPushButton::clicked, [this] {
this->addButtonPressed.invoke(); this->addButtonPressed.invoke();
}); });
// remove // remove
QPushButton *remove = new QPushButton("Remove"); QPushButton *remove = new QPushButton("&Remove");
buttons->addWidget(remove); buttons->addWidget(remove);
QObject::connect(remove, &QPushButton::clicked, [this] { QObject::connect(remove, &QPushButton::clicked, [this] {
auto selected = this->getTableView()->selectionModel()->selectedRows(0); auto selected = this->getTableView()->selectionModel()->selectedRows(0);
@ -71,14 +71,14 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
if (movable) if (movable)
{ {
// move up // move up
QPushButton *moveUp = new QPushButton("Move up"); QPushButton *moveUp = new QPushButton("&Move up");
buttons->addWidget(moveUp); buttons->addWidget(moveUp);
QObject::connect(moveUp, &QPushButton::clicked, this, [this] { QObject::connect(moveUp, &QPushButton::clicked, this, [this] {
this->moveRow(-1); this->moveRow(-1);
}); });
// move down // move down
QPushButton *moveDown = new QPushButton("Move down"); QPushButton *moveDown = new QPushButton("M&ove down");
buttons->addWidget(moveDown); buttons->addWidget(moveDown);
QObject::connect(moveDown, &QPushButton::clicked, this, [this] { QObject::connect(moveDown, &QPushButton::clicked, this, [this] {
this->moveRow(1); this->moveRow(1);