X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Fbufferviewfilter.cpp;h=81f03d33344a02271d76f51b465d94c155469caf;hb=b82e9603ab7ce1164e8f550132f0c649653ad8ab;hp=4c5d4a9c6e3673472bceee45bec89d4a50f764f6;hpb=30cc5367bf38d8720e55ece5cab218c4b52e0dbf;p=quassel.git diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 4c5d4a9c..81f03d33 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2016 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -137,6 +137,14 @@ QList BufferViewFilter::actions(const QModelIndex &index) return actionList; } +void BufferViewFilter::setFilterString(const QString string) +{ + beginResetModel(); + _filterString = string; + endResetModel(); + enableEditMode(!string.isEmpty()); +} + void BufferViewFilter::enableEditMode(bool enable) { @@ -346,6 +354,16 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) return false; } + if (!_filterString.isEmpty()) { + const BufferInfo info = qvariant_cast(Client::bufferModel()->data(source_bufferIndex, NetworkModel::BufferInfoRole)); + QString name = info.bufferName(); + if (name.contains(_filterString)) { + return true; + } else { + 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())