diff --git a/lib/Filter.cpp b/lib/Filter.cpp index 50c1d24..0cc5933 100644 --- a/lib/Filter.cpp +++ b/lib/Filter.cpp @@ -22,7 +22,6 @@ // System #include -#include // Qt #include @@ -193,12 +192,7 @@ Filter::~Filter() } void Filter::reset() { - for (HotSpot* const currentHotSpot : qAsConst(_hotspotList)) { - if (currentHotSpot->hasAnotherParent()) { - continue; - } - delete currentHotSpot; - } + qDeleteAll(_hotspotList); _hotspots.clear(); _hotspotList.clear(); } @@ -285,18 +279,15 @@ Filter::HotSpot* Filter::hotSpotAt(int line , int column) const } Filter::HotSpot::HotSpot(int startLine , int startColumn , int endLine , int endColumn) - : _hasAnotherParent(false) - , _startLine(startLine) + : _startLine(startLine) , _startColumn(startColumn) , _endLine(endLine) , _endColumn(endColumn) , _type(NotSpecified) { } -QList Filter::HotSpot::actions(QWidget* parent) +QList Filter::HotSpot::actions() { - Q_UNUSED(parent); - return QList(); } int Filter::HotSpot::startLine() const @@ -508,28 +499,14 @@ FilterObject* UrlFilter::HotSpot::getUrlObject() const return _urlObject; } -class UrlAction : public QAction { -public: - UrlAction(QWidget* parent, std::shared_ptr hotspotPtr) - : QAction(parent) - , _hotspotPtr(hotspotPtr) - { - } - -private: - std::shared_ptr _hotspotPtr; -}; - -QList UrlFilter::HotSpot::actions(QWidget* parent) +QList UrlFilter::HotSpot::actions() { - this->_hasAnotherParent = true; QList list; const UrlType kind = urlType(); - std::shared_ptr hotspotPtr(this); - UrlAction* openAction = new UrlAction(parent, hotspotPtr); - UrlAction* copyAction = new UrlAction(parent, hotspotPtr); + QAction* openAction = new QAction(_urlObject); + QAction* copyAction = new QAction(_urlObject);; Q_ASSERT( kind == StandardUrl || kind == Email ); diff --git a/lib/Filter.h b/lib/Filter.h index bb411ef..9692b91 100644 --- a/lib/Filter.h +++ b/lib/Filter.h @@ -115,22 +115,19 @@ public: * Returns a list of actions associated with the hotspot which can be used in a * menu or toolbar */ - virtual QList actions(QWidget* parent); - - bool hasAnotherParent() const { return _hasAnotherParent; } + virtual QList actions(); protected: /** Sets the type of a hotspot. This should only be set once */ void setType(Type type); - bool _hasAnotherParent; - private: int _startLine; int _startColumn; int _endLine; int _endColumn; Type _type; + }; /** Constructs a new filter. */ @@ -259,7 +256,7 @@ public: FilterObject* getUrlObject() const; - virtual QList actions(QWidget* parent); + virtual QList actions(); /** * Open a web browser at the current URL. The url itself can be determined using diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index f17f017..35f6b4b 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -1962,14 +1962,14 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev) } } -QList TerminalDisplay::filterActions(const QPoint& position, QWidget* parent) +QList TerminalDisplay::filterActions(const QPoint& position) { int charLine, charColumn; getCharacterPosition(position,charLine,charColumn); Filter::HotSpot* spot = _filterChain->hotSpotAt(charLine,charColumn); - return spot ? spot->actions(parent) : QList(); + return spot ? spot->actions() : QList(); } void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev) diff --git a/lib/TerminalDisplay.h b/lib/TerminalDisplay.h index adf446a..9978d0f 100644 --- a/lib/TerminalDisplay.h +++ b/lib/TerminalDisplay.h @@ -158,7 +158,7 @@ public: * Returns a list of menu actions created by the filters for the content * at the given @p position. */ - QList filterActions(const QPoint& position, QWidget* parent); + QList filterActions(const QPoint& position); /** Returns true if the cursor is set to blink or false otherwise. */ bool blinkingCursor() { return _hasBlinkingCursor; } diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index edf4232..5c3e56f 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -671,9 +671,9 @@ Filter::HotSpot* QTermWidget::getHotSpotAt(int row, int column) const return m_impl->m_terminalDisplay->filterChain()->hotSpotAt(row, column); } -QList QTermWidget::filterActions(const QPoint& position, QWidget* parent) +QList QTermWidget::filterActions(const QPoint& position) { - return m_impl->m_terminalDisplay->filterActions(position, parent); + return m_impl->m_terminalDisplay->filterActions(position); } int QTermWidget::getPtySlaveFd() const diff --git a/lib/qtermwidget.h b/lib/qtermwidget.h index 03b017b..a43249d 100644 --- a/lib/qtermwidget.h +++ b/lib/qtermwidget.h @@ -186,7 +186,7 @@ public: /* * Proxy for TerminalDisplay::filterActions * */ - QList filterActions(const QPoint& position, QWidget* parent); + QList filterActions(const QPoint& position); /** * Returns a pty slave file descriptor.