X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fbufferviewoverlay.cpp;h=b1938d1120f5ac131a65d1a68587f41fdf78f29a;hp=66dec133f941989e783761f613b30a983f8a3cd9;hb=f6b9eeda207d42c99fc3e9085631722cf2ec83dc;hpb=27b9b5de238731138578ddef6c1d7de968b7ace7 diff --git a/src/client/bufferviewoverlay.cpp b/src/client/bufferviewoverlay.cpp index 66dec133..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() { @@ -108,6 +135,9 @@ void BufferViewOverlay::update() { } void BufferViewOverlay::updateHelper() { + if(!_aboutToUpdate) + return; + bool changed = false; bool addBuffersAutomatically = false; @@ -162,6 +192,9 @@ void BufferViewOverlay::updateHelper() { if(minimumActivity == -1 || config->minimumActivity() < minimumActivity) minimumActivity = config->minimumActivity(); } + QSet availableBuffers = Client::networkModel()->allBufferIds().toSet(); + buffers.intersect(availableBuffers); + tempRemovedBuffers.intersect(availableBuffers); } changed |= (addBuffersAutomatically != _addBuffersAutomatically); @@ -182,6 +215,8 @@ void BufferViewOverlay::updateHelper() { _removedBuffers = removedBuffers; _tempRemovedBuffers = tempRemovedBuffers; + _aboutToUpdate = false; + if(changed) emit hasChanged(); } @@ -189,6 +224,50 @@ void BufferViewOverlay::updateHelper() { void BufferViewOverlay::customEvent(QEvent *event) { if(event->type() == _updateEventId) { updateHelper(); - _aboutToUpdate = false; } } + +bool BufferViewOverlay::allNetworks() { + updateHelper(); + return _networkIds.contains(NetworkId()); +} + +const QSet &BufferViewOverlay::networkIds() { + updateHelper(); + return _networkIds; +} + +const QSet &BufferViewOverlay::bufferIds() { + updateHelper(); + return _buffers; +} + +const QSet &BufferViewOverlay::removedBufferIds() { + updateHelper(); + return _removedBuffers; +} + +const QSet &BufferViewOverlay::tempRemovedBufferIds() { + updateHelper(); + return _tempRemovedBuffers; +} + +bool BufferViewOverlay::addBuffersAutomatically() { + updateHelper(); + return _addBuffersAutomatically; +} + +bool BufferViewOverlay::hideInactiveBuffers() { + updateHelper(); + return _hideInactiveBuffers; +} + +int BufferViewOverlay::allowedBufferTypes() { + updateHelper(); + return _allowedBufferTypes; +} + +int BufferViewOverlay::minimumActivity() { + updateHelper(); + return _minimumActivity; +}