X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fbufferviewoverlay.cpp;h=b1938d1120f5ac131a65d1a68587f41fdf78f29a;hb=17492fb6c867296692b782227de660d352545f73;hp=cba8035a7389d7de9a12ef12d99d147e9c00f404;hpb=7fc418e5841a1633f651e08a34ccd2123ba6e0db;p=quassel.git diff --git a/src/client/bufferviewoverlay.cpp b/src/client/bufferviewoverlay.cpp index cba8035a..b1938d11 100644 --- a/src/client/bufferviewoverlay.cpp +++ b/src/client/bufferviewoverlay.cpp @@ -32,6 +32,7 @@ const int BufferViewOverlay::_updateEventId = QEvent::registerEventType(); BufferViewOverlay::BufferViewOverlay(QObject *parent) : QObject(parent), _aboutToUpdate(false), + _uninitializedViewCount(0), _addBuffersAutomatically(false), _hideInactiveBuffers(false), _allowedBufferTypes(0), @@ -50,11 +51,14 @@ void BufferViewOverlay::addView(int viewId) { } _bufferViewIds << viewId; + _uninitializedViewCount++; if(config->isInitialized()) { viewInitialized(config); } else { disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized())); - connect(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); } } @@ -63,10 +67,28 @@ void BufferViewOverlay::removeView(int viewId) { return; _bufferViewIds.remove(viewId); - BufferViewConfig *config = qobject_cast(sender()); + BufferViewConfig *config = Client::bufferViewManager()->bufferViewConfig(viewId); if(config) disconnect(config, 0, this, 0); + + // update initialized State: + bool wasInitialized = isInitialized(); + _uninitializedViewCount = 0; + QSet::iterator viewIter = _bufferViewIds.begin(); + while(viewIter != _bufferViewIds.end()) { + config = Client::bufferViewManager()->bufferViewConfig(*viewIter); + if(!config) { + viewIter = _bufferViewIds.erase(viewIter); + } else { + if(!config->isInitialized()) + _uninitializedViewCount++; + viewIter++; + } + } + update(); + if(!wasInitialized && isInitialized()) + emit initDone(); } void BufferViewOverlay::viewInitialized(BufferViewConfig *config) { @@ -76,20 +98,25 @@ void BufferViewOverlay::viewInitialized(BufferViewConfig *config) { } disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized())); - connect(config, SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(update())); - connect(config, SIGNAL(addNewBuffersAutomaticallySet(bool)), this, SLOT(update())); - connect(config, SIGNAL(sortAlphabeticallySet(bool)), this, SLOT(update())); - connect(config, SIGNAL(hideInactiveBuffersSet(bool)), this, SLOT(update())); - connect(config, SIGNAL(allowedBufferTypesSet(int)), this, SLOT(update())); - connect(config, SIGNAL(minimumActivitySet(int)), this, SLOT(update())); - connect(config, SIGNAL(bufferListSet()), this, SLOT(update())); - connect(config, SIGNAL(bufferAdded(const BufferId &, int)), this, SLOT(update())); - connect(config, SIGNAL(bufferRemoved(const BufferId &)), this, SLOT(update())); - connect(config, SIGNAL(bufferPermanentlyRemoved(const BufferId &)), this, SLOT(update())); + connect(config, SIGNAL(configChanged()), this, SLOT(update())); +// connect(config, SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(update())); +// connect(config, SIGNAL(addNewBuffersAutomaticallySet(bool)), this, SLOT(update())); +// connect(config, SIGNAL(sortAlphabeticallySet(bool)), this, SLOT(update())); +// connect(config, SIGNAL(hideInactiveBuffersSet(bool)), this, SLOT(update())); +// connect(config, SIGNAL(allowedBufferTypesSet(int)), this, SLOT(update())); +// connect(config, SIGNAL(minimumActivitySet(int)), this, SLOT(update())); +// connect(config, SIGNAL(bufferListSet()), this, SLOT(update())); +// connect(config, SIGNAL(bufferAdded(const BufferId &, int)), this, SLOT(update())); +// connect(config, SIGNAL(bufferRemoved(const BufferId &)), this, SLOT(update())); +// connect(config, SIGNAL(bufferPermanentlyRemoved(const BufferId &)), this, SLOT(update())); // check if the view was removed in the meantime... if(_bufferViewIds.contains(config->bufferViewId())) update(); + + _uninitializedViewCount--; + if(isInitialized()) + emit initDone(); } void BufferViewOverlay::viewInitialized() {