Package: quassel / 1:0.13.1-5

qt514/0004-qa-Avoid-deprecation-warnings-for-QList-QSet-convers.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
From 52209badc8e769e50aa3019b63689dda0e79e9d0 Mon Sep 17 00:00:00 2001
From: Manuel Nickschas <sputnick@quassel-irc.org>
Date: Tue, 7 Jan 2020 20:31:31 +0100
Subject: [PATCH 4/6] qa: Avoid deprecation warnings for QList/QSet conversions
Bug: https://bugs.quassel-irc.org/issues/1544
Bug-Ubuntu: https://bugs.launchpad.net/quassel/+bug/1885436
Origin: upstream, https://github.com/quassel/quassel/pull/518
Origin: upstream, https://github.com/quassel/quassel/commit/52209badc8e769e50aa3019b63689dda0e79e9d0

Qt 5.14 deprecated the explicit functions for converting between
QSet and QList, preferring instead the use of range-based ctors.
Unfortunately, those ctors were only added in Qt 5.14, so we can't
use them when compiling against older versions.

Add a util function for QList->QSet to keep the version check in
a single place. Replace the other direction by using QSet::values().
In some cases, conversions could be avoided altogether, or an STL
container be used easily, so do that.
---
 src/client/backlogrequester.cpp               | 22 +++++++------------
 src/client/backlogrequester.h                 | 15 +++++--------
 src/client/bufferviewoverlay.cpp              |  9 ++++----
 src/client/clientbacklogmanager.cpp           |  3 ++-
 src/client/messagefilter.cpp                  |  5 +++--
 src/common/ircuser.cpp                        |  2 +-
 src/common/util.h                             | 11 ++++++++++
 src/core/corebuffersyncer.cpp                 |  3 ++-
 src/qtui/chatview.cpp                         |  3 ++-
 src/qtui/chatviewsearchcontroller.cpp         |  5 ++---
 .../settingspages/chatmonitorsettingspage.cpp |  3 ++-
 src/uisupport/bufferviewfilter.cpp            |  3 ++-
 12 files changed, 46 insertions(+), 38 deletions(-)

--- a/src/client/backlogrequester.cpp
+++ b/src/client/backlogrequester.cpp
@@ -35,26 +35,18 @@ BacklogRequester::BacklogRequester(bool
     Q_ASSERT(backlogManager);
 }
 
-
-void BacklogRequester::setWaitingBuffers(const QSet<BufferId> &buffers)
-{
-    _buffersWaiting = buffers;
-    _totalBuffers = _buffersWaiting.count();
-}
-
-
-void BacklogRequester::addWaitingBuffer(BufferId buffer)
+void BacklogRequester::setWaitingBuffers(const BufferIdList& buffers)
 {
-    _buffersWaiting << buffer;
-    _totalBuffers++;
+    _buffersWaiting = {buffers.begin(), buffers.end()};
+    _totalBuffers = int(_buffersWaiting.size());
 }
 
 
 bool BacklogRequester::buffer(BufferId bufferId, const MessageList &messages)
 {
     _bufferedMessages << messages;
-    _buffersWaiting.remove(bufferId);
-    return !_buffersWaiting.isEmpty();
+    _buffersWaiting.erase(bufferId);
+    return !_buffersWaiting.empty();
 }
 
 
@@ -62,15 +54,14 @@ BufferIdList BacklogRequester::allBuffer
 {
     QSet<BufferId> bufferIds = Client::bufferViewOverlay()->bufferIds();
     bufferIds += Client::bufferViewOverlay()->tempRemovedBufferIds();
-    return bufferIds.toList();
+    return bufferIds.values();
 }
 
 
 void BacklogRequester::flushBuffer()
 {
-    if (!_buffersWaiting.isEmpty()) {
-        qWarning() << Q_FUNC_INFO << "was called before all backlog was received:"
-                   << _buffersWaiting.count() << "buffers are waiting.";
+    if (!_buffersWaiting.empty()) {
+        qWarning() << Q_FUNC_INFO << "was called before all backlog was received:" << _buffersWaiting.size() << "buffers are waiting.";
     }
     _bufferedMessages.clear();
     _totalBuffers = 0;
--- a/src/client/backlogrequester.h
+++ b/src/client/backlogrequester.h
@@ -18,8 +18,9 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef BACKLOGREQUESTER_H
-#define BACKLOGREQUESTER_H
+#pragma once
+
+#include <set>
 
 #include <QList>
 
@@ -47,7 +48,7 @@ public:
     inline RequesterType type() { return _requesterType; }
     inline const QList<Message> &bufferedMessages() { return _bufferedMessages; }
 
-    inline int buffersWaiting() const { return _buffersWaiting.count(); }
+    inline int buffersWaiting() const { return int(_buffersWaiting.size()); }
     inline int totalBuffers() const { return _totalBuffers; }
 
     bool buffer(BufferId bufferId, const MessageList &messages); //! returns false if it was the last missing backlogpart
@@ -59,9 +60,7 @@ public:
 
 protected:
     BufferIdList allBufferIds() const;
-    inline void setWaitingBuffers(const QList<BufferId> &buffers) { setWaitingBuffers(buffers.toSet()); }
-    void setWaitingBuffers(const QSet<BufferId> &buffers);
-    void addWaitingBuffer(BufferId buffer);
+    void setWaitingBuffers(const BufferIdList& buffers);
 
     ClientBacklogManager *backlogManager;
 
@@ -70,7 +69,7 @@ private:
     RequesterType _requesterType;
     MessageList _bufferedMessages;
     int _totalBuffers;
-    QSet<BufferId> _buffersWaiting;
+    std::set<BufferId> _buffersWaiting;
 };
 
 
@@ -117,6 +116,3 @@ private:
     int _limit;
     int _additional;
 };
