uisupport: Let ClickableList inherit from std::vector instead of QList
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 2 Sep 2018 21:18:40 +0000 (23:18 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 18 Nov 2018 10:06:43 +0000 (11:06 +0100)
Apparently, a class inheriting from a QList specialization cannot
be properly exported, while this works fine when inheriting from
std::vector instead. Since we now prefer std containers over Qt's
anyway, changing the baseclass is a Good Thing™ either way, so
just do it.

src/qtui/chatitem.cpp
src/uisupport/clickable.cpp
src/uisupport/clickable.h

index 9fadc12..bbd49bf 100644 (file)
@@ -759,7 +759,7 @@ Clickable ContentsChatItem::clickableAt(const QPointF &pos) const
 UiStyle::FormatList ContentsChatItem::formatList() const
 {
     UiStyle::FormatList fmtList = ChatItem::formatList();
-    for (int i = 0; i < privateData()->clickables.count(); i++) {
+    for (size_t i = 0; i < privateData()->clickables.size(); i++) {
         Clickable click = privateData()->clickables.at(i);
         if (click.type() == Clickable::Url) {
             overlayFormat(fmtList, click.start(), click.start() + click.length(), UiStyle::FormatType::Url);
index 899277d..1f5720e 100644 (file)
@@ -110,7 +110,7 @@ ClickableList ClickableList::fromString(const QString &str)
                 if (QRegExp("^#\\d+$").exactMatch(match))
                     continue;
             }
-            result.append(Clickable((Clickable::Type)type, matches[type], matchEnd[type] - matches[type]));
+            result.emplace_back((Clickable::Type)type, matches[type], matchEnd[type] - matches[type]);
         }
     }
     while (type >= 0);
index 2c760b9..8d1c2f7 100644 (file)
@@ -18,8 +18,9 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef CLICKABLE_H_
-#define CLICKABLE_H_
+#pragma once
+
+#include <vector>
 
 #include <QStackedWidget>
 
@@ -57,13 +58,10 @@ private:
 };
 
 
-class ClickableList : public QList<Clickable>
+class ClickableList : public std::vector<Clickable>
 {
 public:
     static ClickableList fromString(const QString &);
 
     Clickable atCursorPos(int idx);
 };
-
-
-#endif // CLICKABLE_H_