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
03d9be91
Commit
03d9be91
authored
Sep 08, 2009
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qt4: implement drag&drop in playlist selector
parent
c7853345
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
5 deletions
+52
-5
modules/gui/qt4/components/playlist/playlist_item.hpp
modules/gui/qt4/components/playlist/playlist_item.hpp
+1
-0
modules/gui/qt4/components/playlist/selector.cpp
modules/gui/qt4/components/playlist/selector.cpp
+48
-4
modules/gui/qt4/components/playlist/selector.hpp
modules/gui/qt4/components/playlist/selector.hpp
+3
-1
No files found.
modules/gui/qt4/components/playlist/playlist_item.hpp
View file @
03d9be91
...
...
@@ -54,6 +54,7 @@ public:
int
childCount
()
const
{
return
children
.
count
();
};
PLItem
*
parent
()
{
return
parentItem
;
};
input_item_t
*
inputItem
()
{
return
p_input
;
}
protected:
QList
<
PLItem
*>
children
;
...
...
modules/gui/qt4/components/playlist/selector.cpp
View file @
03d9be91
...
...
@@ -29,11 +29,12 @@
#include <assert.h>
#include "components/playlist/selector.hpp"
#include "playlist_item.hpp"
#include "qt4.hpp"
#include <QVBoxLayout>
#include <QHeaderView>
#include <Q
TreeWidget
>
#include <Q
MimeData
>
#include <vlc_playlist.h>
#include <vlc_services_discovery.h>
...
...
@@ -48,8 +49,9 @@ PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf )
setRootIsDecorated
(
false
);
// model = new PLModel( THEPL, p_intf, THEPL->p_root_category, 1, this );
// view->setModel( model );
// view->setAcceptDrops(true);
// view->setDropIndicatorShown(true);
viewport
()
->
setAcceptDrops
(
true
);
setDropIndicatorShown
(
true
);
invisibleRootItem
()
->
setFlags
(
invisibleRootItem
()
->
flags
()
&
~
Qt
::
ItemIsDropEnabled
);
createItems
();
CONNECT
(
this
,
itemActivated
(
QTreeWidgetItem
*
,
int
),
...
...
@@ -102,7 +104,6 @@ void PLSelector::createItems()
pl
->
setText
(
0
,
qtr
(
"Playlist"
)
);
pl
->
setData
(
0
,
TYPE_ROLE
,
PL_TYPE
);
pl
->
setData
(
0
,
PPL_ITEM_ROLE
,
QVariant
::
fromValue
(
THEPL
->
p_local_category
)
);
/* QTreeWidgetItem *empty = new QTreeWidgetItem( view );
empty->setFlags(Qt::NoItemFlags); */
...
...
@@ -117,6 +118,7 @@ void PLSelector::createItems()
QTreeWidgetItem
*
sds
=
new
QTreeWidgetItem
(
this
);
sds
->
setExpanded
(
true
);
sds
->
setText
(
0
,
qtr
(
"Libraries"
)
);
sds
->
setFlags
(
sds
->
flags
()
&
~
Qt
::
ItemIsDropEnabled
);
char
**
ppsz_longnames
;
char
**
ppsz_names
=
vlc_sd_GetNames
(
&
ppsz_longnames
);
...
...
@@ -130,10 +132,52 @@ void PLSelector::createItems()
sd_item
=
new
QTreeWidgetItem
(
QStringList
(
*
ppsz_longname
)
);
sd_item
->
setData
(
0
,
TYPE_ROLE
,
SD_TYPE
);
sd_item
->
setData
(
0
,
NAME_ROLE
,
qfu
(
*
ppsz_name
)
);
sd_item
->
setFlags
(
sd_item
->
flags
()
&
~
Qt
::
ItemIsDropEnabled
);
sds
->
addChild
(
sd_item
);
}
}
#include <iostream>
QStringList
PLSelector
::
mimeTypes
()
const
{
QStringList
types
;
types
<<
"vlc/qt-playlist-item"
;
return
types
;
}
bool
PLSelector
::
dropMimeData
(
QTreeWidgetItem
*
parent
,
int
index
,
const
QMimeData
*
data
,
Qt
::
DropAction
action
)
{
if
(
!
parent
)
return
false
;
QVariant
type
=
parent
->
data
(
0
,
TYPE_ROLE
);
if
(
type
==
QVariant
()
)
return
false
;
int
i_type
=
type
.
toInt
();
if
(
i_type
!=
PL_TYPE
&&
i_type
!=
ML_TYPE
)
return
false
;
bool
to_pl
=
i_type
==
PL_TYPE
;
if
(
data
->
hasFormat
(
"vlc/qt-playlist-item"
)
)
{
QByteArray
encodedData
=
data
->
data
(
"vlc/qt-playlist-item"
);
QDataStream
stream
(
&
encodedData
,
QIODevice
::
ReadOnly
);
playlist_Lock
(
THEPL
);
while
(
!
stream
.
atEnd
()
)
{
PLItem
*
item
;
stream
.
readRawData
(
(
char
*
)
&
item
,
sizeof
(
PLItem
*
)
);
input_item_t
*
pl_input
=
item
->
inputItem
();
playlist_AddExt
(
THEPL
,
pl_input
->
psz_uri
,
pl_input
->
psz_name
,
PLAYLIST_APPEND
|
PLAYLIST_SPREPARSE
,
PLAYLIST_END
,
pl_input
->
i_duration
,
pl_input
->
i_options
,
pl_input
->
ppsz_options
,
pl_input
->
optflagc
,
to_pl
,
true
);
}
playlist_Unlock
(
THEPL
);
}
return
true
;
}
PLSelector
::~
PLSelector
()
{
}
modules/gui/qt4/components/playlist/selector.hpp
View file @
03d9be91
...
...
@@ -60,8 +60,10 @@ public:
protected:
friend
class
PlaylistWidget
;
private:
intf_thread_t
*
p_intf
;
QStringList
mimeTypes
()
const
;
bool
dropMimeData
(
QTreeWidgetItem
*
parent
,
int
index
,
const
QMimeData
*
data
,
Qt
::
DropAction
action
);
void
createItems
();
intf_thread_t
*
p_intf
;
private
slots
:
void
setSource
(
QTreeWidgetItem
*
item
);
signals:
...
...
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