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
Multimedia
Kdenlive
Commits
8bc21ec4
Commit
8bc21ec4
authored
Dec 05, 2020
by
Jean-Baptiste Mardelle
Browse files
Add "unused clip" filter in Project Bin.
BUG: 430035
parent
3b5250a0
Pipeline
#43029
passed with stage
in 10 minutes and 8 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/bin.cpp
View file @
8bc21ec4
...
...
@@ -1091,11 +1091,14 @@ Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent)
QList
<
QAction
*>
list
=
m_filterMenu
->
actions
();
int
rateFilters
=
0
;
int
typeFilters
=
0
;
bool
usedFilter
=
false
;
QStringList
tagFilters
;
for
(
QAction
*
ac
:
qAsConst
(
list
))
{
if
(
ac
->
isChecked
())
{
QString
actionData
=
ac
->
data
().
toString
();
if
(
actionData
.
startsWith
(
QLatin1Char
(
'#'
)))
{
if
(
actionData
==
QLatin1String
(
"unused"
))
{
usedFilter
=
true
;
}
else
if
(
actionData
.
startsWith
(
QLatin1Char
(
'#'
)))
{
// Filter by tag
tagFilters
<<
actionData
;
}
else
if
(
actionData
.
startsWith
(
QLatin1Char
(
'.'
)))
{
...
...
@@ -1118,7 +1121,7 @@ Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent)
}
else
{
m_filterButton
->
setChecked
(
false
);
}
m_proxyModel
->
slotSetFilters
(
tagFilters
,
rateFilters
,
typeFilters
);
m_proxyModel
->
slotSetFilters
(
tagFilters
,
rateFilters
,
typeFilters
,
usedFilter
);
});
connect
(
m_filterMenu
,
&
QMenu
::
triggered
,
this
,
[
this
](
QAction
*
action
)
{
...
...
@@ -1137,11 +1140,14 @@ Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent)
QList
<
QAction
*>
list
=
m_filterMenu
->
actions
();
int
rateFilters
=
0
;
int
typeFilters
=
0
;
bool
usedFilter
=
false
;
QStringList
tagFilters
;
for
(
QAction
*
ac
:
qAsConst
(
list
))
{
if
(
ac
->
isChecked
())
{
QString
actionData
=
ac
->
data
().
toString
();
if
(
actionData
.
startsWith
(
QLatin1Char
(
'#'
)))
{
if
(
actionData
==
QLatin1String
(
"unused"
))
{
usedFilter
=
true
;
}
else
if
(
actionData
.
startsWith
(
QLatin1Char
(
'#'
)))
{
// Filter by tag
tagFilters
<<
actionData
;
}
else
if
(
actionData
.
startsWith
(
QLatin1Char
(
'.'
)))
{
...
...
@@ -1164,7 +1170,7 @@ Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent)
}
else
{
m_filterButton
->
setChecked
(
false
);
}
m_proxyModel
->
slotSetFilters
(
tagFilters
,
rateFilters
,
typeFilters
);
m_proxyModel
->
slotSetFilters
(
tagFilters
,
rateFilters
,
typeFilters
,
usedFilter
);
});
m_tagAction
->
setCheckable
(
true
);
...
...
@@ -1738,6 +1744,12 @@ void Bin::rebuildFilters(QMap <QString, QString> tags)
rateFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
rateFilter
);
}
// Add unused filter
m_filterMenu
->
addSeparator
();
QAction
*
unusedFilter
=
new
QAction
(
i18n
(
"Unused clips"
),
this
);
unusedFilter
->
setData
(
QStringLiteral
(
"unused"
));
unusedFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
unusedFilter
);
// Add type filters
m_filterMenu
->
addSeparator
();
...
...
src/bin/projectitemmodel.cpp
View file @
8bc21ec4
...
...
@@ -104,6 +104,9 @@ int ProjectItemModel::mapToColumn(int column) const
case
7
:
return
AbstractProjectItem
::
DataRating
;
break
;
case
8
:
return
AbstractProjectItem
::
UsageCount
;
break
;
default:
return
AbstractProjectItem
::
DataName
;
}
...
...
src/bin/projectsortproxymodel.cpp
View file @
8bc21ec4
...
...
@@ -28,6 +28,7 @@ ProjectSortProxyModel::ProjectSortProxyModel(QObject *parent)
:
QSortFilterProxyModel
(
parent
)
,
m_searchType
(
0
)
,
m_searchRating
(
0
)
,
m_unusedFilter
(
false
)
{
m_collator
.
setLocale
(
QLocale
());
// Locale used for sorting → OK
m_collator
.
setCaseSensitivity
(
Qt
::
CaseInsensitive
);
...
...
@@ -49,6 +50,13 @@ bool ProjectSortProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
bool
ProjectSortProxyModel
::
filterAcceptsRowItself
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
{
if
(
m_unusedFilter
)
{
// Column 8 contains the usage
QModelIndex
indexTag
=
sourceModel
()
->
index
(
sourceRow
,
8
,
sourceParent
);
if
(
sourceModel
()
->
data
(
indexTag
).
toInt
()
>
0
)
{
return
false
;
}
}
if
(
m_searchRating
>
0
)
{
// Column 7 contains the rating
QModelIndex
indexTag
=
sourceModel
()
->
index
(
sourceRow
,
7
,
sourceParent
);
...
...
@@ -146,11 +154,12 @@ void ProjectSortProxyModel::slotSetSearchString(const QString &str)
invalidateFilter
();
}
void
ProjectSortProxyModel
::
slotSetFilters
(
const
QStringList
tagFilters
,
const
int
rateFilters
,
const
int
typeFilters
)
void
ProjectSortProxyModel
::
slotSetFilters
(
const
QStringList
tagFilters
,
const
int
rateFilters
,
const
int
typeFilters
,
bool
unusedFilter
)
{
m_searchType
=
typeFilters
;
m_searchRating
=
rateFilters
;
m_searchTag
=
tagFilters
;
m_unusedFilter
=
unusedFilter
;
invalidateFilter
();
}
...
...
@@ -159,6 +168,7 @@ void ProjectSortProxyModel::slotClearSearchFilters()
m_searchTag
.
clear
();
m_searchRating
=
0
;
m_searchType
=
0
;
m_unusedFilter
=
false
;
invalidateFilter
();
}
...
...
src/bin/projectsortproxymodel.h
View file @
8bc21ec4
...
...
@@ -44,7 +44,7 @@ public slots:
/** @brief Set search string that will filter the view */
void
slotSetSearchString
(
const
QString
&
str
);
/** @brief Set search tag that will filter the view */
void
slotSetFilters
(
const
QStringList
tagFilters
,
int
rateFilters
,
int
typeFilters
);
void
slotSetFilters
(
const
QStringList
tagFilters
,
int
rateFilters
,
int
typeFilters
,
bool
unusedFilter
);
/** @brief Reset search filters */
void
slotClearSearchFilters
();
/** @brief Relay datachanged signal from view's model */
...
...
@@ -71,6 +71,7 @@ private:
QStringList
m_searchTag
;
int
m_searchType
;
int
m_searchRating
;
bool
m_unusedFilter
;
QCollator
m_collator
;
signals:
...
...
Davy Bartoloni
🍕
@bartoloni
·
Dec 06, 2020
this is very usefull :) thank you jean
this is very usefull :) thank you jean
Write
Preview
Supports
Markdown
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