uisupport: Provide helpers for dealing with widget changes
[quassel.git] / src / client / bufferviewoverlay.cpp
index 8356022..02e5702 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2013 by the Quassel Project                        *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 const int BufferViewOverlay::_updateEventId = QEvent::registerEventType();
 
 BufferViewOverlay::BufferViewOverlay(QObject *parent)
-    : QObject(parent),
-    _aboutToUpdate(false),
-    _uninitializedViewCount(0),
-    _allowedBufferTypes(0),
-    _minimumActivity(0)
+    : QObject(parent)
 {
 }
 
@@ -70,7 +66,7 @@ void BufferViewOverlay::restore()
     currentIds += CoreAccountSettings().bufferViewOverlay();
 
     QSet<int>::const_iterator iter;
-    for (iter = currentIds.constBegin(); iter != currentIds.constEnd(); iter++) {
+    for (iter = currentIds.constBegin(); iter != currentIds.constEnd(); ++iter) {
         addView(*iter);
     }
 }
@@ -113,10 +109,9 @@ void BufferViewOverlay::addView(int viewId)
         }
     }
     else {
-        disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()));
         // we use a queued connection here since manipulating the connection list of a sending object
         // doesn't seem to be such a good idea while executing a connected slots.
-        connect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()), Qt::QueuedConnection);
+        connect(config, &BufferViewConfig::initDone, this, selectOverload<>(&BufferViewOverlay::viewInitialized), Qt::QueuedConnection);
     }
     save();
 }
@@ -130,7 +125,7 @@ void BufferViewOverlay::removeView(int viewId)
     _bufferViewIds.remove(viewId);
     BufferViewConfig *config = Client::bufferViewManager()->bufferViewConfig(viewId);
     if (config)
-        disconnect(config, 0, this, 0);
+        disconnect(config, nullptr, this, nullptr);
 
     // update initialized State:
     bool wasInitialized = isInitialized();
@@ -144,7 +139,7 @@ void BufferViewOverlay::removeView(int viewId)
         else {
             if (!config->isInitialized())
                 _uninitializedViewCount++;
-            viewIter++;
+            ++viewIter;
         }
     }
 
@@ -161,9 +156,7 @@ void BufferViewOverlay::viewInitialized(BufferViewConfig *config)
         qWarning() << "BufferViewOverlay::viewInitialized() received invalid view!";
         return;
     }
-    disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()));
-
-    connect(config, SIGNAL(configChanged()), this, SLOT(update()));
+    connect(config, &BufferViewConfig::configChanged, this, &BufferViewOverlay::update);
 
     // check if the view was removed in the meantime...
     if (_bufferViewIds.contains(config->bufferViewId()))
@@ -177,7 +170,7 @@ void BufferViewOverlay::viewInitialized(BufferViewConfig *config)
 
 void BufferViewOverlay::viewInitialized()
 {
-    BufferViewConfig *config = qobject_cast<BufferViewConfig *>(sender());
+    auto *config = qobject_cast<BufferViewConfig *>(sender());
     Q_ASSERT(config);
 
     viewInitialized(config);
@@ -209,9 +202,9 @@ void BufferViewOverlay::updateHelper()
     QSet<BufferId> tempRemovedBuffers;
 
     if (Client::bufferViewManager()) {
-        BufferViewConfig *config = 0;
+        BufferViewConfig *config = nullptr;
         QSet<int>::const_iterator viewIter;
-        for (viewIter = _bufferViewIds.constBegin(); viewIter != _bufferViewIds.constEnd(); viewIter++) {
+        for (viewIter = _bufferViewIds.constBegin(); viewIter != _bufferViewIds.constEnd(); ++viewIter) {
             config = Client::bufferViewManager()->bufferViewConfig(*viewIter);
             if (!config)
                 continue;