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
|
} // namespace
|
||||||
|
|
||||||
static Hotkey prevCommitHotKey = HotkeyManager::registerHotkey(
|
static Hotkey selectCommitDownHotKey = HotkeyManager::registerHotkey(
|
||||||
"J", "commitList/prevCommit", "CommitList/PrevCommit");
|
"j", "commitList/selectCommitDown", "CommitList/Select Next Commit Down");
|
||||||
|
|
||||||
static Hotkey nextCommitHotKey = HotkeyManager::registerHotkey(
|
static Hotkey selectCommitUpHotKey = HotkeyManager::registerHotkey(
|
||||||
"K", "commitList/nextCommit", "CommitList/NextCommit");
|
"k", "commitList/selectCommitUp", "CommitList/Select Next Commit Up");
|
||||||
|
|
||||||
CommitList::CommitList(Index *index, QWidget *parent)
|
CommitList::CommitList(Index *index, QWidget *parent)
|
||||||
: QListView(parent), mIndex(index) {
|
: QListView(parent), mIndex(index) {
|
||||||
@ -1231,16 +1231,13 @@ CommitList::CommitList(Index *index, QWidget *parent)
|
|||||||
[this](const QModelIndex &index) { update(index); });
|
[this](const QModelIndex &index) { update(index); });
|
||||||
|
|
||||||
QShortcut *shortcut = new QShortcut(this);
|
QShortcut *shortcut = new QShortcut(this);
|
||||||
prevCommitHotKey.use(shortcut);
|
selectCommitDownHotKey.use(shortcut);
|
||||||
connect(shortcut, &QShortcut::activated, [this] {
|
connect(shortcut, &QShortcut::activated, [this] { selectCommitRelative(1); });
|
||||||
printf("prevCommit\n");
|
|
||||||
});
|
|
||||||
|
|
||||||
shortcut = new QShortcut(this);
|
shortcut = new QShortcut(this);
|
||||||
nextCommitHotKey.use(shortcut);
|
selectCommitUpHotKey.use(shortcut);
|
||||||
connect(shortcut, &QShortcut::activated, [this] {
|
connect(shortcut, &QShortcut::activated,
|
||||||
printf("nextCommit\n");
|
[this] { selectCommitRelative(-1); });
|
||||||
});
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QFont font = this->font();
|
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 CommitList::selectRange(const QString &range, const QString &file,
|
||||||
bool spontaneous) {
|
bool spontaneous) {
|
||||||
// Try to select the "status" index.
|
// Try to select the "status" index.
|
||||||
|
@ -47,6 +47,7 @@ public:
|
|||||||
void selectReference(const git::Reference &ref);
|
void selectReference(const git::Reference &ref);
|
||||||
void resetSelection(bool spontaneous = false);
|
void resetSelection(bool spontaneous = false);
|
||||||
void selectFirstCommit(bool spontaneous = false);
|
void selectFirstCommit(bool spontaneous = false);
|
||||||
|
void selectCommitRelative(int offset);
|
||||||
bool selectRange(const QString &range, const QString &file = QString(),
|
bool selectRange(const QString &range, const QString &file = QString(),
|
||||||
bool spontaneous = false);
|
bool spontaneous = false);
|
||||||
void suppressResetWalker(bool suppress);
|
void suppressResetWalker(bool suppress);
|
||||||
|
Loading…
Reference in New Issue
Block a user