mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-09-17 13:37:18 +03:00
Add selectCommitRelative()
This commit is contained in:
parent
770ac3c7a5
commit
7e182735e2
@ -1169,11 +1169,11 @@ public:
|
||||
|
||||
} // namespace
|
||||
|
||||
static Hotkey prevCommitHotKey = HotkeyManager::registerHotkey(
|
||||
"J", "commitList/prevCommit", "CommitList/PrevCommit");
|
||||
static Hotkey selectCommitDownHotKey = HotkeyManager::registerHotkey(
|
||||
"j", "commitList/selectCommitDown", "CommitList/Select Next Commit Down");
|
||||
|
||||
static Hotkey nextCommitHotKey = HotkeyManager::registerHotkey(
|
||||
"K", "commitList/nextCommit", "CommitList/NextCommit");
|
||||
static Hotkey selectCommitUpHotKey = HotkeyManager::registerHotkey(
|
||||
"k", "commitList/selectCommitUp", "CommitList/Select Next Commit Up");
|
||||
|
||||
CommitList::CommitList(Index *index, QWidget *parent)
|
||||
: QListView(parent), mIndex(index) {
|
||||
@ -1231,16 +1231,13 @@ CommitList::CommitList(Index *index, QWidget *parent)
|
||||
[this](const QModelIndex &index) { update(index); });
|
||||
|
||||
QShortcut *shortcut = new QShortcut(this);
|
||||
prevCommitHotKey.use(shortcut);
|
||||
connect(shortcut, &QShortcut::activated, [this] {
|
||||
printf("prevCommit\n");
|
||||
});
|
||||
selectCommitDownHotKey.use(shortcut);
|
||||
connect(shortcut, &QShortcut::activated, [this] { selectCommitRelative(1); });
|
||||
|
||||
shortcut = new QShortcut(this);
|
||||
nextCommitHotKey.use(shortcut);
|
||||
connect(shortcut, &QShortcut::activated, [this] {
|
||||
printf("nextCommit\n");
|
||||
});
|
||||
selectCommitUpHotKey.use(shortcut);
|
||||
connect(shortcut, &QShortcut::activated,
|
||||
[this] { selectCommitRelative(-1); });
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
QFont font = this->font();
|
||||
@ -1364,6 +1361,19 @@ void CommitList::selectFirstCommit(bool spontaneous) {
|
||||
}
|
||||
}
|
||||
|
||||
void CommitList::selectCommitRelative(int offset) {
|
||||
QModelIndexList indices = selectionModel()->selectedIndexes();
|
||||
QModelIndex index = indices[0];
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
QModelIndex new_index = model()->index(index.row() + offset, index.column());
|
||||
if (!new_index.isValid()) {
|
||||
return;
|
||||
}
|
||||
selectIndexes(QItemSelection(new_index, new_index), QString(), true);
|
||||
}
|
||||
|
||||
bool CommitList::selectRange(const QString &range, const QString &file,
|
||||
bool spontaneous) {
|
||||
// Try to select the "status" index.
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
void selectReference(const git::Reference &ref);
|
||||
void resetSelection(bool spontaneous = false);
|
||||
void selectFirstCommit(bool spontaneous = false);
|
||||
void selectCommitRelative(int offset);
|
||||
bool selectRange(const QString &range, const QString &file = QString(),
|
||||
bool spontaneous = false);
|
||||
void suppressResetWalker(bool suppress);
|
||||
|
Loading…
Reference in New Issue
Block a user