Skip to content
GitLab
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
1718d1a9
Commit
1718d1a9
authored
Dec 27, 2019
by
Jean-Baptiste Mardelle
Browse files
Add sort by duration and filter by type actions
parent
46929e31
Pipeline
#12510
passed with stage
in 13 minutes and 18 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/bin.cpp
View file @
1718d1a9
...
...
@@ -877,8 +877,13 @@ Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent)
sortByType
->
setCheckable
(
true
);
sortByType
->
setData
(
3
);
sortByType
->
setChecked
(
binSort
==
3
);
QAction
*
sortByDuration
=
new
QAction
(
i18n
(
"Duration"
),
m_sortGroup
);
sortByDuration
->
setCheckable
(
true
);
sortByDuration
->
setData
(
5
);
sortByDuration
->
setChecked
(
binSort
==
5
);
sort
->
addAction
(
sortByName
);
sort
->
addAction
(
sortByDate
);
sort
->
addAction
(
sortByDuration
);
sort
->
addAction
(
sortByType
);
sort
->
addAction
(
sortByDesc
);
sort
->
addSeparator
();
...
...
@@ -944,11 +949,20 @@ Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent)
filterButton
->
setPopupMode
(
QToolButton
::
InstantPopup
);
m_toolbar
->
addWidget
(
filterButton
);
connect
(
m_filterMenu
,
&
QMenu
::
triggered
,
[
&
]
(
QAction
*
ac
)
{
QString
action
=
ac
->
data
().
toString
();
if
(
action
.
startsWith
(
QLatin1Char
(
'#'
)))
{
m_proxyModel
->
slotSetSearchTag
(
action
);
}
else
{
QString
actionData
=
ac
->
data
().
toString
();
if
(
actionData
.
startsWith
(
QLatin1Char
(
'#'
)))
{
// Filter by tag
m_proxyModel
->
slotSetSearchType
(
0
,
false
);
m_proxyModel
->
slotSetSearchTag
(
actionData
);
}
else
if
(
actionData
.
isEmpty
())
{
// Reset filter
m_proxyModel
->
slotSetSearchType
(
0
,
false
);
m_proxyModel
->
slotSetSearchTag
(
QString
());
}
else
{
// Filter by type
int
type
=
actionData
.
toInt
();
m_proxyModel
->
slotSetSearchTag
(
QString
(),
false
);
m_proxyModel
->
slotSetSearchType
(
type
);
}
});
...
...
@@ -1389,6 +1403,7 @@ void Bin::setDocument(KdenliveDoc *project)
QAction
*
clearFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-clear"
)),
i18n
(
"Clear"
),
filterGrp
);
clearFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
clearFilter
);
// Add tag filters
int
tagsCount
=
pCore
->
getProjectTags
().
size
();
for
(
int
i
=
1
;
i
<=
tagsCount
;
i
++
)
{
QAction
*
tag
=
pCore
->
window
()
->
actionCollection
()
->
action
(
QString
(
"tag_%1"
).
arg
(
i
));
...
...
@@ -1399,6 +1414,44 @@ void Bin::setDocument(KdenliveDoc *project)
m_filterMenu
->
addAction
(
tagFilter
);
}
}
// Add type filters
m_filterMenu
->
addSeparator
();
QAction
*
typeFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"video-x-generic"
)),
i18n
(
"AV Clip"
),
filterGrp
);
typeFilter
->
setData
(
ClipType
::
AV
);
typeFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
typeFilter
);
typeFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"video-x-matroska"
)),
i18n
(
"Mute Video"
),
filterGrp
);
typeFilter
->
setData
(
ClipType
::
Video
);
typeFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
typeFilter
);
typeFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"audio-x-generic"
)),
i18n
(
"Audio"
),
filterGrp
);
typeFilter
->
setData
(
ClipType
::
Audio
);
typeFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
typeFilter
);
typeFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"image-jpeg"
)),
i18n
(
"Image"
),
filterGrp
);
typeFilter
->
setData
(
ClipType
::
Image
);
typeFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
typeFilter
);
typeFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"kdenlive-add-slide-clip"
)),
i18n
(
"Slideshow"
),
filterGrp
);
typeFilter
->
setData
(
ClipType
::
SlideShow
);
typeFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
typeFilter
);
typeFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"video-mlt-playlist"
)),
i18n
(
"Playlist"
),
filterGrp
);
typeFilter
->
setData
(
ClipType
::
Playlist
);
typeFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
typeFilter
);
typeFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"draw-text"
)),
i18n
(
"Title"
),
filterGrp
);
typeFilter
->
setData
(
ClipType
::
Text
);
typeFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
typeFilter
);
typeFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"draw-text"
)),
i18n
(
"Title Template"
),
filterGrp
);
typeFilter
->
setData
(
ClipType
::
TextTemplate
);
typeFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
typeFilter
);
typeFilter
=
new
QAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"kdenlive-add-color-clip"
)),
i18n
(
"Color"
),
filterGrp
);
typeFilter
->
setData
(
ClipType
::
Color
);
typeFilter
->
setCheckable
(
true
);
m_filterMenu
->
addAction
(
typeFilter
);
// connect(m_itemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), m_itemView
// connect(m_itemModel, SIGNAL(updateCurrentItem()), this, SLOT(autoSelect()));
...
...
src/bin/projectsortproxymodel.cpp
View file @
1718d1a9
...
...
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
ProjectSortProxyModel
::
ProjectSortProxyModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
,
m_searchType
(
0
)
{
m_collator
.
setNumericMode
(
true
);
m_collator
.
setCaseSensitivity
(
Qt
::
CaseInsensitive
);
...
...
@@ -46,14 +47,25 @@ bool ProjectSortProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
bool
ProjectSortProxyModel
::
filterAcceptsRowItself
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
{
int
cols
=
sourceModel
()
->
columnCount
();
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
QModelIndex
index0
=
sourceModel
()
->
index
(
sourceRow
,
i
,
sourceParent
);
if
(
!
index0
.
isValid
())
{
return
false
;
}
bool
typeAccepted
=
false
;
bool
tagAccepted
=
false
;
auto
data
=
sourceModel
()
->
data
(
index0
);
if
(
m_searchType
>
0
)
{
QModelIndex
indexTag
=
sourceModel
()
->
index
(
sourceRow
,
3
,
sourceParent
);
if
(
sourceModel
()
->
data
(
indexTag
).
toInt
()
==
m_searchType
)
{
typeAccepted
=
true
;
}
}
else
{
typeAccepted
=
true
;
}
if
(
!
typeAccepted
)
{
return
false
;
}
if
(
!
m_searchTag
.
isEmpty
())
{
// Column 4 contains the item tag data
QModelIndex
indexTag
=
sourceModel
()
->
index
(
sourceRow
,
4
,
sourceParent
);
...
...
@@ -135,10 +147,20 @@ void ProjectSortProxyModel::slotSetSearchString(const QString &str)
invalidateFilter
();
}
void
ProjectSortProxyModel
::
slotSetSearchTag
(
const
QString
&
str
)
void
ProjectSortProxyModel
::
slotSetSearchTag
(
const
QString
&
str
,
bool
reload
)
{
m_searchTag
=
str
;
invalidateFilter
();
if
(
reload
)
{
invalidateFilter
();
}
}
void
ProjectSortProxyModel
::
slotSetSearchType
(
const
int
type
,
bool
reload
)
{
m_searchType
=
type
;
if
(
reload
)
{
invalidateFilter
();
}
}
void
ProjectSortProxyModel
::
onCurrentRowChanged
(
const
QItemSelection
&
current
,
const
QItemSelection
&
previous
)
...
...
src/bin/projectsortproxymodel.h
View file @
1718d1a9
...
...
@@ -44,7 +44,9 @@ 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
slotSetSearchTag
(
const
QString
&
str
);
void
slotSetSearchTag
(
const
QString
&
str
,
bool
reload
=
true
);
/** @brief Set search type that will filter the view */
void
slotSetSearchType
(
const
int
type
,
bool
reload
=
true
);
/** @brief Relay datachanged signal from view's model */
void
slotDataChanged
(
const
QModelIndex
&
ix1
,
const
QModelIndex
&
ix2
,
const
QVector
<
int
>
&
roles
);
...
...
@@ -65,6 +67,7 @@ private:
QItemSelectionModel
*
m_selection
;
QString
m_searchString
;
QString
m_searchTag
;
int
m_searchType
;
QCollator
m_collator
;
signals:
...
...
Eugen Mohr
@emohr
mentioned in issue
#378 (closed)
·
Dec 27, 2019
mentioned in issue
#378 (closed)
mentioned in issue #378
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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