_buffers << buffer.value<BufferId>();
}
+ // normaly initSeters don't need an emit. this one is to track changes in the settingspage
emit bufferListSet();
}
_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<BufferId>();
+ }
+}
+
void BufferViewConfig::addBuffer(const BufferId &bufferId, int pos) {
if(_buffers.contains(bufferId))
return;
pos = 0;
if(pos > _buffers.count())
pos = _buffers.count();
+
+ if(_removedBuffers.contains(bufferId))
+ _removedBuffers.remove(bufferId);
_buffers.insert(pos, bufferId);
emit bufferAdded(bufferId, pos);
_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);
+}
virtual inline void requestSetBufferViewName(const QString &bufferViewName) { emit setBufferViewNameRequested(bufferViewName); }
const QList<BufferId> &bufferList() const { return _buffers; }
+ const QSet<BufferId> &removedBuffers() const { return _removedBuffers; }
+
QVariantList initBufferList() const;
void initSetBufferList(const QVariantList &buffers);
void initSetBufferList(const QList<BufferId> &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);
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);
int _allowedBufferTypes;
int _minimumActivity;
QList<BufferId> _buffers;
+ QSet<BufferId> _removedBuffers;
};
#endif // BUFFERVIEWCONFIG_H
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); }
};
_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),
} else {
BufferViewFilter *filter = new BufferViewFilter(model_, config);
setModel(filter);
- connect(this, SIGNAL(removeBuffer(const QModelIndex &)),
- filter, SLOT(removeBuffer(const QModelIndex &)));
}
setConfig(config);
}
QTreeView::keyPressEvent(event);
}
-void BufferView::removeSelectedBuffers() {
- QSet<int> removedRows;
+void BufferView::removeSelectedBuffers(bool permanently) {
+ if(!config())
+ return;
+
+ BufferId bufferId;
+ QSet<BufferId> 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<BufferId>();
+ if(removedRows.contains(bufferId))
+ continue;
+
+ removedRows << bufferId;
+
+ if(permanently)
+ config()->requestRemoveBufferPermanently(bufferId);
+ else
+ config()->requestRemoveBuffer(bufferId);
}
}
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;
}
}
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<BufferInfo>();
int res = QMessageBox::question(this, tr("Remove buffer permanently?"),
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 *);
QAction _joinBufferAction;
QAction _partBufferAction;
- QAction _hideBufferAction;
+ QAction _hideBufferTemporarilyAction;
+ QAction _hideBufferPermanentlyAction;
QAction _removeBufferAction;
QAction _ignoreListAction;
}
_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();
}
return true;
}
-void BufferViewFilter::addBuffer(const BufferId &bufferId) {
+void BufferViewFilter::addBuffer(const BufferId &bufferId) const {
if(!config() || config()->bufferList().contains(bufferId))
return;
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<BufferId>();
- config()->requestRemoveBuffer(bufferId);
-}
-
-
bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) const {
BufferId bufferId = sourceModel()->data(source_bufferIndex, NetworkModel::BufferIdRole).value<BufferId>();
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<NetworkId>())
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<BufferId>())
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 {
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);
signals:
void _dataChanged(const QModelIndex &source_topLeft, const QModelIndex &source_bottomRight);
-
+
+private slots:
+ void configInitialized();
+
private:
QPointer<BufferViewConfig> _config;
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)
{ 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;