*****************************************/
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"))
- connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(source_rowsInserted(const QModelIndex &, int, int)));
-
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];
- if(!(config()->allowedBufferTypes() & (BufferInfo::Type)source_bufferIndex.data(NetworkModel::BufferTypeRole).toInt()))
+ if(!config()->bufferList().contains(bufferId)) {
+ // 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)...
+ || (config()->temporarilyRemovedBuffers().contains(bufferId) && activityLevel > BufferInfo::OtherActivity))) { // or was just temporarily hidden and has a new message waiting for us.
+ addBuffer(bufferId);
+ }
+ // note: adding the buffer to the valid list does not temper with the following filters ("show only channels" and stuff)
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();
+
- if(activity & Buffer::Highlight)
+ return QVariant();
+}
+
+QVariant BufferViewFilter::foreground(const QModelIndex &index) const {
+ BufferInfo::ActivityLevel activity = (BufferInfo::ActivityLevel)index.data(NetworkModel::BufferActivityRole).toInt();
+
+ if(activity & BufferInfo::Highlight)
- return _FgColorNoActivity;
-}
-
-void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start, int end) {
- if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType)
- return;
-
- if(!config() || !config()->addNewBuffersAutomatically())
- return;
+ if(!index.data(NetworkModel::ItemActiveRole).toBool() || index.data(NetworkModel::UserAwayRole).toBool())
+ return _FgColorInactiveActivity;
- QModelIndex child;
- for(int row = start; row <= end; row++) {
- child = sourceModel()->index(row, 0, parent);
- addBuffer(sourceModel()->data(child, NetworkModel::BufferIdRole).value<BufferId>());
- }
+ return _FgColorNoActivity;
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);