X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferviewfilter.cpp;h=51f8b0e5d3ccb58ac7e05e9ade4fdc878b1c1d8f;hp=fa2935812ae2daaed717b49e5ad99fa595d34711;hb=1066294489c2469323a2813b63ae4653d148bbc7;hpb=e190d576540cf5dfb2e63d33a69662083f3db210 diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index fa293581..51f8b0e5 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -20,8 +20,6 @@ #include "bufferviewfilter.h" -#include - #include "buffermodel.h" #include "client.h" #include "networkmodel.h" @@ -40,6 +38,17 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig * connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(source_rowsInserted(const QModelIndex &, int, int))); setDynamicSortFilter(true); + + loadColors(); +} + +void BufferViewFilter::loadColors() { + UiSettings s("QtUi/Colors"); + _FgColorInactiveActivity = s.value("inactiveActivityFG", QVariant(QColor(Qt::gray))).value(); + _FgColorNoActivity = s.value("noActivityFG", QVariant(QColor(Qt::black))).value(); + _FgColorHighlightActivity = s.value("highlightActivityFG", QVariant(QColor(Qt::magenta))).value(); + _FgColorNewMessageActivity = s.value("newMessageActivityFG", QVariant(QColor(Qt::green))).value(); + _FgColorOtherActivity = s.value("otherActivityFG", QVariant(QColor(Qt::darkGreen))).value(); } void BufferViewFilter::setConfig(BufferViewConfig *config) { @@ -144,9 +153,11 @@ void BufferViewFilter::removeBuffer(const QModelIndex &index) { bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) const { + BufferId bufferId = sourceModel()->data(source_bufferIndex, NetworkModel::BufferIdRole).value(); + Q_ASSERT(bufferId.isValid()); if(!_config) return true; - + if(config()->networkId().isValid() && config()->networkId() != sourceModel()->data(source_bufferIndex, NetworkModel::NetworkIdRole).value()) return false; @@ -157,11 +168,10 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) return false; if(_config->minimumActivity() > source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt()) { - if(!Client::bufferModel()->standardSelectionModel()->isSelected(source_bufferIndex)) + if(bufferId != Client::bufferModel()->standardSelectionModel()->currentIndex().data(NetworkModel::BufferIdRole).value()) return false; } - BufferId bufferId = sourceModel()->data(source_bufferIndex, NetworkModel::BufferIdRole).value(); return _config->bufferList().contains(bufferId); } @@ -184,7 +194,7 @@ bool BufferViewFilter::filterAcceptsRow(int source_row, const QModelIndex &sourc return false; } - if(source_parent == QModelIndex()) + if(!source_parent.isValid()) return filterAcceptNetwork(child); else return filterAcceptBuffer(child); @@ -229,27 +239,19 @@ QVariant BufferViewFilter::data(const QModelIndex &index, int role) const { } QVariant BufferViewFilter::foreground(const QModelIndex &index) const { - UiSettings s("QtUi/Colors"); - QVariant inactiveActivity = s.value("inactiveActivityFG", QVariant(QColor(Qt::gray))); - QVariant noActivity = s.value("noActivityFG", QVariant(QColor(Qt::black))); - QVariant highlightActivity = s.value("highlightActivityFG", QVariant(QColor(Qt::magenta))); - QVariant newMessageActivity = s.value("newMessageActivityFG", QVariant(QColor(Qt::green))); - QVariant otherActivity = s.value("otherActivityFG", QVariant(QColor(Qt::darkGreen))); - if(!index.data(NetworkModel::ItemActiveRole).toBool()) - return inactiveActivity; + return _FgColorInactiveActivity; Buffer::ActivityLevel activity = (Buffer::ActivityLevel)index.data(NetworkModel::BufferActivityRole).toInt(); if(activity & Buffer::Highlight) - return highlightActivity; + return _FgColorHighlightActivity; if(activity & Buffer::NewMessage) - return newMessageActivity; + return _FgColorNewMessageActivity; if(activity & Buffer::OtherActivity) - return otherActivity; - - return noActivity; + return _FgColorOtherActivity; + return _FgColorNoActivity; } void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start, int end) { @@ -259,8 +261,10 @@ void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start, if(!config() || !config()->addNewBuffersAutomatically()) return; + QModelIndex child; for(int row = start; row <= end; row++) { - addBuffer(parent.child(row, 0).data(NetworkModel::BufferIdRole).value()); + child = sourceModel()->index(row, 0, parent); + addBuffer(sourceModel()->data(child, NetworkModel::BufferIdRole).value()); } }