*****************************************/
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];
// 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()->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()->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())
+ // 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);
case NetworkModel::BufferItemType:
return bufferLessThan(source_left, source_right);
default:
case NetworkModel::BufferItemType:
return bufferLessThan(source_left, source_right);
default:
-QVariant BufferViewFilter::foreground(const QModelIndex &index) const {
+QVariant BufferViewFilter::icon(const QModelIndex &index) const {
+ if(!_showUserStateIcons)
+ return QVariant();
+
+ if(index.column() != 0)
+ return QVariant();
+
+ if(index.data(NetworkModel::BufferTypeRole).toInt() != BufferInfo::QueryBuffer)
+ return QVariant();
+
- Buffer::ActivityLevel activity = (Buffer::ActivityLevel)index.data(NetworkModel::BufferActivityRole).toInt();
+ if(index.data(NetworkModel::UserAwayRole).toBool())
+ return _userAwayIcon;
+ else
+ return _userOnlineIcon;
+
+ return QVariant();
+}
+
+QVariant BufferViewFilter::foreground(const QModelIndex &index) const {
+ BufferInfo::ActivityLevel activity = (BufferInfo::ActivityLevel)index.data(NetworkModel::BufferActivityRole).toInt();
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);