Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
System
Dolphin
Commits
65b283a9
Commit
65b283a9
authored
Nov 08, 2019
by
Ismael Asensio
Browse files
search: Add action to clear tag selection
BUG: 432719
parent
5ce25a5c
Pipeline
#60611
passed with stage
in 5 minutes and 7 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/search/dolphinfacetswidget.cpp
View file @
65b283a9
...
...
@@ -53,6 +53,12 @@ DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) :
m_ratingSelector
->
addItem
(
QIcon
::
fromTheme
(
QStringLiteral
(
"starred-symbolic"
)),
i18nc
(
"@item:inlistbox"
,
"Highest Rating"
),
5
);
initComboBox
(
m_ratingSelector
);
m_clearTagsAction
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-clear-all"
)),
i18nc
(
"@action:inmenu"
,
"Clear Selection"
),
this
);
connect
(
m_clearTagsAction
,
&
QAction
::
triggered
,
this
,
[
this
]()
{
resetSearchTags
();
Q_EMIT
facetChanged
();
});
m_tagsSelector
=
new
QToolButton
(
this
);
m_tagsSelector
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"tag"
)));
m_tagsSelector
->
setMenu
(
new
QMenu
(
this
));
...
...
@@ -97,9 +103,7 @@ void DolphinFacetsWidget::resetSearchTerms()
m_dateSelector
->
setCurrentIndex
(
0
);
m_ratingSelector
->
setCurrentIndex
(
0
);
m_searchTags
=
QStringList
();
updateTagsSelector
();
updateTagsMenu
();
resetSearchTags
();
}
QStringList
DolphinFacetsWidget
::
searchTerms
()
const
...
...
@@ -218,6 +222,13 @@ void DolphinFacetsWidget::removeSearchTag(const QString& tag)
updateTagsSelector
();
}
void
DolphinFacetsWidget
::
resetSearchTags
()
{
m_searchTags
=
QStringList
();
updateTagsSelector
();
updateTagsMenu
();
}
void
DolphinFacetsWidget
::
initComboBox
(
QComboBox
*
combo
)
{
combo
->
setFrame
(
false
);
...
...
@@ -240,6 +251,7 @@ void DolphinFacetsWidget::updateTagsSelector()
}
m_tagsSelector
->
setEnabled
(
isEnabled
()
&&
(
hasListedTags
||
hasSelectedTags
));
m_clearTagsAction
->
setEnabled
(
hasSelectedTags
);
}
void
DolphinFacetsWidget
::
updateTagsMenu
()
...
...
@@ -250,7 +262,8 @@ void DolphinFacetsWidget::updateTagsMenu()
void
DolphinFacetsWidget
::
updateTagsMenuItems
(
const
QUrl
&
,
const
KFileItemList
&
items
)
{
m_tagsSelector
->
menu
()
->
clear
();
QMenu
*
tagsMenu
=
m_tagsSelector
->
menu
();
tagsMenu
->
clear
();
QStringList
allTags
=
QStringList
(
m_searchTags
);
for
(
const
KFileItem
&
item
:
items
)
{
...
...
@@ -262,7 +275,7 @@ void DolphinFacetsWidget::updateTagsMenuItems(const QUrl&, const KFileItemList&
const
bool
onlyOneTag
=
allTags
.
count
()
==
1
;
for
(
const
QString
&
tagName
:
qAsConst
(
allTags
))
{
QAction
*
action
=
m_
tags
Selector
->
m
enu
()
->
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"tag"
)),
tagName
);
QAction
*
action
=
tags
M
enu
->
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"tag"
)),
tagName
);
action
->
setCheckable
(
true
);
action
->
setChecked
(
m_searchTags
.
contains
(
tagName
));
...
...
@@ -280,5 +293,10 @@ void DolphinFacetsWidget::updateTagsMenuItems(const QUrl&, const KFileItemList&
});
}
if
(
allTags
.
count
()
>
1
)
{
tagsMenu
->
addSeparator
();
tagsMenu
->
addAction
(
m_clearTagsAction
);
}
updateTagsSelector
();
}
src/search/dolphinfacetswidget.h
View file @
65b283a9
...
...
@@ -63,6 +63,7 @@ private:
void
setTimespan
(
const
QDate
&
date
);
void
addSearchTag
(
const
QString
&
tag
);
void
removeSearchTag
(
const
QString
&
tag
);
void
resetSearchTags
();
void
initComboBox
(
QComboBox
*
combo
);
void
updateTagsSelector
();
...
...
@@ -75,6 +76,7 @@ private:
QStringList
m_searchTags
;
KCoreDirLister
m_tagsLister
;
QAction
*
m_clearTagsAction
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment