X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fnickviewfilter.cpp;h=746385221a0eb2940d52b4f94080aba1736c6fab;hp=0fd884592c458213edaf8e2af85744909122e924;hb=c64a887d0f05222590299fb2bb8d56fa9fadb16d;hpb=2a92703a6941fb7aa85f5876c51b360878475f01 diff --git a/src/uisupport/nickviewfilter.cpp b/src/uisupport/nickviewfilter.cpp index 0fd88459..74638522 100644 --- a/src/uisupport/nickviewfilter.cpp +++ b/src/uisupport/nickviewfilter.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-2012 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,53 +15,51 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "nickviewfilter.h" + +#include "buffersettings.h" +#include "graphicalui.h" +#include "iconloader.h" #include "networkmodel.h" -#include "uisettings.h" +#include "uistyle.h" /****************************************************************************************** * NickViewFilter ******************************************************************************************/ NickViewFilter::NickViewFilter(const BufferId &bufferId, NetworkModel *parent) - : QSortFilterProxyModel(parent), + : QSortFilterProxyModel(parent), _bufferId(bufferId) { - setSourceModel(parent); - setDynamicSortFilter(true); - setSortCaseSensitivity(Qt::CaseInsensitive); - setSortRole(TreeModel::SortRole); - loadColors(); + setSourceModel(parent); + setDynamicSortFilter(true); + setSortCaseSensitivity(Qt::CaseInsensitive); + setSortRole(TreeModel::SortRole); } -void NickViewFilter::loadColors() { - UiSettings s("QtUiStyle/Colors"); - _FgOnlineStatus = s.value("onlineStatusFG", QVariant(QColor(Qt::black))).value(); - _FgAwayStatus = s.value("awayStatusFG", QVariant(QColor(Qt::gray))).value(); - // FIXME: use the style interface instead of qsettings -} -QVariant NickViewFilter::data(const QModelIndex &index, int role) const { - if(role == Qt::ForegroundRole) - return foreground(index); - else - return QSortFilterProxyModel::data(index, role); -} +bool NickViewFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + // root node, networkindexes, the bufferindex of the buffer this filter is active for and it's children are accepted + if (!source_parent.isValid()) + return true; -QVariant NickViewFilter::foreground(const QModelIndex &index) const { - if(!index.data(NetworkModel::ItemActiveRole).toBool()) - return _FgAwayStatus; - return _FgOnlineStatus; + QModelIndex source_child = source_parent.child(source_row, 0); + return (sourceModel()->data(source_child, NetworkModel::BufferIdRole).value() == _bufferId); } -bool NickViewFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { - // root node, networkindexes, the bufferindex of the buffer this filter is active for and it's childs are accepted - if(!source_parent.isValid()) - return true; - - QModelIndex source_child = source_parent.child(source_row, 0); - return (sourceModel()->data(source_child, NetworkModel::BufferIdRole).value() == _bufferId); +QVariant NickViewFilter::data(const QModelIndex &index, int role) const +{ + switch (role) { + case Qt::FontRole: + case Qt::ForegroundRole: + case Qt::BackgroundRole: + case Qt::DecorationRole: + return GraphicalUi::uiStyle()->nickViewItemData(mapToSource(index), role); + default: + return QSortFilterProxyModel::data(index, role); + } }