Commit af7527d6 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Allow single double click in git-status-view


Signed-off-by: Waqar Ahmed's avatarWaqar Ahmed <waqar.17a@gmail.com>
parent 9098449d
......@@ -215,6 +215,10 @@ GitWidget::GitWidget(KateProject *project, KTextEditor::MainWindow *mainWindow,
connect(&m_gitStatusWatcher, &QFutureWatcher<GitUtils::GitParsedStatus>::finished, this, &GitWidget::parseStatusReady);
connect(m_commitBtn, &QPushButton::clicked, this, &GitWidget::opencommitChangesDialog);
// single / double click
connect(m_treeView, &QTreeView::clicked, this, &GitWidget::treeViewSingleClicked);
connect(m_treeView, &QTreeView::doubleClicked, this, &GitWidget::treeViewDoubleClicked);
}
void GitWidget::initGitExe()
......@@ -608,6 +612,46 @@ void GitWidget::opencommitChangesDialog()
}
}
void GitWidget::handleClick(const QModelIndex &idx, int clickAction)
{
auto type = idx.data(GitStatusModel::TreeItemType);
if (type != GitStatusModel::NodeFile) {
return;
}
if (clickAction == ClickAction::NoAction) {
return;
}
const QString file = m_gitPath + idx.data(GitStatusModel::FileNameRole).toString();
bool staged = idx.internalId() == GitStatusModel::NodeStage;
if (clickAction == ClickAction::StageUnstage) {
if (staged) {
return unstage({file});
}
return stage({file});
}
if (clickAction == ClickAction::ShowDiff) {
showDiff(file, staged);
}
if (clickAction == ClickAction::OpenFile) {
m_mainWin->openUrl(QUrl::fromLocalFile(file));
}
}
void GitWidget::treeViewSingleClicked(const QModelIndex &idx)
{
handleClick(idx, m_pluginView->plugin()->singleClickAcion());
}
void GitWidget::treeViewDoubleClicked(const QModelIndex &idx)
{
handleClick(idx, m_pluginView->plugin()->doubleClickAcion());
}
void GitWidget::gitStatusReady(int exit, QProcess::ExitStatus status)
{
// sever connection
......
......@@ -97,6 +97,9 @@ private Q_SLOTS:
void gitStatusReady(int exit, QProcess::ExitStatus);
void parseStatusReady();
void opencommitChangesDialog();
void handleClick(const QModelIndex &idx, int clickAction);
void treeViewSingleClicked(const QModelIndex &idx);
void treeViewDoubleClicked(const QModelIndex &idx);
// signals
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment