Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
9f9dfeb8
Commit
9f9dfeb8
authored
Feb 09, 2010
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: PLModel: simplify and fix current item update
parent
8d499950
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
32 deletions
+13
-32
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
+12
-30
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/playlist_model.hpp
+1
-2
No files found.
modules/gui/qt4/components/playlist/playlist_model.cpp
View file @
9f9dfeb8
...
@@ -65,7 +65,6 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
...
@@ -65,7 +65,6 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
i_cached_id
=
-
1
;
i_cached_id
=
-
1
;
i_cached_input_id
=
-
1
;
i_cached_input_id
=
-
1
;
i_popup_item
=
i_popup_parent
=
-
1
;
i_popup_item
=
i_popup_parent
=
-
1
;
currentItem
=
NULL
;
rootItem
=
NULL
;
/* PLItem rootItem, will be set in rebuild( ) */
rootItem
=
NULL
;
/* PLItem rootItem, will be set in rebuild( ) */
...
@@ -349,8 +348,9 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
...
@@ -349,8 +348,9 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
bool
PLModel
::
isCurrent
(
const
QModelIndex
&
index
)
const
bool
PLModel
::
isCurrent
(
const
QModelIndex
&
index
)
const
{
{
if
(
!
currentItem
)
return
false
;
input_thread_t
*
p_input_thread
=
THEMIM
->
getInput
();
return
getItem
(
index
)
->
p_input
==
currentItem
->
p_input
;
if
(
!
p_input_thread
)
return
false
;
return
getItem
(
index
)
->
p_input
==
input_GetItem
(
p_input_thread
);
}
}
int
PLModel
::
itemId
(
const
QModelIndex
&
index
)
const
int
PLModel
::
itemId
(
const
QModelIndex
&
index
)
const
...
@@ -399,6 +399,14 @@ QModelIndex PLModel::index( PLItem *item, int column ) const
...
@@ -399,6 +399,14 @@ QModelIndex PLModel::index( PLItem *item, int column ) const
return
QModelIndex
();
return
QModelIndex
();
}
}
QModelIndex
PLModel
::
currentIndex
()
{
input_thread_t
*
p_input_thread
=
THEMIM
->
getInput
();
if
(
!
p_input_thread
)
return
QModelIndex
();
PLItem
*
item
=
findByInput
(
rootItem
,
input_GetItem
(
p_input_thread
)
->
i_id
);
return
index
(
item
,
0
);
}
QModelIndex
PLModel
::
parent
(
const
QModelIndex
&
index
)
const
QModelIndex
PLModel
::
parent
(
const
QModelIndex
&
index
)
const
{
{
if
(
!
index
.
isValid
()
)
return
QModelIndex
();
if
(
!
index
.
isValid
()
)
return
QModelIndex
();
...
@@ -577,12 +585,7 @@ void PLModel::processInputItemUpdate( input_thread_t *p_input )
...
@@ -577,12 +585,7 @@ void PLModel::processInputItemUpdate( input_thread_t *p_input )
if
(
p_input
&&
!
(
p_input
->
b_dead
||
!
vlc_object_alive
(
p_input
)
)
)
if
(
p_input
&&
!
(
p_input
->
b_dead
||
!
vlc_object_alive
(
p_input
)
)
)
{
{
PLItem
*
item
=
findByInput
(
rootItem
,
input_GetItem
(
p_input
)
->
i_id
);
PLItem
*
item
=
findByInput
(
rootItem
,
input_GetItem
(
p_input
)
->
i_id
);
currentItem
=
item
;
if
(
item
)
emit
currentChanged
(
index
(
item
,
0
)
);
emit
currentChanged
(
index
(
item
,
0
)
);
}
else
{
currentItem
=
NULL
;
}
}
processInputItemUpdate
(
input_GetItem
(
p_input
)
);
processInputItemUpdate
(
input_GetItem
(
p_input
)
);
}
}
...
@@ -624,18 +627,10 @@ void PLModel::processItemAppend( int i_item, int i_parent )
...
@@ -624,18 +627,10 @@ void PLModel::processItemAppend( int i_item, int i_parent )
newItem
=
new
PLItem
(
p_item
,
nodeItem
);
newItem
=
new
PLItem
(
p_item
,
nodeItem
);
PL_UNLOCK
;
PL_UNLOCK
;
currentInputThread
=
THEMIM
->
getInput
();
if
(
currentInputThread
&&
newItem
->
p_input
==
input_GetItem
(
currentInputThread
)
)
currentItem
=
newItem
;
beginInsertRows
(
index
(
nodeItem
,
0
),
pos
,
pos
);
beginInsertRows
(
index
(
nodeItem
,
0
),
pos
,
pos
);
nodeItem
->
insertChild
(
newItem
,
pos
);
nodeItem
->
insertChild
(
newItem
,
pos
);
endInsertRows
();
endInsertRows
();
if
(
currentItem
==
newItem
)
emit
currentChanged
(
index
(
newItem
,
0
)
);
return
;
return
;
end:
end:
PL_UNLOCK
;
PL_UNLOCK
;
...
@@ -705,12 +700,6 @@ void PLModel::removeItem( PLItem *item )
...
@@ -705,12 +700,6 @@ void PLModel::removeItem( PLItem *item )
if
(
item
->
i_id
==
i_cached_id
)
i_cached_id
=
-
1
;
if
(
item
->
i_id
==
i_cached_id
)
i_cached_id
=
-
1
;
i_cached_input_id
=
-
1
;
i_cached_input_id
=
-
1
;
if
(
currentItem
==
item
||
rootItem
==
item
)
{
currentItem
=
NULL
;
emit
currentChanged
(
QModelIndex
()
);
}
if
(
item
==
rootItem
)
if
(
item
==
rootItem
)
rootItem
=
NULL
;
rootItem
=
NULL
;
...
@@ -729,24 +718,17 @@ void PLModel::removeItem( PLItem *item )
...
@@ -729,24 +718,17 @@ void PLModel::removeItem( PLItem *item )
void
PLModel
::
updateChildren
(
PLItem
*
root
)
void
PLModel
::
updateChildren
(
PLItem
*
root
)
{
{
playlist_item_t
*
p_node
=
playlist_ItemGetById
(
p_playlist
,
root
->
i_id
);
playlist_item_t
*
p_node
=
playlist_ItemGetById
(
p_playlist
,
root
->
i_id
);
currentItem
=
NULL
;
updateChildren
(
p_node
,
root
);
updateChildren
(
p_node
,
root
);
emit
currentChanged
(
index
(
currentItem
,
0
)
);
}
}
/* This function must be entered WITH the playlist lock */
/* This function must be entered WITH the playlist lock */
void
PLModel
::
updateChildren
(
playlist_item_t
*
p_node
,
PLItem
*
root
)
void
PLModel
::
updateChildren
(
playlist_item_t
*
p_node
,
PLItem
*
root
)
{
{
playlist_item_t
*
p_item
=
playlist_CurrentPlayingItem
(
p_playlist
);
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
);
root
->
appendChild
(
newItem
);
root
->
appendChild
(
newItem
);
if
(
p_item
&&
newItem
->
p_input
==
p_item
->
p_input
)
{
currentItem
=
newItem
;
}
if
(
p_node
->
pp_children
[
i
]
->
i_children
!=
-
1
)
if
(
p_node
->
pp_children
[
i
]
->
i_children
!=
-
1
)
updateChildren
(
p_node
->
pp_children
[
i
],
newItem
);
updateChildren
(
p_node
->
pp_children
[
i
],
newItem
);
}
}
...
...
modules/gui/qt4/components/playlist/playlist_model.hpp
View file @
9f9dfeb8
...
@@ -87,7 +87,7 @@ public:
...
@@ -87,7 +87,7 @@ public:
QStringList
selectedURIs
();
QStringList
selectedURIs
();
QModelIndex
index
(
PLItem
*
,
int
c
)
const
;
QModelIndex
index
(
PLItem
*
,
int
c
)
const
;
QModelIndex
index
(
int
i_id
,
int
c
);
QModelIndex
index
(
int
i_id
,
int
c
);
QModelIndex
currentIndex
(
)
{
return
index
(
currentItem
,
0
);
}
;
QModelIndex
currentIndex
(
)
;
bool
isCurrent
(
const
QModelIndex
&
index
)
const
;
bool
isCurrent
(
const
QModelIndex
&
index
)
const
;
int
itemId
(
const
QModelIndex
&
index
)
const
;
int
itemId
(
const
QModelIndex
&
index
)
const
;
...
@@ -111,7 +111,6 @@ private:
...
@@ -111,7 +111,6 @@ private:
/* General */
/* General */
PLItem
*
rootItem
;
PLItem
*
rootItem
;
PLItem
*
currentItem
;
playlist_t
*
p_playlist
;
playlist_t
*
p_playlist
;
intf_thread_t
*
p_intf
;
intf_thread_t
*
p_intf
;
...
...
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