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
23748912
Commit
23748912
authored
Aug 30, 2009
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qt4: let QTreeView manage visible playlist columns selection
And remove a lot of unnecessary code.
parent
73cad20b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
183 deletions
+56
-183
modules/gui/qt4/components/playlist/panels.hpp
modules/gui/qt4/components/playlist/panels.hpp
+2
-2
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
+17
-120
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/playlist_model.hpp
+2
-10
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
+35
-51
No files found.
modules/gui/qt4/components/playlist/panels.hpp
View file @
23748912
...
...
@@ -75,7 +75,7 @@ private:
QTreeView
*
view
;
QPushButton
*
repeatButton
,
*
randomButton
,
*
addButton
,
*
gotoPlayingButton
;
int
currentRootId
;
QSignalMapper
*
ContextUpdate
Mapper
;
QSignalMapper
*
selectColumnsSig
Mapper
;
public
slots
:
void
removeItem
(
int
);
virtual
void
setRoot
(
int
);
...
...
@@ -90,7 +90,7 @@ private slots:
void
setCurrentRootId
(
int
);
void
popupAdd
();
void
popupSelectColumn
(
QPoint
);
void
checkSortingIndicator
(
int
);
void
toggleColumnShown
(
int
);
};
#endif
modules/gui/qt4/components/playlist/playlist_model.cpp
View file @
23748912
...
...
@@ -78,17 +78,6 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
rootItem
=
NULL
;
/* PLItem rootItem, will be set in rebuild( ) */
if
(
i_depth
==
DEPTH_SEL
)
i_showflags
=
0
;
else
{
i_showflags
=
getSettings
()
->
value
(
"qt-pl-showflags"
,
COLUMN_DEFAULT
).
toInt
();
if
(
i_showflags
<
1
)
i_showflags
=
COLUMN_DEFAULT
;
/* reasonable default to show something */
else
if
(
i_showflags
>=
COLUMN_END
)
i_showflags
=
COLUMN_END
-
1
;
/* show everything */
}
/* Icons initialization */
#define ADD_ICON(type, x) icons[ITEM_TYPE_##type] = QIcon( QPixmap( x ) )
ADD_ICON
(
UNKNOWN
,
type_unknown_xpm
);
...
...
@@ -102,20 +91,15 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
ADD_ICON
(
NODE
,
":/type/node"
);
#undef ADD_ICON
ContextUpdateMapper
=
new
QSignalMapper
(
this
);
rebuild
(
p_root
);
CONNECT
(
THEMIM
->
getIM
(),
metaChanged
(
input_item_t
*
),
this
,
processInputItemUpdate
(
input_item_t
*
)
);
CONNECT
(
THEMIM
,
inputChanged
(
input_thread_t
*
),
this
,
processInputItemUpdate
(
input_thread_t
*
)
);
CONNECT
(
ContextUpdateMapper
,
mapped
(
int
),
this
,
toggleColumnShown
(
int
)
);
}
PLModel
::~
PLModel
()
{
if
(
i_depth
==
-
1
)
getSettings
()
->
setValue
(
"qt-pl-showflags"
,
i_showflags
);
delCallbacks
();
delete
rootItem
;
}
...
...
@@ -374,7 +358,7 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
return
QVariant
(
returninfo
);
}
int
metadata
=
columnToMeta
(
index
.
column
()
,
i_showflags
);
int
metadata
=
columnToMeta
(
index
.
column
()
);
if
(
metadata
==
COLUMN_END
)
return
QVariant
();
QString
returninfo
;
...
...
@@ -423,7 +407,7 @@ QVariant PLModel::headerData( int section, Qt::Orientation orientation,
if
(
i_depth
==
DEPTH_SEL
)
return
QVariant
(
QString
(
""
)
);
int
meta_col
=
columnToMeta
(
section
,
i_showflags
);
int
meta_col
=
columnToMeta
(
section
);
if
(
meta_col
==
COLUMN_END
)
return
QVariant
();
...
...
@@ -478,17 +462,7 @@ QModelIndex PLModel::parent( const QModelIndex &index ) const
int
PLModel
::
columnCount
(
const
QModelIndex
&
i
)
const
{
int
columnCount
=
0
;
int
metadata
=
1
;
if
(
i_depth
==
DEPTH_SEL
)
return
1
;
while
(
metadata
<
COLUMN_END
)
{
if
(
metadata
&
i_showflags
)
columnCount
++
;
metadata
<<=
1
;
}
return
columnCount
;
return
i_depth
==
DEPTH_SEL
?
1
:
columnFromMeta
(
COLUMN_END
);
}
int
PLModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
...
...
@@ -625,48 +599,32 @@ PLItem *PLModel::getItem( QModelIndex index )
return
static_cast
<
PLItem
*>
(
index
.
internalPointer
()
);
}
/*
Computes meta data column id from shown column index and shown columns flags.
Returns COLUMN_END in case of failure.
*/
int
PLModel
::
columnToMeta
(
int
column
,
int
shown_flags
)
const
int
PLModel
::
columnToMeta
(
int
_column
)
const
{
int
meta
=
1
;
int
index
=
-
1
;
int
column
=
0
;
while
(
meta
<
COLUMN_END
)
while
(
column
!=
_column
&&
meta
!=
COLUMN_END
)
{
if
(
meta
&
shown_flags
)
index
++
;
if
(
index
==
column
)
break
;
meta
<<=
1
;
column
++
;
}
return
meta
;
}
/*
Computes shown column index from meta data column id and shown columns flags.
meta_col must be contained in shown_flags!
*/
int
PLModel
::
columnFromMeta
(
int
meta_col
,
int
shown_flags
)
const
int
PLModel
::
columnFromMeta
(
int
meta_col
)
const
{
assert
(
meta_col
&
shown_flags
);
int
meta
=
1
;
int
index
=
-
1
;
int
column
=
0
;
while
(
meta
<
COLUMN_END
)
while
(
meta
!=
meta_col
&&
meta
!=
COLUMN_END
)
{
if
(
meta
&
shown_flags
)
index
++
;
if
(
meta
==
meta_col
)
break
;
meta
<<=
1
;
column
++
;
}
return
index
;
return
column
;
}
/************************* Updates handling *****************************/
...
...
@@ -930,20 +888,8 @@ void PLModel::sort( int column, Qt::SortOrder order )
void
PLModel
::
sort
(
int
i_root_id
,
int
column
,
Qt
::
SortOrder
order
)
{
int
i_index
=
-
1
;
int
i_flag
=
0
;
int
i_column
=
1
;
for
(
i_column
=
1
;
i_column
!=
COLUMN_END
;
i_column
<<=
1
)
{
if
(
(
shownFlags
()
&
i_column
)
)
i_index
++
;
if
(
column
==
i_index
)
{
i_flag
=
i_column
;
break
;
}
}
int
meta
=
columnToMeta
(
column
);
if
(
meta
==
COLUMN_END
)
return
;
PLItem
*
item
=
findById
(
rootItem
,
i_root_id
);
if
(
!
item
)
return
;
...
...
@@ -960,10 +906,10 @@ void PLModel::sort( int i_root_id, int column, Qt::SortOrder order )
{
playlist_item_t
*
p_root
=
playlist_ItemGetById
(
p_playlist
,
i_root_id
);
if
(
p_root
&&
i_flag
)
if
(
p_root
)
{
playlist_RecursiveNodeSort
(
p_playlist
,
p_root
,
i_column_sorting
(
i_flag
),
i_column_sorting
(
meta
),
order
==
Qt
::
AscendingOrder
?
ORDER_NORMAL
:
ORDER_REVERSE
);
}
...
...
@@ -1031,7 +977,7 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
menu
->
addAction
(
qtr
(
I_POP_INFO
),
this
,
SLOT
(
popupInfo
()
)
);
menu
->
addSeparator
();
QMenu
*
sort_menu
=
menu
->
addMenu
(
qtr
(
"Sort by "
)
+
qfu
(
psz_column_title
(
columnToMeta
(
index
.
column
()
,
i_showflags
)
)
)
);
qfu
(
psz_column_title
(
columnToMeta
(
index
.
column
()
)
)
)
);
sort_menu
->
addAction
(
qtr
(
"Ascending"
),
this
,
SLOT
(
popupSortAsc
()
)
);
sort_menu
->
addAction
(
qtr
(
"Descending"
),
...
...
@@ -1044,58 +990,9 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
menu
->
addSeparator
();
menu
->
addAction
(
qtr
(
I_POP_EXPLORE
),
this
,
SLOT
(
popupExplore
()
)
);
}
if
(
tree
||
i_popup_item
>
-
1
)
menu
->
addSeparator
();
QMenu
*
col_selector
=
menu
->
addMenu
(
qtr
(
"Visible columns"
)
);
makeColumnSelectMenu
(
col_selector
);
menu
->
popup
(
point
);
}
void
PLModel
::
makeColumnSelectMenu
(
QMenu
*
menu
)
{
int
i_column
=
1
;
for
(
i_column
=
1
;
i_column
!=
COLUMN_END
;
i_column
<<=
1
)
{
QAction
*
option
=
menu
->
addAction
(
qfu
(
psz_column_title
(
i_column
)
)
);
option
->
setCheckable
(
true
);
option
->
setChecked
(
shownFlags
()
&
i_column
);
ContextUpdateMapper
->
setMapping
(
option
,
i_column
);
CONNECT
(
option
,
triggered
(),
ContextUpdateMapper
,
map
()
);
}
}
void
PLModel
::
toggleColumnShown
(
int
meta
)
{
assert
(
meta
);
if
(
rootItem
)
{
if
(
i_showflags
&
meta
)
{
/* Removing columns */
int
index
=
columnFromMeta
(
meta
,
i_showflags
);
beginRemoveColumns
(
QModelIndex
(),
index
,
index
);
i_showflags
&=
~
(
meta
);
getSettings
()
->
setValue
(
"qt-pl-showflags"
,
i_showflags
);
endRemoveColumns
();
}
else
{
/* Adding columns */
int
sf
=
i_showflags
;
sf
|=
meta
;
int
index
=
columnFromMeta
(
meta
,
sf
);
beginInsertColumns
(
QModelIndex
(),
index
,
index
);
i_showflags
=
sf
;
getSettings
()
->
setValue
(
"qt-pl-showflags"
,
i_showflags
);
endInsertColumns
();
}
emit
columnsChanged
(
meta
);
}
}
void
PLModel
::
popupDel
()
{
doDelete
(
current_selection
);
...
...
modules/gui/qt4/components/playlist/playlist_model.hpp
View file @
23748912
...
...
@@ -113,7 +113,6 @@ public:
/* Lookups */
QStringList
selectedURIs
();
bool
hasRandom
();
bool
hasLoop
();
bool
hasRepeat
();
int
shownFlags
()
{
return
i_showflags
;
}
QModelIndex
index
(
PLItem
*
,
int
c
)
const
;
QModelIndex
currentIndex
(
)
{
return
index
(
currentItem
,
0
);
};
bool
isCurrent
(
const
QModelIndex
&
index
)
const
;
...
...
@@ -128,8 +127,6 @@ public:
void
removeItem
(
int
);
void
rebuild
();
void
rebuild
(
playlist_item_t
*
);
/* Helpers */
void
makeColumnSelectMenu
(
QMenu
*
menu
);
private:
/* General */
...
...
@@ -139,7 +136,6 @@ private:
playlist_t
*
p_playlist
;
intf_thread_t
*
p_intf
;
int
i_depth
;
int
i_showflags
;
static
QIcon
icons
[
ITEM_TYPE_NUMBER
];
...
...
@@ -166,15 +162,14 @@ private:
/* Popup */
int
i_popup_item
,
i_popup_parent
,
i_popup_column
;
QModelIndexList
current_selection
;
QSignalMapper
*
ContextUpdateMapper
;
/* Lookups */
PLItem
*
findById
(
PLItem
*
,
int
);
PLItem
*
findByInput
(
PLItem
*
,
int
);
PLItem
*
findInner
(
PLItem
*
,
int
,
bool
);
static
inline
PLItem
*
getItem
(
QModelIndex
index
);
int
columnFromMeta
(
int
meta_column
,
int
shown_flags
)
const
;
int
columnToMeta
(
int
column
,
int
shown_flags
)
const
;
int
columnFromMeta
(
int
meta_column
)
const
;
int
columnToMeta
(
int
column
)
const
;
PLItem
*
p_cached_item
;
PLItem
*
p_cached_item_bi
;
int
i_cached_id
;
...
...
@@ -183,8 +178,6 @@ private:
signals:
void
shouldRemove
(
int
);
void
currentChanged
(
const
QModelIndex
&
);
void
columnsChanged
(
int
);
public
slots
:
void
activateItem
(
const
QModelIndex
&
index
);
...
...
@@ -203,7 +196,6 @@ private slots:
void
popupAddNode
();
void
popupSortAsc
();
void
popupSortDesc
();
void
toggleColumnShown
(
int
meta_column
);
void
processInputItemUpdate
(
input_item_t
*
);
void
processInputItemUpdate
(
input_thread_t
*
p_input
);
};
...
...
modules/gui/qt4/components/playlist/standardpanel.cpp
View file @
23748912
...
...
@@ -83,9 +83,13 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
}
else
{
/* Configure the size of the header */
view
->
header
()
->
resizeSection
(
0
,
200
);
view
->
header
()
->
resizeSection
(
1
,
80
);
int
m
,
c
;
for
(
m
=
1
,
c
=
0
;
m
!=
COLUMN_END
;
m
<<=
1
,
c
++
)
{
view
->
setColumnHidden
(
c
,
!
(
m
&
COLUMN_DEFAULT
)
);
if
(
m
==
COLUMN_TITLE
)
view
->
header
()
->
resizeSection
(
c
,
200
);
else
if
(
m
==
COLUMN_DURATION
)
view
->
header
()
->
resizeSection
(
c
,
80
);
}
}
view
->
header
()
->
setSortIndicatorShown
(
true
);
view
->
header
()
->
setClickable
(
true
);
...
...
@@ -101,8 +105,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
this
,
popupSelectColumn
(
QPoint
)
);
CONNECT
(
model
,
currentChanged
(
const
QModelIndex
&
),
this
,
handleExpansion
(
const
QModelIndex
&
)
);
CONNECT
(
model
,
columnsChanged
(
int
),
this
,
checkSortingIndicator
(
int
)
);
currentRootId
=
-
1
;
CONNECT
(
parent
,
rootChanged
(
int
),
this
,
setCurrentRootId
(
int
)
);
...
...
@@ -172,6 +174,9 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
layout
->
addLayout
(
buttons
);
// layout->addWidget( bar );
setLayout
(
layout
);
selectColumnsSigMapper
=
new
QSignalMapper
(
this
);
CONNECT
(
selectColumnsSigMapper
,
mapped
(
int
),
this
,
toggleColumnShown
(
int
)
);
}
/* Function to toggle between the Repeat states */
...
...
@@ -260,59 +265,38 @@ void StandardPLPanel::popupAdd()
+
QPoint
(
0
,
addButton
->
height
()
)
);
}
/* Set sortingindicator to -1 if it's on column thats removed,
* else check that it's still showing on correct column
*/
void
StandardPLPanel
::
checkSortingIndicator
(
int
meta
)
void
StandardPLPanel
::
popupSelectColumn
(
QPoint
pos
)
{
int
index
=
0
;
if
(
view
->
header
()
->
isSortIndicatorShown
()
==
false
)
return
;
int
sortIndex
=
view
->
header
()
->
sortIndicatorSection
();
if
(
sortIndex
<
0
||
sortIndex
>
view
->
header
()
->
count
()
||
meta
==
0
)
return
;
QMenu
menu
;
int
_meta
=
meta
;
while
(
_meta
)
int
i
,
j
;
for
(
i
=
1
,
j
=
0
;
i
<
COLUMN_END
;
i
<<=
1
,
j
++
)
{
if
(
_meta
&
model
->
shownFlags
()
)
index
++
;
_meta
>>=
1
;
QAction
*
option
=
menu
.
addAction
(
qfu
(
psz_column_title
(
i
)
)
);
option
->
setCheckable
(
true
);
option
->
setChecked
(
!
view
->
isColumnHidden
(
j
)
);
selectColumnsSigMapper
->
setMapping
(
option
,
j
);
CONNECT
(
option
,
triggered
(),
selectColumnsSigMapper
,
map
()
);
}
/* Adding column */
if
(
model
->
shownFlags
()
&
meta
)
{
/* If column is added before sortIndex, move it one to right*/
if
(
sortIndex
>=
index
)
{
sortIndex
+=
1
;
}
}
else
{
/* Column removed */
if
(
sortIndex
==
index
)
{
sortIndex
=
-
1
;
}
else
if
(
sortIndex
>
index
)
{
/* Move indicator left one step*/
sortIndex
-=
1
;
}
}
view
->
header
()
->
setSortIndicator
(
sortIndex
,
view
->
header
()
->
sortIndicatorOrder
()
);
menu
.
exec
(
QCursor
::
pos
()
);
}
void
StandardPLPanel
::
popupSelectColumn
(
QPoint
pos
)
void
StandardPLPanel
::
toggleColumnShown
(
int
i
)
{
QMenu
selectColMenu
;
model
->
makeColumnSelectMenu
(
&
selectColMenu
);
selectColMenu
.
exec
(
QCursor
::
pos
()
);
if
(
view
->
isColumnHidden
(
i
)
)
{
view
->
setColumnHidden
(
i
,
false
);
}
else
{
int
visible
=
0
;
int
m
,
c
;
for
(
m
=
1
,
c
=
0
;
m
!=
COLUMN_END
&&
visible
<
2
;
m
<<=
1
,
c
++
)
if
(
!
view
->
isColumnHidden
(
c
)
)
visible
++
;
if
(
visible
<
2
)
return
;
view
->
setColumnHidden
(
i
,
true
);
}
}
/* Search in the playlist */
...
...
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