┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/dolphinview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-03-14 16:51:21 +0100
committerPeter Penz <[email protected]>2012-03-14 16:53:31 +0100
commitd6e10a5942442f8423385ff1301c9163b334e4ed (patch)
treeffe62eb1c5efbd4278776ebecbe88d18899bf11b /src/views/dolphinview.cpp
parentd048fe0161cdf4a4c161db660947a167dd18dc80 (diff)
Use sub-menus for the "Sort By"- and "Additional Information"-menu
This allows doing some grouping for the visible roles by e.g. Image, Document, Music or whatever.
Diffstat (limited to 'src/views/dolphinview.cpp')
-rw-r--r--src/views/dolphinview.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 890a39d89..29a132184 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -779,17 +779,33 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
KItemListView* view = m_container->controller()->view();
const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet();
+ QString groupName;
+ QMenu* groupMenu = 0;
+
// Add all roles to the menu that can be shown or hidden by the user
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
- if (info.role != "name") {
- const QString text = fileItemModel()->roleDescription(info.role);
+ if (info.role == "name") {
+ // It should not be possible to hide the "name" role
+ continue;
+ }
+
+ const QString text = fileItemModel()->roleDescription(info.role);
+ QAction* action = 0;
+ if (info.group.isEmpty()) {
+ action = menu.data()->addAction(text);
+ } else {
+ if (!groupMenu || info.group != groupName) {
+ groupName = info.group;
+ groupMenu = menu.data()->addMenu(groupName);
+ }
- QAction* action = menu.data()->addAction(text);
- action->setCheckable(true);
- action->setChecked(visibleRolesSet.contains(info.role));
- action->setData(info.role);
+ action = groupMenu->addAction(text);
}
+
+ action->setCheckable(true);
+ action->setChecked(visibleRolesSet.contains(info.role));
+ action->setData(info.role);
}
QAction* action = menu.data()->exec(pos.toPoint());