-
-
-#endif //BACKLOGREQUESTER_H
--- a/src/client/bufferviewoverlay.cpp
+++ b/src/client/bufferviewoverlay.cpp
@@ -27,6 +27,7 @@
 #include "clientbacklogmanager.h"
 #include "clientbufferviewmanager.h"
 #include "networkmodel.h"
+#include "util.h"
 
 const int BufferViewOverlay::_updateEventId = QEvent::registerEventType();
 
@@ -101,13 +102,13 @@ void BufferViewOverlay::addView(int view
                     if (Client::networkModel()->networkId(bufferId) == config->networkId())
                         buffers << bufferId;
                 }
-                foreach(BufferId bufferId, config->temporarilyRemovedBuffers().toList()) {
+                for (BufferId bufferId : config->temporarilyRemovedBuffers()) {
                     if (Client::networkModel()->networkId(bufferId) == config->networkId())
                         buffers << bufferId;
                 }
             }
             else {
-                buffers = BufferIdList::fromSet(config->bufferList().toSet() + config->temporarilyRemovedBuffers());
+                buffers = (toQSet(config->bufferList()) + config->temporarilyRemovedBuffers()).values();
             }
             Client::backlogManager()->checkForBacklog(buffers);
         }
@@ -224,12 +225,12 @@ void BufferViewOverlay::updateHelper()
 
             // we have to apply several filters before we can add a buffer to a category (visible, removed, ...)
             buffers += filterBuffersByConfig(config->bufferList(), config);
-            tempRemovedBuffers += filterBuffersByConfig(config->temporarilyRemovedBuffers().toList(), config);
+            tempRemovedBuffers += filterBuffersByConfig(config->temporarilyRemovedBuffers().values(), config);
             removedBuffers += config->removedBuffers();
         }
 
         // prune the sets from overlap
-        QSet<BufferId> availableBuffers = Client::networkModel()->allBufferIds().toSet();
+        QSet<BufferId> availableBuffers = toQSet(Client::networkModel()->allBufferIds());
 
         buffers.intersect(availableBuffers);
 
--- a/src/client/clientbacklogmanager.cpp
+++ b/src/client/clientbacklogmanager.cpp
@@ -24,6 +24,7 @@
 #include "backlogsettings.h"
 #include "backlogrequester.h"
 #include "client.h"
+#include "util.h"
 
 #include <ctime>
 
