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
c3581f43
Commit
c3581f43
authored
Jul 20, 2012
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: PLTreeView: use delegate for emphasing font.
Also fixes a mistake in
229c807c
where isCurrent == isSelected
parent
c0d24a1b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
21 deletions
+54
-21
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
+1
-19
modules/gui/qt4/components/playlist/views.cpp
modules/gui/qt4/components/playlist/views.cpp
+41
-2
modules/gui/qt4/components/playlist/views.hpp
modules/gui/qt4/components/playlist/views.hpp
+12
-0
No files found.
modules/gui/qt4/components/playlist/standardpanel.cpp
View file @
c3581f43
...
...
@@ -525,25 +525,7 @@ void StandardPLPanel::createCoverView()
void
StandardPLPanel
::
createTreeView
()
{
/* Create and configure the QTreeView */
treeView
=
new
PlTreeView
;
treeView
->
setIconSize
(
QSize
(
20
,
20
)
);
treeView
->
setAlternatingRowColors
(
true
);
treeView
->
setAnimated
(
true
);
treeView
->
setUniformRowHeights
(
true
);
treeView
->
setSortingEnabled
(
true
);
treeView
->
setAttribute
(
Qt
::
WA_MacShowFocusRect
,
false
);
treeView
->
header
()
->
setSortIndicator
(
-
1
,
Qt
::
AscendingOrder
);
treeView
->
header
()
->
setSortIndicatorShown
(
true
);
treeView
->
header
()
->
setClickable
(
true
);
treeView
->
header
()
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
treeView
->
setSelectionBehavior
(
QAbstractItemView
::
SelectRows
);
treeView
->
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
treeView
->
setDragEnabled
(
true
);
treeView
->
setAcceptDrops
(
true
);
treeView
->
setDropIndicatorShown
(
true
);
treeView
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
treeView
=
new
PlTreeView
(
model
,
this
);
/* setModel after setSortingEnabled(true), or the model will sort immediately! */
...
...
modules/gui/qt4/components/playlist/views.cpp
View file @
c3581f43
...
...
@@ -33,6 +33,7 @@
#include <QDrag>
#include <QDragMoveEvent>
#include <QMetaType>
#include <QHeaderView>
#include "assert.h"
...
...
@@ -80,7 +81,7 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
QFont
font
(
index
.
data
(
Qt
::
FontRole
).
value
<
QFont
>
()
);
font
.
setPointSize
(
__MAX
(
font
.
pointSize
()
+
i_zoom
,
4
)
);
font
.
setBold
(
option
.
state
&
QStyle
::
State_Selected
);
font
.
setBold
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
);
painter
->
setFont
(
font
);
QFontMetrics
fm
=
painter
->
fontMetrics
();
...
...
@@ -221,7 +222,7 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
//Draw title info
f
.
setItalic
(
true
);
f
.
setPointSize
(
__MAX
(
f
.
pointSize
()
+
i_zoom
,
4
)
);
f
.
setBold
(
option
.
state
&
QStyle
::
State_Selected
);
f
.
setBold
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
);
painter
->
setFont
(
f
);
QFontMetrics
fm
(
painter
->
fontMetrics
()
);
...
...
@@ -272,6 +273,21 @@ QSize PlListViewItemDelegate::sizeHint ( const QStyleOptionViewItem &, const QMo
return
QSize
(
0
,
height
);
}
void
PlTreeViewItemDelegate
::
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
if
(
index
.
data
(
PLModel
::
IsCurrentRole
).
toBool
()
)
{
QStyleOptionViewItem
myoptions
=
option
;
myoptions
.
font
.
setBold
(
true
);
AbstractPlViewItemDelegate
::
paint
(
painter
,
myoptions
,
index
);
}
else
{
AbstractPlViewItemDelegate
::
paint
(
painter
,
option
,
index
);
}
}
static
inline
void
plViewStartDrag
(
QAbstractItemView
*
view
,
const
Qt
::
DropActions
&
supportedActions
)
{
QDrag
*
drag
=
new
QDrag
(
view
);
...
...
@@ -384,6 +400,29 @@ bool PlListView::viewportEvent ( QEvent * event )
}
}
PlTreeView
::
PlTreeView
(
PLModel
*
,
QWidget
*
parent
)
:
QTreeView
(
parent
)
{
setItemDelegate
(
new
PlTreeViewItemDelegate
(
this
)
);
setIconSize
(
QSize
(
20
,
20
)
);
setAlternatingRowColors
(
true
);
setAnimated
(
true
);
setUniformRowHeights
(
true
);
setSortingEnabled
(
true
);
setAttribute
(
Qt
::
WA_MacShowFocusRect
,
false
);
header
()
->
setSortIndicator
(
-
1
,
Qt
::
AscendingOrder
);
header
()
->
setSortIndicatorShown
(
true
);
header
()
->
setClickable
(
true
);
header
()
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
setSelectionBehavior
(
QAbstractItemView
::
SelectRows
);
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
setDragEnabled
(
true
);
setAcceptDrops
(
true
);
setDropIndicatorShown
(
true
);
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
}
void
PlTreeView
::
setModel
(
QAbstractItemModel
*
model
)
{
QTreeView
::
setModel
(
model
);
...
...
modules/gui/qt4/components/playlist/views.hpp
View file @
c3581f43
...
...
@@ -69,6 +69,16 @@ public:
virtual
QSize
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
};
class
PlTreeViewItemDelegate
:
public
AbstractPlViewItemDelegate
{
Q_OBJECT
public:
PlTreeViewItemDelegate
(
QWidget
*
parent
=
0
)
:
AbstractPlViewItemDelegate
(
parent
)
{}
virtual
void
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
;
};
class
PlIconView
:
public
QListView
{
Q_OBJECT
...
...
@@ -98,6 +108,8 @@ class PlTreeView : public QTreeView
{
Q_OBJECT
public:
PlTreeView
(
PLModel
*
,
QWidget
*
parent
=
0
);
protected:
virtual
void
startDrag
(
Qt
::
DropActions
supportedActions
);
virtual
void
dragMoveEvent
(
QDragMoveEvent
*
event
);
...
...
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