uisupport: Provide helpers for dealing with widget changes
[quassel.git] / src / qtui / chatitem.cpp
index 79ee339..d94a2a9 100644 (file)
@@ -33,6 +33,7 @@
 #include <QTextLayout>
 #include <QMenu>
 
+#include "action.h"
 #include "buffermodel.h"
 #include "bufferview.h"
 #include "chatline.h"
@@ -297,7 +298,7 @@ QVector<QTextLayout::FormatRange> ChatItem::additionalFormats() const
     using Label = UiStyle::MessageLabel;
     using Format = UiStyle::Format;
 
-    Label itemLabel = data(ChatLineModel::MsgLabelRole).value<Label>();
+    auto itemLabel = data(ChatLineModel::MsgLabelRole).value<Label>();
     const auto &fmtList = formatList();
 
     struct LabelFormat {
@@ -660,7 +661,7 @@ void ContentsChatItem::clearCache()
 ContentsChatItemPrivate *ContentsChatItem::privateData() const
 {
     if (!_data) {
-        ContentsChatItem *that = const_cast<ContentsChatItem *>(this);
+        auto *that = const_cast<ContentsChatItem *>(this);
         that->_data = new ContentsChatItemPrivate(ClickableList::fromString(data(ChatLineModel::DisplayRole).toString()), that);
     }
     return _data;
@@ -869,10 +870,13 @@ void ContentsChatItem::addActionsToMenu(QMenu *menu, const QPointF &pos)
         Clickable click = privateData()->currentClickable;
         switch (click.type()) {
         case Clickable::Url:
+        {
             privateData()->activeClickable = click;
-            menu->addAction(icon::get("edit-copy"), tr("Copy Link Address"),
-                &_actionProxy, SLOT(copyLinkToClipboard()))->setData(QVariant::fromValue<void *>(this));
+            auto action = new Action{icon::get("edit-copy"), tr("Copy Link Address"), menu, &_actionProxy, SLOT(copyLinkToClipboard())};
+            action->setData(QVariant::fromValue<void *>(this));
+            menu->addAction(action);
             break;
+        }
         case Clickable::Channel:
         {
             // Remove existing menu actions, they confuse us when right-clicking on a clickable
@@ -949,11 +953,6 @@ ContentsChatItem::WrapColumnFinder::WrapColumnFinder(const ChatItem *_item)
 }
 
 
-ContentsChatItem::WrapColumnFinder::~WrapColumnFinder()
-{
-}
-
-
 qint16 ContentsChatItem::WrapColumnFinder::nextWrapColumn(qreal width)
 {
     if (wordidx >= wrapList.count())