X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fbufferviewconfig.cpp;h=14e4d044fbbc356a9904c7e71ade8b01e2fe5f61;hp=1affaba7bee6a8661508ef933863985e2ed709ac;hb=f6b9eeda207d42c99fc3e9085631722cf2ec83dc;hpb=31bc2be0785c614dead827c849ff8f6f3a0cff6a diff --git a/src/common/bufferviewconfig.cpp b/src/common/bufferviewconfig.cpp index 1affaba7..14e4d044 100644 --- a/src/common/bufferviewconfig.cpp +++ b/src/common/bufferviewconfig.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -22,12 +22,14 @@ #include "bufferinfo.h" +INIT_SYNCABLE_OBJECT(BufferViewConfig) BufferViewConfig::BufferViewConfig(int bufferViewId, QObject *parent) : SyncableObject(parent), _bufferViewId(bufferViewId), _addNewBuffersAutomatically(true), _sortAlphabetically(true), _hideInactiveBuffers(false), + _disableDecoration(false), _allowedBufferTypes(BufferInfo::StatusBuffer | BufferInfo::ChannelBuffer | BufferInfo::QueryBuffer | BufferInfo::GroupBuffer), _minimumActivity(0) { @@ -47,6 +49,7 @@ void BufferViewConfig::setBufferViewName(const QString &bufferViewName) { return; _bufferViewName = bufferViewName; + SYNC(ARG(bufferViewName)) emit bufferViewNameSet(bufferViewName); } @@ -55,7 +58,9 @@ void BufferViewConfig::setNetworkId(const NetworkId &networkId) { return; _networkId = networkId; + SYNC(ARG(networkId)) emit networkIdSet(networkId); + emit configChanged(); } void BufferViewConfig::setAddNewBuffersAutomatically(bool addNewBuffersAutomatically) { @@ -63,7 +68,8 @@ void BufferViewConfig::setAddNewBuffersAutomatically(bool addNewBuffersAutomatic return; _addNewBuffersAutomatically = addNewBuffersAutomatically; - emit addNewBuffersAutomaticallySet(addNewBuffersAutomatically); + SYNC(ARG(addNewBuffersAutomatically)) + emit configChanged(); } void BufferViewConfig::setSortAlphabetically(bool sortAlphabetically) { @@ -71,7 +77,16 @@ void BufferViewConfig::setSortAlphabetically(bool sortAlphabetically) { return; _sortAlphabetically = sortAlphabetically; - emit sortAlphabeticallySet(sortAlphabetically); + SYNC(ARG(sortAlphabetically)) + emit configChanged(); +} + +void BufferViewConfig::setDisableDecoration(bool disableDecoration) { + if(_disableDecoration == disableDecoration) + return; + + _disableDecoration = disableDecoration; + SYNC(ARG(disableDecoration)) } void BufferViewConfig::setAllowedBufferTypes(int bufferTypes) { @@ -79,7 +94,8 @@ void BufferViewConfig::setAllowedBufferTypes(int bufferTypes) { return; _allowedBufferTypes = bufferTypes; - emit allowedBufferTypesSet(bufferTypes); + SYNC(ARG(bufferTypes)) + emit configChanged(); } void BufferViewConfig::setMinimumActivity(int activity) { @@ -87,7 +103,8 @@ void BufferViewConfig::setMinimumActivity(int activity) { return; _minimumActivity = activity; - emit minimumActivitySet(activity); + SYNC(ARG(activity)) + emit configChanged(); } void BufferViewConfig::setHideInactiveBuffers(bool hideInactiveBuffers) { @@ -95,7 +112,8 @@ void BufferViewConfig::setHideInactiveBuffers(bool hideInactiveBuffers) { return; _hideInactiveBuffers = hideInactiveBuffers; - emit hideInactiveBuffersSet(hideInactiveBuffers); + SYNC(ARG(hideInactiveBuffers)) + emit configChanged(); } QVariantList BufferViewConfig::initBufferList() const { @@ -115,7 +133,7 @@ void BufferViewConfig::initSetBufferList(const QVariantList &buffers) { _buffers << buffer.value(); } - emit bufferListSet(); + emit configChanged(); // used to track changes in the settingspage } void BufferViewConfig::initSetBufferList(const QList &buffers) { @@ -125,7 +143,43 @@ void BufferViewConfig::initSetBufferList(const QList &buffers) { _buffers << bufferId; } - emit bufferListSet(); + emit configChanged(); // used to track changes in the settingspage +} + +QVariantList BufferViewConfig::initRemovedBuffers() const { + QVariantList removedBuffers; + + foreach(BufferId bufferId, _removedBuffers) { + removedBuffers << qVariantFromValue(bufferId); + } + + return removedBuffers; +} + +void BufferViewConfig::initSetRemovedBuffers(const QVariantList &buffers) { + _removedBuffers.clear(); + + foreach(QVariant buffer, buffers) { + _removedBuffers << buffer.value(); + } +} + +QVariantList BufferViewConfig::initTemporarilyRemovedBuffers() const { + QVariantList temporarilyRemovedBuffers; + + foreach(BufferId bufferId, _temporarilyRemovedBuffers) { + temporarilyRemovedBuffers << qVariantFromValue(bufferId); + } + + return temporarilyRemovedBuffers; +} + +void BufferViewConfig::initSetTemporarilyRemovedBuffers(const QVariantList &buffers) { + _temporarilyRemovedBuffers.clear(); + + foreach(QVariant buffer, buffers) { + _temporarilyRemovedBuffers << buffer.value(); + } } void BufferViewConfig::addBuffer(const BufferId &bufferId, int pos) { @@ -136,9 +190,16 @@ void BufferViewConfig::addBuffer(const BufferId &bufferId, int pos) { pos = 0; if(pos > _buffers.count()) pos = _buffers.count(); - + + if(_removedBuffers.contains(bufferId)) + _removedBuffers.remove(bufferId); + + if(_temporarilyRemovedBuffers.contains(bufferId)) + _temporarilyRemovedBuffers.remove(bufferId); + _buffers.insert(pos, bufferId); emit bufferAdded(bufferId, pos); + emit configChanged(); } void BufferViewConfig::moveBuffer(const BufferId &bufferId, int pos) { @@ -152,12 +213,31 @@ void BufferViewConfig::moveBuffer(const BufferId &bufferId, int pos) { _buffers.move(_buffers.indexOf(bufferId), pos); emit bufferMoved(bufferId, pos); + emit configChanged(); } void BufferViewConfig::removeBuffer(const BufferId &bufferId) { - if(!_buffers.contains(bufferId)) - return; - - _buffers.removeAt(_buffers.indexOf(bufferId)); + if(_buffers.contains(bufferId)) + _buffers.removeAt(_buffers.indexOf(bufferId)); + + if(_removedBuffers.contains(bufferId)) + _removedBuffers.remove(bufferId); + + _temporarilyRemovedBuffers << bufferId; + emit bufferRemoved(bufferId); + emit configChanged(); +} + +void BufferViewConfig::removeBufferPermanently(const BufferId &bufferId) { + if(_buffers.contains(bufferId)) + _buffers.removeAt(_buffers.indexOf(bufferId)); + + if(_temporarilyRemovedBuffers.contains(bufferId)) + _temporarilyRemovedBuffers.remove(bufferId); + + _removedBuffers << bufferId; + + emit bufferPermanentlyRemoved(bufferId); + emit configChanged(); }