Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
259
Issues
259
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Multimedia
Kdenlive
Commits
6e5bb1f5
Commit
6e5bb1f5
authored
Jul 11, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save folder status (expanded or not).
Related to #287
parent
6fa7f38a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
6 deletions
+74
-6
src/bin/bin.cpp
src/bin/bin.cpp
+37
-0
src/bin/bin.h
src/bin/bin.h
+4
-0
src/bin/projectitemmodel.cpp
src/bin/projectitemmodel.cpp
+18
-3
src/bin/projectitemmodel.h
src/bin/projectitemmodel.h
+4
-2
src/project/projectmanager.cpp
src/project/projectmanager.cpp
+1
-0
src/timeline2/model/builders/meltBuilder.cpp
src/timeline2/model/builders/meltBuilder.cpp
+10
-1
No files found.
src/bin/bin.cpp
View file @
6e5bb1f5
...
...
@@ -4233,3 +4233,40 @@ void Bin::checkMissingProxies()
pCore
->
currentDoc
()
->
slotProxyCurrentItem
(
true
,
toProxy
);
}
}
void
Bin
::
saveFolderState
()
{
// Check folder state (expanded or not)
if
(
m_itemView
==
nullptr
||
m_listType
!=
BinTreeView
)
{
// Folder state is only valid in tree view mode
return
;
}
auto
*
view
=
static_cast
<
QTreeView
*>
(
m_itemView
);
QList
<
std
::
shared_ptr
<
ProjectFolder
>
>
folders
=
m_itemModel
->
getFolders
();
QStringList
expandedFolders
;
for
(
const
auto
&
folder
:
folders
)
{
QModelIndex
ix
=
m_itemModel
->
getIndexFromItem
(
folder
);
if
(
view
->
isExpanded
(
m_proxyModel
->
mapFromSource
(
ix
)))
{
// Save expanded state
expandedFolders
<<
folder
->
clipId
();
}
}
m_itemModel
->
saveProperty
(
QStringLiteral
(
"kdenlive:expandedFolders"
),
expandedFolders
.
join
(
QLatin1Char
(
';'
)));
}
void
Bin
::
loadFolderState
(
QStringList
foldersToExpand
)
{
// Check folder state (expanded or not)
if
(
m_itemView
==
nullptr
||
m_listType
!=
BinTreeView
)
{
// Folder state is only valid in tree view mode
return
;
}
auto
*
view
=
static_cast
<
QTreeView
*>
(
m_itemView
);
for
(
const
QString
&
id
:
foldersToExpand
)
{
std
::
shared_ptr
<
ProjectFolder
>
folder
=
m_itemModel
->
getFolderByBinId
(
id
);
if
(
folder
)
{
QModelIndex
ix
=
m_itemModel
->
getIndexFromItem
(
folder
);
view
->
setExpanded
(
m_proxyModel
->
mapFromSource
(
ix
),
true
);
}
}
}
src/bin/bin.h
View file @
6e5bb1f5
...
...
@@ -285,6 +285,10 @@ public:
void
invalidateClip
(
const
QString
&
binId
);
/** @brief Recreate missing proxies on document opening */
void
checkMissingProxies
();
/** @brief Save folder state (expanded or not) */
void
saveFolderState
();
/** @brief Load folder state (expanded or not) */
void
loadFolderState
(
QStringList
foldersToExpand
);
// TODO refac: remove this and call directly the function in ProjectItemModel
void
cleanup
();
...
...
src/bin/projectitemmodel.cpp
View file @
6e5bb1f5
...
...
@@ -423,6 +423,19 @@ std::shared_ptr<ProjectFolder> ProjectItemModel::getFolderByBinId(const QString
return
nullptr
;
}
QList
<
std
::
shared_ptr
<
ProjectFolder
>
>
ProjectItemModel
::
getFolders
()
{
READ_LOCK
();
QList
<
std
::
shared_ptr
<
ProjectFolder
>
>
folders
;
for
(
const
auto
&
clip
:
m_allItems
)
{
auto
c
=
std
::
static_pointer_cast
<
AbstractProjectItem
>
(
clip
.
second
.
lock
());
if
(
c
->
itemType
()
==
AbstractProjectItem
::
FolderItem
)
{
folders
<<
std
::
static_pointer_cast
<
ProjectFolder
>
(
c
);
}
}
return
folders
;
}
const
QString
ProjectItemModel
::
getFolderIdByName
(
const
QString
&
folderName
)
{
READ_LOCK
();
...
...
@@ -881,7 +894,7 @@ QStringList ProjectItemModel::getClipByUrl(const QFileInfo &url) const
return
result
;
}
bool
ProjectItemModel
::
loadFolders
(
Mlt
::
Properties
&
folders
)
bool
ProjectItemModel
::
loadFolders
(
Mlt
::
Properties
&
folders
,
std
::
unordered_map
<
QString
,
QString
>
&
binIdCorresp
)
{
QWriteLocker
locker
(
&
m_lock
);
// At this point, we expect the folders properties to have a name of the form "x.y" where x is the id of the parent folder and y the id of the child.
...
...
@@ -938,6 +951,7 @@ bool ProjectItemModel::loadFolders(Mlt::Properties &folders)
Q_ASSERT
(
undone
);
return
false
;
}
binIdCorresp
[
QString
::
number
(
current
)]
=
id
;
newIds
[
current
]
=
id
;
}
for
(
int
c
:
downLinks
[
current
])
{
...
...
@@ -962,7 +976,7 @@ bool ProjectItemModel::isIdFree(const QString &id) const
return
true
;
}
void
ProjectItemModel
::
loadBinPlaylist
(
Mlt
::
Tractor
*
documentTractor
,
Mlt
::
Tractor
*
modelTractor
,
std
::
unordered_map
<
QString
,
QString
>
&
binIdCorresp
,
QProgressDialog
*
progressDialog
)
void
ProjectItemModel
::
loadBinPlaylist
(
Mlt
::
Tractor
*
documentTractor
,
Mlt
::
Tractor
*
modelTractor
,
std
::
unordered_map
<
QString
,
QString
>
&
binIdCorresp
,
Q
StringList
&
expandedFolders
,
Q
ProgressDialog
*
progressDialog
)
{
QWriteLocker
locker
(
&
m_lock
);
clean
();
...
...
@@ -983,8 +997,9 @@ void ProjectItemModel::loadBinPlaylist(Mlt::Tractor *documentTractor, Mlt::Tract
// Load folders
Mlt
::
Properties
folderProperties
;
Mlt
::
Properties
playlistProps
(
playlist
.
get_properties
());
expandedFolders
=
QString
(
playlistProps
.
get
(
"kdenlive:expandedFolders"
)).
split
(
QLatin1Char
(
';'
));
folderProperties
.
pass_values
(
playlistProps
,
"kdenlive:folder."
);
loadFolders
(
folderProperties
);
loadFolders
(
folderProperties
,
binIdCorresp
);
// Read notes
QString
notes
=
playlistProps
.
get
(
"kdenlive:documentnotes"
);
...
...
src/bin/projectitemmodel.h
View file @
6e5bb1f5
...
...
@@ -78,6 +78,8 @@ public:
/** @brief Gets a folder by its id. If none is found, nullptr is returned */
std
::
shared_ptr
<
ProjectFolder
>
getFolderByBinId
(
const
QString
&
binId
);
/** @brief Gets a list of all folders in this project */
QList
<
std
::
shared_ptr
<
ProjectFolder
>
>
getFolders
();
/** @brief Gets a id folder by its name. If none is found, empty string returned */
const
QString
getFolderIdByName
(
const
QString
&
folderName
);
...
...
@@ -105,10 +107,10 @@ public:
std
::
shared_ptr
<
AbstractProjectItem
>
getBinItemByIndex
(
const
QModelIndex
&
index
)
const
;
/* @brief Load the folders given the property containing them */
bool
loadFolders
(
Mlt
::
Properties
&
folders
);
bool
loadFolders
(
Mlt
::
Properties
&
folders
,
std
::
unordered_map
<
QString
,
QString
>
&
binIdCorresp
);
/* @brief Parse a bin playlist from the document tractor and reconstruct the tree */
void
loadBinPlaylist
(
Mlt
::
Tractor
*
documentTractor
,
Mlt
::
Tractor
*
modelTractor
,
std
::
unordered_map
<
QString
,
QString
>
&
binIdCorresp
,
QProgressDialog
*
progressDialog
=
nullptr
);
void
loadBinPlaylist
(
Mlt
::
Tractor
*
documentTractor
,
Mlt
::
Tractor
*
modelTractor
,
std
::
unordered_map
<
QString
,
QString
>
&
binIdCorresp
,
Q
StringList
&
expandedFolders
,
Q
ProgressDialog
*
progressDialog
=
nullptr
);
/** @brief Save document properties in MLT's bin playlist */
void
saveDocumentProperties
(
const
QMap
<
QString
,
QString
>
&
props
,
const
QMap
<
QString
,
QString
>
&
metadata
,
std
::
shared_ptr
<
MarkerListModel
>
guideModel
);
...
...
src/project/projectmanager.cpp
View file @
6e5bb1f5
...
...
@@ -724,6 +724,7 @@ void ProjectManager::prepareSave()
{
pCore
->
projectItemModel
()
->
saveDocumentProperties
(
pCore
->
window
()
->
getMainTimeline
()
->
controller
()
->
documentProperties
(),
m_project
->
metadata
(),
m_project
->
getGuideModel
());
pCore
->
bin
()
->
saveFolderState
();
pCore
->
projectItemModel
()
->
saveProperty
(
QStringLiteral
(
"kdenlive:documentnotes"
),
documentNotes
());
pCore
->
projectItemModel
()
->
saveProperty
(
QStringLiteral
(
"kdenlive:docproperties.groups"
),
m_mainTimelineModel
->
groupsData
());
}
...
...
src/timeline2/model/builders/meltBuilder.cpp
View file @
6e5bb1f5
...
...
@@ -57,8 +57,17 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
timeline
->
requestReset
(
undo
,
redo
);
m_errorMessage
.
clear
();
std
::
unordered_map
<
QString
,
QString
>
binIdCorresp
;
pCore
->
projectItemModel
()
->
loadBinPlaylist
(
&
tractor
,
timeline
->
tractor
(),
binIdCorresp
,
progressDialog
);
QStringList
expandedFolders
;
pCore
->
projectItemModel
()
->
loadBinPlaylist
(
&
tractor
,
timeline
->
tractor
(),
binIdCorresp
,
expandedFolders
,
progressDialog
);
pCore
->
bin
()
->
checkMissingProxies
();
QStringList
foldersToExpand
;
// Find updated ids for expanded folders
for
(
const
QString
&
folderId
:
expandedFolders
)
{
if
(
binIdCorresp
.
count
(
folderId
)
>
0
)
{
foldersToExpand
<<
binIdCorresp
.
at
(
folderId
);
}
}
pCore
->
bin
()
->
loadFolderState
(
foldersToExpand
);
QSet
<
QString
>
reserved_names
{
QLatin1String
(
"playlistmain"
),
QLatin1String
(
"timeline_preview"
),
QLatin1String
(
"timeline_overlay"
),
QLatin1String
(
"black_track"
)};
...
...
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