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
f80154be
Commit
f80154be
authored
Oct 29, 2010
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt, playlist: Move getMeta helper functions to PLModel
parent
56a27db4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
65 deletions
+66
-65
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
+54
-1
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/playlist_model.hpp
+3
-0
modules/gui/qt4/components/playlist/views.cpp
modules/gui/qt4/components/playlist/views.cpp
+9
-62
modules/gui/qt4/components/playlist/views.hpp
modules/gui/qt4/components/playlist/views.hpp
+0
-2
No files found.
modules/gui/qt4/components/playlist/playlist_model.cpp
View file @
f80154be
...
...
@@ -48,7 +48,7 @@
#include <QDesktopServices>
#include <QInputDialog>
#include <QSignalMapper>
#include <QPixmapCache>
#define I_NEW_DIR \
I_DIR_OR_FOLDER( N_("Create Directory"), N_( "Create Folder" ) )
...
...
@@ -597,6 +597,59 @@ bool PLModel::canEdit() const
)
);
}
QString
PLModel
::
getMeta
(
const
QModelIndex
&
index
,
int
meta
)
{
return
index
.
model
()
->
index
(
index
.
row
(),
PLModel
::
columnFromMeta
(
meta
),
index
.
parent
()
)
.
data
().
toString
();
}
QPixmap
PLModel
::
getArtPixmap
(
const
QModelIndex
&
index
,
const
QSize
&
size
)
{
PLItem
*
item
=
static_cast
<
PLItem
*>
(
index
.
internalPointer
()
);
assert
(
item
);
QString
artUrl
=
InputManager
::
decodeArtURL
(
item
->
inputItem
()
);
/* If empty, take one of the children art URL */
if
(
artUrl
.
isEmpty
()
)
{
for
(
int
i
=
0
;
i
<
item
->
childCount
();
i
++
)
{
artUrl
=
InputManager
::
decodeArtURL
(
item
->
child
(
i
)
->
inputItem
()
);
if
(
!
artUrl
.
isEmpty
()
)
break
;
}
}
QPixmap
artPix
;
QString
key
=
artUrl
+
QString
(
"%1%2"
).
arg
(
size
.
width
()).
arg
(
size
.
height
());
/* Lookup in the QPixmapCache */
if
(
!
QPixmapCache
::
find
(
key
,
artPix
))
{
if
(
artUrl
.
isEmpty
()
||
!
artPix
.
load
(
artUrl
)
)
{
key
=
QString
(
"noart%1%2"
).
arg
(
size
.
width
()).
arg
(
size
.
height
());
if
(
!
QPixmapCache
::
find
(
key
,
artPix
)
)
{
artPix
=
QPixmap
(
":/noart"
).
scaled
(
size
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
);
QPixmapCache
::
insert
(
key
,
artPix
);
}
}
else
{
artPix
=
artPix
.
scaled
(
size
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
);
QPixmapCache
::
insert
(
key
,
artPix
);
}
}
return
artPix
;
}
/************************* Updates handling *****************************/
/**** Events processing ****/
...
...
modules/gui/qt4/components/playlist/playlist_model.hpp
View file @
f80154be
...
...
@@ -93,6 +93,9 @@ public:
static
int
columnFromMeta
(
int
meta_column
);
static
int
columnToMeta
(
int
column
);
static
QString
getMeta
(
const
QModelIndex
&
index
,
int
meta
);
static
QPixmap
getArtPixmap
(
const
QModelIndex
&
index
,
const
QSize
&
size
);
/* Actions */
bool
popup
(
const
QModelIndex
&
index
,
const
QPoint
&
point
,
const
QModelIndexList
&
list
);
void
doDelete
(
QModelIndexList
selected
);
...
...
modules/gui/qt4/components/playlist/views.cpp
View file @
f80154be
...
...
@@ -31,7 +31,6 @@
#include <QRect>
#include <QStyleOptionViewItem>
#include <QFontMetrics>
#include <QPixmapCache>
#include <QDrag>
#include <QDragMoveEvent>
...
...
@@ -42,14 +41,6 @@
#define ART_RADIUS 5
#define SPACER 5
QString
AbstractPlViewItemDelegate
::
getMeta
(
const
QModelIndex
&
index
,
int
meta
)
const
{
return
index
.
model
()
->
index
(
index
.
row
(),
PLModel
::
columnFromMeta
(
meta
),
index
.
parent
()
)
.
data
().
toString
();
}
void
AbstractPlViewItemDelegate
::
paintBackground
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
...
...
@@ -82,54 +73,10 @@ void AbstractPlViewItemDelegate::paintBackground(
painter
->
restore
();
}
QPixmap
AbstractPlViewItemDelegate
::
getArtPixmap
(
const
QModelIndex
&
index
,
const
QSize
&
size
)
const
{
PLItem
*
item
=
static_cast
<
PLItem
*>
(
index
.
internalPointer
()
);
assert
(
item
);
QString
artUrl
=
InputManager
::
decodeArtURL
(
item
->
inputItem
()
);
if
(
artUrl
.
isEmpty
()
)
{
for
(
int
i
=
0
;
i
<
item
->
childCount
();
i
++
)
{
artUrl
=
InputManager
::
decodeArtURL
(
item
->
child
(
i
)
->
inputItem
()
);
if
(
!
artUrl
.
isEmpty
()
)
break
;
}
}
QPixmap
artPix
;
QString
key
=
artUrl
+
QString
(
"%1%2"
).
arg
(
size
.
width
()).
arg
(
size
.
height
());
if
(
!
QPixmapCache
::
find
(
key
,
artPix
))
{
if
(
artUrl
.
isEmpty
()
||
!
artPix
.
load
(
artUrl
)
)
{
key
=
QString
(
"noart%1%2"
).
arg
(
size
.
width
()).
arg
(
size
.
height
());
if
(
!
QPixmapCache
::
find
(
key
,
artPix
)
)
{
artPix
=
QPixmap
(
":/noart"
).
scaled
(
size
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
);
QPixmapCache
::
insert
(
key
,
artPix
);
}
}
else
{
artPix
=
artPix
.
scaled
(
size
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
);
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
);
QString
title
=
PLModel
::
getMeta
(
index
,
COLUMN_TITLE
);
QString
artist
=
PLModel
::
getMeta
(
index
,
COLUMN_ARTIST
);
QFont
font
(
index
.
data
(
Qt
::
FontRole
).
value
<
QFont
>
()
);
painter
->
setFont
(
font
);
...
...
@@ -139,7 +86,7 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
int
art_width
=
averagewidth
*
ICON_SCALER
;
int
art_height
=
averagewidth
*
ICON_SCALER
;
QPixmap
artPix
=
getArtPixmap
(
index
,
QSize
(
art_width
,
art_height
)
);
QPixmap
artPix
=
PLModel
::
getArtPixmap
(
index
,
QSize
(
art_width
,
art_height
)
);
paintBackground
(
painter
,
option
,
index
);
...
...
@@ -234,13 +181,13 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
QModelIndex
parent
=
index
.
parent
();
QModelIndex
i
;
QString
title
=
getMeta
(
index
,
COLUMN_TITLE
);
QString
duration
=
getMeta
(
index
,
COLUMN_DURATION
);
QString
title
=
PLModel
::
getMeta
(
index
,
COLUMN_TITLE
);
QString
duration
=
PLModel
::
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
artist
=
PLModel
::
getMeta
(
index
,
COLUMN_ARTIST
);
QString
album
=
PLModel
::
getMeta
(
index
,
COLUMN_ALBUM
);
QString
trackNum
=
PLModel
::
getMeta
(
index
,
COLUMN_TRACK_NUMBER
);
QString
artistAlbum
=
artist
;
if
(
!
album
.
isEmpty
()
)
{
...
...
@@ -249,7 +196,7 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
if
(
!
trackNum
.
isEmpty
()
)
artistAlbum
+=
QString
(
" [#%1]"
).
arg
(
trackNum
);
}
QPixmap
artPix
=
getArtPixmap
(
index
,
QSize
(
LISTVIEW_ART_SIZE
,
LISTVIEW_ART_SIZE
)
);
QPixmap
artPix
=
PLModel
::
getArtPixmap
(
index
,
QSize
(
LISTVIEW_ART_SIZE
,
LISTVIEW_ART_SIZE
)
);
//Draw selection rectangle and current playing item indication
paintBackground
(
painter
,
option
,
index
);
...
...
modules/gui/qt4/components/playlist/views.hpp
View file @
f80154be
...
...
@@ -35,9 +35,7 @@ class AbstractPlViewItemDelegate : public QStyledItemDelegate
{
public:
AbstractPlViewItemDelegate
(
QWidget
*
parent
=
0
)
:
QStyledItemDelegate
(
parent
)
{}
QString
getMeta
(
const
QModelIndex
&
index
,
int
meta
)
const
;
void
paintBackground
(
QPainter
*
,
const
QStyleOptionViewItem
&
,
const
QModelIndex
&
)
const
;
QPixmap
getArtPixmap
(
const
QModelIndex
&
index
,
const
QSize
&
size
)
const
;
};
class
PlIconViewItemDelegate
:
public
AbstractPlViewItemDelegate
...
...
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