X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferviewfilter.cpp;h=6bd65653e5f5757d2d15fd9cec1a3c8ef60bb238;hp=5b9d684573c208d34bd207ec085a061c3aa8a6ba;hb=6daace85c6e97db23d0ab946f59479db20defb63;hpb=deba2421d87cbdea05c925cb3425042559d6ba21 diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 5b9d6845..6bd65653 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -47,8 +47,9 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig * : QSortFilterProxyModel(model), _config(0), _sortOrder(Qt::AscendingOrder), + _showServerQueries(false), _editMode(false), - _enableEditMode(tr("Show / Hide buffers"), this) + _enableEditMode(tr("Show / Hide Chats"), this) { setConfig(config); setSourceModel(model); @@ -62,6 +63,9 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig * _enableEditMode.setChecked(_editMode); connect(&_enableEditMode, SIGNAL(toggled(bool)), this, SLOT(enableEditMode(bool))); + BufferSettings defaultSettings; + defaultSettings.notify("ServerNoticesTarget", this, SLOT(showServerQueriesChanged())); + showServerQueriesChanged(); } void BufferViewFilter::setConfig(BufferViewConfig *config) { @@ -83,7 +87,9 @@ void BufferViewFilter::setConfig(BufferViewConfig *config) { if(config->isInitialized()) { configInitialized(); } else { - connect(config, SIGNAL(initDone()), this, SLOT(configInitialized())); + // we use a queued connection here since manipulating the connection list of a sending object + // doesn't seem to be such a good idea while executing a connected slots. + connect(config, SIGNAL(initDone()), this, SLOT(configInitialized()), Qt::QueuedConnection); invalidate(); } } @@ -92,18 +98,19 @@ void BufferViewFilter::configInitialized() { if(!config()) return; - 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(sortAlphabeticallySet(bool)), this, SLOT(invalidate())); - connect(config(), SIGNAL(hideInactiveBuffersSet(bool)), this, SLOT(invalidate())); - connect(config(), SIGNAL(allowedBufferTypesSet(int)), this, SLOT(invalidate())); - connect(config(), SIGNAL(minimumActivitySet(int)), this, SLOT(invalidate())); - connect(config(), SIGNAL(bufferListSet()), 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(bufferPermanentlyRemoved(const BufferId &)), this, SLOT(invalidate())); +// connect(config(), SIGNAL(bufferViewNameSet(const QString &)), this, SLOT(invalidate())); + connect(config(), SIGNAL(configChanged()), this, SLOT(invalidate())); +// connect(config(), SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(invalidate())); +// connect(config(), SIGNAL(addNewBuffersAutomaticallySet(bool)), this, SLOT(invalidate())); +// connect(config(), SIGNAL(sortAlphabeticallySet(bool)), this, SLOT(invalidate())); +// connect(config(), SIGNAL(hideInactiveBuffersSet(bool)), this, SLOT(invalidate())); +// connect(config(), SIGNAL(allowedBufferTypesSet(int)), this, SLOT(invalidate())); +// connect(config(), SIGNAL(minimumActivitySet(int)), this, SLOT(invalidate())); +// connect(config(), SIGNAL(bufferListSet()), 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(bufferPermanentlyRemoved(const BufferId &)), this, SLOT(invalidate())); disconnect(config(), SIGNAL(initDone()), this, SLOT(configInitialized())); @@ -113,6 +120,16 @@ void BufferViewFilter::configInitialized() { emit configChanged(); } +void BufferViewFilter::showServerQueriesChanged() { + BufferSettings bufferSettings; + + bool showQueries = (bufferSettings.serverNoticesTarget() & BufferSettings::DefaultBuffer); + if(_showServerQueries != showQueries) { + _showServerQueries = showQueries; + invalidate(); + } +} + QList BufferViewFilter::actions(const QModelIndex &index) { Q_UNUSED(index) QList actionList; @@ -305,9 +322,14 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) int allowedBufferTypes = config()->allowedBufferTypes(); if(!config()->networkId().isValid()) allowedBufferTypes &= ~BufferInfo::StatusBuffer; - if(!(allowedBufferTypes & sourceModel()->data(source_bufferIndex, NetworkModel::BufferTypeRole).toInt())) + int bufferType = sourceModel()->data(source_bufferIndex, NetworkModel::BufferTypeRole).toInt(); + if(!(allowedBufferTypes & bufferType)) return false; + if(bufferType & BufferInfo::QueryBuffer && !_showServerQueries && sourceModel()->data(source_bufferIndex, Qt::DisplayRole).toString().contains('.')) { + return false; + } + // the following dynamic filters may not trigger if the buffer is currently selected. QModelIndex currentIndex = Client::bufferModel()->standardSelectionModel()->currentIndex(); if(bufferId == Client::bufferModel()->data(currentIndex, NetworkModel::BufferIdRole).value()) @@ -394,6 +416,8 @@ QVariant BufferViewFilter::data(const QModelIndex &index, int role) const { case Qt::ForegroundRole: case Qt::BackgroundRole: case Qt::DecorationRole: + if((config() && config()->disableDecoration())) + return QVariant(); return GraphicalUi::uiStyle()->bufferViewItemData(mapToSource(index), role); case Qt::CheckStateRole: return checkedState(index); @@ -506,3 +530,4 @@ bool BufferViewFilter::bufferIdLessThan(const BufferId &left, const BufferId &ri return QString::compare(Client::networkModel()->data(leftIndex, Qt::DisplayRole).toString(), Client::networkModel()->data(rightIndex, Qt::DisplayRole).toString(), Qt::CaseInsensitive) < 0; } +