From: Manuel Nickschas Date: Fri, 19 Dec 2008 21:42:57 +0000 (+0100) Subject: Add a property disableDecoration to BufferViewConfig X-Git-Tag: 0.4.0~354 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=731ec69d4608ba95e3ae4f154b8ca1852e1db2e5 Add a property disableDecoration to BufferViewConfig If set, this disables colors and icons in a BufferView. Mostly useful for having plain BufferViews in settingspages and similar. We use this for the ChatMonitorSettingsPage now. --- diff --git a/src/common/bufferviewconfig.cpp b/src/common/bufferviewconfig.cpp index 27d32976..935d175f 100644 --- a/src/common/bufferviewconfig.cpp +++ b/src/common/bufferviewconfig.cpp @@ -28,6 +28,7 @@ BufferViewConfig::BufferViewConfig(int bufferViewId, QObject *parent) _addNewBuffersAutomatically(true), _sortAlphabetically(true), _hideInactiveBuffers(false), + _disableDecoration(false), _allowedBufferTypes(BufferInfo::StatusBuffer | BufferInfo::ChannelBuffer | BufferInfo::QueryBuffer | BufferInfo::GroupBuffer), _minimumActivity(0) { @@ -36,7 +37,8 @@ BufferViewConfig::BufferViewConfig(int bufferViewId, QObject *parent) BufferViewConfig::BufferViewConfig(int bufferViewId, const QVariantMap &properties, QObject *parent) : SyncableObject(parent), - _bufferViewId(bufferViewId) + _bufferViewId(bufferViewId), + _disableDecoration(false) // FIXME remove as soon as we have bumped the protocol version to v8 { fromVariantMap(properties); setObjectName(QString::number(bufferViewId)); @@ -74,6 +76,14 @@ void BufferViewConfig::setSortAlphabetically(bool sortAlphabetically) { emit sortAlphabeticallySet(sortAlphabetically); } +void BufferViewConfig::setDisableDecoration(bool disableDecoration) { + if(_disableDecoration == disableDecoration) + return; + + _disableDecoration = disableDecoration; + emit disableDecorationSet(disableDecoration); +} + void BufferViewConfig::setAllowedBufferTypes(int bufferTypes) { if(_allowedBufferTypes == bufferTypes) return; @@ -177,10 +187,10 @@ void BufferViewConfig::addBuffer(const BufferId &bufferId, int pos) { if(_removedBuffers.contains(bufferId)) _removedBuffers.remove(bufferId); - + if(_temporarilyRemovedBuffers.contains(bufferId)) _temporarilyRemovedBuffers.remove(bufferId); - + _buffers.insert(pos, bufferId); emit bufferAdded(bufferId, pos); } @@ -201,7 +211,7 @@ void BufferViewConfig::moveBuffer(const BufferId &bufferId, int pos) { void BufferViewConfig::removeBuffer(const BufferId &bufferId) { if(_buffers.contains(bufferId)) _buffers.removeAt(_buffers.indexOf(bufferId)); - + if(_removedBuffers.contains(bufferId)) _removedBuffers.remove(bufferId); @@ -216,7 +226,7 @@ void BufferViewConfig::removeBufferPermanently(const BufferId &bufferId) { if(_temporarilyRemovedBuffers.contains(bufferId)) _temporarilyRemovedBuffers.remove(bufferId); - + _removedBuffers << bufferId; emit bufferPermanentlyRemoved(bufferId); diff --git a/src/common/bufferviewconfig.h b/src/common/bufferviewconfig.h index 3c88580c..d9a52f31 100644 --- a/src/common/bufferviewconfig.h +++ b/src/common/bufferviewconfig.h @@ -32,6 +32,7 @@ class BufferViewConfig : public SyncableObject { Q_PROPERTY(bool addNewBuffersAutomatically READ addNewBuffersAutomatically WRITE setAddNewBuffersAutomatically) Q_PROPERTY(bool sortAlphabetically READ sortAlphabetically WRITE setSortAlphabetically) Q_PROPERTY(bool hideInactiveBuffers READ hideInactiveBuffers WRITE setHideInactiveBuffers) + Q_PROPERTY(bool disableDecoration READ disableDecoration WRITE setDisableDecoration) Q_PROPERTY(int allowedBufferTypes READ allowedBufferTypes WRITE setAllowedBufferTypes) Q_PROPERTY(int minimumActivity READ minimumActivity WRITE setMinimumActivity) @@ -55,6 +56,9 @@ public slots: inline bool sortAlphabetically() const { return _sortAlphabetically; } void setSortAlphabetically(bool sortAlphabetically); + inline bool disableDecoration() const { return _disableDecoration; } + void setDisableDecoration(bool disableDecoration); + inline int allowedBufferTypes() const { return _allowedBufferTypes; } void setAllowedBufferTypes(int bufferTypes); @@ -63,7 +67,7 @@ public slots: inline bool hideInactiveBuffers() const { return _hideInactiveBuffers; } void setHideInactiveBuffers(bool hideInactiveBuffers); - + virtual inline void requestSetBufferViewName(const QString &bufferViewName) { emit setBufferViewNameRequested(bufferViewName); } const QList &bufferList() const { return _buffers; } @@ -88,13 +92,14 @@ public slots: virtual inline void requestRemoveBuffer(const BufferId &bufferId) { emit removeBufferRequested(bufferId); } void removeBufferPermanently(const BufferId &bufferId); virtual inline void requestRemoveBufferPermanently(const BufferId &bufferId) { emit removeBufferPermanentlyRequested(bufferId); } - - + + signals: void bufferViewNameSet(const QString &bufferViewName); void networkIdSet(const NetworkId &networkId); void addNewBuffersAutomaticallySet(bool addNewBuffersAutomatically); - void sortAlphabeticallySet(bool sortAlphabetically); + void sortAlphabeticallySet(bool sortAlphabetically); + void disableDecorationSet(bool disableDecoration); void allowedBufferTypesSet(int allowedBufferTypes); void minimumActivitySet(int activity); void hideInactiveBuffersSet(bool hideInactiveBuffers); @@ -108,7 +113,7 @@ signals: void bufferPermanentlyRemoved(const BufferId &bufferId); void removeBufferRequested(const BufferId &bufferId); void removeBufferPermanentlyRequested(const BufferId &bufferId); - + void setBufferViewNameRequested(const QString &bufferViewName); private: @@ -118,6 +123,7 @@ private: bool _addNewBuffersAutomatically; bool _sortAlphabetically; bool _hideInactiveBuffers; + bool _disableDecoration; int _allowedBufferTypes; int _minimumActivity; QList _buffers; diff --git a/src/qtui/settingspages/chatmonitorsettingspage.cpp b/src/qtui/settingspages/chatmonitorsettingspage.cpp index 2858f6e7..cbfa26eb 100644 --- a/src/qtui/settingspages/chatmonitorsettingspage.cpp +++ b/src/qtui/settingspages/chatmonitorsettingspage.cpp @@ -42,6 +42,7 @@ ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget *parent) _configAvailable = new BufferViewConfig(-667, this); _configAvailable->setBufferViewName("tmpChatMonitorAvailableBuffers"); _configAvailable->setSortAlphabetically(true); + _configAvailable->setDisableDecoration(true); _configAvailable->setNetworkId(NetworkId()); _configAvailable->setInitialized(); @@ -49,6 +50,7 @@ ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget *parent) _configActive = new BufferViewConfig(-666, this); _configActive->setBufferViewName("tmpChatMonitorActiveBuffers"); _configActive->setSortAlphabetically(true); + _configActive->setDisableDecoration(true); _configActive->setNetworkId(NetworkId()); _configActive->setInitialized(); diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 322ee93d..aaa21840 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -311,7 +311,7 @@ QVariant BufferViewFilter::data(const QModelIndex &index, int role) const { } QVariant BufferViewFilter::icon(const QModelIndex &index) const { - if(!_showUserStateIcons) + if(!_showUserStateIcons || config() && config()->disableDecoration()) return QVariant(); if(index.column() != 0) @@ -332,6 +332,9 @@ QVariant BufferViewFilter::icon(const QModelIndex &index) const { } QVariant BufferViewFilter::foreground(const QModelIndex &index) const { + if(config() && config()->disableDecoration()) + return _FgColorNoActivity; + BufferInfo::ActivityLevel activity = (BufferInfo::ActivityLevel)index.data(NetworkModel::BufferActivityRole).toInt(); if(activity & BufferInfo::Highlight)