mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
feat: Automatically select newly added table rows (#4216)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
783b05c103
commit
36c8fffee2
|
@ -5,6 +5,7 @@
|
||||||
- Minor: Added ability to negate search options by prefixing it with an exclamation mark (e.g. `!badge:mod` to search for messages where the author does not have the moderator badge). (#4207)
|
- Minor: Added ability to negate search options by prefixing it with an exclamation mark (e.g. `!badge:mod` to search for messages where the author does not have the moderator badge). (#4207)
|
||||||
- Minor: Search window input will automatically use currently selected text if present. (#4178)
|
- Minor: Search window input will automatically use currently selected text if present. (#4178)
|
||||||
- Minor: Cleared up highlight sound settings (#4194)
|
- Minor: Cleared up highlight sound settings (#4194)
|
||||||
|
- Minor: Tables in settings window will now scroll to newly added rows. (#4216)
|
||||||
- Minor: Added link to streamlink docs for easier user setup. (#4217)
|
- Minor: Added link to streamlink docs for easier user setup. (#4217)
|
||||||
- Bugfix: Fixed highlight sounds not reloading on change properly. (#4194)
|
- Bugfix: Fixed highlight sounds not reloading on change properly. (#4194)
|
||||||
- Bugfix: Fixed CTRL + C not working in reply thread popups. (#4209)
|
- Bugfix: Fixed CTRL + C not working in reply thread popups. (#4209)
|
||||||
|
|
|
@ -82,7 +82,13 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
|
||||||
QObject::connect(this->model_, &QAbstractTableModel::rowsMoved, this,
|
QObject::connect(this->model_, &QAbstractTableModel::rowsMoved, this,
|
||||||
[this](const QModelIndex &parent, int start, int end,
|
[this](const QModelIndex &parent, int start, int end,
|
||||||
const QModelIndex &destination, int row) {
|
const QModelIndex &destination, int row) {
|
||||||
this->selectRow(row);
|
this->tableView_->selectRow(row);
|
||||||
|
});
|
||||||
|
|
||||||
|
// select freshly added row
|
||||||
|
QObject::connect(this->model_, &QAbstractTableModel::rowsInserted, this,
|
||||||
|
[this](const QModelIndex &parent, int first, int last) {
|
||||||
|
this->tableView_->selectRow(last);
|
||||||
});
|
});
|
||||||
|
|
||||||
// add tableview
|
// add tableview
|
||||||
|
@ -149,15 +155,7 @@ void EditableModelView::moveRow(int dir)
|
||||||
|
|
||||||
model_->moveRows(model_->index(row, 0), row, selected.size(),
|
model_->moveRows(model_->index(row, 0), row, selected.size(),
|
||||||
model_->index(row + dir, 0), row + dir);
|
model_->index(row + dir, 0), row + dir);
|
||||||
this->selectRow(row + dir);
|
this->tableView_->selectRow(row + dir);
|
||||||
}
|
|
||||||
|
|
||||||
void EditableModelView::selectRow(int row)
|
|
||||||
{
|
|
||||||
this->getTableView()->selectionModel()->clear();
|
|
||||||
this->getTableView()->selectionModel()->select(
|
|
||||||
this->model_->index(row, 0),
|
|
||||||
QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -31,9 +31,6 @@ private:
|
||||||
QHBoxLayout *buttons_{};
|
QHBoxLayout *buttons_{};
|
||||||
|
|
||||||
void moveRow(int dir);
|
void moveRow(int dir);
|
||||||
|
|
||||||
public:
|
|
||||||
void selectRow(int row);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -40,13 +40,6 @@ KeyboardSettingsPage::KeyboardSettingsPage()
|
||||||
auto newHotkey = dialog.data();
|
auto newHotkey = dialog.data();
|
||||||
int vectorIndex = getApp()->hotkeys->hotkeys_.append(newHotkey);
|
int vectorIndex = getApp()->hotkeys->hotkeys_.append(newHotkey);
|
||||||
getApp()->hotkeys->save();
|
getApp()->hotkeys->save();
|
||||||
|
|
||||||
// Select and scroll to newly added hotkey
|
|
||||||
auto modelRow = model->getModelIndexFromVectorIndex(vectorIndex);
|
|
||||||
auto modelIndex = model->index(modelRow, 0);
|
|
||||||
view->selectRow(modelRow);
|
|
||||||
view->getTableView()->scrollTo(modelIndex,
|
|
||||||
QAbstractItemView::PositionAtCenter);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,11 +82,6 @@ void KeyboardSettingsPage::tableCellClicked(const QModelIndex &clicked,
|
||||||
auto vectorIndex =
|
auto vectorIndex =
|
||||||
getApp()->hotkeys->replaceHotkey(hotkey->name(), newHotkey);
|
getApp()->hotkeys->replaceHotkey(hotkey->name(), newHotkey);
|
||||||
getApp()->hotkeys->save();
|
getApp()->hotkeys->save();
|
||||||
|
|
||||||
// Select the replaced hotkey
|
|
||||||
auto modelRow = model->getModelIndexFromVectorIndex(vectorIndex);
|
|
||||||
auto modelIndex = model->index(modelRow, 0);
|
|
||||||
view->selectRow(modelRow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue