From 4319168202d99ddb5895ae0984b2eb0c30b46952 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Mon, 5 May 2008 16:52:56 +0000 Subject: [PATCH 1/1] - It's now possible to select multiple buffers at once (helpfull for view customization) - added a context menu entry "remove buffers" to custom buffer views --- src/uisupport/bufferview.cpp | 33 +++++++++++++++++++++++---------- src/uisupport/bufferview.h | 1 + version.inc | 4 ++-- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 180db0da..87e474ba 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -39,6 +39,7 @@ #include #include #include +#include /***************************************** * The TreeView showing the Buffers @@ -50,6 +51,8 @@ BufferView::BufferView(QWidget *parent) : QTreeView(parent) { connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showContextMenu(const QPoint &))); + + setSelectionMode(QAbstractItemView::ExtendedSelection); } void BufferView::init() { @@ -191,14 +194,21 @@ void BufferView::joinChannel(const QModelIndex &index) { } void BufferView::keyPressEvent(QKeyEvent *event) { - if((event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) && !selectionModel()->selectedIndexes().isEmpty()) { + if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) { event->accept(); - QModelIndex index = selectionModel()->selectedIndexes().first(); - if(index.isValid() && index.data(NetworkModel::ItemTypeRole) == NetworkModel::BufferItemType) { + removeSelectedBuffers(); + } + QTreeView::keyPressEvent(event); +} + +void BufferView::removeSelectedBuffers() { + QSet removedRows; + foreach(QModelIndex index, selectionModel()->selectedIndexes()) { + if(index.data(NetworkModel::ItemTypeRole) == NetworkModel::BufferItemType && !removedRows.contains(index.row())) { + removedRows << index.row(); emit removeBuffer(index); } } - QTreeView::keyPressEvent(event); } void BufferView::rowsInserted(const QModelIndex & parent, int start, int end) { @@ -273,6 +283,8 @@ void BufferView::showContextMenu(const QPoint &pos) { QAction *joinBufferAction = new QAction(tr("Join"), this); QAction *partBufferAction = new QAction(tr("Part"), this); + QAction *hideBufferAction = new QAction(tr("Remove buffers"), this); + hideBufferAction->setToolTip(tr("Removes the selected buffers from a custom view but leaves the buffer itself untouched")); QAction *removeBufferAction = new QAction(tr("Delete buffer"), this); QMenu *hideEventsMenu = new QMenu(tr("Hide Events"), this); @@ -313,6 +325,8 @@ void BufferView::showContextMenu(const QPoint &pos) { if(bufferInfo.type() != BufferInfo::ChannelBuffer && bufferInfo.type() != BufferInfo::QueryBuffer) return; contextMenu.addAction(joinBufferAction); contextMenu.addAction(partBufferAction); + if(config()) + contextMenu.addAction(hideBufferAction); contextMenu.addAction(removeBufferAction); contextMenu.addMenu(hideEventsMenu); contextMenu.addAction(ignoreListAction); @@ -357,14 +371,13 @@ void BufferView::showContextMenu(const QPoint &pos) { } } #endif - } else - if(result == joinBufferAction) { + } else if(result == joinBufferAction) { Client::instance()->userInput(bufferInfo, QString("/JOIN %1").arg(channelname)); - } else - if(result == partBufferAction) { + } else if(result == partBufferAction) { Client::instance()->userInput(bufferInfo, QString("/PART %1").arg(channelname)); - } else - if(result == removeBufferAction) { + } else if(result == hideBufferAction) { + removeSelectedBuffers(); + } else if(result == removeBufferAction) { int res = QMessageBox::question(this, tr("Remove buffer permanently?"), tr("Do you want to delete the buffer \"%1\" permanently? This will delete all related data, including all backlog " "data, from the core's database!").arg(bufferInfo.bufferName()), diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index 66ee467b..09d66130 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -49,6 +49,7 @@ public: public slots: void setRootIndexForNetworkId(const NetworkId &networkId); + void removeSelectedBuffers(); signals: void removeBuffer(const QModelIndex &); diff --git a/version.inc b/version.inc index f6692a5c..95305857 100644 --- a/version.inc +++ b/version.inc @@ -4,8 +4,8 @@ { using namespace Global; quasselVersion = "0.2.0-beta1-pre"; - quasselDate = "2008-05-04"; - quasselBuild = 814; + quasselDate = "2008-05-05"; + quasselBuild = 817; //! Minimum client build number the core needs clientBuildNeeded = 731; -- 2.20.1