@@ -119,8 +120,8 @@ void ClientBacklogManager::requestInitia
 BufferIdList ClientBacklogManager::filterNewBufferIds(const BufferIdList &bufferIds)
 {
     BufferIdList newBuffers;
-    QSet<BufferId> availableBuffers = Client::networkModel()->allBufferIds().toSet();
-    foreach(BufferId bufferId, bufferIds) {
+    QSet<BufferId> availableBuffers = toQSet(Client::networkModel()->allBufferIds());
+    foreach (BufferId bufferId, bufferIds) {
         if (_buffersRequested.contains(bufferId) || !availableBuffers.contains(bufferId))
             continue;
         newBuffers << bufferId;
--- a/src/client/messagefilter.cpp
+++ b/src/client/messagefilter.cpp
@@ -28,6 +28,7 @@
 #include "messagemodel.h"
 #include "networkmodel.h"
 #include "clientignorelistmanager.h"
+#include "util.h"
 
 MessageFilter::MessageFilter(QAbstractItemModel *source, QObject *parent)
     : QSortFilterProxyModel(parent),
@@ -40,7 +41,7 @@ MessageFilter::MessageFilter(QAbstractIt
 
 MessageFilter::MessageFilter(MessageModel *source, const QList<BufferId> &buffers, QObject *parent)
     : QSortFilterProxyModel(parent),
-    _validBuffers(buffers.toSet()),
+    _validBuffers(toQSet(buffers)),
     _messageTypeFilter(0)
 {
     init();
@@ -119,7 +120,7 @@ QString MessageFilter::idString() const
     if (_validBuffers.isEmpty())
         return "*";
 
-    QList<BufferId> bufferIds = _validBuffers.toList();
+    QList<BufferId> bufferIds = _validBuffers.values();
     qSort(bufferIds);
 
     QStringList bufferIdStrings;
--- a/src/common/ircuser.cpp
+++ b/src/common/ircuser.cpp
@@ -353,7 +353,7 @@ void IrcUser::partChannel(const QString
 
 void IrcUser::quit()
 {
-    QList<IrcChannel *> channels = _channels.toList();
+    QList<IrcChannel*> channels = _channels.values();
     _channels.clear();
     foreach(IrcChannel *channel, channels) {
         disconnect(channel, 0, this, 0);
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -21,6 +21,7 @@
 #pragma once
 
 #include <QList>
+#include <QSet>
 #include <QString>
 #include <QVariant>
 
@@ -60,6 +61,16 @@ QVariantList toVariantList(const QList<T
 
 
 template<typename T>
+QSet<T> toQSet(const QList<T>& list)
+{
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
+    return list.toSet();
+#else
+    return {list.begin(), list.end()};
+#endif
+}
+
+template<typename T>
 QList<T> fromVariantList(const QVariantList &variants)
 {
     QList<T> list;
--- a/src/core/corebuffersyncer.cpp
+++ b/src/core/corebuffersyncer.cpp
@@ -24,6 +24,7 @@
 #include "coresession.h"
 #include "corenetwork.h"
 #include "ircchannel.h"
+#include "util.h"
 
 class PurgeEvent : public QEvent
 {
@@ -193,7 +194,7 @@ void CoreBufferSyncer::purgeBufferIds()
         actualBuffers << bufferInfo.bufferId();
     }
 
-    QSet<BufferId> storedIds = lastSeenBufferIds().toSet() + markerLineBufferIds().toSet();
+    QSet<BufferId> storedIds = toQSet(lastSeenBufferIds()) + toQSet(markerLineBufferIds());
     foreach(BufferId bufferId, storedIds) {
         if (!actualBuffers.contains(bufferId)) {
             BufferSyncer::removeBuffer(bufferId);
--- a/src/qtui/chatview.cpp
+++ b/src/qtui/chatview.cpp
@@ -31,6 +31,7 @@
 #include "qtui.h"
 #include "qtuistyle.h"
 #include "clientignorelistmanager.h"
+#include "util.h"
 
 #include "chatline.h"
 
@@ -316,7 +317,7 @@ QSet<ChatLine *> ChatView::visibleChatLi
 
 QList<ChatLine *> ChatView::visibleChatLinesSorted(Qt::ItemSelectionMode mode) const
 {
-    QList<ChatLine *> result = visibleChatLines(mode).toList();
+    QList<ChatLine *> result = visibleChatLines(mode).values();
     qSort(result.begin(), result.end(), chatLinePtrLessThan);
     return result;
 }
--- a/src/qtui/chatviewsearchcontroller.cpp
+++ b/src/qtui/chatviewsearchcontroller.cpp
@@ -128,7 +128,7 @@ void ChatViewSearchController::updateHig
             if (line)
                 chatLines << line;
         }
-        foreach(ChatLine *line, QList<ChatLine *>(chatLines.toList())) {
+        foreach (ChatLine* line, chatLines) {
             updateHighlights(line);
         }
     }
@@ -314,8 +314,7 @@ void ChatViewSearchController::repositio
         if (line)
             chatLines << line;
     }
-    QList<ChatLine *> chatLineList(chatLines.toList());
-    foreach(ChatLine *line, chatLineList) {
+    foreach (ChatLine* line, chatLines) {
         repositionHighlights(line);
     }
 }
--- a/src/qtui/settingspages/chatmonitorsettingspage.cpp
+++ b/src/qtui/settingspages/chatmonitorsettingspage.cpp
@@ -28,6 +28,7 @@
 #include "bufferview.h"
 #include "bufferviewfilter.h"
 #include "chatviewsettings.h"
+#include "util.h"
 
 #include <QVariant>
 
@@ -196,7 +197,7 @@ bool ChatMonitorSettingsPage::testHasCha
     if (_configActive->bufferList().count() != settings["Buffers"].toList().count())
         return true;
 
-    QSet<BufferId> uiBufs = _configActive->bufferList().toSet();
+    QSet<BufferId> uiBufs = toQSet(_configActive->bufferList());
     QSet<BufferId> settingsBufs;
     foreach(QVariant v, settings["Buffers"].toList())
     settingsBufs << v.value<BufferId>();
--- a/src/uisupport/bufferviewfilter.cpp
+++ b/src/uisupport/bufferviewfilter.cpp
@@ -32,6 +32,7 @@
 #include "graphicalui.h"
 #include "networkmodel.h"
 #include "uistyle.h"
+#include "util.h"
 
 
 /*****************************************
@@ -159,7 +160,7 @@ void BufferViewFilter::enableEditMode(bo
         return;
 
     if (enable == false) {
-        addBuffers(QList<BufferId>::fromSet(_toAdd));
+        addBuffers(_toAdd.values());
         QSet<BufferId>::const_iterator iter;
         for (iter = _toTempRemove.constBegin(); iter != _toTempRemove.constEnd(); ++iter) {
             if (config()->temporarilyRemovedBuffers().contains(*iter))