*****************************************/
BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig *config)
: QSortFilterProxyModel(model),
*****************************************/
BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig *config)
: QSortFilterProxyModel(model),
+ _config(0),
+ _sortOrder(Qt::AscendingOrder),
+ _userOfflineIcon(SmallIcon("user-offline")),
+ _userAwayIcon(SmallIcon("user-away")),
+ _userOnlineIcon(SmallIcon("user-online"))
setDynamicSortFilter(true);
loadColors();
connect(this, SIGNAL(_dataChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
setDynamicSortFilter(true);
loadColors();
connect(this, SIGNAL(_dataChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
_FgColorInactiveActivity = s.value("inactiveActivityFG", QVariant(QColor(Qt::gray))).value<QColor>();
_FgColorNoActivity = s.value("noActivityFG", QVariant(QColor(Qt::black))).value<QColor>();
_FgColorHighlightActivity = s.value("highlightActivityFG", QVariant(QColor(Qt::magenta))).value<QColor>();
_FgColorInactiveActivity = s.value("inactiveActivityFG", QVariant(QColor(Qt::gray))).value<QColor>();
_FgColorNoActivity = s.value("noActivityFG", QVariant(QColor(Qt::black))).value<QColor>();
_FgColorHighlightActivity = s.value("highlightActivityFG", QVariant(QColor(Qt::magenta))).value<QColor>();
if(_config) {
disconnect(_config, 0, this, 0);
}
_config = config;
if(_config) {
disconnect(_config, 0, this, 0);
}
_config = config;
connect(config(), SIGNAL(bufferViewNameSet(const QString &)), this, SLOT(invalidate()));
connect(config(), SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(invalidate()));
connect(config(), SIGNAL(addNewBuffersAutomaticallySet(bool)), this, SLOT(invalidate()));
connect(config(), SIGNAL(bufferViewNameSet(const QString &)), this, SLOT(invalidate()));
connect(config(), SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(invalidate()));
connect(config(), SIGNAL(addNewBuffersAutomaticallySet(bool)), this, SLOT(invalidate()));
connect(config(), SIGNAL(bufferAdded(const BufferId &, int)), this, SLOT(invalidate()));
connect(config(), SIGNAL(bufferMoved(const BufferId &, int)), this, SLOT(invalidate()));
connect(config(), SIGNAL(bufferRemoved(const BufferId &)), this, SLOT(invalidate()));
connect(config(), SIGNAL(bufferAdded(const BufferId &, int)), this, SLOT(invalidate()));
connect(config(), SIGNAL(bufferMoved(const BufferId &, int)), this, SLOT(invalidate()));
connect(config(), SIGNAL(bufferRemoved(const BufferId &)), this, SLOT(invalidate()));
disconnect(config(), SIGNAL(initDone()), this, SLOT(configInitialized()));
invalidate();
disconnect(config(), SIGNAL(initDone()), this, SLOT(configInitialized()));
invalidate();
}
Qt::ItemFlags BufferViewFilter::flags(const QModelIndex &index) const {
Qt::ItemFlags flags = mapToSource(index).flags();
}
Qt::ItemFlags BufferViewFilter::flags(const QModelIndex &index) const {
Qt::ItemFlags flags = mapToSource(index).flags();
if(row < rowCount(parent)) {
BufferId beforeBufferId = parent.child(row, 0).data(NetworkModel::BufferIdRole).value<BufferId>();
pos = config()->bufferList().indexOf(beforeBufferId);
if(row < rowCount(parent)) {
BufferId beforeBufferId = parent.child(row, 0).data(NetworkModel::BufferIdRole).value<BufferId>();
pos = config()->bufferList().indexOf(beforeBufferId);
void BufferViewFilter::addBuffer(const BufferId &bufferId) const {
if(!config() || config()->bufferList().contains(bufferId))
return;
void BufferViewFilter::addBuffer(const BufferId &bufferId) const {
if(!config() || config()->bufferList().contains(bufferId))
return;
lt = bufferIdLessThan(bufferId, config()->bufferList()[i]);
else
lt = bufferId < config()->bufferList()[i];
lt = bufferIdLessThan(bufferId, config()->bufferList()[i]);
else
lt = bufferId < config()->bufferList()[i];
Q_ASSERT(bufferId.isValid());
int activityLevel = source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt();
Q_ASSERT(bufferId.isValid());
int activityLevel = source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt();
// add the buffer if...
if(config()->isInitialized() && !config()->removedBuffers().contains(bufferId) // it hasn't been manually removed and either
&& ((config()->addNewBuffersAutomatically() && !config()->temporarilyRemovedBuffers().contains(bufferId)) // is totally unknown to us (a new buffer)...
// add the buffer if...
if(config()->isInitialized() && !config()->removedBuffers().contains(bufferId) // it hasn't been manually removed and either
&& ((config()->addNewBuffersAutomatically() && !config()->temporarilyRemovedBuffers().contains(bufferId)) // is totally unknown to us (a new buffer)...
- if(config()->hideInactiveBuffers() && !source_bufferIndex.data(NetworkModel::ItemActiveRole).toBool())
+ // the following dynamic filters may not trigger if the buffer is currently selected.
+ if(bufferId == Client::bufferModel()->standardSelectionModel()->currentIndex().data(NetworkModel::BufferIdRole).value<BufferId>())
+ return true;
+
+ if(config()->hideInactiveBuffers() && !source_bufferIndex.data(NetworkModel::ItemActiveRole).toBool() && activityLevel <= BufferInfo::OtherActivity)
}
}
bool BufferViewFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
QModelIndex child = sourceModel()->index(source_row, 0, source_parent);
}
}
bool BufferViewFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
QModelIndex child = sourceModel()->index(source_row, 0, source_parent);
switch(itemType) {
case NetworkModel::NetworkItemType:
return networkLessThan(source_left, source_right);
case NetworkModel::BufferItemType:
return bufferLessThan(source_left, source_right);
default:
switch(itemType) {
case NetworkModel::NetworkItemType:
return networkLessThan(source_left, source_right);
case NetworkModel::BufferItemType:
return bufferLessThan(source_left, source_right);
default:
- BufferId leftBufferId = sourceModel()->data(source_left, NetworkModel::BufferIdRole).value<BufferId>();
- BufferId rightBufferId = sourceModel()->data(source_right, NetworkModel::BufferIdRole).value<BufferId>();
+ BufferId leftBufferId = source_left.data(NetworkModel::BufferIdRole).value<BufferId>();
+ BufferId rightBufferId = source_right.data(NetworkModel::BufferIdRole).value<BufferId>();
- NetworkId leftNetworkId = sourceModel()->data(source_left, NetworkModel::NetworkIdRole).value<NetworkId>();
- NetworkId rightNetworkId = sourceModel()->data(source_right, NetworkModel::NetworkIdRole).value<NetworkId>();
+ NetworkId leftNetworkId = source_left.data(NetworkModel::NetworkIdRole).value<NetworkId>();
+ NetworkId rightNetworkId = source_right.data(NetworkModel::NetworkIdRole).value<NetworkId>();
if(config() && config()->sortAlphabetically())
return QSortFilterProxyModel::lessThan(source_left, source_right);
if(config() && config()->sortAlphabetically())
return QSortFilterProxyModel::lessThan(source_left, source_right);
-QVariant BufferViewFilter::foreground(const QModelIndex &index) const {
+QVariant BufferViewFilter::icon(const QModelIndex &index) const {
+ if(!_showUserStateIcons || config() && config()->disableDecoration())
+ return QVariant();
+
+ if(index.column() != 0)
+ return QVariant();
+
+ if(index.data(NetworkModel::BufferTypeRole).toInt() != BufferInfo::QueryBuffer)
+ return QVariant();
+
- if(activity & Buffer::Highlight)
+ return QVariant();
+}
+
+QVariant BufferViewFilter::foreground(const QModelIndex &index) const {
+ if(config() && config()->disableDecoration())
+ return _FgColorNoActivity;
+
+ BufferInfo::ActivityLevel activity = (BufferInfo::ActivityLevel)index.data(NetworkModel::BufferActivityRole).toInt();
+
+ if(activity & BufferInfo::Highlight)
CheckRemovalEvent *removalEvent = static_cast<CheckRemovalEvent *>(event);
checkItemForRemoval(removalEvent->index);
CheckRemovalEvent *removalEvent = static_cast<CheckRemovalEvent *>(event);
checkItemForRemoval(removalEvent->index);
QModelIndex leftIndex = Client::networkModel()->bufferIndex(left);
QModelIndex rightIndex = Client::networkModel()->bufferIndex(right);
QModelIndex leftIndex = Client::networkModel()->bufferIndex(left);
QModelIndex rightIndex = Client::networkModel()->bufferIndex(right);
- int leftType = Client::networkModel()->data(leftIndex, NetworkModel::BufferTypeRole).toInt();
- int rightType = Client::networkModel()->data(rightIndex, NetworkModel::BufferTypeRole).toInt();
+ int leftType = leftIndex.data(NetworkModel::BufferTypeRole).toInt();
+ int rightType = rightIndex.data(NetworkModel::BufferTypeRole).toInt();
- return QString::compare(Client::networkModel()->data(leftIndex, Qt::DisplayRole).toString(), Client::networkModel()->data(rightIndex, Qt::DisplayRole).toString(), Qt::CaseInsensitive) < 0;
+ return QString::compare(leftIndex.data(Qt::DisplayRole).toString(), rightIndex.data(Qt::DisplayRole).toString(), Qt::CaseInsensitive) < 0;