Newly created buffers are now selected automatically.
[quassel.git] / src / uisupport / bufferview.cpp
index 27858a9..4ac92f3 100644 (file)
@@ -118,6 +118,15 @@ void BufferView::rowsInserted(const QModelIndex & parent, int start, int end) {
     update(parent); 
     expand(parent);
   }
+
+
+  // select newly inserted buffers
+  if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
+    return;
+
+  QModelIndex newCurrent = parent.child(end, 0);
+  selectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+  selectionModel()->select(newCurrent, QItemSelectionModel::ClearAndSelect);
 }
 
 void BufferView::toggleHeader(bool checked) {
@@ -138,15 +147,18 @@ void BufferView::showContextMenu(const QPoint &pos) {
 
   QMenu *hideEventsMenu = new QMenu(tr("Hide Events"), this);
   QAction *hideJoinAction = hideEventsMenu->addAction(tr("Join Events"));
-  QAction *hidePartAction = hideEventsMenu->addAction(tr("PartEvents"));
-  QAction *hideQuitAction = hideEventsMenu->addAction(tr("QuitEvents"));
+  QAction *hidePartAction = hideEventsMenu->addAction(tr("Part Events"));
+  QAction *hideKillAction = hideEventsMenu->addAction(tr("Kill Events"));
+  QAction *hideQuitAction = hideEventsMenu->addAction(tr("Quit Events"));
   QAction *hideModeAction = hideEventsMenu->addAction(tr("Mode Events"));
   hideJoinAction->setCheckable(true);
   hidePartAction->setCheckable(true);
+  hideKillAction->setCheckable(true);
   hideQuitAction->setCheckable(true);
   hideModeAction->setCheckable(true);
   hideJoinAction->setEnabled(false);
   hidePartAction->setEnabled(false);
+  hideKillAction->setEnabled(false);
   hideQuitAction->setEnabled(false);
   hideModeAction->setEnabled(false);
 
@@ -174,11 +186,17 @@ void BufferView::showContextMenu(const QPoint &pos) {
     contextMenu.addAction(ignoreListAction);
     contextMenu.addAction(whoBufferAction);
 
-    if(bufferInfo.type() == BufferInfo::ChannelBuffer && index.data(NetworkModel::ItemActiveRole).toBool()) {
-       removeBufferAction->setEnabled(false);
-       joinBufferAction->setVisible(false);
+    if(bufferInfo.type() == BufferInfo::ChannelBuffer) {
+      if(index.data(NetworkModel::ItemActiveRole).toBool()) {
+        removeBufferAction->setEnabled(false);
+        removeBufferAction->setToolTip("To delete the buffer, part the channel first.");
+        joinBufferAction->setVisible(false);
+      } else {
+        partBufferAction->setVisible(false);
+      }
     } else {
-       partBufferAction->setVisible(false);
+      joinBufferAction->setVisible(false);
+      partBufferAction->setVisible(false);
     }
   }
 
@@ -203,7 +221,7 @@ void BufferView::showContextMenu(const QPoint &pos) {
                                        "data, from the core's database!").arg(bufferInfo.bufferName()),
                                         QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
     if(res == QMessageBox::Yes) {
-        Client::bufferSyncer()->requestRemoveBuffer(bufferInfo.bufferId());
+      Client::removeBuffer(bufferInfo.bufferId());
     } 
   } else 
   if(result == whoBufferAction) {