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
4e7f747f
Commit
4e7f747f
authored
Jul 18, 2012
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: PLModel: Move Popup() creation out of the PLModel
parent
26222c9b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
145 deletions
+150
-145
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
+0
-129
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/playlist_model.hpp
+5
-12
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
+133
-2
modules/gui/qt4/components/playlist/standardpanel.hpp
modules/gui/qt4/components/playlist/standardpanel.hpp
+2
-0
modules/gui/qt4/components/playlist/vlc_model.hpp
modules/gui/qt4/components/playlist/vlc_model.hpp
+10
-2
No files found.
modules/gui/qt4/components/playlist/playlist_model.cpp
View file @
4e7f747f
...
@@ -1215,135 +1215,6 @@ void PLModel::actionSlot( QAction *action )
...
@@ -1215,135 +1215,6 @@ void PLModel::actionSlot( QAction *action )
}
}
}
}
/*********** Popup *********/
bool
PLModel
::
popup
(
const
QModelIndex
&
index
,
const
QPoint
&
point
,
const
QModelIndexList
&
selectionlist
)
{
QModelIndexList
callerAsList
;
callerAsList
<<
(
index
.
isValid
()
?
index
:
QModelIndex
()
);
#define ADD_MENU_ENTRY( icon, title, act, data ) \
action = menu.addAction( icon, title ); \
container.action = act; \
container.indexes = data; \
action->setData( QVariant::fromValue( container ) )
/* */
QMenu
menu
;
QAction
*
action
;
PLModel
::
actionsContainerType
container
;
/* Play/Stream/Info static actions */
if
(
index
.
isValid
()
)
{
ADD_MENU_ENTRY
(
QIcon
(
":/menu/play"
),
qtr
(
I_POP_PLAY
),
container
.
ACTION_PLAY
,
callerAsList
);
ADD_MENU_ENTRY
(
QIcon
(
":/menu/stream"
),
qtr
(
I_POP_STREAM
),
container
.
ACTION_STREAM
,
selectionlist
);
ADD_MENU_ENTRY
(
QIcon
(),
qtr
(
I_POP_SAVE
),
container
.
ACTION_SAVE
,
selectionlist
);
ADD_MENU_ENTRY
(
QIcon
(
":/menu/info"
),
qtr
(
I_POP_INFO
),
container
.
ACTION_INFO
,
callerAsList
);
menu
.
addSeparator
();
if
(
getURI
(
index
).
startsWith
(
"file://"
)
)
{
ADD_MENU_ENTRY
(
QIcon
(
":/type/folder-grey"
),
qtr
(
I_POP_EXPLORE
),
container
.
ACTION_EXPLORE
,
callerAsList
);
}
}
/* In PL or ML, allow to add a file/folder */
if
(
canEdit
()
)
{
QIcon
addIcon
(
":/buttons/playlist/playlist_add"
);
if
(
isTree
()
)
{
ADD_MENU_ENTRY
(
addIcon
,
qtr
(
I_POP_NEWFOLDER
),
container
.
ACTION_ADDNODE
,
callerAsList
);
}
menu
.
addSeparator
();
if
(
isCurrentItem
(
rootIndex
(),
PLModel
::
IN_PLAYLIST
)
)
{
menu
.
addAction
(
addIcon
,
qtr
(
I_PL_ADDF
),
THEDP
,
SLOT
(
simplePLAppendDialog
())
);
menu
.
addAction
(
addIcon
,
qtr
(
I_PL_ADDDIR
),
THEDP
,
SLOT
(
PLAppendDir
())
);
menu
.
addAction
(
addIcon
,
qtr
(
I_OP_ADVOP
),
THEDP
,
SLOT
(
PLAppendDialog
())
);
}
else
if
(
isCurrentItem
(
rootIndex
(),
PLModel
::
IN_MEDIALIBRARY
)
)
{
menu
.
addAction
(
addIcon
,
qtr
(
I_PL_ADDF
),
THEDP
,
SLOT
(
simpleMLAppendDialog
())
);
menu
.
addAction
(
addIcon
,
qtr
(
I_PL_ADDDIR
),
THEDP
,
SLOT
(
MLAppendDir
()
)
);
menu
.
addAction
(
addIcon
,
qtr
(
I_OP_ADVOP
),
THEDP
,
SLOT
(
MLAppendDialog
()
)
);
}
}
if
(
index
.
isValid
()
)
{
if
(
!
isCurrentItem
(
rootIndex
(),
PLModel
::
IN_PLAYLIST
)
)
{
ADD_MENU_ENTRY
(
QIcon
(),
qtr
(
"Add to playlist"
),
container
.
ACTION_ADDTOPLAYLIST
,
selectionlist
);
}
}
menu
.
addSeparator
();
/* Item removal */
if
(
index
.
isValid
()
)
{
ADD_MENU_ENTRY
(
QIcon
(
":/buttons/playlist/playlist_remove"
),
qtr
(
I_POP_DEL
),
container
.
ACTION_REMOVE
,
selectionlist
);
}
if
(
canEdit
()
)
{
menu
.
addAction
(
QIcon
(
":/toolbar/clear"
),
qtr
(
"Clear playlist"
),
this
,
SLOT
(
clearPlaylist
()
)
);
}
menu
.
addSeparator
();
/* Playlist sorting */
QMenu
*
sortingMenu
=
new
QMenu
(
qtr
(
"Sort by"
)
);
/* Choose what columns to show in sorting menu, not sure if this should be configurable*/
QList
<
int
>
sortingColumns
;
sortingColumns
<<
COLUMN_TITLE
<<
COLUMN_ARTIST
<<
COLUMN_ALBUM
<<
COLUMN_TRACK_NUMBER
<<
COLUMN_URI
;
container
.
action
=
container
.
ACTION_SORT
;
container
.
indexes
=
callerAsList
;
foreach
(
int
Column
,
sortingColumns
)
{
action
=
sortingMenu
->
addAction
(
qfu
(
psz_column_title
(
Column
)
)
+
" "
+
qtr
(
"Ascending"
)
);
container
.
column
=
columnFromMeta
(
Column
)
+
1
;
action
->
setData
(
QVariant
::
fromValue
(
container
)
);
action
=
sortingMenu
->
addAction
(
qfu
(
psz_column_title
(
Column
)
)
+
" "
+
qtr
(
"Descending"
)
);
container
.
column
=
-
1
*
(
columnFromMeta
(
Column
)
+
1
);
action
->
setData
(
QVariant
::
fromValue
(
container
)
);
}
menu
.
addMenu
(
sortingMenu
);
/* Zoom */
QMenu
*
zoomMenu
=
new
QMenu
(
qtr
(
"Display size"
)
);
zoomMenu
->
addAction
(
qtr
(
"Increase"
),
this
,
SLOT
(
increaseZoom
()
)
);
zoomMenu
->
addAction
(
qtr
(
"Decrease"
),
this
,
SLOT
(
decreaseZoom
()
)
);
menu
.
addMenu
(
zoomMenu
);
CONNECT
(
&
menu
,
triggered
(
QAction
*
),
this
,
actionSlot
(
QAction
*
)
);
/* Display and forward the result */
if
(
!
menu
.
isEmpty
()
)
{
menu
.
exec
(
point
);
return
true
;
}
else
return
false
;
#undef ADD_MENU_ENTRY
}
/* */
/* */
void
PLModel
::
increaseZoom
()
void
PLModel
::
increaseZoom
()
{
{
...
...
modules/gui/qt4/components/playlist/playlist_model.hpp
View file @
4e7f747f
...
@@ -97,26 +97,19 @@ public:
...
@@ -97,26 +97,19 @@ public:
/* Lookups */
/* Lookups */
QModelIndex
index
(
const
int
i_id
,
const
int
c
);
QModelIndex
index
(
const
int
i_id
,
const
int
c
);
QModelIndex
rootIndex
()
const
;
virtual
QModelIndex
rootIndex
()
const
;
bool
isTree
()
const
;
virtual
bool
isTree
()
const
;
bool
canEdit
()
const
;
virtual
bool
canEdit
()
const
;
virtual
QModelIndex
currentIndex
()
const
;
virtual
QModelIndex
currentIndex
()
const
;
int
itemId
(
const
QModelIndex
&
index
)
const
;
int
itemId
(
const
QModelIndex
&
index
)
const
;
QString
getURI
(
const
QModelIndex
&
index
)
const
;
virtual
QString
getURI
(
const
QModelIndex
&
index
)
const
;
QString
getTitle
(
const
QModelIndex
&
index
)
const
;
QString
getTitle
(
const
QModelIndex
&
index
)
const
;
enum
playLocation
virtual
bool
isCurrentItem
(
const
QModelIndex
&
index
,
playLocation
where
)
const
;
{
IN_PLAYLIST
,
IN_MEDIALIBRARY
};
bool
isCurrentItem
(
const
QModelIndex
&
index
,
playLocation
where
)
const
;
/* */
/* */
void
search
(
const
QString
&
search_text
,
const
QModelIndex
&
root
,
bool
b_recursive
);
void
search
(
const
QString
&
search_text
,
const
QModelIndex
&
root
,
bool
b_recursive
);
void
rebuild
(
playlist_item_t
*
p
=
NULL
);
void
rebuild
(
playlist_item_t
*
p
=
NULL
);
/* Popup Actions */
virtual
bool
popup
(
const
QModelIndex
&
index
,
const
QPoint
&
point
,
const
QModelIndexList
&
list
);
virtual
void
doDelete
(
QModelIndexList
selected
);
virtual
void
doDelete
(
QModelIndexList
selected
);
signals:
signals:
...
...
modules/gui/qt4/components/playlist/standardpanel.cpp
View file @
4e7f747f
...
@@ -35,11 +35,12 @@
...
@@ -35,11 +35,12 @@
#include "components/playlist/selector.hpp"
/* PLSelector */
#include "components/playlist/selector.hpp"
/* PLSelector */
#include "menus.hpp"
/* Popup */
#include "menus.hpp"
/* Popup */
#include "input_manager.hpp"
/* THEMIM */
#include "input_manager.hpp"
/* THEMIM */
#include "dialogs_provider.hpp"
/* THEDP */
#include <vlc_services_discovery.h>
/* SD_CMD_SEARCH */
#include <vlc_services_discovery.h>
/* SD_CMD_SEARCH */
#include <vlc_intf_strings.h>
/* POP_ */
#include <QHeaderView>
#include <QHeaderView>
#include <QModelIndexList>
#include <QMenu>
#include <QMenu>
#include <QKeyEvent>
#include <QKeyEvent>
#include <QWheelEvent>
#include <QWheelEvent>
...
@@ -118,10 +119,140 @@ void StandardPLPanel::popupPlView( const QPoint &point )
...
@@ -118,10 +119,140 @@ void StandardPLPanel::popupPlView( const QPoint &point )
QItemSelectionModel
*
selection
=
currentView
->
selectionModel
();
QItemSelectionModel
*
selection
=
currentView
->
selectionModel
();
QModelIndexList
list
=
selection
->
selectedRows
();
QModelIndexList
list
=
selection
->
selectedRows
();
if
(
!
model
->
popup
(
index
,
globalPoint
,
list
)
)
if
(
!
popup
(
index
,
globalPoint
,
list
)
)
VLCMenuBar
::
PopupMenu
(
p_intf
,
true
);
VLCMenuBar
::
PopupMenu
(
p_intf
,
true
);
}
}
/*********** Popup *********/
bool
StandardPLPanel
::
popup
(
const
QModelIndex
&
index
,
const
QPoint
&
point
,
const
QModelIndexList
&
selectionlist
)
{
VLCModel
*
model
=
qobject_cast
<
VLCModel
*>
(
currentView
->
model
());
QModelIndexList
callerAsList
;
callerAsList
<<
(
index
.
isValid
()
?
index
:
QModelIndex
()
);
#define ADD_MENU_ENTRY( icon, title, act, data ) \
action = menu.addAction( icon, title ); \
container.action = act; \
container.indexes = data; \
action->setData( QVariant::fromValue( container ) )
/* */
QMenu
menu
;
QAction
*
action
;
PLModel
::
actionsContainerType
container
;
/* Play/Stream/Info static actions */
if
(
index
.
isValid
()
)
{
ADD_MENU_ENTRY
(
QIcon
(
":/menu/play"
),
qtr
(
I_POP_PLAY
),
container
.
ACTION_PLAY
,
callerAsList
);
ADD_MENU_ENTRY
(
QIcon
(
":/menu/stream"
),
qtr
(
I_POP_STREAM
),
container
.
ACTION_STREAM
,
selectionlist
);
ADD_MENU_ENTRY
(
QIcon
(),
qtr
(
I_POP_SAVE
),
container
.
ACTION_SAVE
,
selectionlist
);
ADD_MENU_ENTRY
(
QIcon
(
":/menu/info"
),
qtr
(
I_POP_INFO
),
container
.
ACTION_INFO
,
callerAsList
);
menu
.
addSeparator
();
if
(
model
->
getURI
(
index
).
startsWith
(
"file://"
)
)
{
ADD_MENU_ENTRY
(
QIcon
(
":/type/folder-grey"
),
qtr
(
I_POP_EXPLORE
),
container
.
ACTION_EXPLORE
,
callerAsList
);
}
}
/* In PL or ML, allow to add a file/folder */
if
(
model
->
canEdit
()
)
{
QIcon
addIcon
(
":/buttons/playlist/playlist_add"
);
if
(
model
->
isTree
()
)
{
ADD_MENU_ENTRY
(
addIcon
,
qtr
(
I_POP_NEWFOLDER
),
container
.
ACTION_ADDNODE
,
callerAsList
);
}
menu
.
addSeparator
();
if
(
model
->
isCurrentItem
(
model
->
rootIndex
(),
PLModel
::
IN_PLAYLIST
)
)
{
menu
.
addAction
(
addIcon
,
qtr
(
I_PL_ADDF
),
THEDP
,
SLOT
(
simplePLAppendDialog
())
);
menu
.
addAction
(
addIcon
,
qtr
(
I_PL_ADDDIR
),
THEDP
,
SLOT
(
PLAppendDir
())
);
menu
.
addAction
(
addIcon
,
qtr
(
I_OP_ADVOP
),
THEDP
,
SLOT
(
PLAppendDialog
())
);
}
else
if
(
model
->
isCurrentItem
(
model
->
rootIndex
(),
PLModel
::
IN_MEDIALIBRARY
)
)
{
menu
.
addAction
(
addIcon
,
qtr
(
I_PL_ADDF
),
THEDP
,
SLOT
(
simpleMLAppendDialog
())
);
menu
.
addAction
(
addIcon
,
qtr
(
I_PL_ADDDIR
),
THEDP
,
SLOT
(
MLAppendDir
()
)
);
menu
.
addAction
(
addIcon
,
qtr
(
I_OP_ADVOP
),
THEDP
,
SLOT
(
MLAppendDialog
()
)
);
}
}
if
(
index
.
isValid
()
)
{
if
(
!
model
->
isCurrentItem
(
model
->
rootIndex
(),
PLModel
::
IN_PLAYLIST
)
)
{
ADD_MENU_ENTRY
(
QIcon
(),
qtr
(
"Add to playlist"
),
container
.
ACTION_ADDTOPLAYLIST
,
selectionlist
);
}
}
menu
.
addSeparator
();
/* Item removal */
if
(
index
.
isValid
()
)
{
ADD_MENU_ENTRY
(
QIcon
(
":/buttons/playlist/playlist_remove"
),
qtr
(
I_POP_DEL
),
container
.
ACTION_REMOVE
,
selectionlist
);
}
if
(
model
->
canEdit
()
)
{
menu
.
addAction
(
QIcon
(
":/toolbar/clear"
),
qtr
(
"Clear playlist"
),
model
,
SLOT
(
clearPlaylist
()
)
);
}
menu
.
addSeparator
();
/* Playlist sorting */
QMenu
*
sortingMenu
=
new
QMenu
(
qtr
(
"Sort by"
)
);
/* Choose what columns to show in sorting menu, not sure if this should be configurable*/
QList
<
int
>
sortingColumns
;
sortingColumns
<<
COLUMN_TITLE
<<
COLUMN_ARTIST
<<
COLUMN_ALBUM
<<
COLUMN_TRACK_NUMBER
<<
COLUMN_URI
;
container
.
action
=
container
.
ACTION_SORT
;
container
.
indexes
=
callerAsList
;
foreach
(
int
Column
,
sortingColumns
)
{
action
=
sortingMenu
->
addAction
(
qfu
(
psz_column_title
(
Column
)
)
+
" "
+
qtr
(
"Ascending"
)
);
container
.
column
=
model
->
columnFromMeta
(
Column
)
+
1
;
action
->
setData
(
QVariant
::
fromValue
(
container
)
);
action
=
sortingMenu
->
addAction
(
qfu
(
psz_column_title
(
Column
)
)
+
" "
+
qtr
(
"Descending"
)
);
container
.
column
=
-
1
*
(
model
->
columnFromMeta
(
Column
)
+
1
);
action
->
setData
(
QVariant
::
fromValue
(
container
)
);
}
menu
.
addMenu
(
sortingMenu
);
/* Zoom */
QMenu
*
zoomMenu
=
new
QMenu
(
qtr
(
"Display size"
)
);
zoomMenu
->
addAction
(
qtr
(
"Increase"
),
model
,
SLOT
(
increaseZoom
()
)
);
zoomMenu
->
addAction
(
qtr
(
"Decrease"
),
model
,
SLOT
(
decreaseZoom
()
)
);
menu
.
addMenu
(
zoomMenu
);
CONNECT
(
&
menu
,
triggered
(
QAction
*
),
model
,
actionSlot
(
QAction
*
)
);
/* Display and forward the result */
if
(
!
menu
.
isEmpty
()
)
{
menu
.
exec
(
point
);
return
true
;
}
else
return
false
;
#undef ADD_MENU_ENTRY
}
void
StandardPLPanel
::
popupSelectColumn
(
QPoint
)
void
StandardPLPanel
::
popupSelectColumn
(
QPoint
)
{
{
QMenu
menu
;
QMenu
menu
;
...
...
modules/gui/qt4/components/playlist/standardpanel.hpp
View file @
4e7f747f
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include "components/playlist/playlist.hpp"
#include "components/playlist/playlist.hpp"
#include <QWidget>
#include <QWidget>
#include <QModelIndexList>
#include <vlc_playlist.h>
/* playlist_item_t */
#include <vlc_playlist.h>
/* playlist_item_t */
...
@@ -74,6 +75,7 @@ protected:
...
@@ -74,6 +75,7 @@ protected:
PLModel
*
model
;
PLModel
*
model
;
MLModel
*
mlmodel
;
MLModel
*
mlmodel
;
virtual
void
wheelEvent
(
QWheelEvent
*
e
);
virtual
void
wheelEvent
(
QWheelEvent
*
e
);
bool
popup
(
const
QModelIndex
&
index
,
const
QPoint
&
point
,
const
QModelIndexList
&
selectionlist
);
private:
private:
intf_thread_t
*
p_intf
;
intf_thread_t
*
p_intf
;
...
...
modules/gui/qt4/components/playlist/vlc_model.hpp
View file @
4e7f747f
...
@@ -52,13 +52,21 @@ public:
...
@@ -52,13 +52,21 @@ public:
VLCModel
(
intf_thread_t
*
_p_intf
,
QObject
*
parent
=
0
);
VLCModel
(
intf_thread_t
*
_p_intf
,
QObject
*
parent
=
0
);
virtual
int
itemId
(
const
QModelIndex
&
)
const
=
0
;
virtual
int
itemId
(
const
QModelIndex
&
)
const
=
0
;
virtual
QModelIndex
currentIndex
()
const
=
0
;
virtual
QModelIndex
currentIndex
()
const
=
0
;
virtual
bool
popup
(
const
QModelIndex
&
index
,
const
QPoint
&
point
,
const
QModelIndexList
&
list
)
=
0
;
virtual
void
doDelete
(
QModelIndexList
)
=
0
;
virtual
void
doDelete
(
QModelIndexList
)
=
0
;
virtual
~
VLCModel
();
virtual
~
VLCModel
();
static
QString
getMeta
(
const
QModelIndex
&
index
,
int
meta
);
static
QString
getMeta
(
const
QModelIndex
&
index
,
int
meta
);
static
QPixmap
getArtPixmap
(
const
QModelIndex
&
index
,
const
QSize
&
size
);
static
QPixmap
getArtPixmap
(
const
QModelIndex
&
index
,
const
QSize
&
size
);
static
QString
getArtUrl
(
const
QModelIndex
&
index
);
static
QString
getArtUrl
(
const
QModelIndex
&
index
);
virtual
QString
getURI
(
const
QModelIndex
&
index
)
const
=
0
;
virtual
QModelIndex
rootIndex
()
const
=
0
;
virtual
bool
isTree
()
const
=
0
;
virtual
bool
canEdit
()
const
=
0
;
enum
playLocation
{
IN_PLAYLIST
,
IN_MEDIALIBRARY
};
virtual
bool
isCurrentItem
(
const
QModelIndex
&
index
,
playLocation
where
)
const
=
0
;
struct
actionsContainerType
struct
actionsContainerType
{
{
...
...
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