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
f18a9358
Commit
f18a9358
authored
Oct 24, 2010
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: playlist code refactoring
parent
da1239a1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
125 additions
and
75 deletions
+125
-75
modules/gui/qt4/components/playlist/playlist.cpp
modules/gui/qt4/components/playlist/playlist.cpp
+72
-9
modules/gui/qt4/components/playlist/playlist.hpp
modules/gui/qt4/components/playlist/playlist.hpp
+19
-2
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
+6
-54
modules/gui/qt4/components/playlist/standardpanel.hpp
modules/gui/qt4/components/playlist/standardpanel.hpp
+15
-10
modules/gui/qt4/util/customwidgets.cpp
modules/gui/qt4/util/customwidgets.cpp
+9
-0
modules/gui/qt4/util/customwidgets.hpp
modules/gui/qt4/util/customwidgets.hpp
+4
-0
No files found.
modules/gui/qt4/components/playlist/playlist.cpp
View file @
f18a9358
...
...
@@ -35,6 +35,7 @@
#include "main_interface.hpp"
/* DropEvent TODO remove this*/
#include <QGroupBox>
#include <QMenu>
#include <iostream>
/**********************************************************************
...
...
@@ -46,12 +47,14 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
{
setContentsMargins
(
3
,
3
,
3
,
3
);
/* We use a QSplitter for the left part*/
/*******************
* Left *
*******************/
/* We use a QSplitter for the left part */
leftSplitter
=
new
QSplitter
(
Qt
::
Vertical
,
this
);
/* Source Selector */
selector
=
new
PLSelector
(
this
,
p_intf
);
leftSplitter
->
addWidget
(
selector
);
/* Create a Container for the Art Label
...
...
@@ -65,27 +68,81 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
/* Art label */
art
=
new
ArtLabel
(
artContainer
,
p_intf
);
art
->
setToolTip
(
qtr
(
"Double click to get media information"
)
);
artContLay
->
addWidget
(
art
,
1
);
CONNECT
(
THEMIM
->
getIM
(),
artChanged
(
QString
),
art
,
showArtUpdate
(
const
QString
&
)
);
artContLay
->
addWidget
(
art
,
1
);
leftSplitter
->
addWidget
(
artContainer
);
/*******************
* Right *
*******************/
/* Initialisation of the playlist */
playlist_t
*
p_playlist
=
THEPL
;
PL_LOCK
;
playlist_item_t
*
p_root
=
THEPL
->
p_playing
;
PL_UNLOCK
;
rightPanel
=
new
StandardPLPanel
(
this
,
p_intf
,
THEPL
,
p_root
,
selector
);
QWidget
*
rightPanel
=
new
QWidget
(
this
);
QGridLayout
*
layout
=
new
QGridLayout
(
rightPanel
);
layout
->
setSpacing
(
0
);
layout
->
setMargin
(
0
);
setMinimumWidth
(
300
);
PLModel
*
model
=
new
PLModel
(
p_playlist
,
p_intf
,
p_root
,
this
);
mainView
=
new
StandardPLPanel
(
this
,
p_intf
,
THEPL
,
p_root
,
selector
);
/* Location Bar */
locationBar
=
new
LocationBar
(
model
);
locationBar
->
setSizePolicy
(
QSizePolicy
::
Ignored
,
QSizePolicy
::
Preferred
);
layout
->
addWidget
(
locationBar
,
0
,
0
);
layout
->
setColumnStretch
(
0
,
5
);
CONNECT
(
locationBar
,
invoked
(
const
QModelIndex
&
),
mainView
,
browseInto
(
const
QModelIndex
&
)
);
/* Button to switch views */
QToolButton
*
viewButton
=
new
QToolButton
(
this
);
viewButton
->
setIcon
(
style
()
->
standardIcon
(
QStyle
::
SP_FileDialogDetailedView
)
);
viewButton
->
setToolTip
(
qtr
(
"Change playlistview"
)
);
layout
->
addWidget
(
viewButton
,
0
,
1
);
/* View selection menu */
viewSelectionMapper
=
new
QSignalMapper
(
this
);
CONNECT
(
viewSelectionMapper
,
mapped
(
int
),
mainView
,
showView
(
int
)
);
QActionGroup
*
actionGroup
=
new
QActionGroup
(
this
);
for
(
int
i
=
0
;
i
<
StandardPLPanel
::
VIEW_COUNT
;
i
++
)
{
viewActions
[
i
]
=
actionGroup
->
addAction
(
viewNames
[
i
]
);
viewActions
[
i
]
->
setCheckable
(
true
);
viewSelectionMapper
->
setMapping
(
viewActions
[
i
],
i
);
CONNECT
(
viewActions
[
i
],
triggered
(),
viewSelectionMapper
,
map
()
);
}
CONNECT
(
viewButton
,
clicked
(),
mainView
,
cycleViews
()
);
QMenu
*
viewMenu
=
new
QMenu
(
this
);
viewMenu
->
addActions
(
actionGroup
->
actions
()
);
viewButton
->
setMenu
(
viewMenu
);
/* Search */
searchEdit
=
new
SearchLineEdit
(
this
);
searchEdit
->
setMaximumWidth
(
250
);
searchEdit
->
setMinimumWidth
(
80
);
layout
->
addWidget
(
searchEdit
,
0
,
2
);
CONNECT
(
searchEdit
,
textEdited
(
const
QString
&
),
mainView
,
search
(
const
QString
&
)
);
CONNECT
(
searchEdit
,
searchDelayedChanged
(
const
QString
&
),
mainView
,
searchDelayed
(
const
QString
&
)
);
CONNECT
(
mainView
,
viewChanged
(
const
QModelIndex
&
),
this
,
changeView
(
const
QModelIndex
&
)
);
layout
->
setColumnStretch
(
2
,
3
);
/* Connect the activation of the selector to a redefining of the PL */
DCONNECT
(
selector
,
activated
(
playlist_item_t
*
),
rightPanel
,
setRoot
(
playlist_item_t
*
)
);
mainView
,
setRoot
(
playlist_item_t
*
)
);
rightPanel
->
setRoot
(
p_root
);
mainView
->
setRoot
(
p_root
);
layout
->
addWidget
(
mainView
,
1
,
0
,
1
,
-
1
);
/* Add the two sides of the QSplitter */
addWidget
(
leftSplitter
);
...
...
@@ -151,17 +208,23 @@ void PlaylistWidget::closeEvent( QCloseEvent *event )
void
PlaylistWidget
::
forceHide
()
{
leftSplitter
->
hide
();
rightPanel
->
hide
();
mainView
->
hide
();
updateGeometry
();
}
void
PlaylistWidget
::
forceShow
()
{
leftSplitter
->
show
();
rightPanel
->
show
();
mainView
->
show
();
updateGeometry
();
}
void
PlaylistWidget
::
changeView
(
const
QModelIndex
&
index
)
{
searchEdit
->
clear
();
locationBar
->
setIndex
(
index
);
}
#include <QSignalMapper>
#include <QMenu>
...
...
modules/gui/qt4/components/playlist/playlist.hpp
View file @
f18a9358
...
...
@@ -33,14 +33,22 @@
#include "qt4.hpp"
#include "dialogs_provider.hpp"
/* Media Info from ArtLabel */
#include "components/playlist/standardpanel.hpp"
/* CoverArt */
#include "components/interface_widgets.hpp"
/* CoverArt */
//#include <vlc_playlist.h>
#include <QSplitter>
class
PLSelector
;
class
StandardPLPanel
;
class
QPushButton
;
class
StandardPLPanel
;
static
const
QString
viewNames
[]
=
{
qtr
(
"Detailed View"
),
qtr
(
"Icon View"
),
qtr
(
"List View"
)
};
class
ArtLabel
:
public
CoverArtLabel
{
...
...
@@ -55,6 +63,7 @@ public:
}
};
class
LocationBar
;
class
PlaylistWidget
:
public
QSplitter
{
Q_OBJECT
...
...
@@ -66,15 +75,23 @@ public:
private:
PLSelector
*
selector
;
ArtLabel
*
art
;
StandardPLPanel
*
rightPanel
;
QPushButton
*
addButton
;
QSplitter
*
leftSplitter
;
QSignalMapper
*
viewSelectionMapper
;
QAction
*
viewActions
[
3
];
StandardPLPanel
*
mainView
;
LocationBar
*
locationBar
;
SearchLineEdit
*
searchEdit
;
protected:
intf_thread_t
*
p_intf
;
virtual
void
dropEvent
(
QDropEvent
*
);
virtual
void
dragEnterEvent
(
QDragEnterEvent
*
);
virtual
void
closeEvent
(
QCloseEvent
*
);
private
slots
:
void
changeView
(
const
QModelIndex
&
index
);
};
class
LocationButton
:
public
QPushButton
...
...
modules/gui/qt4/components/playlist/standardpanel.cpp
View file @
f18a9358
...
...
@@ -34,6 +34,7 @@
#include "components/playlist/selector.hpp"
#include "util/customwidgets.hpp"
#include "menus.hpp"
#include "input_manager.hpp"
#include <vlc_intf_strings.h>
...
...
@@ -52,9 +53,6 @@
#include "sorting.h"
static
const
QString
viewNames
[]
=
{
qtr
(
"Detailed View"
),
qtr
(
"Icon View"
),
qtr
(
"List View"
)
};
StandardPLPanel
::
StandardPLPanel
(
PlaylistWidget
*
_parent
,
intf_thread_t
*
_p_intf
,
...
...
@@ -79,49 +77,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
currentRootIndexId
=
-
1
;
lastActivatedId
=
-
1
;
locationBar
=
new
LocationBar
(
model
);
locationBar
->
setSizePolicy
(
QSizePolicy
::
Ignored
,
QSizePolicy
::
Preferred
);
layout
->
addWidget
(
locationBar
,
0
,
0
);
layout
->
setColumnStretch
(
0
,
5
);
CONNECT
(
locationBar
,
invoked
(
const
QModelIndex
&
),
this
,
browseInto
(
const
QModelIndex
&
)
);
searchEdit
=
new
SearchLineEdit
(
this
);
searchEdit
->
setMaximumWidth
(
250
);
searchEdit
->
setMinimumWidth
(
80
);
layout
->
addWidget
(
searchEdit
,
0
,
2
);
CONNECT
(
searchEdit
,
textEdited
(
const
QString
&
),
this
,
search
(
const
QString
&
)
);
CONNECT
(
searchEdit
,
editingFinished
(),
this
,
searchDelayed
()
);
layout
->
setColumnStretch
(
2
,
3
);
/* Button to switch views */
QToolButton
*
viewButton
=
new
QToolButton
(
this
);
viewButton
->
setIcon
(
style
()
->
standardIcon
(
QStyle
::
SP_FileDialogDetailedView
)
);
viewButton
->
setToolTip
(
qtr
(
"Change playlistview"
));
layout
->
addWidget
(
viewButton
,
0
,
1
);
/* View selection menu */
viewSelectionMapper
=
new
QSignalMapper
(
this
);
CONNECT
(
viewSelectionMapper
,
mapped
(
int
),
this
,
showView
(
int
)
);
QActionGroup
*
actionGroup
=
new
QActionGroup
(
this
);
for
(
int
i
=
0
;
i
<
VIEW_COUNT
;
i
++
)
{
viewActions
[
i
]
=
actionGroup
->
addAction
(
viewNames
[
i
]
);
viewActions
[
i
]
->
setCheckable
(
true
);
viewSelectionMapper
->
setMapping
(
viewActions
[
i
],
i
);
CONNECT
(
viewActions
[
i
],
triggered
(),
viewSelectionMapper
,
map
()
);
}
BUTTONACT
(
viewButton
,
cycleViews
()
);
QMenu
*
viewMenu
=
new
QMenu
(
this
);
viewMenu
->
addActions
(
actionGroup
->
actions
()
);
viewButton
->
setMenu
(
viewMenu
);
/* Saved Settings */
getSettings
()
->
beginGroup
(
"Playlist"
);
...
...
@@ -223,7 +178,7 @@ void StandardPLPanel::search( const QString& searchText )
}
}
void
StandardPLPanel
::
searchDelayed
()
void
StandardPLPanel
::
searchDelayed
(
const
QString
&
searchText
)
{
int
type
;
QString
name
;
...
...
@@ -231,8 +186,8 @@ void StandardPLPanel::searchDelayed()
if
(
type
==
SD_TYPE
)
{
if
(
!
name
.
isEmpty
()
&&
!
search
Edit
->
text
()
.
isEmpty
()
)
playlist_QueryServicesDiscovery
(
THEPL
,
qtu
(
name
),
qtu
(
searchEdit
->
text
()
)
);
if
(
!
name
.
isEmpty
()
&&
!
search
Text
.
isEmpty
()
)
playlist_QueryServicesDiscovery
(
THEPL
,
qtu
(
name
),
qtu
(
searchText
)
);
}
}
...
...
@@ -251,8 +206,7 @@ void StandardPLPanel::browseInto( const QModelIndex &index )
currentView
->
setRootIndex
(
index
);
}
locationBar
->
setIndex
(
index
);
searchEdit
->
clear
();
emit
viewChanged
(
index
);
}
void
StandardPLPanel
::
browseInto
(
)
...
...
@@ -406,7 +360,7 @@ void StandardPLPanel::showView( int i_view )
}
viewStack
->
setCurrentWidget
(
currentView
);
viewActions
[
i_view
]
->
setChecked
(
true
);
//
viewActions[i_view]->setChecked( true );
browseInto
();
gotoPlayingItem
();
}
...
...
@@ -466,6 +420,4 @@ void StandardPLPanel::browseInto( input_item_t *p_input )
lastActivatedId
=
-
1
;
}
modules/gui/qt4/components/playlist/standardpanel.hpp
View file @
f18a9358
...
...
@@ -49,6 +49,9 @@ class QStackedLayout;
class
PlIconView
;
class
PlListView
;
class
LocationBar
;
class
PLSelector
;
class
QAbstractItemView
;
class
PlaylistWidget
;
class
StandardPLPanel
:
public
QWidget
{
...
...
@@ -74,10 +77,7 @@ private:
intf_thread_t
*
p_intf
;
QWidget
*
parent
;
QLabel
*
title
;
QGridLayout
*
layout
;
LocationBar
*
locationBar
;
SearchLineEdit
*
searchEdit
;
PLSelector
*
p_selector
;
QTreeView
*
treeView
;
...
...
@@ -86,11 +86,8 @@ private:
QAbstractItemView
*
currentView
;
QStackedLayout
*
viewStack
;
QAction
*
viewActions
[
VIEW_COUNT
];
QAction
*
iconViewAction
,
*
treeViewAction
;
int
currentRootId
;
QSignalMapper
*
selectColumnsSigMapper
;
QSignalMapper
*
viewSelectionMapper
;
int
lastActivatedId
;
int
currentRootIndexId
;
...
...
@@ -105,20 +102,28 @@ public slots:
void
setRoot
(
playlist_item_t
*
);
void
browseInto
(
const
QModelIndex
&
);
void
browseInto
(
);
private
slots
:
void
deleteSelection
();
void
handleExpansion
(
const
QModelIndex
&
);
void
handleRootChange
();
void
activate
(
const
QModelIndex
&
);
void
browseInto
(
input_item_t
*
);
void
gotoPlayingItem
();
void
search
(
const
QString
&
searchText
);
void
searchDelayed
();
void
popupSelectColumn
(
QPoint
);
void
searchDelayed
(
const
QString
&
searchText
);
void
popupPlView
(
const
QPoint
&
);
void
popupSelectColumn
(
QPoint
);
void
toggleColumnShown
(
int
);
void
showView
(
int
);
void
cycleViews
();
void
activate
(
const
QModelIndex
&
);
void
browseInto
(
input_item_t
*
);
signals:
void
viewChanged
(
const
QModelIndex
&
);
};
#endif
modules/gui/qt4/util/customwidgets.cpp
View file @
f18a9358
...
...
@@ -148,6 +148,10 @@ SearchLineEdit::SearchLineEdit( QWidget *parent ) : QLineEdit( parent )
CONNECT
(
this
,
textEdited
(
const
QString
&
),
this
,
updateText
(
const
QString
&
)
);
CONNECT
(
this
,
editingFinished
(),
this
,
searchEditingFinished
()
);
}
void
SearchLineEdit
::
clear
()
...
...
@@ -208,6 +212,11 @@ void SearchLineEdit::paintEvent( QPaintEvent *event )
painter
.
drawText
(
rect
,
Qt
::
AlignLeft
|
Qt
::
AlignVCenter
,
qtr
(
I_PL_FILTER
)
);
}
void
SearchLineEdit
::
searchEditingFinished
()
{
emit
searchDelayedChanged
(
text
()
);
}
QVLCElidingLabel
::
QVLCElidingLabel
(
const
QString
&
s
,
Qt
::
TextElideMode
mode
,
QWidget
*
parent
)
:
elideMode
(
mode
),
QLabel
(
s
,
parent
)
...
...
modules/gui/qt4/util/customwidgets.hpp
View file @
f18a9358
...
...
@@ -89,6 +89,10 @@ public slots:
private
slots
:
void
updateText
(
const
QString
&
);
void
searchEditingFinished
();
signals:
void
searchDelayedChanged
(
const
QString
&
);
};
class
QVLCElidingLabel
:
public
QLabel
...
...
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