From: Marcus Eggenberger Date: Fri, 30 May 2008 11:38:28 +0000 (+0000) Subject: Merging -r 859:865 branches/0.2/ with trunk X-Git-Tag: 0.3.0~400 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=72f1a93311815cc637358f52046a4cf311bbd9f4 Merging -r 859:865 branches/0.2/ with trunk --- diff --git a/src/common/bufferviewconfig.cpp b/src/common/bufferviewconfig.cpp index 88c9dc0e..27d32976 100644 --- a/src/common/bufferviewconfig.cpp +++ b/src/common/bufferviewconfig.cpp @@ -130,7 +130,7 @@ void BufferViewConfig::initSetBufferList(const QList &buffers) { emit bufferListSet(); } -QVariantList BufferViewConfig::initRemovedBuffersList() const { +QVariantList BufferViewConfig::initRemovedBuffers() const { QVariantList removedBuffers; foreach(BufferId bufferId, _removedBuffers) { @@ -140,7 +140,7 @@ QVariantList BufferViewConfig::initRemovedBuffersList() const { return removedBuffers; } -void BufferViewConfig::initSetRemovedBuffersList(const QVariantList &buffers) { +void BufferViewConfig::initSetRemovedBuffers(const QVariantList &buffers) { _removedBuffers.clear(); foreach(QVariant buffer, buffers) { @@ -148,6 +148,24 @@ void BufferViewConfig::initSetRemovedBuffersList(const QVariantList &buffers) { } } +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) { if(_buffers.contains(bufferId)) return; @@ -160,6 +178,9 @@ 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); } @@ -178,16 +199,23 @@ void BufferViewConfig::moveBuffer(const BufferId &bufferId, int pos) { } void BufferViewConfig::removeBuffer(const BufferId &bufferId) { - if(!_buffers.contains(bufferId)) - return; + if(_buffers.contains(bufferId)) + _buffers.removeAt(_buffers.indexOf(bufferId)); - _buffers.removeAt(_buffers.indexOf(bufferId)); + if(_removedBuffers.contains(bufferId)) + _removedBuffers.remove(bufferId); + + _temporarilyRemovedBuffers << bufferId; + emit bufferRemoved(bufferId); } void BufferViewConfig::removeBufferPermanently(const BufferId &bufferId) { if(_buffers.contains(bufferId)) _buffers.removeAt(_buffers.indexOf(bufferId)); + + if(_temporarilyRemovedBuffers.contains(bufferId)) + _temporarilyRemovedBuffers.remove(bufferId); _removedBuffers << bufferId; diff --git a/src/common/bufferviewconfig.h b/src/common/bufferviewconfig.h index 81e2cb33..3c88580c 100644 --- a/src/common/bufferviewconfig.h +++ b/src/common/bufferviewconfig.h @@ -68,13 +68,17 @@ public slots: const QList &bufferList() const { return _buffers; } const QSet &removedBuffers() const { return _removedBuffers; } + const QSet &temporarilyRemovedBuffers() const { return _temporarilyRemovedBuffers; } QVariantList initBufferList() const; void initSetBufferList(const QVariantList &buffers); void initSetBufferList(const QList &buffers); - QVariantList initRemovedBuffersList() const; - void initSetRemovedBuffersList(const QVariantList &buffers); + QVariantList initRemovedBuffers() const; + void initSetRemovedBuffers(const QVariantList &buffers); + + QVariantList initTemporarilyRemovedBuffers() const; + void initSetTemporarilyRemovedBuffers(const QVariantList &buffers); void addBuffer(const BufferId &bufferId, int pos); virtual inline void requestAddBuffer(const BufferId &bufferId, int pos) { emit addBufferRequested(bufferId, pos); } @@ -118,6 +122,7 @@ private: int _minimumActivity; QList _buffers; QSet _removedBuffers; + QSet _temporarilyRemovedBuffers; }; #endif // BUFFERVIEWCONFIG_H diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index dac8d9f9..5dcb7e8c 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -43,7 +43,6 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig * { setConfig(config); setSourceModel(model); - connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(source_rowsInserted(const QModelIndex &, int, int))); setDynamicSortFilter(true); @@ -168,12 +167,26 @@ void BufferViewFilter::addBuffer(const BufferId &bufferId) const { } bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) const { - BufferId bufferId = sourceModel()->data(source_bufferIndex, NetworkModel::BufferIdRole).value(); - Q_ASSERT(bufferId.isValid()); + // no config -> "all buffers" -> accept everything if(!config()) return true; + BufferId bufferId = sourceModel()->data(source_bufferIndex, NetworkModel::BufferIdRole).value(); + Q_ASSERT(bufferId.isValid()); + int activityLevel = source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt(); + + if(!config()->bufferList().contains(bufferId)) { + // add the buffer if... + if(config()->isInitialized() && !config()->removedBuffers().contains(bufferId) // it hasn't been manually removed and either + && ((config()->addNewBuffersAutomatically() && !config()->temporarilyRemovedBuffers().contains(bufferId)) // is totally unknown to us (a new buffer)... + || activityLevel > Buffer::OtherActivity)) { // or was just temporarily hidden and has a new message waiting for us. + addBuffer(bufferId); + } + // note: adding the buffer to the valid list does not temper with the filters ("show only channels" and stuff) + return false; + } + if(config()->networkId().isValid() && config()->networkId() != sourceModel()->data(source_bufferIndex, NetworkModel::NetworkIdRole).value()) return false; @@ -188,13 +201,7 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) return false; } - if(config()->bufferList().contains(bufferId)) - return true; - - if(config()->isInitialized() && !config()->removedBuffers().contains(bufferId) && activityLevel > Buffer::OtherActivity) - addBuffer(bufferId); - - return false; + return true; } bool BufferViewFilter::filterAcceptNetwork(const QModelIndex &source_index) const { @@ -276,20 +283,6 @@ QVariant BufferViewFilter::foreground(const QModelIndex &index) const { return _FgColorNoActivity; } -void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start, int end) { - if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType) - return; - - if(!config() || !config()->addNewBuffersAutomatically()) - return; - - QModelIndex child; - for(int row = start; row <= end; row++) { - child = sourceModel()->index(row, 0, parent); - addBuffer(sourceModel()->data(child, NetworkModel::BufferIdRole).value()); - } -} - void BufferViewFilter::checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous) { Q_UNUSED(current); if(previous.isValid()) diff --git a/src/uisupport/bufferviewfilter.h b/src/uisupport/bufferviewfilter.h index 7fc62394..128b3e83 100644 --- a/src/uisupport/bufferviewfilter.h +++ b/src/uisupport/bufferviewfilter.h @@ -65,7 +65,6 @@ public slots: void checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous); void checkItemForRemoval(const QModelIndex &index) { checkItemsForRemoval(index, index); } void checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight); - void source_rowsInserted(const QModelIndex &parent, int start, int end); protected: bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; diff --git a/version.inc b/version.inc index 2ba5ac07..44f0891d 100644 --- a/version.inc +++ b/version.inc @@ -4,8 +4,8 @@ { using namespace Global; quasselVersion = "0.3.0-pre"; - quasselDate = "2008-05-26"; - quasselBuild = 861; + quasselDate = "2008-05-30"; + quasselBuild = 866; //! Minimum client build number the core needs clientBuildNeeded = 731;