Enable multi-selection in nick list
authorManuel Nickschas <sputnick@quassel-irc.org>
Sat, 10 Jan 2009 23:42:00 +0000 (00:42 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 10 Jan 2009 23:42:00 +0000 (00:42 +0100)
This allows you, for example, to op/deop multiple users at once.

src/uisupport/nickview.cpp

index e0a5893..bfdaf1e 100644 (file)
@@ -47,6 +47,7 @@ NickView::NickView(QWidget *parent)
   sortByColumn(0, Qt::AscendingOrder);
 
   setContextMenuPolicy(Qt::CustomContextMenu);
+  setSelectionMode(QAbstractItemView::ExtendedSelection);
 
   connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(showContextMenu(const QPoint&)));
 
@@ -89,8 +90,13 @@ void NickView::showContextMenu(const QPoint & pos ) {
   if(index.data(NetworkModel::ItemTypeRole) != NetworkModel::IrcUserItemType)
     return;
 
+  QModelIndexList indexList = selectedIndexes();
+  // make sure the item we clicked on is first
+  indexList.removeAll(index);
+  indexList.prepend(index);
+
   QMenu contextMenu(this);
-  Client::mainUi()->actionProvider()->addActions(&contextMenu, index);
+  Client::mainUi()->actionProvider()->addActions(&contextMenu, indexList);
   contextMenu.exec(QCursor::pos());
 }