From: Marcus Eggenberger Date: Mon, 26 May 2008 15:21:58 +0000 (+0000) Subject: Merging branches/0.2/@r859 with trunk X-Git-Tag: 0.3.0~402 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=a1bcca1c86e88406a0c5495b08731e6b11dd987e Merging branches/0.2/@r859 with trunk --- diff --git a/src/common/bufferviewconfig.cpp b/src/common/bufferviewconfig.cpp index 1affaba7..88c9dc0e 100644 --- a/src/common/bufferviewconfig.cpp +++ b/src/common/bufferviewconfig.cpp @@ -115,6 +115,7 @@ void BufferViewConfig::initSetBufferList(const QVariantList &buffers) { _buffers << buffer.value(); } + // normaly initSeters don't need an emit. this one is to track changes in the settingspage emit bufferListSet(); } @@ -125,9 +126,28 @@ void BufferViewConfig::initSetBufferList(const QList &buffers) { _buffers << bufferId; } + // normaly initSeters don't need an emit. this one is to track changes in the settingspage emit bufferListSet(); } +QVariantList BufferViewConfig::initRemovedBuffersList() const { + QVariantList removedBuffers; + + foreach(BufferId bufferId, _removedBuffers) { + removedBuffers << qVariantFromValue(bufferId); + } + + return removedBuffers; +} + +void BufferViewConfig::initSetRemovedBuffersList(const QVariantList &buffers) { + _removedBuffers.clear(); + + foreach(QVariant buffer, buffers) { + _removedBuffers << buffer.value(); + } +} + void BufferViewConfig::addBuffer(const BufferId &bufferId, int pos) { if(_buffers.contains(bufferId)) return; @@ -136,6 +156,9 @@ void BufferViewConfig::addBuffer(const BufferId &bufferId, int pos) { pos = 0; if(pos > _buffers.count()) pos = _buffers.count(); + + if(_removedBuffers.contains(bufferId)) + _removedBuffers.remove(bufferId); _buffers.insert(pos, bufferId); emit bufferAdded(bufferId, pos); @@ -161,3 +184,12 @@ void BufferViewConfig::removeBuffer(const BufferId &bufferId) { _buffers.removeAt(_buffers.indexOf(bufferId)); emit bufferRemoved(bufferId); } + +void BufferViewConfig::removeBufferPermanently(const BufferId &bufferId) { + if(_buffers.contains(bufferId)) + _buffers.removeAt(_buffers.indexOf(bufferId)); + + _removedBuffers << bufferId; + + emit bufferPermanentlyRemoved(bufferId); +} diff --git a/src/common/bufferviewconfig.h b/src/common/bufferviewconfig.h index 2e2a9aa6..81e2cb33 100644 --- a/src/common/bufferviewconfig.h +++ b/src/common/bufferviewconfig.h @@ -67,16 +67,24 @@ public slots: virtual inline void requestSetBufferViewName(const QString &bufferViewName) { emit setBufferViewNameRequested(bufferViewName); } const QList &bufferList() const { return _buffers; } + const QSet &removedBuffers() const { return _removedBuffers; } + QVariantList initBufferList() const; void initSetBufferList(const QVariantList &buffers); void initSetBufferList(const QList &buffers); + QVariantList initRemovedBuffersList() const; + void initSetRemovedBuffersList(const QVariantList &buffers); + void addBuffer(const BufferId &bufferId, int pos); virtual inline void requestAddBuffer(const BufferId &bufferId, int pos) { emit addBufferRequested(bufferId, pos); } void moveBuffer(const BufferId &bufferId, int pos); virtual inline void requestMoveBuffer(const BufferId &bufferId, int pos) { emit moveBufferRequested(bufferId, pos); } void removeBuffer(const BufferId &bufferId); 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); @@ -93,7 +101,9 @@ signals: void bufferMoved(const BufferId &bufferId, int pos); void moveBufferRequested(const BufferId &bufferId, int pos); void bufferRemoved(const BufferId &bufferId); + void bufferPermanentlyRemoved(const BufferId &bufferId); void removeBufferRequested(const BufferId &bufferId); + void removeBufferPermanentlyRequested(const BufferId &bufferId); void setBufferViewNameRequested(const QString &bufferViewName); @@ -107,6 +117,7 @@ private: int _allowedBufferTypes; int _minimumActivity; QList _buffers; + QSet _removedBuffers; }; #endif // BUFFERVIEWCONFIG_H diff --git a/src/core/corebufferviewconfig.h b/src/core/corebufferviewconfig.h index b0d9e96c..bb7eb95f 100644 --- a/src/core/corebufferviewconfig.h +++ b/src/core/corebufferviewconfig.h @@ -35,6 +35,7 @@ public: public slots: virtual inline void requestSetBufferViewName(const QString &bufferViewName) { setBufferViewName(bufferViewName); } virtual inline void requestRemoveBuffer(const BufferId &bufferId) { removeBuffer(bufferId); } + virtual inline void requestRemoveBufferPermanently(const BufferId &bufferId) { removeBufferPermanently(bufferId); } virtual inline void requestAddBuffer(const BufferId &bufferId, int pos) { addBuffer(bufferId, pos); } virtual inline void requestMoveBuffer(const BufferId &bufferId, int pos) { moveBuffer(bufferId, pos); } }; diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 7f690e17..ed530edb 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -54,7 +54,8 @@ BufferView::BufferView(QWidget *parent) _joinBufferAction(tr("Join"), this), _partBufferAction(tr("Part"), this), - _hideBufferAction(tr("Hide selected buffers"), this), + _hideBufferTemporarilyAction(tr("Hide buffers"), this), + _hideBufferPermanentlyAction(tr("Hide buffers permanently"), this), _removeBufferAction(tr("Delete buffer"), this), _ignoreListAction(tr("Ignore list"), this), @@ -158,8 +159,6 @@ void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig * } else { BufferViewFilter *filter = new BufferViewFilter(model_, config); setModel(filter); - connect(this, SIGNAL(removeBuffer(const QModelIndex &)), - filter, SLOT(removeBuffer(const QModelIndex &))); } setConfig(config); } @@ -227,13 +226,26 @@ void BufferView::keyPressEvent(QKeyEvent *event) { QTreeView::keyPressEvent(event); } -void BufferView::removeSelectedBuffers() { - QSet removedRows; +void BufferView::removeSelectedBuffers(bool permanently) { + if(!config()) + return; + + BufferId bufferId; + QSet removedRows; foreach(QModelIndex index, selectionModel()->selectedIndexes()) { - if(index.data(NetworkModel::ItemTypeRole) == NetworkModel::BufferItemType && !removedRows.contains(index.row())) { - removedRows << index.row(); - emit removeBuffer(index); - } + if(index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType) + continue; + + bufferId = index.data(NetworkModel::BufferIdRole).value(); + if(removedRows.contains(bufferId)) + continue; + + removedRows << bufferId; + + if(permanently) + config()->requestRemoveBufferPermanently(bufferId); + else + config()->requestRemoveBuffer(bufferId); } } @@ -405,18 +417,21 @@ void BufferView::contextMenuEvent(QContextMenuEvent *event) { case BufferInfo::ChannelBuffer: addItemToMenu(_joinBufferAction, contextMenu, index, InactiveState); addItemToMenu(_partBufferAction, contextMenu, index, ActiveState); - addItemToMenu(_hideBufferAction, contextMenu, (bool)config()); + addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config()); + addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config()); addItemToMenu(_removeBufferAction, contextMenu, index, InactiveState); createHideEventsSubMenu(contextMenu); addItemToMenu(_ignoreListAction, contextMenu); break; case BufferInfo::QueryBuffer: - addItemToMenu(_hideBufferAction, contextMenu, (bool)config()); + addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config()); + addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config()); addItemToMenu(_removeBufferAction, contextMenu); createHideEventsSubMenu(contextMenu); break; default: - addItemToMenu(_hideBufferAction, contextMenu, (bool)config()); + addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config()); + addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config()); break; } } @@ -467,11 +482,16 @@ void BufferView::contextMenuEvent(QContextMenuEvent *event) { return; } - if(result == &_hideBufferAction) { + if(result == &_hideBufferTemporarilyAction) { removeSelectedBuffers(); return; } + if(result == &_hideBufferPermanentlyAction) { + removeSelectedBuffers(true); + return; + } + if(result == &_removeBufferAction) { BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value(); int res = QMessageBox::question(this, tr("Remove buffer permanently?"), diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index cb5a68de..b47904a6 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -52,10 +52,11 @@ class BufferView : public QTreeView { public slots: void setRootIndexForNetworkId(const NetworkId &networkId); - void removeSelectedBuffers(); + void removeSelectedBuffers(bool permanently = false); signals: void removeBuffer(const QModelIndex &); + void removeBufferPermanently(const QModelIndex &); protected: virtual void keyPressEvent(QKeyEvent *); @@ -89,7 +90,8 @@ class BufferView : public QTreeView { QAction _joinBufferAction; QAction _partBufferAction; - QAction _hideBufferAction; + QAction _hideBufferTemporarilyAction; + QAction _hideBufferPermanentlyAction; QAction _removeBufferAction; QAction _ignoreListAction; diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index e02549c6..dac8d9f9 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -71,19 +71,32 @@ void BufferViewFilter::setConfig(BufferViewConfig *config) { } _config = config; - if(config) { - connect(config, SIGNAL(bufferViewNameSet(const QString &)), this, SLOT(invalidate())); - connect(config, SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(invalidate())); - connect(config, SIGNAL(addNewBuffersAutomaticallySet(bool)), this, SLOT(invalidate())); - connect(config, SIGNAL(sortAlphabeticallySet(bool)), this, SLOT(invalidate())); - connect(config, SIGNAL(hideInactiveBuffersSet(bool)), this, SLOT(invalidate())); - connect(config, SIGNAL(allowedBufferTypesSet(int)), this, SLOT(invalidate())); - connect(config, SIGNAL(minimumActivitySet(int)), this, SLOT(invalidate())); - connect(config, SIGNAL(bufferListSet()), this, SLOT(invalidate())); - connect(config, SIGNAL(bufferAdded(const BufferId &, int)), this, SLOT(invalidate())); - connect(config, SIGNAL(bufferMoved(const BufferId &, int)), this, SLOT(invalidate())); - connect(config, SIGNAL(bufferRemoved(const BufferId &)), this, SLOT(invalidate())); + if(config->isInitialized()) { + configInitialized(); + } else { + connect(config, SIGNAL(initDone()), this, SLOT(configInitialized())); + invalidate(); } +} + +void BufferViewFilter::configInitialized() { + if(!config()) + return; + + connect(config(), SIGNAL(bufferViewNameSet(const QString &)), this, SLOT(invalidate())); + connect(config(), SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(invalidate())); + connect(config(), SIGNAL(addNewBuffersAutomaticallySet(bool)), this, SLOT(invalidate())); + connect(config(), SIGNAL(sortAlphabeticallySet(bool)), this, SLOT(invalidate())); + connect(config(), SIGNAL(hideInactiveBuffersSet(bool)), this, SLOT(invalidate())); + connect(config(), SIGNAL(allowedBufferTypesSet(int)), this, SLOT(invalidate())); + connect(config(), SIGNAL(minimumActivitySet(int)), this, SLOT(invalidate())); + connect(config(), SIGNAL(bufferListSet()), this, SLOT(invalidate())); + connect(config(), SIGNAL(bufferAdded(const BufferId &, int)), this, SLOT(invalidate())); + connect(config(), SIGNAL(bufferMoved(const BufferId &, int)), this, SLOT(invalidate())); + connect(config(), SIGNAL(bufferRemoved(const BufferId &)), this, SLOT(invalidate())); + + disconnect(config(), SIGNAL(initDone()), this, SLOT(configInitialized())); + invalidate(); } @@ -134,7 +147,7 @@ bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action return true; } -void BufferViewFilter::addBuffer(const BufferId &bufferId) { +void BufferViewFilter::addBuffer(const BufferId &bufferId) const { if(!config() || config()->bufferList().contains(bufferId)) return; @@ -154,36 +167,34 @@ void BufferViewFilter::addBuffer(const BufferId &bufferId) { config()->requestAddBuffer(bufferId, pos); } -void BufferViewFilter::removeBuffer(const QModelIndex &index) { - if(!config() || !index.isValid() || index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType) - return; - - BufferId bufferId = data(index, NetworkModel::BufferIdRole).value(); - config()->requestRemoveBuffer(bufferId); -} - - bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) const { BufferId bufferId = sourceModel()->data(source_bufferIndex, NetworkModel::BufferIdRole).value(); Q_ASSERT(bufferId.isValid()); - if(!_config) + if(!config()) return true; - + + int activityLevel = source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt(); if(config()->networkId().isValid() && config()->networkId() != sourceModel()->data(source_bufferIndex, NetworkModel::NetworkIdRole).value()) return false; - if(!(_config->allowedBufferTypes() & (BufferInfo::Type)source_bufferIndex.data(NetworkModel::BufferTypeRole).toInt())) + if(!(config()->allowedBufferTypes() & (BufferInfo::Type)source_bufferIndex.data(NetworkModel::BufferTypeRole).toInt())) return false; - if(_config->hideInactiveBuffers() && !source_bufferIndex.data(NetworkModel::ItemActiveRole).toBool()) + if(config()->hideInactiveBuffers() && !source_bufferIndex.data(NetworkModel::ItemActiveRole).toBool()) return false; - if(_config->minimumActivity() > source_bufferIndex.data(NetworkModel::BufferActivityRole).toInt()) { + if(config()->minimumActivity() > activityLevel) { if(bufferId != Client::bufferModel()->standardSelectionModel()->currentIndex().data(NetworkModel::BufferIdRole).value()) return false; } - return _config->bufferList().contains(bufferId); + if(config()->bufferList().contains(bufferId)) + return true; + + if(config()->isInitialized() && !config()->removedBuffers().contains(bufferId) && activityLevel > Buffer::OtherActivity) + addBuffer(bufferId); + + return false; } bool BufferViewFilter::filterAcceptNetwork(const QModelIndex &source_index) const { diff --git a/src/uisupport/bufferviewfilter.h b/src/uisupport/bufferviewfilter.h index 4a80f7ec..7fc62394 100644 --- a/src/uisupport/bufferviewfilter.h +++ b/src/uisupport/bufferviewfilter.h @@ -62,7 +62,6 @@ public: inline BufferViewConfig *config() const { return _config; } public slots: - void removeBuffer(const QModelIndex &); void checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous); void checkItemForRemoval(const QModelIndex &index) { checkItemsForRemoval(index, index); } void checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight); @@ -77,7 +76,10 @@ protected: signals: void _dataChanged(const QModelIndex &source_topLeft, const QModelIndex &source_bottomRight); - + +private slots: + void configInitialized(); + private: QPointer _config; @@ -90,7 +92,7 @@ private: bool filterAcceptBuffer(const QModelIndex &) const; bool filterAcceptNetwork(const QModelIndex &) const; - void addBuffer(const BufferId &); + void addBuffer(const BufferId &) const; }; Q_DECLARE_OPERATORS_FOR_FLAGS(BufferViewFilter::Modes) diff --git a/version.inc b/version.inc index 38bb553f..59d2abf0 100644 --- a/version.inc +++ b/version.inc @@ -4,8 +4,8 @@ { using namespace Global; quasselVersion = "0.3.0-pre"; - quasselDate = "2008-05-23"; - quasselBuild = 858; + quasselDate = "2008-05-26"; + quasselBuild = 860; //! Minimum client build number the core needs clientBuildNeeded = 731;