Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
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
videolan
vlc-2-2
Commits
26201e1c
Commit
26201e1c
authored
Aug 19, 2009
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qt4 playlist: simplify view notification, don't rebuild on popup sort
parent
c149ea80
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
47 deletions
+48
-47
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
+43
-43
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/playlist_model.hpp
+5
-4
No files found.
modules/gui/qt4/components/playlist/playlist_model.cpp
View file @
26201e1c
...
@@ -708,11 +708,9 @@ void PLModel::ProcessItemAppend( const playlist_add_t *p_add )
...
@@ -708,11 +708,9 @@ void PLModel::ProcessItemAppend( const playlist_add_t *p_add )
newItem
=
new
PLItem
(
p_item
,
nodeItem
);
newItem
=
new
PLItem
(
p_item
,
nodeItem
);
PL_UNLOCK
;
PL_UNLOCK
;
emit
layoutAboutToBeChanged
();
beginInsertRows
(
index
(
nodeItem
,
0
),
nodeItem
->
childCount
(),
nodeItem
->
childCount
()
);
emit
beginInsertRows
(
index
(
newItem
,
0
),
nodeItem
->
childCount
(),
nodeItem
->
childCount
()
+
1
);
nodeItem
->
appendChild
(
newItem
);
nodeItem
->
appendChild
(
newItem
);
emit
endInsertRows
();
endInsertRows
();
emit
layoutChanged
();
UpdateTreeItem
(
newItem
,
true
);
UpdateTreeItem
(
newItem
,
true
);
return
;
return
;
end:
end:
...
@@ -734,20 +732,8 @@ void PLModel::rebuild( playlist_item_t *p_root )
...
@@ -734,20 +732,8 @@ void PLModel::rebuild( playlist_item_t *p_root )
/* Invalidate cache */
/* Invalidate cache */
i_cached_id
=
i_cached_input_id
=
-
1
;
i_cached_id
=
i_cached_input_id
=
-
1
;
emit
layoutAboutToBeChanged
(
);
if
(
rootItem
)
RemoveChildren
(
rootItem
);
/* Clear the tree */
if
(
rootItem
)
{
if
(
rootItem
->
children
.
size
()
)
{
emit
beginRemoveRows
(
index
(
rootItem
,
0
),
0
,
rootItem
->
children
.
size
()
-
1
);
qDeleteAll
(
rootItem
->
children
);
rootItem
->
children
.
clear
();
emit
endRemoveRows
();
}
}
PL_LOCK
;
PL_LOCK
;
if
(
p_root
)
if
(
p_root
)
{
{
...
@@ -756,7 +742,7 @@ void PLModel::rebuild( playlist_item_t *p_root )
...
@@ -756,7 +742,7 @@ void PLModel::rebuild( playlist_item_t *p_root )
}
}
assert
(
rootItem
);
assert
(
rootItem
);
/* Recreate from root */
/* Recreate from root */
Update
Node
Children
(
rootItem
);
UpdateChildren
(
rootItem
);
if
(
(
p_item
=
playlist_CurrentPlayingItem
(
p_playlist
))
)
if
(
(
p_item
=
playlist_CurrentPlayingItem
(
p_playlist
))
)
currentItem
=
FindByInput
(
rootItem
,
p_item
->
p_input
->
i_id
);
currentItem
=
FindByInput
(
rootItem
,
p_item
->
p_input
->
i_id
);
else
else
...
@@ -764,33 +750,38 @@ void PLModel::rebuild( playlist_item_t *p_root )
...
@@ -764,33 +750,38 @@ void PLModel::rebuild( playlist_item_t *p_root )
PL_UNLOCK
;
PL_UNLOCK
;
/* And signal the view */
/* And signal the view */
reset
();
emit
currentChanged
(
index
(
currentItem
,
0
)
);
emit
currentChanged
(
index
(
currentItem
,
0
)
);
emit
layoutChanged
();
addCallbacks
();
addCallbacks
();
}
}
void
PLModel
::
RemoveChildren
(
PLItem
*
root
)
{
if
(
root
->
children
.
size
()
)
{
qDeleteAll
(
root
->
children
);
root
->
children
.
clear
();
}
}
/* This function must be entered WITH the playlist lock */
/* This function must be entered WITH the playlist lock */
void
PLModel
::
Update
Node
Children
(
PLItem
*
root
)
void
PLModel
::
UpdateChildren
(
PLItem
*
root
)
{
{
emit
layoutAboutToBeChanged
();
playlist_item_t
*
p_node
=
playlist_ItemGetById
(
p_playlist
,
root
->
i_id
);
playlist_item_t
*
p_node
=
playlist_ItemGetById
(
p_playlist
,
root
->
i_id
);
UpdateNodeChildren
(
p_node
,
root
);
UpdateChildren
(
p_node
,
root
);
emit
layoutChanged
();
}
}
/* This function must be entered WITH the playlist lock */
/* This function must be entered WITH the playlist lock */
void
PLModel
::
Update
Node
Children
(
playlist_item_t
*
p_node
,
PLItem
*
root
)
void
PLModel
::
UpdateChildren
(
playlist_item_t
*
p_node
,
PLItem
*
root
)
{
{
for
(
int
i
=
0
;
i
<
p_node
->
i_children
;
i
++
)
for
(
int
i
=
0
;
i
<
p_node
->
i_children
;
i
++
)
{
{
if
(
p_node
->
pp_children
[
i
]
->
i_flags
&
PLAYLIST_DBL_FLAG
)
continue
;
if
(
p_node
->
pp_children
[
i
]
->
i_flags
&
PLAYLIST_DBL_FLAG
)
continue
;
PLItem
*
newItem
=
new
PLItem
(
p_node
->
pp_children
[
i
],
root
);
PLItem
*
newItem
=
new
PLItem
(
p_node
->
pp_children
[
i
],
root
);
emit
beginInsertRows
(
index
(
newItem
,
0
),
root
->
childCount
(),
root
->
childCount
()
+
1
);
root
->
appendChild
(
newItem
);
root
->
appendChild
(
newItem
);
emit
endInsertRows
();
UpdateTreeItem
(
newItem
,
true
,
true
);
if
(
i_depth
==
DEPTH_PL
&&
p_node
->
pp_children
[
i
]
->
i_children
!=
-
1
)
if
(
i_depth
==
DEPTH_PL
&&
p_node
->
pp_children
[
i
]
->
i_children
!=
-
1
)
Update
Node
Children
(
p_node
->
pp_children
[
i
],
newItem
);
UpdateChildren
(
p_node
->
pp_children
[
i
],
newItem
);
}
}
}
}
...
@@ -860,10 +851,10 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
...
@@ -860,10 +851,10 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
playlist_NodeDelete
(
p_playlist
,
p_item
,
true
,
false
);
playlist_NodeDelete
(
p_playlist
,
p_item
,
true
,
false
);
PL_UNLOCK
;
PL_UNLOCK
;
/* And finally, remove it from the tree */
/* And finally, remove it from the tree */
emit
beginRemoveRows
(
index
(
item
->
parentItem
,
0
),
item
->
parentItem
->
children
.
indexOf
(
item
),
int
itemIndex
=
item
->
parentItem
->
children
.
indexOf
(
item
);
item
->
parentItem
->
children
.
indexOf
(
item
)
+
1
);
beginRemoveRows
(
index
(
item
->
parentItem
,
0
),
itemIndex
,
itemIndex
);
item
->
remove
(
item
,
i_depth
);
item
->
remove
(
item
,
i_depth
);
e
mit
e
ndRemoveRows
();
endRemoveRows
();
}
}
/******* Volume III: Sorting and searching ********/
/******* Volume III: Sorting and searching ********/
...
@@ -885,12 +876,21 @@ void PLModel::sort( int i_root_id, int column, Qt::SortOrder order )
...
@@ -885,12 +876,21 @@ void PLModel::sort( int i_root_id, int column, Qt::SortOrder order )
if
(
column
==
i_index
)
if
(
column
==
i_index
)
{
{
i_flag
=
i_column
;
i_flag
=
i_column
;
goto
next
;
break
;
}
}
}
}
PLItem
*
item
=
FindById
(
rootItem
,
i_root_id
);
if
(
!
item
)
return
;
QModelIndex
qIndex
=
index
(
item
,
0
);
int
count
=
item
->
children
.
size
();
if
(
count
)
{
beginRemoveRows
(
qIndex
,
0
,
count
-
1
);
RemoveChildren
(
item
);
endRemoveRows
(
);
}
next:
PL_LOCK
;
PL_LOCK
;
{
{
playlist_item_t
*
p_root
=
playlist_ItemGetById
(
p_playlist
,
playlist_item_t
*
p_root
=
playlist_ItemGetById
(
p_playlist
,
...
@@ -903,8 +903,13 @@ next:
...
@@ -903,8 +903,13 @@ next:
ORDER_NORMAL
:
ORDER_REVERSE
);
ORDER_NORMAL
:
ORDER_REVERSE
);
}
}
}
}
if
(
count
)
{
beginInsertRows
(
qIndex
,
0
,
count
-
1
);
UpdateChildren
(
item
);
endInsertRows
(
);
}
PL_UNLOCK
;
PL_UNLOCK
;
rebuild
();
}
}
void
PLModel
::
search
(
const
QString
&
search_text
)
void
PLModel
::
search
(
const
QString
&
search_text
)
...
@@ -991,32 +996,27 @@ void PLModel::viewchanged( int meta )
...
@@ -991,32 +996,27 @@ void PLModel::viewchanged( int meta )
_meta
>>=
1
;
_meta
>>=
1
;
}
}
/* UNUSED emit layoutAboutToBeChanged(); */
index
=
__MIN
(
index
,
columnCount
()
);
index
=
__MIN
(
index
,
columnCount
()
);
QModelIndex
parent
=
createIndex
(
0
,
0
,
rootItem
);
QModelIndex
parent
=
createIndex
(
0
,
0
,
rootItem
);
emit
layoutAboutToBeChanged
();
if
(
i_showflags
&
meta
)
if
(
i_showflags
&
meta
)
/* Removing columns */
/* Removing columns */
{
{
emit
beginRemoveColumns
(
parent
,
index
,
index
+
1
);
beginRemoveColumns
(
parent
,
index
,
index
+
1
);
i_showflags
&=
~
(
meta
);
i_showflags
&=
~
(
meta
);
getSettings
()
->
setValue
(
"qt-pl-showflags"
,
i_showflags
);
getSettings
()
->
setValue
(
"qt-pl-showflags"
,
i_showflags
);
e
mit
e
ndRemoveColumns
();
endRemoveColumns
();
}
}
else
else
{
{
/* Adding columns */
/* Adding columns */
emit
beginInsertColumns
(
parent
,
index
,
index
+
1
);
beginInsertColumns
(
parent
,
index
,
index
+
1
);
i_showflags
|=
meta
;
i_showflags
|=
meta
;
getSettings
()
->
setValue
(
"qt-pl-showflags"
,
i_showflags
);
getSettings
()
->
setValue
(
"qt-pl-showflags"
,
i_showflags
);
e
mit
e
ndInsertColumns
();
endInsertColumns
();
}
}
emit
columnsChanged
(
meta
);
emit
columnsChanged
(
meta
);
emit
layoutChanged
();
}
}
}
}
...
...
modules/gui/qt4/components/playlist/playlist_model.hpp
View file @
26201e1c
...
@@ -147,13 +147,14 @@ private:
...
@@ -147,13 +147,14 @@ private:
void
ProcessItemRemoval
(
int
i_id
);
void
ProcessItemRemoval
(
int
i_id
);
void
ProcessItemAppend
(
const
playlist_add_t
*
p_add
);
void
ProcessItemAppend
(
const
playlist_add_t
*
p_add
);
void
UpdateTreeItem
(
PLItem
*
,
bool
,
bool
force
=
false
);
void
UpdateNodeChildren
(
PLItem
*
);
void
UpdateNodeChildren
(
playlist_item_t
*
,
PLItem
*
);
/* Actions */
/* Actions */
void
recurseDelete
(
QList
<
PLItem
*>
children
,
QModelIndexList
*
fullList
);
void
recurseDelete
(
QList
<
PLItem
*>
children
,
QModelIndexList
*
fullList
);
void
doDeleteItem
(
PLItem
*
item
,
QModelIndexList
*
fullList
);
void
doDeleteItem
(
PLItem
*
item
,
QModelIndexList
*
fullList
);
void
UpdateTreeItem
(
PLItem
*
,
bool
,
bool
force
=
false
);
/* The following actions will not signal the view! */
void
RemoveChildren
(
PLItem
*
);
void
UpdateChildren
(
PLItem
*
);
void
UpdateChildren
(
playlist_item_t
*
,
PLItem
*
);
/* Popup */
/* Popup */
int
i_popup_item
,
i_popup_parent
,
i_popup_column
;
int
i_popup_item
,
i_popup_parent
,
i_popup_column
;
...
...
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