Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
bc778682
Commit
bc778682
authored
Feb 11, 2010
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: add a list view
parent
01de7da1
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
284 additions
and
113 deletions
+284
-113
modules/gui/qt4/components/playlist/icon_view.cpp
modules/gui/qt4/components/playlist/icon_view.cpp
+169
-84
modules/gui/qt4/components/playlist/icon_view.hpp
modules/gui/qt4/components/playlist/icon_view.hpp
+30
-2
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
+7
-2
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/playlist_model.hpp
+2
-2
modules/gui/qt4/components/playlist/sorting.h
modules/gui/qt4/components/playlist/sorting.h
+1
-0
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
+63
-17
modules/gui/qt4/components/playlist/standardpanel.hpp
modules/gui/qt4/components/playlist/standardpanel.hpp
+12
-6
No files found.
modules/gui/qt4/components/playlist/icon_view.cpp
View file @
bc778682
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include "components/playlist/icon_view.hpp"
#include "components/playlist/icon_view.hpp"
#include "components/playlist/playlist_model.hpp"
#include "components/playlist/playlist_model.hpp"
#include "components/playlist/sorting.h"
#include "input_manager.hpp"
#include "input_manager.hpp"
#include <QApplication>
#include <QApplication>
...
@@ -41,141 +42,213 @@
...
@@ -41,141 +42,213 @@
#define ITEMS_SPACING 10
#define ITEMS_SPACING 10
#define ART_RADIUS 5
#define ART_RADIUS 5
QString
AbstractPlViewItemDelegate
::
getMeta
(
const
QModelIndex
&
index
,
int
meta
)
const
static
const
QRect
drawRect
=
QRect
(
0
,
0
,
RECT_SIZE_W
,
RECT_SIZE_H
);
static
const
QRect
artRect
=
drawRect
.
adjusted
(
OFFSET
-
1
,
2
,
-
OFFSET
,
-
OFFSET
*
2
);
void
PlListViewItemDelegate
::
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
{
PLItem
*
currentItem
=
static_cast
<
PLItem
*>
(
index
.
internalPointer
()
);
return
index
.
model
()
->
index
(
index
.
row
(),
assert
(
currentItem
);
PLModel
::
columnFromMeta
(
meta
),
index
.
parent
()
)
.
data
().
toString
();
}
char
*
meta
=
input_item_GetTitleFbName
(
currentItem
->
inputItem
()
);
void
AbstractPlViewItemDelegate
::
paintPlayingItemBg
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
)
const
QString
title
=
qfu
(
meta
);
{
free
(
meta
);
painter
->
save
();
painter
->
setOpacity
(
0.5
);
painter
->
setBrush
(
QBrush
(
Qt
::
gray
)
);
painter
->
fillRect
(
option
.
rect
,
option
.
palette
.
color
(
QPalette
::
Dark
)
);
painter
->
restore
();
}
meta
=
input_item_GetArtist
(
currentItem
->
inputItem
()
);
QPixmap
AbstractPlViewItemDelegate
::
getArtPixmap
(
const
QModelIndex
&
index
,
const
QSize
&
size
)
const
QString
artist
=
qfu
(
meta
);
{
free
(
meta
);
PLItem
*
item
=
static_cast
<
PLItem
*>
(
index
.
internalPointer
()
);
assert
(
item
);
/* Primary ArtUrl */
QString
artUrl
=
InputManager
::
decodeArtURL
(
item
->
inputItem
()
);
QString
artUrl
=
InputManager
::
decodeArtURL
(
currentItem
->
inputItem
()
);
/* else look up through all children and use the first picture found */
if
(
artUrl
.
isEmpty
()
)
if
(
artUrl
.
isEmpty
()
)
{
{
for
(
int
i
=
0
;
i
<
currentI
tem
->
childCount
();
i
++
)
for
(
int
i
=
0
;
i
<
i
tem
->
childCount
();
i
++
)
{
{
artUrl
=
InputManager
::
decodeArtURL
(
currentI
tem
->
child
(
i
)
->
inputItem
()
);
artUrl
=
InputManager
::
decodeArtURL
(
i
tem
->
child
(
i
)
->
inputItem
()
);
if
(
!
artUrl
.
isEmpty
()
)
if
(
!
artUrl
.
isEmpty
()
)
break
;
break
;
}
}
}
}
/*if( option.state & QStyle::State_Selected )
QPixmap
artPix
(
size
);
painter->fillRect(option.rect, option.palette.highlight());*/
QApplication
::
style
()
->
drawPrimitive
(
QStyle
::
PE_PanelItemViewItem
,
&
option
,
painter
);
/* Pixmap where all the rendering will happen and that will be cached */
QString
key
=
artUrl
+
QString
(
"%1%2"
).
arg
(
size
.
width
()).
arg
(
size
.
height
());
QPixmap
pix
;
QString
key
=
title
+
artist
+
artUrl
if
(
!
QPixmapCache
::
find
(
key
,
artPix
))
+
QString
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
);
if
(
QPixmapCache
::
find
(
key
,
pix
))
{
{
// cool, we found it in the cache
QPixmap
tmp
;
painter
->
drawPixmap
(
option
.
rect
,
pix
);
bool
cache
=
false
;
return
;
if
(
artUrl
.
isEmpty
()
||
!
tmp
.
load
(
artUrl
)
)
{
tmp
=
QPixmap
(
":/noart64"
).
scaled
(
size
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
);
}
else
{
tmp
=
tmp
.
scaled
(
size
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
);
cache
=
true
;
}
}
artPix
.
fill
(
Qt
::
black
);
QPainter
p
(
&
artPix
);
p
.
drawPixmap
(
(
size
.
width
()
-
tmp
.
width
())
/
2
,
(
size
.
height
()
-
tmp
.
height
())
/
2
,
tmp
);
if
(
cache
)
QPixmapCache
::
insert
(
key
,
artPix
);
}
return
artPix
;
}
void
PlIconViewItemDelegate
::
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
QString
title
=
getMeta
(
index
,
COLUMN_TITLE
);
QString
artist
=
getMeta
(
index
,
COLUMN_ARTIST
);
/* Background decorations */
QPixmap
artPix
=
getArtPixmap
(
index
,
QSize
(
ART_SIZE
,
ART_SIZE
)
);
pix
=
QPixmap
(
RECT_SIZE_W
,
RECT_SIZE_H
);
pix
.
fill
(
Qt
::
transparent
);
QPainter
*
pixpainter
=
new
QPainter
(
&
pix
);
QApplication
::
style
()
->
drawPrimitive
(
QStyle
::
PE_PanelItemViewItem
,
&
option
,
painter
);
pixpainter
->
setRenderHints
(
painter
->
save
();
QPainter
::
Antialiasing
|
QPainter
::
SmoothPixmapTransform
|
QPainter
::
TextAntialiasing
);
if
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
)
if
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
)
{
{
p
ixp
ainter
->
save
();
painter
->
save
();
p
ixp
ainter
->
setOpacity
(
0.2
);
painter
->
setOpacity
(
0.2
);
p
ixp
ainter
->
setBrush
(
QBrush
(
Qt
::
gray
)
);
painter
->
setBrush
(
QBrush
(
Qt
::
gray
)
);
p
ixpainter
->
drawRoundedRect
(
0
,
0
,
RECT_SIZE_W
,
RECT_SIZE_H
,
ART_RADIUS
,
ART_RADIUS
);
p
ainter
->
drawRoundedRect
(
option
.
rect
.
adjusted
(
0
,
0
,
-
1
,
-
1
)
,
ART_RADIUS
,
ART_RADIUS
);
p
ixp
ainter
->
restore
();
painter
->
restore
();
}
}
// Draw the drop shadow
QRect
artRect
=
option
.
rect
.
adjusted
(
OFFSET
-
1
,
2
,
-
OFFSET
,
-
OFFSET
*
2
);
pixpainter
->
save
();
pixpainter
->
setOpacity
(
0.7
);
pixpainter
->
setBrush
(
QBrush
(
Qt
::
gray
)
);
pixpainter
->
drawRoundedRect
(
artRect
.
adjusted
(
2
,
2
,
2
,
2
),
ART_RADIUS
,
ART_RADIUS
);
pixpainter
->
restore
();
//
load album art in the pixmap
//
Draw the drop shadow
QPixmap
artPix
;
painter
->
save
()
;
if
(
artUrl
.
isEmpty
()
||
!
artPix
.
load
(
artUrl
)
)
painter
->
setOpacity
(
0.7
);
artPix
=
QPixmap
(
":/noart64"
);
painter
->
setBrush
(
QBrush
(
Qt
::
darkGray
)
);
else
painter
->
setPen
(
Qt
::
NoPen
);
artPix
=
artPix
.
scaled
(
ART_SIZE
,
ART_SIZE
,
painter
->
drawRoundedRect
(
artRect
.
adjusted
(
0
,
0
,
2
,
2
),
ART_RADIUS
,
ART_RADIUS
);
Qt
::
KeepAspectRatioByExpanding
);
painter
->
restore
(
);
// Draw the art pixmap
// Draw the art pixmap
QPainterPath
artRectPath
;
QPainterPath
artRectPath
;
artRectPath
.
addRoundedRect
(
artRect
,
ART_RADIUS
,
ART_RADIUS
);
artRectPath
.
addRoundedRect
(
artRect
,
ART_RADIUS
,
ART_RADIUS
);
p
ixp
ainter
->
setClipPath
(
artRectPath
);
painter
->
setClipPath
(
artRectPath
);
p
ixp
ainter
->
drawPixmap
(
artRect
,
artPix
);
painter
->
drawPixmap
(
artRect
,
artPix
);
p
ixp
ainter
->
setClipping
(
false
);
painter
->
setClipping
(
false
);
/* */
if
(
option
.
state
&
QStyle
::
State_Selected
)
QColor
text
=
qApp
->
palette
().
text
().
color
(
);
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
HighlightedText
)
);
// Draw title
pixpainter
->
setPen
(
text
);
QFont
font
;
QFont
font
;
font
.
setPointSize
(
7
);
font
.
setPointSize
(
7
);
font
.
setItalic
(
true
);
font
.
setBold
(
index
.
data
(
Qt
::
FontRole
).
value
<
QFont
>
().
bold
()
);
font
.
setBold
(
index
.
data
(
Qt
::
FontRole
).
value
<
QFont
>
().
bold
()
);
pixpainter
->
setFont
(
font
);
QFontMetrics
fm
=
pixpainter
->
fontMetrics
();
// Draw title
QRect
textRect
=
drawRect
.
adjusted
(
1
,
ART_SIZE
+
4
,
0
,
-
1
);
font
.
setItalic
(
true
);
painter
->
setFont
(
font
);
QFontMetrics
fm
=
painter
->
fontMetrics
();
QRect
textRect
=
option
.
rect
.
adjusted
(
1
,
ART_SIZE
+
8
,
0
,
-
1
);
textRect
.
setHeight
(
fm
.
height
()
+
1
);
textRect
.
setHeight
(
fm
.
height
()
+
1
);
p
ixp
ainter
->
drawText
(
textRect
,
painter
->
drawText
(
textRect
,
fm
.
elidedText
(
title
,
Qt
::
ElideRight
,
textRect
.
width
()
),
fm
.
elidedText
(
title
,
Qt
::
ElideRight
,
textRect
.
width
()
),
QTextOption
(
Qt
::
AlignCenter
)
);
QTextOption
(
Qt
::
AlignCenter
)
);
// Draw artist
// Draw artist
p
ixpainter
->
setPen
(
text
.
lighter
(
22
0
)
);
p
ainter
->
setPen
(
painter
->
pen
().
color
().
lighter
(
15
0
)
);
font
.
setItalic
(
false
);
font
.
setItalic
(
false
);
p
ixp
ainter
->
setFont
(
font
);
painter
->
setFont
(
font
);
fm
=
p
ixp
ainter
->
fontMetrics
();
fm
=
painter
->
fontMetrics
();
textRect
=
textRect
.
adjusted
(
0
,
textRect
.
height
(),
textRect
=
textRect
.
adjusted
(
0
,
textRect
.
height
(),
0
,
textRect
.
height
()
);
0
,
textRect
.
height
()
);
p
ixp
ainter
->
drawText
(
textRect
,
painter
->
drawText
(
textRect
,
fm
.
elidedText
(
artist
,
Qt
::
ElideRight
,
textRect
.
width
()
),
fm
.
elidedText
(
artist
,
Qt
::
ElideRight
,
textRect
.
width
()
),
QTextOption
(
Qt
::
AlignCenter
)
);
QTextOption
(
Qt
::
AlignCenter
)
);
delete
pixpainter
;
// Ensure all paint operations have finished
painter
->
restore
();
}
// Here real drawing happens
QSize
PlIconViewItemDelegate
::
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
painter
->
drawPixmap
(
option
.
rect
,
pix
);
{
return
QSize
(
RECT_SIZE_W
,
RECT_SIZE_H
);
}
// Cache the rendering
#define LISTVIEW_ART_SIZE 45
QPixmapCache
::
insert
(
key
,
pix
);
void
PlListViewItemDelegate
::
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
QModelIndex
parent
=
index
.
parent
();
QModelIndex
i
;
QString
title
=
getMeta
(
index
,
COLUMN_TITLE
);
QString
duration
=
getMeta
(
index
,
COLUMN_DURATION
);
if
(
!
duration
.
isEmpty
()
)
title
+=
QString
(
" [%1]"
).
arg
(
duration
);
QString
artist
=
getMeta
(
index
,
COLUMN_ARTIST
);
QString
album
=
getMeta
(
index
,
COLUMN_ALBUM
);
QString
trackNum
=
getMeta
(
index
,
COLUMN_TRACK_NUMBER
);
QString
artistAlbum
=
artist
+
(
artist
.
isEmpty
()
?
QString
()
:
QString
(
": "
)
)
+
album
+
(
album
.
isEmpty
()
||
trackNum
.
isEmpty
()
?
QString
()
:
QString
(
" [#%1]"
).
arg
(
trackNum
)
);
QPixmap
artPix
=
getArtPixmap
(
index
,
QSize
(
LISTVIEW_ART_SIZE
,
LISTVIEW_ART_SIZE
)
);
QApplication
::
style
()
->
drawPrimitive
(
QStyle
::
PE_PanelItemViewItem
,
&
option
,
painter
);
if
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
)
paintPlayingItemBg
(
painter
,
option
);
painter
->
drawPixmap
(
option
.
rect
.
topLeft
()
+
QPoint
(
3
,
3
),
artPix
);
int
textH
=
option
.
fontMetrics
.
height
()
+
2
;
int
margin
=
(
option
.
rect
.
height
()
/
2
)
-
textH
;
QRect
textRect
=
option
.
rect
.
adjusted
(
LISTVIEW_ART_SIZE
+
10
,
margin
,
-
10
,
margin
*
-
1
-
(
artistAlbum
.
isEmpty
()
?
0
:
textH
)
);
painter
->
save
();
if
(
option
.
state
&
QStyle
::
State_Selected
)
painter
->
setPen
(
option
.
palette
.
color
(
QPalette
::
HighlightedText
)
);
QTextOption
textOpt
(
Qt
::
AlignVCenter
|
Qt
::
AlignLeft
);
textOpt
.
setWrapMode
(
QTextOption
::
NoWrap
);
QFont
f
(
option
.
font
);
if
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
)
f
.
setBold
(
true
);
f
.
setItalic
(
true
);
painter
->
setFont
(
f
);
painter
->
drawText
(
textRect
,
title
,
textOpt
);
f
.
setItalic
(
false
);
painter
->
setFont
(
f
);
textRect
.
moveTop
(
textRect
.
top
()
+
textH
);
painter
->
drawText
(
textRect
,
artistAlbum
,
textOpt
);
painter
->
restore
();
}
}
QSize
PlListViewItemDelegate
::
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
QSize
PlListViewItemDelegate
::
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
{
return
QSize
(
RECT_SIZE_W
,
RECT_SIZE_H
);
return
QSize
(
LISTVIEW_ART_SIZE
+
6
,
LISTVIEW_ART_SIZE
+
6
);
}
}
PlIconView
::
PlIconView
(
PLModel
*
model
,
QWidget
*
parent
)
:
QListView
(
parent
)
PlIconView
::
PlIconView
(
PLModel
*
model
,
QWidget
*
parent
)
:
QListView
(
parent
)
{
{
setModel
(
model
);
setModel
(
model
);
...
@@ -183,12 +256,24 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
...
@@ -183,12 +256,24 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
setMovement
(
QListView
::
Static
);
setMovement
(
QListView
::
Static
);
setResizeMode
(
QListView
::
Adjust
);
setResizeMode
(
QListView
::
Adjust
);
setGridSize
(
QSize
(
RECT_SIZE_W
,
RECT_SIZE_H
)
);
setGridSize
(
QSize
(
RECT_SIZE_W
,
RECT_SIZE_H
)
);
setUniformItemSizes
(
true
);
setWrapping
(
true
);
setWrapping
(
true
);
setUniformItemSizes
(
true
);
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
setAcceptDrops
(
true
);
setAcceptDrops
(
true
);
Pl
ListViewItemDelegate
*
pl
=
new
PlList
ViewItemDelegate
(
this
);
Pl
IconViewItemDelegate
*
delegate
=
new
PlIcon
ViewItemDelegate
(
this
);
setItemDelegate
(
pl
);
setItemDelegate
(
delegate
);
}
}
PlListView
::
PlListView
(
PLModel
*
model
,
QWidget
*
parent
)
:
QListView
(
parent
)
{
setModel
(
model
);
setViewMode
(
QListView
::
ListMode
);
setUniformItemSizes
(
true
);
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
setAcceptDrops
(
true
);
setAlternatingRowColors
(
true
);
PlListViewItemDelegate
*
delegate
=
new
PlListViewItemDelegate
(
this
);
setItemDelegate
(
delegate
);
}
modules/gui/qt4/components/playlist/icon_view.hpp
View file @
bc778682
...
@@ -30,12 +30,32 @@
...
@@ -30,12 +30,32 @@
class
QPainter
;
class
QPainter
;
class
PLModel
;
class
PLModel
;
class
PlListViewItemDelegate
:
public
QStyledItemDelegate
class
AbstractPlViewItemDelegate
:
public
QStyledItemDelegate
{
public:
AbstractPlViewItemDelegate
(
QWidget
*
parent
=
0
)
:
QStyledItemDelegate
(
parent
)
{}
QString
getMeta
(
const
QModelIndex
&
index
,
int
meta
)
const
;
void
paintPlayingItemBg
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
)
const
;
QPixmap
getArtPixmap
(
const
QModelIndex
&
index
,
const
QSize
&
size
)
const
;
};
class
PlIconViewItemDelegate
:
public
AbstractPlViewItemDelegate
{
{
Q_OBJECT
Q_OBJECT
public:
public:
PlListViewItemDelegate
(
QWidget
*
parent
=
0
)
:
QStyledItemDelegate
(
parent
)
{}
PlIconViewItemDelegate
(
QWidget
*
parent
=
0
)
:
AbstractPlViewItemDelegate
(
parent
)
{}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
QSize
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
};
class
PlListViewItemDelegate
:
public
AbstractPlViewItemDelegate
{
Q_OBJECT
public:
PlListViewItemDelegate
(
QWidget
*
parent
=
0
)
:
AbstractPlViewItemDelegate
(
parent
)
{}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
QSize
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
QSize
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
...
@@ -49,5 +69,13 @@ public:
...
@@ -49,5 +69,13 @@ public:
PlIconView
(
PLModel
*
model
,
QWidget
*
parent
=
0
);
PlIconView
(
PLModel
*
model
,
QWidget
*
parent
=
0
);
};
};
class
PlListView
:
public
QListView
{
Q_OBJECT
public:
PlListView
(
PLModel
*
model
,
QWidget
*
parent
=
0
);
};
#endif
#endif
modules/gui/qt4/components/playlist/playlist_model.cpp
View file @
bc778682
...
@@ -339,7 +339,12 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
...
@@ -339,7 +339,12 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
QFont
f
;
f
.
setBold
(
true
);
return
QVariant
(
f
);
QFont
f
;
f
.
setBold
(
true
);
return
QVariant
(
f
);
}
}
}
}
else
if
(
role
==
Qt
::
BackgroundRole
&&
isCurrent
(
index
)
)
{
return
QVariant
(
QBrush
(
Qt
::
gray
)
);
}
else
if
(
role
==
IsCurrentRole
)
return
QVariant
(
isCurrent
(
index
)
);
else
if
(
role
==
IsCurrentRole
)
return
QVariant
(
isCurrent
(
index
)
);
return
QVariant
();
return
QVariant
();
}
}
...
@@ -532,7 +537,7 @@ PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_input )
...
@@ -532,7 +537,7 @@ PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_input )
#undef CACHE
#undef CACHE
#undef ICACHE
#undef ICACHE
int
PLModel
::
columnToMeta
(
int
_column
)
const
int
PLModel
::
columnToMeta
(
int
_column
)
{
{
int
meta
=
1
;
int
meta
=
1
;
int
column
=
0
;
int
column
=
0
;
...
@@ -546,7 +551,7 @@ int PLModel::columnToMeta( int _column ) const
...
@@ -546,7 +551,7 @@ int PLModel::columnToMeta( int _column ) const
return
meta
;
return
meta
;
}
}
int
PLModel
::
columnFromMeta
(
int
meta_col
)
const
int
PLModel
::
columnFromMeta
(
int
meta_col
)
{
{
int
meta
=
1
;
int
meta
=
1
;
int
column
=
0
;
int
column
=
0
;
...
...
modules/gui/qt4/components/playlist/playlist_model.hpp
View file @
bc778682
...
@@ -90,6 +90,8 @@ public:
...
@@ -90,6 +90,8 @@ public:
QModelIndex
currentIndex
();
QModelIndex
currentIndex
();
bool
isCurrent
(
const
QModelIndex
&
index
)
const
;
bool
isCurrent
(
const
QModelIndex
&
index
)
const
;
int
itemId
(
const
QModelIndex
&
index
)
const
;
int
itemId
(
const
QModelIndex
&
index
)
const
;
static
int
columnFromMeta
(
int
meta_column
);
static
int
columnToMeta
(
int
column
);
/* Actions */
/* Actions */
void
popup
(
const
QModelIndex
&
index
,
const
QPoint
&
point
,
const
QModelIndexList
&
list
);
void
popup
(
const
QModelIndex
&
index
,
const
QPoint
&
point
,
const
QModelIndexList
&
list
);
...
@@ -147,8 +149,6 @@ private:
...
@@ -147,8 +149,6 @@ private:
PLItem
*
findById
(
PLItem
*
,
int
);
PLItem
*
findById
(
PLItem
*
,
int
);
PLItem
*
findByInput
(
PLItem
*
,
int
);
PLItem
*
findByInput
(
PLItem
*
,
int
);
PLItem
*
findInner
(
PLItem
*
,
int
,
bool
);
PLItem
*
findInner
(
PLItem
*
,
int
,
bool
);
int
columnFromMeta
(
int
meta_column
)
const
;
int
columnToMeta
(
int
column
)
const
;
bool
canEdit
()
const
;
bool
canEdit
()
const
;
PLItem
*
p_cached_item
;
PLItem
*
p_cached_item
;
...
...
modules/gui/qt4/components/playlist/sorting.h
View file @
bc778682
...
@@ -73,6 +73,7 @@ static inline char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
...
@@ -73,6 +73,7 @@ static inline char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
return
input_item_GetTitleFbName
(
p_item
);
return
input_item_GetTitleFbName
(
p_item
);
case
COLUMN_DURATION
:
case
COLUMN_DURATION
:
i_duration
=
input_item_GetDuration
(
p_item
)
/
1000000
;
i_duration
=
input_item_GetDuration
(
p_item
)
/
1000000
;
if
(
i_duration
==
0
)
return
NULL
;
secstotimestr
(
psz_duration
,
i_duration
);
secstotimestr
(
psz_duration
,
i_duration
);
return
strdup
(
psz_duration
);
return
strdup
(
psz_duration
);
case
COLUMN_ARTIST
:
case
COLUMN_ARTIST
:
...
...
modules/gui/qt4/components/playlist/standardpanel.cpp
View file @
bc778682
...
@@ -52,6 +52,10 @@
...
@@ -52,6 +52,10 @@
#include "sorting.h"
#include "sorting.h"
static
const
QString
viewNames
[]
=
{
qtr
(
"Detailed View"
),
qtr
(
"Icon View"
),
qtr
(
"List View"
)
};
StandardPLPanel
::
StandardPLPanel
(
PlaylistWidget
*
_parent
,
StandardPLPanel
::
StandardPLPanel
(
PlaylistWidget
*
_parent
,
intf_thread_t
*
_p_intf
,
intf_thread_t
*
_p_intf
,
playlist_t
*
p_playlist
,
playlist_t
*
p_playlist
,
...
@@ -64,6 +68,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
...
@@ -64,6 +68,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
iconView
=
NULL
;
iconView
=
NULL
;
treeView
=
NULL
;
treeView
=
NULL
;
listView
=
NULL
;
model
=
new
PLModel
(
p_playlist
,
p_intf
,
p_root
,
this
);
model
=
new
PLModel
(
p_playlist
,
p_intf
,
p_root
,
this
);
currentRootId
=
-
1
;
currentRootId
=
-
1
;
...
@@ -101,15 +106,13 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
...
@@ -101,15 +106,13 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
QActionGroup
*
actionGroup
=
new
QActionGroup
(
this
);
QActionGroup
*
actionGroup
=
new
QActionGroup
(
this
);
treeViewAction
=
actionGroup
->
addAction
(
"Detailed view"
);
for
(
int
i
=
0
;
i
<
VIEW_COUNT
;
i
++
)
treeViewAction
->
setCheckable
(
true
);
{
viewSelectionMapper
->
setMapping
(
treeViewAction
,
TREE_VIEW
);
viewActions
[
i
]
=
actionGroup
->
addAction
(
viewNames
[
i
]
);
CONNECT
(
treeViewAction
,
triggered
(),
viewSelectionMapper
,
map
()
);
viewActions
[
i
]
->
setCheckable
(
true
);
viewSelectionMapper
->
setMapping
(
viewActions
[
i
],
i
);
iconViewAction
=
actionGroup
->
addAction
(
"Icon view"
);
CONNECT
(
viewActions
[
i
],
triggered
(),
viewSelectionMapper
,
map
()
);
iconViewAction
->
setCheckable
(
true
);
}
viewSelectionMapper
->
setMapping
(
iconViewAction
,
ICON_VIEW
);
CONNECT
(
iconViewAction
,
triggered
(),
viewSelectionMapper
,
map
()
);
BUTTONACT
(
viewButton
,
cycleViews
()
);
BUTTONACT
(
viewButton
,
cycleViews
()
);
QMenu
*
viewMenu
=
new
QMenu
(
this
);
QMenu
*
viewMenu
=
new
QMenu
(
this
);
...
@@ -138,7 +141,12 @@ StandardPLPanel::~StandardPLPanel()
...
@@ -138,7 +141,12 @@ StandardPLPanel::~StandardPLPanel()
getSettings
()
->
beginGroup
(
"Playlist"
);
getSettings
()
->
beginGroup
(
"Playlist"
);
if
(
treeView
)
if
(
treeView
)
getSettings
()
->
setValue
(
"headerStateV2"
,
treeView
->
header
()
->
saveState
()
);
getSettings
()
->
setValue
(
"headerStateV2"
,
treeView
->
header
()
->
saveState
()
);
getSettings
()
->
setValue
(
"view-mode"
,
(
currentView
==
iconView
)
?
ICON_VIEW
:
TREE_VIEW
);
if
(
currentView
==
treeView
)
getSettings
()
->
setValue
(
"view-mode"
,
TREE_VIEW
);
else
if
(
currentView
==
listView
)
getSettings
()
->
setValue
(
"view-mode"
,
LIST_VIEW
);
else
if
(
currentView
==
iconView
)
getSettings
()
->
setValue
(
"view-mode"
,
ICON_VIEW
);
getSettings
()
->
endGroup
();
getSettings
()
->
endGroup
();
}
}
...
@@ -287,6 +295,21 @@ void StandardPLPanel::createIconView()
...
@@ -287,6 +295,21 @@ void StandardPLPanel::createIconView()
layout
->
addWidget
(
iconView
,
1
,
0
,
1
,
-
1
);
layout
->
addWidget
(
iconView
,
1
,
0
,
1
,
-
1
);
}
}
void
StandardPLPanel
::
createListView
()
{
listView
=
new
PlListView
(
model
,
this
);
listView
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
CONNECT
(
listView
,
customContextMenuRequested
(
const
QPoint
&
),
this
,
popupPlView
(
const
QPoint
&
)
);
CONNECT
(
listView
,
activated
(
const
QModelIndex
&
),
this
,
activate
(
const
QModelIndex
&
)
);
CONNECT
(
locationBar
,
invoked
(
const
QModelIndex
&
),
listView
,
setRootIndex
(
const
QModelIndex
&
)
);
layout
->
addWidget
(
listView
,
1
,
0
,
1
,
-
1
);
}
void
StandardPLPanel
::
createTreeView
()
void
StandardPLPanel
::
createTreeView
()
{
{
/* Create and configure the QTreeView */
/* Create and configure the QTreeView */
...
@@ -354,9 +377,10 @@ void StandardPLPanel::showView( int i_view )
...
@@ -354,9 +377,10 @@ void StandardPLPanel::showView( int i_view )
createTreeView
();
createTreeView
();
locationBar
->
setIndex
(
treeView
->
rootIndex
()
);
locationBar
->
setIndex
(
treeView
->
rootIndex
()
);
if
(
iconView
)
iconView
->
hide
();
if
(
iconView
)
iconView
->
hide
();
if
(
listView
)
listView
->
hide
();
treeView
->
show
();
treeView
->
show
();
currentView
=
treeView
;
currentView
=
treeView
;
treeViewAction
->
setChecked
(
true
);
viewActions
[
i_view
]
->
setChecked
(
true
);
break
;
break
;
}
}
case
ICON_VIEW
:
case
ICON_VIEW
:
...
@@ -364,11 +388,31 @@ void StandardPLPanel::showView( int i_view )
...
@@ -364,11 +388,31 @@ void StandardPLPanel::showView( int i_view )
if
(
iconView
==
NULL
)
if
(
iconView
==
NULL
)
createIconView
();
createIconView
();
locationBar
->
setIndex
(
iconView
->
rootIndex
()
);
if
(
treeView
)
treeView
->
hide
();
if
(
treeView
)
treeView
->
hide
();
if
(
listView
)
{
listView
->
hide
();
iconView
->
setRootIndex
(
listView
->
rootIndex
()
);
}
locationBar
->
setIndex
(
iconView
->
rootIndex
()
);
iconView
->
show
();
iconView
->
show
();
currentView
=
iconView
;
currentView
=
iconView
;
iconViewAction
->
setChecked
(
true
);
viewActions
[
i_view
]
->
setChecked
(
true
);
break
;
}
case
LIST_VIEW
:
{
if
(
listView
==
NULL
)
createListView
();
if
(
treeView
)
treeView
->
hide
();
if
(
iconView
)
{
iconView
->
hide
();
listView
->
setRootIndex
(
iconView
->
rootIndex
()
);
}
locationBar
->
setIndex
(
listView
->
rootIndex
()
);
listView
->
show
();
currentView
=
listView
;
viewActions
[
i_view
]
->
setChecked
(
true
);
break
;
break
;
}
}
default:
;
default:
;
...
@@ -380,6 +424,8 @@ void StandardPLPanel::cycleViews()
...
@@ -380,6 +424,8 @@ void StandardPLPanel::cycleViews()
if
(
currentView
==
iconView
)
if
(
currentView
==
iconView
)
showView
(
TREE_VIEW
);
showView
(
TREE_VIEW
);
else
if
(
currentView
==
treeView
)
else
if
(
currentView
==
treeView
)
showView
(
LIST_VIEW
);
else
if
(
currentView
==
listView
)
showView
(
ICON_VIEW
);
showView
(
ICON_VIEW
);
else
else
assert
(
0
);
assert
(
0
);
...
@@ -395,8 +441,8 @@ void StandardPLPanel::activate( const QModelIndex &index )
...
@@ -395,8 +441,8 @@ void StandardPLPanel::activate( const QModelIndex &index )
{
{
if
(
model
->
hasChildren
(
index
)
)
if
(
model
->
hasChildren
(
index
)
)
{
{
if
(
currentView
==
iconView
)
{
if
(
currentView
==
iconView
||
currentView
==
listView
)
{
icon
View
->
setRootIndex
(
index
);
current
View
->
setRootIndex
(
index
);
locationBar
->
setIndex
(
index
);
locationBar
->
setIndex
(
index
);
}
}
}
}
...
@@ -429,8 +475,8 @@ void StandardPLPanel::browseInto( input_item_t *p_input )
...
@@ -429,8 +475,8 @@ void StandardPLPanel::browseInto( input_item_t *p_input )
playlist_Unlock
(
THEPL
);
playlist_Unlock
(
THEPL
);
if
(
currentView
==
iconView
)
{
if
(
currentView
==
iconView
||
currentView
==
listView
)
{
icon
View
->
setRootIndex
(
index
);
current
View
->
setRootIndex
(
index
);
locationBar
->
setIndex
(
index
);
locationBar
->
setIndex
(
index
);
}
}
else
else
...
...
modules/gui/qt4/components/playlist/standardpanel.hpp
View file @
bc778682
...
@@ -46,6 +46,7 @@ class QPushButton;
...
@@ -46,6 +46,7 @@ class QPushButton;
class
QKeyEvent
;
class
QKeyEvent
;
class
QWheelEvent
;
class
QWheelEvent
;
class
PlIconView
;
class
PlIconView
;
class
PlListView
;
class
LocationBar
;
class
LocationBar
;
class
StandardPLPanel
:
public
QWidget
class
StandardPLPanel
:
public
QWidget
...
@@ -64,6 +65,14 @@ protected:
...
@@ -64,6 +65,14 @@ protected:
PLModel
*
model
;
PLModel
*
model
;
private:
private:
enum
{
TREE_VIEW
=
0
,
ICON_VIEW
,
LIST_VIEW
,
VIEW_COUNT
};
intf_thread_t
*
p_intf
;
intf_thread_t
*
p_intf
;
QWidget
*
parent
;
QWidget
*
parent
;
...
@@ -74,8 +83,10 @@ private:
...
@@ -74,8 +83,10 @@ private:
QTreeView
*
treeView
;
QTreeView
*
treeView
;
PlIconView
*
iconView
;
PlIconView
*
iconView
;
PlListView
*
listView
;
QAbstractItemView
*
currentView
;
QAbstractItemView
*
currentView
;
QAction
*
viewActions
[
VIEW_COUNT
];
QAction
*
iconViewAction
,
*
treeViewAction
;
QAction
*
iconViewAction
,
*
treeViewAction
;
int
currentRootId
;
int
currentRootId
;
QSignalMapper
*
selectColumnsSigMapper
;
QSignalMapper
*
selectColumnsSigMapper
;
...
@@ -83,14 +94,9 @@ private:
...
@@ -83,14 +94,9 @@ private:
int
last_activated_id
;
int
last_activated_id
;
enum
{
TREE_VIEW
=
0
,
ICON_VIEW
,
COVER_VIEW
,
};
void
createTreeView
();
void
createTreeView
();
void
createIconView
();
void
createIconView
();
void
createListView
();
public
slots
:
public
slots
:
virtual
void
setRoot
(
playlist_item_t
*
);
virtual
void
setRoot
(
playlist_item_t
*
);
...
...
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