#include <QColor>
+#include "buffermodel.h"
#include "client.h"
#include "networkmodel.h"
bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) const {
if(!_config)
return true;
-
+
+ if(config()->networkId().isValid() && config()->networkId() != sourceModel()->data(source_bufferIndex, NetworkModel::NetworkIdRole).value<NetworkId>())
+ return false;
+
if(!(_config->allowedBufferTypes() & (BufferInfo::Type)source_bufferIndex.data(NetworkModel::BufferTypeRole).toInt()))
return false;
if(_config->hideInactiveBuffers() && !source_bufferIndex.data(NetworkModel::ItemActiveRole).toBool())
return false;
- // FIXME: this can result in bad loops :(
- // if(_config->minimumActivity() > source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt())
- // return false;
+ if(_config->minimumActivity() > source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt()) {
+ if(!Client::bufferModel()->standardSelectionModel()->isSelected(source_bufferIndex))
+ return false;
+ }
BufferId bufferId = sourceModel()->data(source_bufferIndex, NetworkModel::BufferIdRole).value<BufferId>();
return _config->bufferList().contains(bufferId);
if(config()) {
return config()->bufferList().indexOf(leftBufferId) < config()->bufferList().indexOf(rightBufferId);
} else
- return leftBufferId < rightBufferId;
+ return bufferIdLessThan(leftBufferId, rightBufferId);
}
bool BufferViewFilter::networkLessThan(const QModelIndex &source_left, const QModelIndex &source_right) const {
if(leftType != rightType)
return leftType < rightType;
else
- return Client::networkModel()->data(leftIndex, Qt::DisplayRole).toString() < Client::networkModel()->data(rightIndex, Qt::DisplayRole).toString();
+ return QString::compare(Client::networkModel()->data(leftIndex, Qt::DisplayRole).toString(), Client::networkModel()->data(rightIndex, Qt::DisplayRole).toString(), Qt::CaseInsensitive) < 0;
}