- }
-
- changed |= (addBuffersAutomatically != _addBuffersAutomatically);
- changed |= (hideInactiveBuffers != _hideInactiveBuffers);
- changed |= (allowedBufferTypes != _allowedBufferTypes);
- changed |= (minimumActivity != _minimumActivity);
- changed |= (networkIds != _networkIds);
- changed |= (buffers != _buffers);
- changed |= (removedBuffers != _removedBuffers);
- changed |= (tempRemovedBuffers != _tempRemovedBuffers);
-
- _addBuffersAutomatically = addBuffersAutomatically;
- _hideInactiveBuffers = hideInactiveBuffers;
- _allowedBufferTypes = allowedBufferTypes;
- _minimumActivity = minimumActivity;
- _networkIds = networkIds;
- _buffers = buffers;
- _removedBuffers = removedBuffers;
- _tempRemovedBuffers = tempRemovedBuffers;
-
- if(changed)
- emit hasChanged();
-}
-
-void BufferViewOverlay::customEvent(QEvent *event) {
- if(event->type() == _updateEventId) {
- updateHelper();
+ disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()));
+
+ connect(config, SIGNAL(configChanged()), 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()
+{
+ BufferViewConfig *config = qobject_cast<BufferViewConfig *>(sender());
+ Q_ASSERT(config);
+
+ viewInitialized(config);
+}
+
+
+void BufferViewOverlay::update()
+{
+ if (_aboutToUpdate) {
+ return;
+ }
+ _aboutToUpdate = true;
+ QCoreApplication::postEvent(this, new QEvent((QEvent::Type)_updateEventId));
+}
+
+
+void BufferViewOverlay::updateHelper()
+{
+ if (!_aboutToUpdate)
+ return;
+
+ bool changed = false;
+
+ int allowedBufferTypes = 0;
+ int minimumActivity = -1;
+ QSet<NetworkId> networkIds;
+ QSet<BufferId> buffers;
+ QSet<BufferId> removedBuffers;
+ QSet<BufferId> tempRemovedBuffers;
+
+ if (Client::bufferViewManager()) {
+ BufferViewConfig *config = 0;
+ QSet<int>::const_iterator viewIter;
+ for (viewIter = _bufferViewIds.constBegin(); viewIter != _bufferViewIds.constEnd(); viewIter++) {
+ config = Client::bufferViewManager()->bufferViewConfig(*viewIter);
+ if (!config)
+ continue;
+
+ allowedBufferTypes |= config->allowedBufferTypes();
+ if (minimumActivity == -1 || config->minimumActivity() < minimumActivity)
+ minimumActivity = config->minimumActivity();
+
+ networkIds << config->networkId();
+
+ // 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);
+ removedBuffers += config->removedBuffers();
+ }
+
+ // prune the sets from overlap
+ QSet<BufferId> availableBuffers = Client::networkModel()->allBufferIds().toSet();
+
+ buffers.intersect(availableBuffers);
+
+ tempRemovedBuffers.intersect(availableBuffers);
+ tempRemovedBuffers.subtract(buffers);
+
+ removedBuffers.intersect(availableBuffers);
+ removedBuffers.subtract(tempRemovedBuffers);
+ removedBuffers.subtract(buffers);
+ }
+
+ changed |= (allowedBufferTypes != _allowedBufferTypes);
+ changed |= (minimumActivity != _minimumActivity);
+ changed |= (networkIds != _networkIds);
+ changed |= (buffers != _buffers);
+ changed |= (removedBuffers != _removedBuffers);
+ changed |= (tempRemovedBuffers != _tempRemovedBuffers);
+
+ _allowedBufferTypes = allowedBufferTypes;
+ _minimumActivity = minimumActivity;
+ _networkIds = networkIds;
+ _buffers = buffers;
+ _removedBuffers = removedBuffers;
+ _tempRemovedBuffers = tempRemovedBuffers;
+