Blob Blame History Raw
From 37de1cca11b96598264e65345872a3c0f354859b Mon Sep 17 00:00:00 2001
From: Arjun AK <arjunak234@gmail.com>
Date: Mon, 3 Nov 2014 19:30:48 +0530
Subject: [PATCH 37/43] Show name of the column under the mouse pointer at the
 top of the treeview header context menu

This makes it easy to hide a column. We can right click on the column
we want to hide and select it from the top of the list instead of having
to go through the big list and selecting the required one from that.

REVIEW: 118913
---
 ktorrent/view/view.cpp | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/ktorrent/view/view.cpp b/ktorrent/view/view.cpp
index f17e926..51736ca 100644
--- a/ktorrent/view/view.cpp
+++ b/ktorrent/view/view.cpp
@@ -91,13 +91,11 @@ namespace kt
 		header()->setContextMenuPolicy(Qt::CustomContextMenu);
 		connect(header(), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showHeaderMenu(const QPoint&)));
 		header_menu = new KMenu(this);
-		header_menu->addTitle(i18n("Columns"));
 
 		for(int i = 0; i < model->columnCount(QModelIndex()); i++)
 		{
 			QString col = model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString();
-			KAction* act = new KAction(col, header_menu);
-			header_menu->addAction(act);
+			KAction* act = new KAction(col, this);
 			act->setCheckable(true);
 			act->setChecked(true);
 			column_idx_map[act] = i;
@@ -671,6 +669,20 @@ namespace kt
 
 	void View::showHeaderMenu(const QPoint& pos)
 	{
+		const int col = columnAt(pos.x());
+
+	        header_menu->clear();
+		header_menu->addTitle(i18n("Columns"));
+	        header_menu->addAction(column_idx_map.key(col));
+	        header_menu->addSeparator();
+	        for(int i = 0; i < model->columnCount(QModelIndex()); i++)
+	        {
+	                if (i == col) {
+	                        continue;
+	                }
+	                header_menu->addAction(column_idx_map.key(i));
+	        }
+
 		header_menu->popup(header()->mapToGlobal(pos));
 	}
 
-- 
1.9.3