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
f5112afb
Commit
f5112afb
authored
Aug 20, 2009
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qt4: cosmetics and consistence
for future generations
parent
be54c4d2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
81 deletions
+79
-81
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
+37
-42
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/playlist_model.hpp
+42
-39
No files found.
modules/gui/qt4/components/playlist/playlist_model.cpp
View file @
f5112afb
...
...
@@ -108,9 +108,9 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
rebuild
(
p_root
);
CONNECT
(
THEMIM
->
getIM
(),
metaChanged
(
input_item_t
*
),
this
,
P
rocessInputItemUpdate
(
input_item_t
*
)
);
this
,
p
rocessInputItemUpdate
(
input_item_t
*
)
);
CONNECT
(
THEMIM
,
inputChanged
(
input_thread_t
*
),
this
,
P
rocessInputItemUpdate
(
input_thread_t
*
)
);
this
,
p
rocessInputItemUpdate
(
input_thread_t
*
)
);
}
PLModel
::~
PLModel
()
...
...
@@ -285,7 +285,7 @@ void PLModel::dropMove( QByteArray& data, PLItem *target, int row )
ids
.
append
(
item
->
i_id
);
model_items
.
append
(
item
);
T
akeItem
(
item
);
t
akeItem
(
item
);
}
int
count
=
ids
.
size
();
if
(
count
)
...
...
@@ -309,15 +309,15 @@ void PLModel::dropMove( QByteArray& data, PLItem *target, int row )
new_pos
);
PL_UNLOCK
;
I
nsertChildren
(
target
,
model_items
,
model_pos
);
i
nsertChildren
(
target
,
model_items
,
model_pos
);
}
}
/* remove item with its id */
void
PLModel
::
removeItem
(
int
i_id
)
{
PLItem
*
item
=
F
indById
(
rootItem
,
i_id
);
R
emoveItem
(
item
);
PLItem
*
item
=
f
indById
(
rootItem
,
i_id
);
r
emoveItem
(
item
);
}
/* callbacks and slots */
...
...
@@ -501,11 +501,6 @@ int PLModel::columnCount( const QModelIndex &i) const
return
columnCount
;
}
int
PLModel
::
childrenCount
(
const
QModelIndex
&
parent
)
const
{
return
rowCount
(
parent
);
}
int
PLModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
PLItem
*
parentItem
=
parent
.
isValid
()
?
getItem
(
parent
)
:
rootItem
;
...
...
@@ -569,21 +564,21 @@ void PLModel::setRandom( bool on )
/************************* Lookups *****************************/
PLItem
*
PLModel
::
F
indById
(
PLItem
*
root
,
int
i_id
)
PLItem
*
PLModel
::
f
indById
(
PLItem
*
root
,
int
i_id
)
{
return
F
indInner
(
root
,
i_id
,
false
);
return
f
indInner
(
root
,
i_id
,
false
);
}
PLItem
*
PLModel
::
F
indByInput
(
PLItem
*
root
,
int
i_id
)
PLItem
*
PLModel
::
f
indByInput
(
PLItem
*
root
,
int
i_id
)
{
PLItem
*
result
=
F
indInner
(
root
,
i_id
,
true
);
PLItem
*
result
=
f
indInner
(
root
,
i_id
,
true
);
return
result
;
}
#define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
#define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
PLItem
*
PLModel
::
F
indInner
(
PLItem
*
root
,
int
i_id
,
bool
b_input
)
PLItem
*
PLModel
::
f
indInner
(
PLItem
*
root
,
int
i_id
,
bool
b_input
)
{
if
(
(
!
b_input
&&
i_cached_id
==
i_id
)
||
(
b_input
&&
i_cached_input_id
==
i_id
)
)
...
...
@@ -617,7 +612,7 @@ PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
}
if
(
(
*
it
)
->
children
.
size
()
)
{
PLItem
*
childFound
=
F
indInner
(
(
*
it
),
i_id
,
b_input
);
PLItem
*
childFound
=
f
indInner
(
(
*
it
),
i_id
,
b_input
);
if
(
childFound
)
{
if
(
b_input
)
...
...
@@ -670,21 +665,21 @@ void PLModel::customEvent( QEvent *event )
PLEvent
*
ple
=
static_cast
<
PLEvent
*>
(
event
);
if
(
type
==
ItemAppend_Type
)
P
rocessItemAppend
(
&
ple
->
add
);
p
rocessItemAppend
(
&
ple
->
add
);
else
if
(
type
==
ItemDelete_Type
)
P
rocessItemRemoval
(
ple
->
i_id
);
p
rocessItemRemoval
(
ple
->
i_id
);
else
rebuild
();
}
/**** Events processing ****/
void
PLModel
::
P
rocessInputItemUpdate
(
input_thread_t
*
p_input
)
void
PLModel
::
p
rocessInputItemUpdate
(
input_thread_t
*
p_input
)
{
if
(
!
p_input
)
return
;
P
rocessInputItemUpdate
(
input_GetItem
(
p_input
)
);
p
rocessInputItemUpdate
(
input_GetItem
(
p_input
)
);
if
(
p_input
&&
!
(
p_input
->
b_dead
||
!
vlc_object_alive
(
p_input
)
)
)
{
PLItem
*
item
=
F
indByInput
(
rootItem
,
input_GetItem
(
p_input
)
->
i_id
);
PLItem
*
item
=
f
indByInput
(
rootItem
,
input_GetItem
(
p_input
)
->
i_id
);
currentItem
=
item
;
emit
currentChanged
(
index
(
item
,
0
)
);
}
...
...
@@ -693,15 +688,15 @@ void PLModel::ProcessInputItemUpdate( input_thread_t *p_input )
currentItem
=
NULL
;
}
}
void
PLModel
::
P
rocessInputItemUpdate
(
input_item_t
*
p_item
)
void
PLModel
::
p
rocessInputItemUpdate
(
input_item_t
*
p_item
)
{
if
(
!
p_item
||
p_item
->
i_id
<=
0
)
return
;
PLItem
*
item
=
F
indByInput
(
rootItem
,
p_item
->
i_id
);
PLItem
*
item
=
f
indByInput
(
rootItem
,
p_item
->
i_id
);
if
(
item
)
U
pdateTreeItem
(
item
,
true
,
true
);
u
pdateTreeItem
(
item
,
true
,
true
);
}
void
PLModel
::
P
rocessItemRemoval
(
int
i_id
)
void
PLModel
::
p
rocessItemRemoval
(
int
i_id
)
{
if
(
i_id
<=
0
)
return
;
if
(
i_id
==
i_cached_id
)
i_cached_id
=
-
1
;
...
...
@@ -710,12 +705,12 @@ void PLModel::ProcessItemRemoval( int i_id )
removeItem
(
i_id
);
}
void
PLModel
::
P
rocessItemAppend
(
const
playlist_add_t
*
p_add
)
void
PLModel
::
p
rocessItemAppend
(
const
playlist_add_t
*
p_add
)
{
playlist_item_t
*
p_item
=
NULL
;
PLItem
*
newItem
=
NULL
;
PLItem
*
nodeItem
=
F
indById
(
rootItem
,
p_add
->
i_node
);
PLItem
*
nodeItem
=
f
indById
(
rootItem
,
p_add
->
i_node
);
if
(
!
nodeItem
)
return
;
PL_LOCK
;
...
...
@@ -731,7 +726,7 @@ void PLModel::ProcessItemAppend( const playlist_add_t *p_add )
beginInsertRows
(
index
(
nodeItem
,
0
),
nodeItem
->
childCount
(),
nodeItem
->
childCount
()
);
nodeItem
->
appendChild
(
newItem
);
endInsertRows
();
U
pdateTreeItem
(
newItem
,
true
);
u
pdateTreeItem
(
newItem
,
true
);
return
;
end:
PL_UNLOCK
;
...
...
@@ -762,9 +757,9 @@ void PLModel::rebuild( playlist_item_t *p_root )
}
assert
(
rootItem
);
/* Recreate from root */
U
pdateChildren
(
rootItem
);
u
pdateChildren
(
rootItem
);
if
(
(
p_item
=
playlist_CurrentPlayingItem
(
p_playlist
))
)
currentItem
=
F
indByInput
(
rootItem
,
p_item
->
p_input
->
i_id
);
currentItem
=
f
indByInput
(
rootItem
,
p_item
->
p_input
->
i_id
);
else
currentItem
=
NULL
;
PL_UNLOCK
;
...
...
@@ -776,7 +771,7 @@ void PLModel::rebuild( playlist_item_t *p_root )
addCallbacks
();
}
void
PLModel
::
T
akeItem
(
PLItem
*
item
)
void
PLModel
::
t
akeItem
(
PLItem
*
item
)
{
assert
(
item
);
PLItem
*
parent
=
item
->
parentItem
;
...
...
@@ -788,7 +783,7 @@ void PLModel::TakeItem( PLItem *item )
endRemoveRows
();
}
void
PLModel
::
I
nsertChildren
(
PLItem
*
node
,
QList
<
PLItem
*>&
items
,
int
i_pos
)
void
PLModel
::
i
nsertChildren
(
PLItem
*
node
,
QList
<
PLItem
*>&
items
,
int
i_pos
)
{
assert
(
node
);
int
count
=
items
.
size
();
...
...
@@ -802,7 +797,7 @@ void PLModel::InsertChildren( PLItem *node, QList<PLItem*>& items, int i_pos )
endInsertRows
();
}
void
PLModel
::
R
emoveItem
(
PLItem
*
item
)
void
PLModel
::
r
emoveItem
(
PLItem
*
item
)
{
if
(
!
item
)
return
;
if
(
currentItem
==
item
)
...
...
@@ -816,14 +811,14 @@ void PLModel::RemoveItem( PLItem *item )
}
/* This function must be entered WITH the playlist lock */
void
PLModel
::
U
pdateChildren
(
PLItem
*
root
)
void
PLModel
::
u
pdateChildren
(
PLItem
*
root
)
{
playlist_item_t
*
p_node
=
playlist_ItemGetById
(
p_playlist
,
root
->
i_id
);
U
pdateChildren
(
p_node
,
root
);
u
pdateChildren
(
p_node
,
root
);
}
/* This function must be entered WITH the playlist lock */
void
PLModel
::
U
pdateChildren
(
playlist_item_t
*
p_node
,
PLItem
*
root
)
void
PLModel
::
u
pdateChildren
(
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
++
)
...
...
@@ -837,12 +832,12 @@ void PLModel::UpdateChildren( playlist_item_t *p_node, PLItem *root )
emit
currentChanged
(
index
(
currentItem
,
0
)
);
}
if
(
i_depth
==
DEPTH_PL
&&
p_node
->
pp_children
[
i
]
->
i_children
!=
-
1
)
U
pdateChildren
(
p_node
->
pp_children
[
i
],
newItem
);
u
pdateChildren
(
p_node
->
pp_children
[
i
],
newItem
);
}
}
/* Function doesn't need playlist-lock, as we don't touch playlist_item_t stuff here*/
void
PLModel
::
U
pdateTreeItem
(
PLItem
*
item
,
bool
signal
,
bool
force
)
void
PLModel
::
u
pdateTreeItem
(
PLItem
*
item
,
bool
signal
,
bool
force
)
{
if
(
!
item
||
!
item
->
p_input
)
return
;
...
...
@@ -909,7 +904,7 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
/* And finally, remove it from the tree */
int
itemIndex
=
item
->
parentItem
->
children
.
indexOf
(
item
);
beginRemoveRows
(
index
(
item
->
parentItem
,
0
),
itemIndex
,
itemIndex
);
R
emoveItem
(
item
);
r
emoveItem
(
item
);
endRemoveRows
();
}
...
...
@@ -936,7 +931,7 @@ void PLModel::sort( int i_root_id, int column, Qt::SortOrder order )
}
}
PLItem
*
item
=
F
indById
(
rootItem
,
i_root_id
);
PLItem
*
item
=
f
indById
(
rootItem
,
i_root_id
);
if
(
!
item
)
return
;
QModelIndex
qIndex
=
index
(
item
,
0
);
int
count
=
item
->
children
.
size
();
...
...
@@ -962,7 +957,7 @@ void PLModel::sort( int i_root_id, int column, Qt::SortOrder order )
if
(
count
)
{
beginInsertRows
(
qIndex
,
0
,
count
-
1
);
U
pdateChildren
(
item
);
u
pdateChildren
(
item
);
endInsertRows
(
);
}
PL_UNLOCK
;
...
...
modules/gui/qt4/components/playlist/playlist_model.hpp
View file @
f5112afb
...
...
@@ -90,49 +90,48 @@ public:
playlist_item_t
*
,
int
,
QObject
*
parent
=
0
);
~
PLModel
();
/* All types of lookups / QModel stuff */
/*** QModel subclassing ***/
/* Data structure */
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
Qt
::
ItemFlags
flags
(
const
QModelIndex
&
index
)
const
;
QVariant
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
=
Qt
::
DisplayRole
)
const
;
QModelIndex
index
(
int
r
,
int
c
,
const
QModelIndex
&
parent
)
const
;
QModelIndex
index
(
PLItem
*
,
int
c
)
const
;
QModelIndex
currentIndex
(
)
{
return
index
(
currentItem
,
0
);
};
int
itemId
(
const
QModelIndex
&
index
)
const
;
bool
isCurrent
(
const
QModelIndex
&
index
)
const
;
QModelIndex
parent
(
const
QModelIndex
&
index
)
const
;
int
childrenCount
(
const
QModelIndex
&
parent
=
QModelIndex
()
)
const
;
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
()
)
const
;
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
()
)
const
;
Qt
::
ItemFlags
flags
(
const
QModelIndex
&
index
)
const
;
QModelIndex
index
(
int
r
,
int
c
,
const
QModelIndex
&
parent
)
const
;
QModelIndex
parent
(
const
QModelIndex
&
index
)
const
;
/* Get current selection */
QStringList
selectedURIs
();
/* Drag and Drop */
Qt
::
DropActions
supportedDropActions
()
const
;
QMimeData
*
mimeData
(
const
QModelIndexList
&
indexes
)
const
;
bool
dropMimeData
(
const
QMimeData
*
data
,
Qt
::
DropAction
action
,
int
row
,
int
column
,
const
QModelIndex
&
target
);
QStringList
mimeTypes
()
const
;
void
rebuild
();
void
rebuild
(
playlist_item_t
*
);
/**** Custom ****/
/* Lookups */
QStringList
selectedURIs
();
bool
hasRandom
();
bool
hasLoop
();
bool
hasRepeat
();
int
shownFlags
()
{
return
i_showflags
;
}
QModelIndex
index
(
PLItem
*
,
int
c
)
const
;
QModelIndex
currentIndex
(
)
{
return
index
(
currentItem
,
0
);
};
bool
isCurrent
(
const
QModelIndex
&
index
)
const
;
int
itemId
(
const
QModelIndex
&
index
)
const
;
/* Actions
made by the views
*/
/* Actions */
void
popup
(
QModelIndex
&
index
,
QPoint
&
point
,
QModelIndexList
list
);
void
doDelete
(
QModelIndexList
selected
);
void
search
(
const
QString
&
search_text
);
void
sort
(
int
column
,
Qt
::
SortOrder
order
);
void
sort
(
int
i_root_id
,
int
column
,
Qt
::
SortOrder
order
);
void
removeItem
(
int
);
/* DnD handling */
Qt
::
DropActions
supportedDropActions
()
const
;
QMimeData
*
mimeData
(
const
QModelIndexList
&
indexes
)
const
;
bool
dropMimeData
(
const
QMimeData
*
data
,
Qt
::
DropAction
action
,
int
row
,
int
column
,
const
QModelIndex
&
target
);
QStringList
mimeTypes
()
const
;
int
shownFlags
()
{
return
i_showflags
;
}
void
rebuild
();
void
rebuild
(
playlist_item_t
*
);
private:
void
addCallbacks
();
void
delCallbacks
();
void
customEvent
(
QEvent
*
);
/* General */
PLItem
*
rootItem
;
PLItem
*
currentItem
;
...
...
@@ -143,22 +142,25 @@ private:
static
QIcon
icons
[
ITEM_TYPE_NUMBER
];
/* Update processing */
void
ProcessItemRemoval
(
int
i_id
);
void
ProcessItemAppend
(
const
playlist_add_t
*
p_add
);
/* Callbacks related */
void
addCallbacks
();
void
delCallbacks
();
void
customEvent
(
QEvent
*
);
void
processItemRemoval
(
int
i_id
);
void
processItemAppend
(
const
playlist_add_t
*
p_add
);
/* Actions */
void
recurseDelete
(
QList
<
PLItem
*>
children
,
QModelIndexList
*
fullList
);
void
doDeleteItem
(
PLItem
*
item
,
QModelIndexList
*
fullList
);
void
UpdateTreeItem
(
PLItem
*
,
bool
,
bool
force
=
false
);
void
updateTreeItem
(
PLItem
*
,
bool
,
bool
force
=
false
);
void
takeItem
(
PLItem
*
);
//will not delete item
void
insertChildren
(
PLItem
*
node
,
QList
<
PLItem
*>&
items
,
int
i_pos
);
void
dropAppendCopy
(
QByteArray
&
data
,
PLItem
*
target
);
void
dropMove
(
QByteArray
&
data
,
PLItem
*
target
,
int
new_pos
);
void
TakeItem
(
PLItem
*
);
void
InsertChildren
(
PLItem
*
node
,
QList
<
PLItem
*>&
items
,
int
i_pos
);
/* The following actions will not signal the view! */
void
R
emoveItem
(
PLItem
*
);
void
U
pdateChildren
(
PLItem
*
);
void
U
pdateChildren
(
playlist_item_t
*
,
PLItem
*
);
void
r
emoveItem
(
PLItem
*
);
void
u
pdateChildren
(
PLItem
*
);
void
u
pdateChildren
(
playlist_item_t
*
,
PLItem
*
);
/* Popup */
int
i_popup_item
,
i_popup_parent
,
i_popup_column
;
...
...
@@ -166,15 +168,16 @@ private:
QSignalMapper
*
ContextUpdateMapper
;
/* Lookups */
PLItem
*
F
indById
(
PLItem
*
,
int
);
PLItem
*
F
indByInput
(
PLItem
*
,
int
);
PLItem
*
F
indInner
(
PLItem
*
,
int
,
bool
);
PLItem
*
f
indById
(
PLItem
*
,
int
);
PLItem
*
f
indByInput
(
PLItem
*
,
int
);
PLItem
*
f
indInner
(
PLItem
*
,
int
,
bool
);
static
inline
PLItem
*
getItem
(
QModelIndex
index
);
int
metaColumn
(
int
column
)
const
;
PLItem
*
p_cached_item
;
PLItem
*
p_cached_item_bi
;
int
i_cached_id
;
int
i_cached_input_id
;
signals:
void
shouldRemove
(
int
);
void
currentChanged
(
const
QModelIndex
&
);
...
...
@@ -199,8 +202,8 @@ private slots:
void
popupSortAsc
();
void
popupSortDesc
();
void
viewchanged
(
int
);
void
P
rocessInputItemUpdate
(
input_item_t
*
);
void
P
rocessInputItemUpdate
(
input_thread_t
*
p_input
);
void
p
rocessInputItemUpdate
(
input_item_t
*
);
void
p
rocessInputItemUpdate
(
input_thread_t
*
p_input
);
};
#endif
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