Commit 51166756 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Cleanup git blame tooltip

- No need for QPointers as function params
- Init GitBlameTooltip::Private when needed
parent 82b2ee11
Pipeline #209155 passed with stage
in 7 minutes and 47 seconds
......@@ -218,7 +218,7 @@ public:
return false;
}
void showTooltip(const QString &text, const QPointer<KTextEditor::View> view)
void showTooltip(const QString &text, KTextEditor::View *view)
{
if (text.isEmpty() || !view) {
return;
......@@ -313,25 +313,31 @@ private:
};
GitBlameTooltip::GitBlameTooltip(KateGitBlamePluginView *pv)
: d(new GitBlameTooltip::Private(pv))
{
}
GitBlameTooltip::~GitBlameTooltip()
: m_pluginView(pv)
{
delete d;
}
void GitBlameTooltip::show(const QString &text, QPointer<KTextEditor::View> view)
GitBlameTooltip::~GitBlameTooltip() = default;
void GitBlameTooltip::show(const QString &text, KTextEditor::View *view)
{
if (text.isEmpty() || !view || !view->document()) {
return;
}
if (!d) {
d = std::make_unique<GitBlameTooltip::Private>(m_pluginView);
}
d->showTooltip(text, view);
}
void GitBlameTooltip::setIgnoreKeySequence(QKeySequence sequence)
void GitBlameTooltip::setIgnoreKeySequence(const QKeySequence &sequence)
{
if (!d) {
d = std::make_unique<GitBlameTooltip::Private>(m_pluginView);
}
d->m_ignoreKeySequence = sequence;
}
......
......@@ -7,10 +7,11 @@
#ifndef GitBlameTooltip_h
#define GitBlameTooltip_h
#include <QPointer>
#include <memory>
class QString;
class KateGitBlamePluginView;
class QKeySequence;
namespace KTextEditor
{
......@@ -23,13 +24,14 @@ public:
GitBlameTooltip(KateGitBlamePluginView *pv);
~GitBlameTooltip();
void show(const QString &text, QPointer<KTextEditor::View> view);
void show(const QString &text, KTextEditor::View *view);
void setIgnoreKeySequence(QKeySequence sequence);
void setIgnoreKeySequence(const QKeySequence &sequence);
private:
class Private;
Private *const d;
std::unique_ptr<Private> d;
KateGitBlamePluginView *m_pluginView;
};
#endif // GitBlameTooltip_h
......@@ -20,6 +20,7 @@
#include <QHash>
#include <QList>
#include <QLocale>
#include <QPointer>
#include <QRegularExpression>
#include <QVariant>
#include <QVector>
......
Supports Markdown
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