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
b2e1a820
Commit
b2e1a820
authored
Sep 11, 2010
by
Jean-Baptiste Kempf
Committed by
Jean-Baptiste Kempf
Sep 15, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt, selector: cleanup
Code cleanup, forward declaration and cosmetics
parent
9eb0513a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
167 deletions
+166
-167
modules/gui/qt4/components/playlist/selector.cpp
modules/gui/qt4/components/playlist/selector.cpp
+123
-128
modules/gui/qt4/components/playlist/selector.hpp
modules/gui/qt4/components/playlist/selector.hpp
+43
-39
No files found.
modules/gui/qt4/components/playlist/selector.cpp
View file @
b2e1a820
...
@@ -26,20 +26,18 @@
...
@@ -26,20 +26,18 @@
# include "config.h"
# include "config.h"
#endif
#endif
#include <assert.h>
#include "components/playlist/selector.hpp"
#include "playlist_model.hpp"
#include "qt4.hpp"
#include "qt4.hpp"
#include "
dialogs_provide
r.hpp"
#include "
components/playlist/selecto
r.hpp"
#include "playlist
.hpp"
#include "playlist
_model.hpp"
/* plMimeData */
#include "
util/customwidgets.hpp"
#include "
input_manager.hpp"
/* MainInputManager, for podcast */
#include <QVBoxLayout>
#include <QHeaderView>
#include <QMimeData>
#include <QInputDialog>
#include <QInputDialog>
#include <QMessageBox>
#include <QMessageBox>
#include <QMimeData>
#include <QDragMoveEvent>
#include <QTreeWidgetItem>
#include <QHBoxLayout>
#include <QPainter>
#include <vlc_playlist.h>
#include <vlc_playlist.h>
#include <vlc_services_discovery.h>
#include <vlc_services_discovery.h>
...
@@ -61,16 +59,13 @@ void SelectorActionButton::paintEvent( QPaintEvent *event )
...
@@ -61,16 +59,13 @@ void SelectorActionButton::paintEvent( QPaintEvent *event )
PLSelItem
::
PLSelItem
(
QTreeWidgetItem
*
i
,
const
QString
&
text
)
PLSelItem
::
PLSelItem
(
QTreeWidgetItem
*
i
,
const
QString
&
text
)
:
qitem
(
i
),
lblAction
(
NULL
)
:
qitem
(
i
),
lblAction
(
NULL
)
{
{
layout
=
new
QHBoxLayout
();
layout
=
new
QHBoxLayout
(
this
);
layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
layout
->
addSpacing
(
3
);
layout
->
addSpacing
(
3
);
lbl
=
new
QVLCElidingLabel
(
text
);
lbl
=
new
QVLCElidingLabel
(
text
);
layout
->
addWidget
(
lbl
,
1
);
layout
->
addWidget
(
lbl
,
1
);
setLayout
(
layout
);
int
height
=
qMax
(
22
,
fontMetrics
().
height
()
+
8
);
int
height
=
qMax
(
22
,
fontMetrics
().
height
()
+
8
);
setMinimumHeight
(
height
);
setMinimumHeight
(
height
);
}
}
...
@@ -101,33 +96,29 @@ void PLSelItem::addAction( ItemAction act, const QString& tooltip )
...
@@ -101,33 +96,29 @@ void PLSelItem::addAction( ItemAction act, const QString& tooltip )
CONNECT
(
lblAction
,
clicked
(),
this
,
triggerAction
()
);
CONNECT
(
lblAction
,
clicked
(),
this
,
triggerAction
()
);
}
}
void
PLSelItem
::
showAction
()
{
if
(
lblAction
)
lblAction
->
show
();
}
void
PLSelItem
::
hideAction
()
{
if
(
lblAction
)
lblAction
->
hide
();
}
void
PLSelItem
::
setText
(
const
QString
&
text
)
{
lbl
->
setText
(
text
);
}
void
PLSelItem
::
enterEvent
(
QEvent
*
ev
){
showAction
();
}
void
PLSelItem
::
leaveEvent
(
QEvent
*
ev
){
hideAction
();
}
PLSelector
::
PLSelector
(
QWidget
*
p
,
intf_thread_t
*
_p_intf
)
PLSelector
::
PLSelector
(
QWidget
*
p
,
intf_thread_t
*
_p_intf
)
:
QTreeWidget
(
p
),
p_intf
(
_p_intf
)
:
QTreeWidget
(
p
),
p_intf
(
_p_intf
)
{
{
/* Properties */
setFrameStyle
(
QFrame
::
NoFrame
);
setFrameStyle
(
QFrame
::
NoFrame
);
viewport
()
->
setAutoFillBackground
(
false
);
viewport
()
->
setAutoFillBackground
(
false
);
setIconSize
(
QSize
(
24
,
24
)
);
setIconSize
(
QSize
(
24
,
24
)
);
setIndentation
(
12
);
setIndentation
(
12
);
header
()
->
hide
(
);
setHeaderHidden
(
true
);
setRootIsDecorated
(
true
);
setRootIsDecorated
(
true
);
setAlternatingRowColors
(
false
);
setAlternatingRowColors
(
false
);
podcastsParent
=
NULL
;
podcastsParentId
=
-
1
;
/* drops */
viewport
()
->
setAcceptDrops
(
true
);
viewport
()
->
setAcceptDrops
(
true
);
setDropIndicatorShown
(
true
);
setDropIndicatorShown
(
true
);
invisibleRootItem
()
->
setFlags
(
invisibleRootItem
()
->
flags
()
&
~
Qt
::
ItemIsDropEnabled
);
invisibleRootItem
()
->
setFlags
(
invisibleRootItem
()
->
flags
()
&
~
Qt
::
ItemIsDropEnabled
);
/* Podcasts */
podcastsParent
=
NULL
;
podcastsParentId
=
-
1
;
/* Podcast connects */
CONNECT
(
THEMIM
,
playlistItemAppended
(
int
,
int
),
CONNECT
(
THEMIM
,
playlistItemAppended
(
int
,
int
),
this
,
plItemAdded
(
int
,
int
)
);
this
,
plItemAdded
(
int
,
int
)
);
CONNECT
(
THEMIM
,
playlistItemRemoved
(
int
),
CONNECT
(
THEMIM
,
playlistItemRemoved
(
int
),
...
@@ -164,6 +155,94 @@ PLSelector::~PLSelector()
...
@@ -164,6 +155,94 @@ PLSelector::~PLSelector()
}
}
}
}
PLSelItem
*
putSDData
(
PLSelItem
*
item
,
const
char
*
name
,
const
char
*
longname
)
{
item
->
treeItem
()
->
setData
(
0
,
NAME_ROLE
,
qfu
(
name
)
);
item
->
treeItem
()
->
setData
(
0
,
LONGNAME_ROLE
,
qfu
(
longname
)
);
return
item
;
}
PLSelItem
*
putPLData
(
PLSelItem
*
item
,
playlist_item_t
*
plItem
)
{
item
->
treeItem
()
->
setData
(
0
,
PL_ITEM_ROLE
,
QVariant
::
fromValue
(
plItem
)
);
/* item->setData( 0, PL_ITEM_ID_ROLE, plItem->i_id );
item->setData( 0, IN_ITEM_ROLE, QVariant::fromValue( (void*) plItem->p_input ) ); );*/
return
item
;
}
void
PLSelector
::
createItems
()
{
/* PL */
PLSelItem
*
pl
=
putPLData
(
addItem
(
PL_ITEM_TYPE
,
"Playlist"
,
true
),
THEPL
->
p_playing
);
pl
->
treeItem
()
->
setData
(
0
,
SPECIAL_ROLE
,
QVariant
(
IS_PL
)
);
/* ML */
PLSelItem
*
ml
=
putPLData
(
addItem
(
PL_ITEM_TYPE
,
"Media Library"
,
true
),
THEPL
->
p_media_library
);
ml
->
treeItem
()
->
setData
(
0
,
SPECIAL_ROLE
,
QVariant
(
IS_ML
)
);
/* SD nodes */
QTreeWidgetItem
*
mycomp
=
addItem
(
CATEGORY_TYPE
,
"My Computer"
)
->
treeItem
();
QTreeWidgetItem
*
devices
=
addItem
(
CATEGORY_TYPE
,
"Devices"
)
->
treeItem
();
QTreeWidgetItem
*
lan
=
addItem
(
CATEGORY_TYPE
,
"Local Network"
)
->
treeItem
();
QTreeWidgetItem
*
internet
=
addItem
(
CATEGORY_TYPE
,
"Internet"
)
->
treeItem
();
/* SD subnodes */
char
**
ppsz_longnames
;
int
*
p_categories
;
char
**
ppsz_names
=
vlc_sd_GetNames
(
THEPL
,
&
ppsz_longnames
,
&
p_categories
);
if
(
!
ppsz_names
)
return
;
char
**
ppsz_name
=
ppsz_names
,
**
ppsz_longname
=
ppsz_longnames
;
int
*
p_category
=
p_categories
;
for
(
;
*
ppsz_name
;
ppsz_name
++
,
ppsz_longname
++
,
p_category
++
)
{
//msg_Dbg( p_intf, "Adding a SD item: %s", *ppsz_longname );
PLSelItem
*
selItem
;
switch
(
*
p_category
)
{
case
SD_CAT_INTERNET
:
{
selItem
=
addItem
(
SD_TYPE
,
*
ppsz_longname
,
false
,
internet
);
if
(
!
strncmp
(
*
ppsz_name
,
"podcast"
,
7
)
)
{
selItem
->
treeItem
()
->
setData
(
0
,
SPECIAL_ROLE
,
QVariant
(
IS_PODCAST
)
);
selItem
->
addAction
(
ADD_ACTION
,
qtr
(
"Subscribe to a podcast"
)
);
CONNECT
(
selItem
,
action
(
PLSelItem
*
),
this
,
podcastAdd
(
PLSelItem
*
)
);
podcastsParent
=
selItem
->
treeItem
();
}
}
break
;
case
SD_CAT_DEVICES
:
selItem
=
addItem
(
SD_TYPE
,
*
ppsz_longname
,
false
,
devices
);
break
;
case
SD_CAT_LAN
:
selItem
=
addItem
(
SD_TYPE
,
*
ppsz_longname
,
false
,
lan
);
break
;
case
SD_CAT_MYCOMPUTER
:
selItem
=
addItem
(
SD_TYPE
,
*
ppsz_longname
,
false
,
mycomp
);
break
;
default:
selItem
=
addItem
(
SD_TYPE
,
*
ppsz_longname
);
}
putSDData
(
selItem
,
*
ppsz_name
,
*
ppsz_longname
);
free
(
*
ppsz_name
);
free
(
*
ppsz_longname
);
}
free
(
ppsz_names
);
free
(
ppsz_longnames
);
free
(
p_categories
);
if
(
mycomp
->
childCount
()
==
0
)
delete
mycomp
;
if
(
devices
->
childCount
()
==
0
)
delete
devices
;
if
(
lan
->
childCount
()
==
0
)
delete
lan
;
if
(
internet
->
childCount
()
==
0
)
delete
internet
;
}
void
PLSelector
::
setSource
(
QTreeWidgetItem
*
item
)
void
PLSelector
::
setSource
(
QTreeWidgetItem
*
item
)
{
{
if
(
!
item
)
if
(
!
item
)
...
@@ -183,13 +262,17 @@ void PLSelector::setSource( QTreeWidgetItem *item )
...
@@ -183,13 +262,17 @@ void PLSelector::setSource( QTreeWidgetItem *item )
playlist_ServicesDiscoveryAdd
(
THEPL
,
qtu
(
qs
)
);
playlist_ServicesDiscoveryAdd
(
THEPL
,
qtu
(
qs
)
);
}
}
/* */
playlist_Lock
(
THEPL
);
playlist_Lock
(
THEPL
);
playlist_item_t
*
pl_item
=
NULL
;
playlist_item_t
*
pl_item
=
NULL
;
if
(
i_type
==
SD_TYPE
)
if
(
i_type
==
SD_TYPE
)
{
{
pl_item
=
playlist_ChildSearchName
(
THEPL
->
p_root
,
qtu
(
item
->
data
(
0
,
LONGNAME_ROLE
).
toString
()
)
);
/* Find the right item for the SD */
pl_item
=
playlist_ChildSearchName
(
THEPL
->
p_root
,
qtu
(
item
->
data
(
0
,
LONGNAME_ROLE
).
toString
()
)
);
/* Podcasts */
if
(
item
->
data
(
0
,
SPECIAL_ROLE
).
toInt
()
==
IS_PODCAST
)
if
(
item
->
data
(
0
,
SPECIAL_ROLE
).
toInt
()
==
IS_PODCAST
)
{
{
if
(
pl_item
&&
!
sd_loaded
)
if
(
pl_item
&&
!
sd_loaded
)
...
@@ -206,16 +289,18 @@ void PLSelector::setSource( QTreeWidgetItem *item )
...
@@ -206,16 +289,18 @@ void PLSelector::setSource( QTreeWidgetItem *item )
playlist_Unlock
(
THEPL
);
playlist_Unlock
(
THEPL
);
/* */
if
(
pl_item
)
if
(
pl_item
)
emit
activated
(
pl_item
);
emit
activated
(
pl_item
);
}
}
PLSelItem
*
PLSelector
::
addItem
(
PLSelItem
*
PLSelector
::
addItem
(
SelectorItemType
type
,
const
char
*
str
,
bool
drop
,
SelectorItemType
type
,
const
char
*
str
,
bool
drop
,
QTreeWidgetItem
*
parentItem
)
QTreeWidgetItem
*
parentItem
)
{
{
QTreeWidgetItem
*
item
=
parentItem
?
QTreeWidgetItem
*
item
=
parentItem
?
new
QTreeWidgetItem
(
parentItem
)
:
new
QTreeWidgetItem
(
this
);
new
QTreeWidgetItem
(
parentItem
)
:
new
QTreeWidgetItem
(
this
);
PLSelItem
*
selItem
=
new
PLSelItem
(
item
,
qtr
(
str
)
);
PLSelItem
*
selItem
=
new
PLSelItem
(
item
,
qtr
(
str
)
);
setItemWidget
(
item
,
0
,
selItem
);
setItemWidget
(
item
,
0
,
selItem
);
item
->
setData
(
0
,
TYPE_ROLE
,
(
int
)
type
);
item
->
setData
(
0
,
TYPE_ROLE
,
(
int
)
type
);
...
@@ -224,113 +309,22 @@ PLSelItem * PLSelector::addItem (
...
@@ -224,113 +309,22 @@ PLSelItem * PLSelector::addItem (
return
selItem
;
return
selItem
;
}
}
PLSelItem
*
putSDData
(
PLSelItem
*
item
,
const
char
*
name
,
const
char
*
longname
)
{
item
->
treeItem
()
->
setData
(
0
,
NAME_ROLE
,
qfu
(
name
)
);
item
->
treeItem
()
->
setData
(
0
,
LONGNAME_ROLE
,
qfu
(
longname
)
);
return
item
;
}
PLSelItem
*
putPLData
(
PLSelItem
*
item
,
playlist_item_t
*
plItem
)
{
item
->
treeItem
()
->
setData
(
0
,
PL_ITEM_ROLE
,
QVariant
::
fromValue
(
plItem
)
);
/* item->setData( 0, PL_ITEM_ID_ROLE, plItem->i_id );
item->setData( 0, IN_ITEM_ROLE, QVariant::fromValue( (void*) plItem->p_input ) ); );*/
return
item
;
}
PLSelItem
*
PLSelector
::
addPodcastItem
(
playlist_item_t
*
p_item
)
PLSelItem
*
PLSelector
::
addPodcastItem
(
playlist_item_t
*
p_item
)
{
{
vlc_gc_incref
(
p_item
->
p_input
);
vlc_gc_incref
(
p_item
->
p_input
);
char
*
psz_name
=
input_item_GetName
(
p_item
->
p_input
);
char
*
psz_name
=
input_item_GetName
(
p_item
->
p_input
);
PLSelItem
*
item
=
addItem
(
PLSelItem
*
item
=
addItem
(
PL_ITEM_TYPE
,
psz_name
,
false
,
podcastsParent
);
PL_ITEM_TYPE
,
psz_name
,
false
,
podcastsParent
);
free
(
psz_name
);
item
->
addAction
(
RM_ACTION
,
qtr
(
"Remove this podcast subscription"
)
);
item
->
addAction
(
RM_ACTION
,
qtr
(
"Remove this podcast subscription"
)
);
item
->
treeItem
()
->
setData
(
0
,
PL_ITEM_ROLE
,
QVariant
::
fromValue
(
p_item
)
);
item
->
treeItem
()
->
setData
(
0
,
PL_ITEM_ROLE
,
QVariant
::
fromValue
(
p_item
)
);
item
->
treeItem
()
->
setData
(
0
,
PL_ITEM_ID_ROLE
,
QVariant
(
p_item
->
i_id
)
);
item
->
treeItem
()
->
setData
(
0
,
PL_ITEM_ID_ROLE
,
QVariant
(
p_item
->
i_id
)
);
item
->
treeItem
()
->
setData
(
0
,
IN_ITEM_ROLE
,
QVariant
::
fromValue
(
p_item
->
p_input
)
);
item
->
treeItem
()
->
setData
(
0
,
IN_ITEM_ROLE
,
QVariant
::
fromValue
(
p_item
->
p_input
)
);
CONNECT
(
item
,
action
(
PLSelItem
*
),
this
,
podcastRemove
(
PLSelItem
*
)
);
CONNECT
(
item
,
action
(
PLSelItem
*
),
this
,
podcastRemove
(
PLSelItem
*
)
);
free
(
psz_name
);
return
item
;
return
item
;
}
}
void
PLSelector
::
createItems
()
{
PLSelItem
*
pl
=
putPLData
(
addItem
(
PL_ITEM_TYPE
,
"Playlist"
,
true
),
THEPL
->
p_playing
);
pl
->
treeItem
()
->
setData
(
0
,
SPECIAL_ROLE
,
QVariant
(
IS_PL
)
);
PLSelItem
*
ml
=
putPLData
(
addItem
(
PL_ITEM_TYPE
,
"Media Library"
,
true
),
THEPL
->
p_media_library
);
ml
->
treeItem
()
->
setData
(
0
,
SPECIAL_ROLE
,
QVariant
(
IS_ML
)
);
QTreeWidgetItem
*
mycomp
=
addItem
(
CATEGORY_TYPE
,
"My Computer"
,
false
)
->
treeItem
();
QTreeWidgetItem
*
devices
=
addItem
(
CATEGORY_TYPE
,
"Devices"
,
false
)
->
treeItem
();
QTreeWidgetItem
*
lan
=
addItem
(
CATEGORY_TYPE
,
"Local Network"
,
false
)
->
treeItem
();
QTreeWidgetItem
*
internet
=
addItem
(
CATEGORY_TYPE
,
"Internet"
,
false
)
->
treeItem
();;
char
**
ppsz_longnames
;
int
*
p_categories
;
char
**
ppsz_names
=
vlc_sd_GetNames
(
THEPL
,
&
ppsz_longnames
,
&
p_categories
);
if
(
!
ppsz_names
)
return
;
char
**
ppsz_name
=
ppsz_names
,
**
ppsz_longname
=
ppsz_longnames
;
int
*
p_category
=
p_categories
;
for
(
;
*
ppsz_name
;
ppsz_name
++
,
ppsz_longname
++
,
p_category
++
)
{
//msg_Dbg( p_intf, "Adding a SD item: %s", *ppsz_longname );
if
(
*
p_category
==
SD_CAT_INTERNET
)
{
PLSelItem
*
selItem
=
addItem
(
SD_TYPE
,
*
ppsz_longname
,
false
,
internet
);
putSDData
(
selItem
,
*
ppsz_name
,
*
ppsz_longname
);
if
(
!
strncmp
(
*
ppsz_name
,
"podcast"
,
7
)
)
{
selItem
->
treeItem
()
->
setData
(
0
,
SPECIAL_ROLE
,
QVariant
(
IS_PODCAST
)
);
selItem
->
addAction
(
ADD_ACTION
,
qtr
(
"Subscribe to a podcast"
)
);
CONNECT
(
selItem
,
action
(
PLSelItem
*
),
this
,
podcastAdd
(
PLSelItem
*
)
);
podcastsParent
=
selItem
->
treeItem
();
}
}
else
if
(
*
p_category
==
SD_CAT_DEVICES
)
{
putSDData
(
addItem
(
SD_TYPE
,
*
ppsz_longname
,
false
,
devices
),
*
ppsz_name
,
*
ppsz_longname
);
}
else
if
(
*
p_category
==
SD_CAT_LAN
)
{
putSDData
(
addItem
(
SD_TYPE
,
*
ppsz_longname
,
false
,
lan
),
*
ppsz_name
,
*
ppsz_longname
);
}
else
if
(
*
p_category
==
SD_CAT_MYCOMPUTER
)
{
putSDData
(
addItem
(
SD_TYPE
,
*
ppsz_longname
,
false
,
mycomp
),
*
ppsz_name
,
*
ppsz_longname
);
}
else
{
putSDData
(
addItem
(
SD_TYPE
,
*
ppsz_longname
,
false
),
*
ppsz_name
,
*
ppsz_longname
);
}
free
(
*
ppsz_name
);
free
(
*
ppsz_longname
);
}
free
(
ppsz_names
);
free
(
ppsz_longnames
);
free
(
p_categories
);
if
(
mycomp
->
childCount
()
==
0
)
delete
mycomp
;
if
(
devices
->
childCount
()
==
0
)
delete
devices
;
if
(
lan
->
childCount
()
==
0
)
delete
lan
;
if
(
internet
->
childCount
()
==
0
)
delete
internet
;
}
QStringList
PLSelector
::
mimeTypes
()
const
QStringList
PLSelector
::
mimeTypes
()
const
{
{
QStringList
types
;
QStringList
types
;
...
@@ -339,15 +333,16 @@ QStringList PLSelector::mimeTypes() const
...
@@ -339,15 +333,16 @@ QStringList PLSelector::mimeTypes() const
}
}
bool
PLSelector
::
dropMimeData
(
QTreeWidgetItem
*
parent
,
int
index
,
bool
PLSelector
::
dropMimeData
(
QTreeWidgetItem
*
parent
,
int
index
,
const
QMimeData
*
data
,
Qt
::
DropAction
action
)
const
QMimeData
*
data
,
Qt
::
DropAction
action
)
{
{
if
(
!
parent
)
return
false
;
if
(
!
parent
)
return
false
;
QVariant
type
=
parent
->
data
(
0
,
TYPE_ROLE
);
QVariant
type
=
parent
->
data
(
0
,
TYPE_ROLE
);
if
(
type
==
QVariant
()
)
return
false
;
if
(
type
==
QVariant
()
)
return
false
;
int
i_truth
=
parent
->
data
(
0
,
SPECIAL_ROLE
).
toInt
();
int
i_truth
=
parent
->
data
(
0
,
SPECIAL_ROLE
).
toInt
();
if
(
i_truth
!=
IS_PL
&&
i_truth
!=
IS_ML
)
return
false
;
if
(
i_truth
!=
IS_PL
&&
i_truth
!=
IS_ML
)
return
false
;
bool
to_pl
=
(
i_truth
==
IS_PL
);
bool
to_pl
=
(
i_truth
==
IS_PL
);
const
PlMimeData
*
plMimeData
=
qobject_cast
<
const
PlMimeData
*>
(
data
);
const
PlMimeData
*
plMimeData
=
qobject_cast
<
const
PlMimeData
*>
(
data
);
...
...
modules/gui/qt4/components/playlist/selector.hpp
View file @
b2e1a820
...
@@ -29,20 +29,16 @@
...
@@ -29,20 +29,16 @@
# include "config.h"
# include "config.h"
#endif
#endif
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QStyledItemDelegate>
#include <QPainter>
#include <QPushButton>
#include <QLabel>
#include <QHBoxLayout>
#include "util/customwidgets.hpp"
#include <vlc_playlist.h>
#include "qt4.hpp"
#include "qt4.hpp"
#include "util/customwidgets.hpp"
/* QVLCFramelessButton */
#include <QTreeWidget>
class
QHBoxLayout
;
class
QPainter
;
class
QTreeWidgetItem
;
class
PlaylistWidget
;
class
PlaylistWidget
;
class
QLabel
;
enum
SelectorItemType
{
enum
SelectorItemType
{
CATEGORY_TYPE
,
CATEGORY_TYPE
,
...
@@ -57,13 +53,13 @@ enum SpecialData {
...
@@ -57,13 +53,13 @@ enum SpecialData {
};
};
enum
{
enum
{
TYPE_ROLE
=
Qt
::
UserRole
,
TYPE_ROLE
=
Qt
::
UserRole
+
1
,
NAME_ROLE
,
//QString
NAME_ROLE
,
//QString
LONGNAME_ROLE
,
//QString
LONGNAME_ROLE
,
//QString
PL_ITEM_ROLE
,
//playlist_item_t*
PL_ITEM_ROLE
,
//playlist_item_t*
PL_ITEM_ID_ROLE
,
//playlist_item_t->i_id
PL_ITEM_ID_ROLE
,
//playlist_item_t->i_id
IN_ITEM_ROLE
,
//input_item_t->i_id
IN_ITEM_ROLE
,
//input_item_t->i_id
SPECIAL_ROLE
//SpecialData
SPECIAL_ROLE
//SpecialData
};
};
enum
ItemAction
{
enum
ItemAction
{
...
@@ -74,11 +70,8 @@ enum ItemAction {
...
@@ -74,11 +70,8 @@ enum ItemAction {
class
SelectorActionButton
:
public
QVLCFramelessButton
class
SelectorActionButton
:
public
QVLCFramelessButton
{
{
public:
protected:
SelectorActionButton
(
QWidget
*
parent
=
NULL
)
virtual
void
paintEvent
(
QPaintEvent
*
);
:
QVLCFramelessButton
(
parent
)
{}
private:
void
paintEvent
(
QPaintEvent
*
);
};
};
class
PLSelItem
:
public
QWidget
class
PLSelItem
:
public
QWidget
...
@@ -86,20 +79,27 @@ class PLSelItem : public QWidget
...
@@ -86,20 +79,27 @@ class PLSelItem : public QWidget
Q_OBJECT
Q_OBJECT
public:
public:
PLSelItem
(
QTreeWidgetItem
*
,
const
QString
&
);
PLSelItem
(
QTreeWidgetItem
*
,
const
QString
&
);
void
setText
(
const
QString
&
);
void
setText
(
const
QString
&
text
)
{
lbl
->
setText
(
text
);
}
const
QString
text
()
{
return
lbl
->
text
();
}
void
addAction
(
ItemAction
,
const
QString
&
toolTip
=
0
);
void
addAction
(
ItemAction
,
const
QString
&
toolTip
=
0
);
QTreeWidgetItem
*
treeItem
()
{
return
qitem
;
}
QTreeWidgetItem
*
treeItem
()
{
return
qitem
;
}
QString
text
()
{
return
lbl
->
text
();
}
public
slots
:
public
slots
:
void
showAction
();
void
showAction
()
{
if
(
lblAction
)
lblAction
->
show
();
}
void
hideAction
();
void
hideAction
()
{
if
(
lblAction
)
lblAction
->
hide
();
}
private
slots
:
private
slots
:
void
triggerAction
()
{
emit
action
(
this
);
}
void
triggerAction
()
{
emit
action
(
this
);
}
signals:
signals:
void
action
(
PLSelItem
*
);
void
action
(
PLSelItem
*
);
private:
private:
void
enterEvent
(
QEvent
*
);
inline
void
enterEvent
(
QEvent
*
){
showAction
();
}
void
leaveEvent
(
QEvent
*
);
inline
void
leaveEvent
(
QEvent
*
){
hideAction
();
}
QTreeWidgetItem
*
qitem
;
QTreeWidgetItem
*
qitem
;
QVLCFramelessButton
*
lblAction
;
QVLCFramelessButton
*
lblAction
;
QLabel
*
lbl
;
QLabel
*
lbl
;
...
@@ -116,20 +116,24 @@ public:
...
@@ -116,20 +116,24 @@ public:
virtual
~
PLSelector
();
virtual
~
PLSelector
();
protected:
protected:
friend
class
PlaylistWidget
;
friend
class
PlaylistWidget
;
private:
private:
QStringList
mimeTypes
()
const
;
bool
dropMimeData
(
QTreeWidgetItem
*
,
int
,
const
QMimeData
*
,
Qt
::
DropAction
);
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
void
createItems
();
void
createItems
();
void
drawBranches
(
QPainter
*
,
const
QRect
&
,
const
QModelIndex
&
)
const
;
PLSelItem
*
addItem
(
SelectorItemType
type
,
const
char
*
str
,
PLSelItem
*
addItem
(
bool
drop
=
false
,
QTreeWidgetItem
*
parentItem
=
0
);
SelectorItemType
type
,
const
char
*
str
,
bool
drop
,
QTreeWidgetItem
*
parentItem
=
0
);
PLSelItem
*
addPodcastItem
(
playlist_item_t
*
p_item
);
PLSelItem
*
addPodcastItem
(
playlist_item_t
*
p_item
);
inline
PLSelItem
*
itemWidget
(
QTreeWidgetItem
*
);
inline
PLSelItem
*
itemWidget
(
QTreeWidgetItem
*
);
intf_thread_t
*
p_intf
;
void
drawBranches
(
QPainter
*
,
const
QRect
&
,
const
QModelIndex
&
)
const
;
QTreeWidgetItem
*
podcastsParent
;
int
podcastsParentId
;
QStringList
mimeTypes
()
const
;
bool
dropMimeData
(
QTreeWidgetItem
*
,
int
,
const
QMimeData
*
,
Qt
::
DropAction
);
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
intf_thread_t
*
p_intf
;
QTreeWidgetItem
*
podcastsParent
;
int
podcastsParentId
;
private
slots
:
private
slots
:
void
setSource
(
QTreeWidgetItem
*
item
);
void
setSource
(
QTreeWidgetItem
*
item
);
void
plItemAdded
(
int
,
int
);
void
plItemAdded
(
int
,
int
);
...
...
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