From 1066294489c2469323a2813b63ae4653d148bbc7 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Tue, 29 Apr 2008 20:11:50 +0000 Subject: [PATCH 1/1] buffer_switching_performance++ --- src/client/networkmodel.cpp | 13 +++++----- src/client/networkmodel.h | 2 +- src/uisupport/abstractbuffercontainer.cpp | 6 ++--- src/uisupport/bufferviewfilter.cpp | 31 ++++++++++++----------- src/uisupport/bufferviewfilter.h | 8 ++++++ version.inc | 4 +-- 6 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index bec3edf1..940feb7f 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -33,7 +33,6 @@ #include "util.h" // get rid of this (needed for isChannelName) - /***************************************** * Fancy Buffer Items *****************************************/ @@ -70,10 +69,11 @@ bool BufferItem::isActive() const { return qobject_cast(parent())->isActive(); } -bool BufferItem::setActivityLevel(Buffer::ActivityLevel level) { - _activity = level; - emit dataChanged(); - return true; +void BufferItem::setActivityLevel(Buffer::ActivityLevel level) { + if(_activity != level) { + _activity = level; + emit dataChanged(); + } } void BufferItem::updateActivityLevel(Buffer::ActivityLevel level) { @@ -107,7 +107,8 @@ QVariant BufferItem::data(int column, int role) const { bool BufferItem::setData(int column, const QVariant &value, int role) { switch(role) { case NetworkModel::BufferActivityRole: - return setActivityLevel((Buffer::ActivityLevel)value.toInt()); + setActivityLevel((Buffer::ActivityLevel)value.toInt()); + return true; default: return PropertyMapItem::setData(column, value, role); } diff --git a/src/client/networkmodel.h b/src/client/networkmodel.h index 634c402e..2a342a69 100644 --- a/src/client/networkmodel.h +++ b/src/client/networkmodel.h @@ -72,7 +72,7 @@ public: bool isActive() const; inline Buffer::ActivityLevel activityLevel() const { return _activity; } - bool setActivityLevel(Buffer::ActivityLevel level); + void setActivityLevel(Buffer::ActivityLevel level); void updateActivityLevel(Buffer::ActivityLevel level); void setLastMsgInsert(QDateTime msgDate); diff --git a/src/uisupport/abstractbuffercontainer.cpp b/src/uisupport/abstractbuffercontainer.cpp index fd2b9da9..f3ffbf84 100644 --- a/src/uisupport/abstractbuffercontainer.cpp +++ b/src/uisupport/abstractbuffercontainer.cpp @@ -23,13 +23,13 @@ #include "client.h" #include "networkmodel.h" -AbstractBufferContainer::AbstractBufferContainer(QWidget *parent) : AbstractItemView(parent), _currentBuffer(0) +AbstractBufferContainer::AbstractBufferContainer(QWidget *parent) + : AbstractItemView(parent), + _currentBuffer(0) { - } AbstractBufferContainer::~AbstractBufferContainer() { - } diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 9ddb6f00..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) { @@ -230,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) { diff --git a/src/uisupport/bufferviewfilter.h b/src/uisupport/bufferviewfilter.h index 07fec1bf..4715f11a 100644 --- a/src/uisupport/bufferviewfilter.h +++ b/src/uisupport/bufferviewfilter.h @@ -21,6 +21,7 @@ #ifndef BUFFERVIEWFILTER_H_ #define BUFFERVIEWFILTER_H_ +#include #include #include #include @@ -73,6 +74,13 @@ protected: private: QPointer _config; + QColor _FgColorInactiveActivity; + QColor _FgColorNoActivity; + QColor _FgColorHighlightActivity; + QColor _FgColorNewMessageActivity; + QColor _FgColorOtherActivity; + void loadColors(); + bool filterAcceptBuffer(const QModelIndex &) const; bool filterAcceptNetwork(const QModelIndex &) const; void addBuffer(const BufferId &); diff --git a/version.inc b/version.inc index cc426431..b428019e 100644 --- a/version.inc +++ b/version.inc @@ -4,8 +4,8 @@ { using namespace Global; quasselVersion = "0.2.0-beta1-pre"; - quasselDate = "2008-04-27"; - quasselBuild = 794; + quasselDate = "2008-04-29"; + quasselBuild = 796; //! Minimum client build number the core needs clientBuildNeeded = 731; -- 2.20.1