1
From: John Tapsell <johnflux@gmail.com>
2
Date: Fri, 08 Jun 2012 13:31:34 +0000
3
Subject: Prevent the user from hiding all of the columns
4
X-Git-Url: http://quickgit.kde.org/?p=kde-workspace.git&a=commitdiff&h=3009ffd7c7f44214b72a72c8b92f37dd194193b1
6
Prevent the user from hiding all of the columns
12
--- a/libs/ksysguard/processui/ksysguardprocesslist.cpp
13
+++ b/libs/ksysguard/processui/ksysguardprocesslist.cpp
14
@@ -427,7 +427,18 @@ void KSysGuardProcessList::showProcessCo
15
QModelIndexList selectedIndexes = d->mUi->treeView->selectionModel()->selectedRows();
16
int numProcesses = selectedIndexes.size();
18
- if(numProcesses == 0) return; //No processes selected, so no context menu
19
+ if(numProcesses == 0) {
20
+ //No processes selected, so no process context menu
22
+ //Check just incase we have no columns visible. In which case show the column context menu
23
+ //so that users can unhide columns if there are no columns visible
24
+ for(int i = 0; i < d->mFilterModel.columnCount(); ++i) {
25
+ if(!d->mUi->treeView->header()->isSectionHidden(i))
28
+ showColumnContextMenu(point);
32
QModelIndex realIndex = d->mFilterModel.mapToSource(selectedIndexes.at(0));
33
KSysGuard::Process *process = reinterpret_cast<KSysGuard::Process *> (realIndex.internalPointer());
34
@@ -580,20 +591,31 @@ void KSysGuardProcessList::showColumnCon
39
+ int num_headings = d->mFilterModel.columnCount();
41
int index = d->mUi->treeView->header()->logicalIndexAt(point);
43
- //selected a column. Give the option to hide it
44
- action = new QAction(&menu);
45
- action->setData(-index-1); //We set data to be negative (and minus 1) to hide a column, and positive to show a column
46
- action->setText(i18n("Hide Column '%1'", d->mFilterModel.headerData(index, Qt::Horizontal, Qt::DisplayRole).toString()));
47
- menu.addAction(action);
48
- if(d->mUi->treeView->header()->sectionsHidden()) {
49
- menu.addSeparator();
50
+ bool anyOtherVisibleColumns = false;
51
+ for(int i = 0; i < num_headings; ++i) {
52
+ if(i != index && !d->mUi->treeView->header()->isSectionHidden(i)) {
53
+ anyOtherVisibleColumns = true;
57
+ if(anyOtherVisibleColumns) {
58
+ //selected a column. Give the option to hide it
59
+ action = new QAction(&menu);
60
+ action->setData(-index-1); //We set data to be negative (and minus 1) to hide a column, and positive to show a column
61
+ action->setText(i18n("Hide Column '%1'", d->mFilterModel.headerData(index, Qt::Horizontal, Qt::DisplayRole).toString()));
62
+ menu.addAction(action);
63
+ if(d->mUi->treeView->header()->sectionsHidden()) {
64
+ menu.addSeparator();
69
if(d->mUi->treeView->header()->sectionsHidden()) {
70
- int num_headings = d->mFilterModel.columnCount();
71
for(int i = 0; i < num_headings; ++i) {
72
if(d->mUi->treeView->header()->isSectionHidden(i)) {