Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
juk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
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
David Planella
juk
Commits
6a1d0ec4
Commit
6a1d0ec4
authored
Dec 21, 2018
by
Michael Pyne
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Applications/18.12'
parents
bcf4f68b
468a5169
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
44 deletions
+36
-44
playlistbox.cpp
playlistbox.cpp
+32
-38
playlistbox.h
playlistbox.h
+4
-6
No files found.
playlistbox.cpp
View file @
6a1d0ec4
...
...
@@ -77,12 +77,15 @@ PlaylistBox::PlaylistBox(PlayerManager *player, QWidget *parent, QStackedWidget
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
setDropIndicatorShown
(
true
);
setColumnCount
(
2
);
// Use fake column for sorting
setColumnHidden
(
1
,
true
);
setSortingEnabled
(
true
);
sortByColumn
(
1
,
Qt
::
AscendingOrder
);
header
()
->
blockSignals
(
true
);
header
()
->
hide
();
header
()
->
blockSignals
(
false
);
sortByColumn
(
0
);
viewport
()
->
setAcceptDrops
(
true
);
setDropIndicatorShown
(
true
);
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
...
...
@@ -648,7 +651,7 @@ PlaylistBox::Item *PlaylistBox::Item::m_collectionItem = 0;
PlaylistBox
::
Item
::
Item
(
PlaylistBox
*
listBox
,
const
QString
&
icon
,
const
QString
&
text
,
Playlist
*
l
)
:
QObject
(
listBox
),
QTreeWidgetItem
(
listBox
,
QStringList
(
text
)),
PlaylistObserver
(
l
),
m_playlist
(
l
),
m_
text
(
text
),
m_
iconName
(
icon
),
m_sortedFirst
(
false
)
m_playlist
(
l
),
m_iconName
(
icon
),
m_sortedFirst
(
false
)
{
init
();
}
...
...
@@ -656,7 +659,7 @@ PlaylistBox::Item::Item(PlaylistBox *listBox, const QString &icon, const QString
PlaylistBox
::
Item
::
Item
(
Item
*
parent
,
const
QString
&
icon
,
const
QString
&
text
,
Playlist
*
l
)
:
QObject
(
parent
->
listView
()),
QTreeWidgetItem
(
parent
,
QStringList
(
text
)),
PlaylistObserver
(
l
),
m_playlist
(
l
),
m_
text
(
text
),
m_
iconName
(
icon
),
m_sortedFirst
(
false
)
m_playlist
(
l
),
m_iconName
(
icon
),
m_sortedFirst
(
false
)
{
init
();
}
...
...
@@ -666,37 +669,13 @@ PlaylistBox::Item::~Item()
}
int
PlaylistBox
::
Item
::
compare
(
QTreeWidgetItem
*
i
,
int
col
,
bool
)
const
{
Item
*
otherItem
=
static_cast
<
Item
*>
(
i
);
PlaylistBox
*
playlistBox
=
static_cast
<
PlaylistBox
*>
(
treeWidget
());
if
(
m_playlist
==
playlistBox
->
upcomingPlaylist
()
&&
otherItem
->
m_playlist
!=
CollectionList
::
instance
())
return
-
1
;
if
(
otherItem
->
m_playlist
==
playlistBox
->
upcomingPlaylist
()
&&
m_playlist
!=
CollectionList
::
instance
())
return
1
;
if
(
m_sortedFirst
&&
!
otherItem
->
m_sortedFirst
)
return
-
1
;
else
if
(
otherItem
->
m_sortedFirst
&&
!
m_sortedFirst
)
return
1
;
return
text
(
col
).
toLower
().
localeAwareCompare
(
i
->
text
(
col
).
toLower
());
}
// FIXME paintcell
// FIXME paintcell
/*void PlaylistBox::Item::paintCell(QPainter *painter, const QColorGroup &colorGroup, int column, int width, int align)
{
PlaylistBox *playlistBox = static_cast<PlaylistBox *>(listView());
playlistBox->viewMode()->paintCell(this, painter, colorGroup, column, width, align);
}*/
void
PlaylistBox
::
Item
::
setText
(
int
column
,
const
QString
&
text
)
{
m_text
=
text
;
QTreeWidgetItem
::
setText
(
column
,
text
);
}
void
PlaylistBox
::
Item
::
setup
()
{
listView
()
->
viewMode
()
->
setupItem
(
this
);
...
...
@@ -708,15 +687,13 @@ void PlaylistBox::Item::setup()
void
PlaylistBox
::
Item
::
slotSetName
(
const
QString
&
name
)
{
if
(
listView
())
{
setText
(
0
,
name
);
setText
(
0
,
name
);
// Display name
setText
(
1
,
sortTextFor
(
name
)
);
setSelected
(
true
);
treeWidget
()
->
sortItems
(
0
,
Qt
::
AscendingOrder
);
treeWidget
()
->
scrollToItem
(
treeWidget
()
->
currentItem
());
treeWidget
()
->
scrollToItem
(
this
);
//FIXME viewmode
//listView()->viewMode()->queueRefresh();
}
}
void
PlaylistBox
::
Item
::
playingItemHasChanged
()
...
...
@@ -741,8 +718,9 @@ void PlaylistBox::Item::init()
list
->
setupItem
(
this
);
const
QString
itemText
(
text
());
setIcon
(
0
,
QIcon
::
fromTheme
(
m_iconName
));
list
->
addNameToDict
(
m_t
ext
);
list
->
addNameToDict
(
itemT
ext
);
if
(
m_playlist
)
{
connect
(
m_playlist
,
SIGNAL
(
signalNameChanged
(
QString
)),
...
...
@@ -759,6 +737,22 @@ void PlaylistBox::Item::init()
if
(
m_playlist
==
list
->
historyPlaylist
()
||
m_playlist
==
list
->
upcomingPlaylist
())
m_sortedFirst
=
true
;
setText
(
1
,
sortTextFor
(
itemText
));
}
QString
PlaylistBox
::
Item
::
sortTextFor
(
const
QString
&
name
)
const
{
// Collection List goes before everything, then
// playlists that 'sort first', then remainder of
// playlists.
const
auto
prefix
=
(
playlist
()
==
CollectionList
::
instance
())
?
QStringLiteral
(
"0"
)
:
m_sortedFirst
?
QStringLiteral
(
"1"
)
:
QStringLiteral
(
"2"
);
return
prefix
+
name
;
}
// vim: set et sw=4 tw=0 sta:
playlistbox.h
View file @
6a1d0ec4
...
...
@@ -157,21 +157,19 @@ public:
virtual
~
Item
();
protected:
using
QTreeWidgetItem
::
text
;
Item
(
PlaylistBox
*
listBox
,
const
QString
&
icon
,
const
QString
&
text
,
Playlist
*
l
=
0
);
Item
(
Item
*
parent
,
const
QString
&
icon
,
const
QString
&
text
,
Playlist
*
l
=
0
);
Playlist
*
playlist
()
const
{
return
m_playlist
;
}
PlaylistBox
*
listView
()
const
{
return
static_cast
<
PlaylistBox
*>
(
QTreeWidgetItem
::
treeWidget
());
}
QString
iconName
()
const
{
return
m_iconName
;
}
QString
text
()
const
{
return
m_text
;
}
QString
text
()
const
{
return
QTreeWidgetItem
::
text
(
0
)
;
}
void
setSortedFirst
(
bool
first
=
true
)
{
m_sortedFirst
=
first
;
}
virtual
int
compare
(
QTreeWidgetItem
*
i
,
int
col
,
bool
)
const
;
/*virtual void paintCell(QPainter *p, const QColorGroup &colorGroup, int column, int width, int align);
virtual void paintFocus(QPainter *, const QColorGroup &, const QRect &) {}*/
virtual
void
setText
(
int
column
,
const
QString
&
text
);
virtual
QString
text
(
int
column
)
const
{
return
QTreeWidgetItem
::
text
(
column
);
}
virtual
void
setup
();
...
...
@@ -194,9 +192,9 @@ protected slots:
private:
// setup() was already taken.
void
init
();
QString
sortTextFor
(
const
QString
&
name
)
const
;
Playlist
*
m_playlist
;
QString
m_text
;
QString
m_iconName
;
bool
m_sortedFirst
;
static
Item
*
m_collectionItem
;
...
...
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