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
fcc3616f
Commit
fcc3616f
authored
Mar 04, 2010
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: allow sorting by any meta in any view using right-click menu
parent
4f5a4010
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
16 deletions
+29
-16
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
+25
-13
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/playlist_model.hpp
+4
-3
No files found.
modules/gui/qt4/components/playlist/playlist_model.cpp
View file @
fcc3616f
...
...
@@ -72,6 +72,7 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
i_cached_id
=
-
1
;
i_cached_input_id
=
-
1
;
i_popup_item
=
i_popup_parent
=
-
1
;
sortingMenu
=
NULL
;
rootItem
=
NULL
;
/* PLItem rootItem, will be set in rebuild( ) */
...
...
@@ -102,6 +103,7 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
PLModel
::~
PLModel
()
{
delete
rootItem
;
delete
sortingMenu
;
}
Qt
::
DropActions
PLModel
::
supportedDropActions
()
const
...
...
@@ -952,12 +954,25 @@ bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode
if
(
i_popup_item
>
-
1
)
{
menu
.
addSeparator
();
QMenu
*
sort_menu
=
menu
.
addMenu
(
qtr
(
"Sort by"
)
+
QString
(
" "
)
+
qfu
(
psz_column_title
(
columnToMeta
(
index
.
column
()
)
)
)
);
sort_menu
->
addAction
(
qtr
(
"Ascending"
),
this
,
SLOT
(
popupSortAsc
()
)
);
sort_menu
->
addAction
(
qtr
(
"Descending"
),
this
,
SLOT
(
popupSortDesc
()
)
);
if
(
!
sortingMenu
)
{
sortingMenu
=
new
QMenu
(
qtr
(
"Sort by"
)
);
sortingMapper
=
new
QSignalMapper
(
this
);
int
i
,
j
;
for
(
i
=
1
,
j
=
1
;
i
<
COLUMN_END
;
i
<<=
1
,
j
++
)
{
if
(
i
==
COLUMN_NUMBER
)
continue
;
QMenu
*
m
=
sortingMenu
->
addMenu
(
qfu
(
psz_column_title
(
i
)
)
);
QAction
*
asc
=
m
->
addAction
(
qtr
(
"Ascending"
)
);
QAction
*
desc
=
m
->
addAction
(
qtr
(
"Descending"
)
);
sortingMapper
->
setMapping
(
asc
,
j
);
sortingMapper
->
setMapping
(
desc
,
-
j
);
CONNECT
(
asc
,
triggered
(),
sortingMapper
,
map
()
);
CONNECT
(
desc
,
triggered
(),
sortingMapper
,
map
()
);
}
CONNECT
(
sortingMapper
,
mapped
(
int
),
this
,
popupSort
(
int
)
);
}
menu
.
addMenu
(
sortingMenu
);
}
if
(
!
menu
.
isEmpty
()
)
{
...
...
@@ -1065,12 +1080,9 @@ void PLModel::popupAddNode()
PL_UNLOCK
;
}
void
PLModel
::
popupSortAsc
()
{
sort
(
i_popup_parent
,
i_popup_column
,
Qt
::
AscendingOrder
);
}
void
PLModel
::
popupSortDesc
()
void
PLModel
::
popupSort
(
int
column
)
{
sort
(
i_popup_parent
,
i_popup_column
,
Qt
::
DescendingOrder
);
sort
(
i_popup_parent
,
column
>
0
?
column
-
1
:
-
column
-
1
,
column
>
0
?
Qt
::
AscendingOrder
:
Qt
::
DescendingOrder
);
}
modules/gui/qt4/components/playlist/playlist_model.hpp
View file @
fcc3616f
...
...
@@ -43,8 +43,8 @@
#include <QSignalMapper>
#include <QAbstractItemModel>
#include <QVariant>
#include <QAction>
class
QSignalMapper
;
class
PLItem
;
class
PLModel
:
public
QAbstractItemModel
...
...
@@ -145,6 +145,8 @@ private:
/* Popup */
int
i_popup_item
,
i_popup_parent
,
i_popup_column
;
QModelIndexList
current_selection
;
QMenu
*
sortingMenu
;
QSignalMapper
*
sortingMapper
;
/* Lookups */
PLItem
*
findById
(
PLItem
*
,
int
);
...
...
@@ -165,8 +167,7 @@ private slots:
void
popupSave
();
void
popupExplore
();
void
popupAddNode
();
void
popupSortAsc
();
void
popupSortDesc
();
void
popupSort
(
int
column
);
void
processInputItemUpdate
(
input_item_t
*
);
void
processInputItemUpdate
(
input_thread_t
*
p_input
);
void
processItemRemoval
(
int
i_id
);
...
...
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