diff options
| author | Renato Araujo Oliveira Filho <[email protected]> | 2017-12-07 11:36:00 -0300 |
|---|---|---|
| committer | Renato Araujo Oliveira Filho <[email protected]> | 2017-12-14 09:42:13 -0300 |
| commit | 5f1df43b87898b380228a3548553de3290ddb0d7 (patch) | |
| tree | 0de269324e3ee153f873c8d9383070fa879555ab /src/panels/places/placespanel.cpp | |
| parent | da6f8fe0862585287153f0d90e19eab0b34bfbef (diff) | |
Implemented support for hide/show groups
Summary:
Added an option on PlacesPanel context menu to show or hide the entire
group of places.
Depends on D8855
Test Plan: Open Donlphin and use PlacesPanel context menu to hide and show groups
Reviewers: franckarrecot, mlaurent, mwolff, elvisangelaccio
Reviewed By: franckarrecot, mlaurent, mwolff, elvisangelaccio
Subscribers: rkflx, mwolff, elvisangelaccio, ngraham, #dolphin
Differential Revision: https://phabricator.kde.org/D9242
Diffstat (limited to 'src/panels/places/placespanel.cpp')
| -rw-r--r-- | src/panels/places/placespanel.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index d8eab7dd9..f7ca7d010 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -223,6 +223,8 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) hideAction->setCheckable(true); hideAction->setChecked(item->isHidden()); + buildGroupContextMenu(&menu, index); + QAction* action = menu.exec(pos.toPoint()); if (action) { if (action == emptyTrashAction) { @@ -273,6 +275,8 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) showAllAction->setChecked(m_model->hiddenItemsShown()); } + buildGroupContextMenu(&menu, m_controller->indexCloseToMousePressedPosition()); + QMenu* iconSizeSubMenu = new QMenu(i18nc("@item:inmenu", "Icon Size"), &menu); struct IconSizeInfo @@ -326,6 +330,24 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) selectClosestItem(); } +QAction *PlacesPanel::buildGroupContextMenu(QMenu *menu, int index) +{ + if (index == -1) { + return nullptr; + } + + KFilePlacesModel::GroupType groupType = m_model->groupType(index); + QAction *hideGroupAction = menu->addAction(i18nc("@item:inmenu", "Hide Section '%1'", m_model->item(index)->group())); + hideGroupAction->setCheckable(true); + hideGroupAction->setChecked(m_model->isGroupHidden(groupType)); + + connect(hideGroupAction, &QAction::triggered, this, [this, groupType, hideGroupAction]{ + m_model->setGroupHidden(groupType, hideGroupAction->isChecked()); + }); + + return hideGroupAction; +} + void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) { if (index < 0) { |
