: QObject(parent),
_aboutToUpdate(false),
_uninitializedViewCount(0),
- _addBuffersAutomatically(false),
- _hideInactiveBuffers(false),
_allowedBufferTypes(0),
_minimumActivity(0)
{
}
disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()));
- connect(config, SIGNAL(configChanged()), 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()));
bool changed = false;
- bool addBuffersAutomatically = false;
- bool hideInactiveBuffers = true;
int allowedBufferTypes = 0;
int minimumActivity = -1;
QSet<NetworkId> networkIds;
if(!config)
continue;
- networkIds << config->networkId();
- if(config->networkId().isValid()) {
- NetworkId networkId = config->networkId();
- // we have to filter out all the buffers that don't belong to this net... :/
- QSet<BufferId> bufferIds;
- foreach(BufferId bufferId, config->bufferList()) {
- if(Client::networkModel()->networkId(bufferId) == networkId)
- bufferIds << bufferId;
- }
- buffers += bufferIds;
-
- bufferIds.clear();
- foreach(BufferId bufferId, config->temporarilyRemovedBuffers()) {
- if(Client::networkModel()->networkId(bufferId) == networkId)
- bufferIds << bufferId;
- }
- tempRemovedBuffers += bufferIds;
- } else {
- buffers += config->bufferList().toSet();
- tempRemovedBuffers += config->temporarilyRemovedBuffers();
- }
-
- // in the overlay a buffer is removed it is removed from all views
- if(removedBuffers.isEmpty())
- removedBuffers = config->removedBuffers();
- else
- removedBuffers.intersect(config->removedBuffers());
-
-
- addBuffersAutomatically |= config->addNewBuffersAutomatically();
- hideInactiveBuffers &= config->hideInactiveBuffers();
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 |= (addBuffersAutomatically != _addBuffersAutomatically);
- changed |= (hideInactiveBuffers != _hideInactiveBuffers);
changed |= (allowedBufferTypes != _allowedBufferTypes);
changed |= (minimumActivity != _minimumActivity);
changed |= (networkIds != _networkIds);
changed |= (removedBuffers != _removedBuffers);
changed |= (tempRemovedBuffers != _tempRemovedBuffers);
- _addBuffersAutomatically = addBuffersAutomatically;
- _hideInactiveBuffers = hideInactiveBuffers;
_allowedBufferTypes = allowedBufferTypes;
_minimumActivity = minimumActivity;
_networkIds = networkIds;
emit hasChanged();
}
+QSet<BufferId> BufferViewOverlay::filterBuffersByConfig(const QList<BufferId> &buffers, const BufferViewConfig *config) {
+ Q_ASSERT(config);
+
+ QSet<BufferId> bufferIds;
+ BufferInfo bufferInfo;
+ foreach(BufferId bufferId, buffers) {
+ bufferInfo = Client::networkModel()->bufferInfo(bufferId);
+ if(!(bufferInfo.type() & config->allowedBufferTypes()))
+ continue;
+ if(config->networkId().isValid() && bufferInfo.networkId() != config->networkId())
+ continue;
+ bufferIds << bufferId;
+ }
+
+ return bufferIds;
+}
+
+
void BufferViewOverlay::customEvent(QEvent *event) {
if(event->type() == _updateEventId) {
updateHelper();
return _tempRemovedBuffers;
}
-bool BufferViewOverlay::addBuffersAutomatically() {
- updateHelper();
- return _addBuffersAutomatically;
-}
-
-bool BufferViewOverlay::hideInactiveBuffers() {
- updateHelper();
- return _hideInactiveBuffers;
-}
-
int BufferViewOverlay::allowedBufferTypes() {
updateHelper();
return _allowedBufferTypes;