Commit 3a4950bd authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Use a single view to file history diffs

parent c64bd22b
......@@ -250,6 +250,6 @@ void FileHistoryWidget::itemClicked(const QModelIndex &idx)
contents.append(git.readAllStandardOutput());
// we send this signal to the parent, which will pass it on to
// the GitWidget from where a temporary file is opened
Q_EMIT commitClicked(fi.fileName(), QStringLiteral("XXXXXX %1.diff"), contents);
Q_EMIT commitClicked(fi.fileName(), /*QStringLiteral("XXXXXX %1.diff"),*/ contents);
}
}
......@@ -21,7 +21,7 @@ private:
Q_SIGNALS:
void backClicked();
void commitClicked(const QString &file, const QString &templString, const QByteArray &contents);
void commitClicked(const QString &file, const QByteArray &contents);
};
#endif // FILEHISTORYWIDGET_H
......@@ -481,14 +481,6 @@ void KateProjectPluginView::switchToProject(const QDir &dir)
}
}
void KateProjectPluginView::openTempFile(const QString &file, const QString &templateString, const QByteArray &contents)
{
if (QWidget *current = m_stackedgitViews->currentWidget()) {
m_stackedgitViews->setFocusProxy(current);
static_cast<GitWidget *>(current)->openTempFile(file, templateString, contents);
}
}
void KateProjectPluginView::slotViewCreated(KTextEditor::View *view)
{
/**
......
......@@ -115,11 +115,6 @@ public Q_SLOTS:
*/
void switchToProject(const QDir &dir);
/**
* tells Git widget to open a temporary file for diff etc.
*/
void openTempFile(const QString &file, const QString &templateString, const QByteArray &contents);
private Q_SLOTS:
/**
* Plugin config updated
......
......@@ -14,6 +14,7 @@
#include "kateprojectpluginview.h"
#include <KTextEditor/Document>
#include <KTextEditor/Editor>
#include <KTextEditor/View>
#include <KActionCollection>
......@@ -148,7 +149,19 @@ void KateProjectView::showFileGitHistory(const QString &file)
// create on demand and on switch back delete
auto fhs = new FileHistoryWidget(file);
connect(fhs, &FileHistoryWidget::backClicked, this, &KateProjectView::setTreeViewAsCurrent);
connect(fhs, &FileHistoryWidget::commitClicked, m_pluginView, &KateProjectPluginView::openTempFile);
connect(fhs, &FileHistoryWidget::commitClicked, this, &KateProjectView::showDiffInFixedView);
m_stackWidget->addWidget(fhs);
m_stackWidget->setCurrentWidget(fhs);
}
void KateProjectView::showDiffInFixedView(const QString & /*file*/, const QByteArray &contents)
{
if (!m_fixedView) {
m_fixedView = m_pluginView->mainWindow()->openUrl(QUrl());
}
if (m_fixedView->document()) {
m_fixedView->document()->setText(QString::fromUtf8(contents));
m_fixedView->document()->setHighlightingMode(QStringLiteral("Diff"));
}
}
......@@ -12,6 +12,7 @@
#include "kateprojectviewtree.h"
#include <QFileSystemWatcher>
#include <QPointer>
class KLineEdit;
class KateProjectPluginView;
......@@ -72,6 +73,8 @@ private Q_SLOTS:
void showFileGitHistory(const QString &file);
void showDiffInFixedView(const QString &file, const QByteArray &contents);
private:
/**
* our plugin view
......@@ -112,6 +115,11 @@ private:
* watches for changes to .git/HEAD
*/
QFileSystemWatcher m_branchChangedWatcher;
/**
* Fixed view for view diffs
*/
QPointer<KTextEditor::View> m_fixedView;
};
#endif
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