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
159fa24a
Commit
159fa24a
authored
Aug 26, 2006
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Sorting
* Fix a memory leak / crasher
parent
69204454
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
+4
-0
modules/gui/qt4/playlist_model.cpp
modules/gui/qt4/playlist_model.cpp
+29
-3
modules/gui/qt4/playlist_model.hpp
modules/gui/qt4/playlist_model.hpp
+1
-0
No files found.
modules/gui/qt4/components/playlist/standardpanel.cpp
View file @
159fa24a
...
...
@@ -46,8 +46,12 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
view
->
setIconSize
(
QSize
(
20
,
20
)
);
view
->
setAlternatingRowColors
(
true
);
view
->
header
()
->
resizeSection
(
0
,
300
);
view
->
header
()
->
setSortIndicatorShown
(
true
);
view
->
header
()
->
setClickable
(
true
);
view
->
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
// connect( view->header(), SIGNAL( sectionClicked( int)), view, SLOT( sortByColumn(int)));
connect
(
view
,
SIGNAL
(
activated
(
const
QModelIndex
&
)
),
model
,
SLOT
(
activateItem
(
const
QModelIndex
&
)
)
);
...
...
modules/gui/qt4/playlist_model.cpp
View file @
159fa24a
...
...
@@ -73,6 +73,7 @@ void PLItem::init( int _i_id, int _i_input_id, PLItem *parent, PLModel *m)
strings
.
append
(
""
);
strings
.
append
(
""
);
strings
.
append
(
""
);
strings
.
append
(
""
);
}
PLItem
::
PLItem
(
int
_i_id
,
int
_i_input_id
,
PLItem
*
parent
,
PLModel
*
m
)
...
...
@@ -88,6 +89,7 @@ PLItem::PLItem( playlist_item_t * p_item, PLItem *parent, PLModel *m )
PLItem
::~
PLItem
()
{
qDeleteAll
(
children
);
children
.
clear
();
}
void
PLItem
::
insertChild
(
PLItem
*
item
,
int
i_pos
,
bool
signal
)
...
...
@@ -118,12 +120,15 @@ int PLItem::row() const
void
PLItem
::
update
(
playlist_item_t
*
p_item
,
bool
iscurrent
)
{
char
psz_duration
[
MSTRTIME_MAX_SIZE
];
assert
(
p_item
->
p_input
->
i_id
==
i_input_id
);
strings
[
0
]
=
QString
::
fromUtf8
(
p_item
->
p_input
->
psz_name
);
if
(
p_item
->
p_input
->
p_meta
)
{
strings
[
1
]
=
QString
::
fromUtf8
(
p_item
->
p_input
->
p_meta
->
psz_artist
);
}
secstotimestr
(
psz_duration
,
p_item
->
p_input
->
i_duration
/
1000000
);
strings
[
2
]
=
QString
(
psz_duration
);
type
=
p_item
->
p_input
->
i_type
;
current
=
iscurrent
;
}
...
...
@@ -301,7 +306,8 @@ QModelIndex PLModel::parent(const QModelIndex &index) const
if
(
!
parentItem
||
parentItem
==
rootItem
)
return
QModelIndex
();
if
(
!
parentItem
->
parentItem
)
{
msg_Err
(
p_playlist
,
"No parent parent, trying row 0 ----- PLEASE REPORT THIS ------"
);
msg_Err
(
p_playlist
,
"No parent parent, trying row 0 "
);
msg_Err
(
p_playlist
,
"----- PLEASE REPORT THIS ------"
);
return
createIndex
(
0
,
0
,
parentItem
);
}
QModelIndex
ind
=
createIndex
(
parentItem
->
row
(),
0
,
parentItem
);
...
...
@@ -311,7 +317,7 @@ QModelIndex PLModel::parent(const QModelIndex &index) const
int
PLModel
::
columnCount
(
const
QModelIndex
&
i
)
const
{
if
(
i_depth
==
1
)
return
1
;
return
2
;
return
3
;
}
int
PLModel
::
childrenCount
(
const
QModelIndex
&
parent
)
const
...
...
@@ -508,10 +514,10 @@ void PLModel::rebuild( playlist_item_t *p_root )
/* Clear the tree */
if
(
rootItem
)
{
PLItem
*
deleted
;
beginRemoveRows
(
index
(
rootItem
,
0
),
0
,
rootItem
->
children
.
size
()
-
1
);
qDeleteAll
(
rootItem
->
children
);
rootItem
->
children
.
clear
();
endRemoveRows
();
}
if
(
p_root
)
...
...
@@ -635,6 +641,26 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
PL_UNLOCK
;
}
/******* Volume III: Sorting and searching ********/
void
PLModel
::
sort
(
int
column
,
Qt
::
SortOrder
order
)
{
PL_LOCK
;
playlist_item_t
*
p_root
=
playlist_ItemGetById
(
p_playlist
,
rootItem
->
i_id
);
int
i_mode
;
switch
(
column
)
{
case
0
:
i_mode
=
SORT_TITLE_NODES_FIRST
;
break
;
case
1
:
i_mode
=
SORT_ARTIST
;
break
;
case
2
:
i_mode
=
SORT_DURATION
;
break
;
}
if
(
p_root
)
playlist_RecursiveNodeSort
(
p_playlist
,
p_root
,
i_mode
,
order
==
Qt
::
AscendingOrder
?
ORDER_NORMAL
:
ORDER_REVERSE
);
PL_UNLOCK
rebuild
();
}
/*********** Popup *********/
void
PLModel
::
popup
(
QModelIndex
&
index
,
QPoint
&
point
,
QModelIndexList
list
)
{
...
...
modules/gui/qt4/playlist_model.hpp
View file @
159fa24a
...
...
@@ -118,6 +118,7 @@ public:
/* Actions made by the views */
void
popup
(
QModelIndex
&
index
,
QPoint
&
point
,
QModelIndexList
list
);
void
doDelete
(
QModelIndexList
selected
);
void
sort
(
int
column
,
Qt
::
SortOrder
order
);
private:
void
addCallbacks
();
void
delCallbacks
();
...
...
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