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
d5603e9a
Commit
d5603e9a
authored
Feb 23, 2014
by
Arnold Dumas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port the Cover dialog from K3ListView and Q3IconView to KListWidget.
REVIEW: 115957
parent
bd33a7b0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
87 deletions
+112
-87
coverdialog.cpp
coverdialog.cpp
+75
-25
coverdialog.h
coverdialog.h
+6
-2
coverdialogbase.ui
coverdialogbase.ui
+8
-46
covericonview.cpp
covericonview.cpp
+16
-8
covericonview.h
covericonview.h
+7
-6
No files found.
coverdialog.cpp
View file @
d5603e9a
/**
* Copyright (C) 2005 Michael Pyne <mpyne@kde.org>
* Copyright (C) 2014 Arnold Dumas <contact@arnolddumas.com>
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
...
...
@@ -16,9 +17,6 @@
#include "coverdialog.h"
#include <k3listview.h>
#include <k3iconview.h>
#include <k3iconviewsearchline.h>
#include <kiconloader.h>
#include <kapplication.h>
#include <kmenu.h>
...
...
@@ -32,32 +30,32 @@
using
CoverUtility
::
CoverIconViewItem
;
class
AllArtistsListViewItem
:
public
K3ListView
Item
class
AllArtistsListViewItem
:
public
QListWidget
Item
{
public:
AllArtistsListViewItem
(
Q3ListView
*
parent
)
:
K3ListViewItem
(
parent
,
i18n
(
"<All Artists>"
)
)
AllArtistsListViewItem
(
KListWidget
*
parent
)
:
QListWidgetItem
(
i18n
(
"<All Artists>"
),
parent
)
{
}
int
compare
(
Q3ListViewItem
*
,
int
,
bool
)
const
bool
operator
<
(
const
QListWidgetItem
&
other
)
const
{
return
-
1
;
// Always be at the top.
Q_UNUSED
(
other
);
return
true
;
// Always be at the top.
}
};
class
CaseInsensitiveItem
:
public
K3ListView
Item
class
CaseInsensitiveItem
:
public
QListWidget
Item
{
public:
CaseInsensitiveItem
(
Q3ListView
*
parent
,
const
QString
&
text
)
:
K3ListViewItem
(
parent
,
tex
t
)
CaseInsensitiveItem
(
KListWidget
*
parent
,
const
QString
&
text
)
:
QListWidgetItem
(
text
,
paren
t
)
{
}
int
compare
(
Q3ListViewItem
*
item
,
int
column
,
bool
ascending
)
const
bool
operator
<
(
const
QListWidgetItem
&
other
)
const
{
Q_UNUSED
(
ascending
);
return
text
(
column
).
toLower
().
localeAwareCompare
(
item
->
text
(
column
).
toLower
());
return
text
().
toLower
().
localeAwareCompare
(
other
.
text
().
toLower
());
}
};
...
...
@@ -68,11 +66,16 @@ CoverDialog::CoverDialog(QWidget *parent) :
setObjectName
(
QLatin1String
(
"juk_cover_dialog"
));
m_covers
->
setResizeMode
(
Q3IconView
::
Adjust
);
m_covers
->
setGridX
(
140
);
m_covers
->
setGridY
(
150
);
m_searchLine
->
setClearButtonShown
(
true
);
m_searchLine
->
setIconView
(
m_covers
);
connect
(
m_artists
,
SIGNAL
(
itemClicked
(
QListWidgetItem
*
)),
this
,
SLOT
(
slotArtistClicked
(
QListWidgetItem
*
)));
connect
(
m_covers
,
SIGNAL
(
customContextMenuRequested
(
QPoint
)),
this
,
SLOT
(
slotContextRequested
(
QPoint
)));
connect
(
m_searchLine
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
slotSearchPatternChanged
(
QString
)));
}
CoverDialog
::~
CoverDialog
()
...
...
@@ -86,13 +89,10 @@ void CoverDialog::show()
QStringList
artists
=
CollectionList
::
instance
()
->
uniqueSet
(
CollectionList
::
Artists
);
m_artists
->
setSorting
(
-
1
);
new
AllArtistsListViewItem
(
m_artists
);
for
(
QStringList
::
ConstIterator
it
=
artists
.
constBegin
();
it
!=
artists
.
constEnd
();
++
it
)
new
CaseInsensitiveItem
(
m_artists
,
*
it
);
m_artists
->
setSorting
(
0
);
QTimer
::
singleShot
(
0
,
this
,
SLOT
(
loadCovers
()));
QWidget
::
show
();
}
...
...
@@ -119,7 +119,7 @@ void CoverDialog::loadCovers()
}
// TODO: Add a way to show cover art for tracks with no artist.
void
CoverDialog
::
slotArtistClicked
(
Q
3ListView
Item
*
item
)
void
CoverDialog
::
slotArtistClicked
(
Q
ListWidget
Item
*
item
)
{
m_covers
->
clear
();
if
(
!
item
)
{
...
...
@@ -130,7 +130,7 @@ void CoverDialog::slotArtistClicked(Q3ListViewItem *item)
loadCovers
();
}
else
{
QString
artist
=
item
->
text
(
0
).
toLower
();
QString
artist
=
item
->
text
().
toLower
();
CoverDataMapIterator
it
,
end
;
...
...
@@ -144,10 +144,12 @@ void CoverDialog::slotArtistClicked(Q3ListViewItem *item)
}
}
void
CoverDialog
::
slotContextRequested
(
Q3IconViewItem
*
item
,
const
QPoint
&
pt
)
void
CoverDialog
::
slotContextRequested
(
const
QPoint
&
pt
)
{
static
KMenu
*
menu
=
0
;
QListWidgetItem
*
item
=
m_covers
->
currentItem
();
if
(
!
item
)
return
;
...
...
@@ -156,7 +158,55 @@ void CoverDialog::slotContextRequested(Q3IconViewItem *item, const QPoint &pt)
menu
->
addAction
(
i18n
(
"Remove Cover"
),
this
,
SLOT
(
removeSelectedCover
()));
}
menu
->
popup
(
pt
);
QPoint
globalPt
=
m_covers
->
mapToGlobal
(
pt
);
menu
->
popup
(
globalPt
);
}
void
CoverDialog
::
slotSearchPatternChanged
(
const
QString
&
pattern
)
{
m_covers
->
clear
();
QListWidgetItem
*
item
=
m_artists
->
currentItem
();
// If the expression is cleared, then use slotArtistClicked.
if
(
pattern
.
isEmpty
())
{
slotArtistClicked
(
item
);
}
else
{
QRegExp
filter
(
pattern
,
Qt
::
CaseInsensitive
,
QRegExp
::
Wildcard
);
QString
artist
=
item
->
text
().
toLower
();
CoverDataMapIterator
it
,
end
;
it
=
CoverManager
::
begin
();
end
=
CoverManager
::
end
();
// Here, only show cover that match the search pattern.
if
(
dynamic_cast
<
AllArtistsListViewItem
*>
(
item
))
{
for
(;
it
!=
end
;
++
it
)
{
if
(
filter
.
indexIn
(
it
.
value
()
->
artist
)
!=
-
1
)
{
(
void
)
new
CoverIconViewItem
(
it
.
key
(),
m_covers
);
}
}
}
// Here, only show the covers that match the search pattern and
// that have the same artist as the currently selected one.
else
{
for
(;
it
!=
end
;
++
it
)
{
if
(
it
.
value
()
->
artist
==
artist
&&
(
filter
.
indexIn
(
it
.
value
()
->
artist
)
!=
-
1
)
||
(
filter
.
indexIn
(
it
.
value
()
->
album
)
!=
-
1
))
{
(
void
)
new
CoverIconViewItem
(
it
.
key
(),
m_covers
);
}
}
}
}
}
void
CoverDialog
::
removeSelectedCover
()
...
...
coverdialog.h
View file @
d5603e9a
/**
* Copyright (C) 2005 Michael Pyne <mpyne@kde.org>
* Copyright (C) 2014 Arnold Dumas <contact@arnolddumas.com>
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
...
...
@@ -21,6 +22,8 @@
#include <QWidget>
class
QListWidgetItem
;
class
CoverDialog
:
public
QWidget
,
public
Ui
::
CoverDialogBase
{
Q_OBJECT
...
...
@@ -31,8 +34,9 @@ public:
virtual
void
show
();
public
slots
:
void
slotArtistClicked
(
Q3ListViewItem
*
item
);
void
slotContextRequested
(
Q3IconViewItem
*
item
,
const
QPoint
&
pt
);
void
slotArtistClicked
(
QListWidgetItem
*
item
);
void
slotContextRequested
(
const
QPoint
&
pt
);
void
slotSearchPatternChanged
(
const
QString
&
pattern
);
private
slots
:
void
loadCovers
();
...
...
coverdialogbase.ui
View file @
d5603e9a
...
...
@@ -20,7 +20,7 @@
<number>6</number>
</property>
<item>
<widget class="K
3ListView
" name="m_artists" >
<widget class="K
ListWidget
" name="m_artists" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
...
...
@@ -35,12 +35,6 @@
<height>0</height>
</size>
</property>
<property name="resizeMode" >
<enum>Q3ListView::LastColumn</enum>
</property>
<property name="shadeSortColumn" >
<bool>false</bool>
</property>
<column>
<property name="text" >
<string>Artist</string>
...
...
@@ -65,7 +59,7 @@
<number>6</number>
</property>
<item>
<widget class="K
3IconViewSearchLine
" native="1" name="m_searchLine" >
<widget class="K
LineEdit
" native="1" name="m_searchLine" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
...
...
@@ -96,14 +90,14 @@
</widget>
<customwidgets>
<customwidget>
<class>K
3ListView
</class>
<extends>Q
3ListView
</extends>
<header>k
3listview
.h</header>
<class>K
ListWidget
</class>
<extends>Q
ListWidget
</extends>
<header>k
listwidget
.h</header>
</customwidget>
<customwidget>
<class>K
3IconViewSearchLine
</class>
<class>K
LineEdit
</class>
<extends>QWidget</extends>
<header>k
3iconviewsearchline
.h</header>
<header>k
lineedit
.h</header>
</customwidget>
<customwidget>
<class>CoverIconView</class>
...
...
@@ -114,42 +108,10 @@
</customwidgets>
<includes>
<include location="local" >k3listview.h</include>
<include location="local" >k
3iconviewsearchline
.h</include>
<include location="local" >k
lineedit
.h</include>
<include location="local" >covericonview.h</include>
</includes>
<resources/>
<connections>
<connection>
<sender>m_artists</sender>
<signal>clicked(Q3ListViewItem*)</signal>
<receiver>CoverDialogBase</receiver>
<slot>slotArtistClicked(Q3ListViewItem*)</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_covers</sender>
<signal>contextMenuRequested(Q3IconViewItem*,QPoint)</signal>
<receiver>CoverDialogBase</receiver>
<slot>slotContextRequested(Q3IconViewItem*,QPoint)</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>
covericonview.cpp
View file @
d5603e9a
/**
* Copyright (C) 2005 Michael Pyne <mpyne@kde.org>
* Copyright (C) 2014 Arnold Dumas <contact@arnolddumas.com>
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
...
...
@@ -19,34 +20,41 @@
using
CoverUtility
::
CoverIconViewItem
;
CoverIconViewItem
::
CoverIconViewItem
(
coverKey
id
,
Q3IconView
*
parent
)
:
K3IconView
Item
(
parent
),
m_id
(
id
)
CoverIconViewItem
::
CoverIconViewItem
(
coverKey
id
,
KListWidget
*
parent
)
:
QListWidget
Item
(
parent
),
m_id
(
id
)
{
CoverDataPtr
data
=
CoverManager
::
coverInfo
(
id
);
setText
(
QString
(
"%1 - %2"
).
arg
(
data
->
artist
,
data
->
album
));
setPixmap
(
data
->
thumbnail
());
setIcon
(
data
->
thumbnail
());
setSizeHint
(
QSize
(
140
,
150
));
}
CoverIconView
::
CoverIconView
(
QWidget
*
parent
,
const
char
*
name
)
:
K
3IconView
(
parent
,
name
)
CoverIconView
::
CoverIconView
(
QWidget
*
parent
,
const
char
*
name
)
:
K
ListWidget
(
parent
)
{
setResizeMode
(
Adjust
);
setObjectName
(
name
);
setResizeMode
(
KListWidget
::
Adjust
);
setViewMode
(
KListWidget
::
IconMode
);
setIconSize
(
QSize
(
130
,
140
));
setMovement
(
KListWidget
::
Static
);
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
}
CoverIconViewItem
*
CoverIconView
::
currentItem
()
const
{
return
static_cast
<
CoverIconViewItem
*>
(
K
3IconView
::
currentItem
());
return
static_cast
<
CoverIconViewItem
*>
(
K
ListWidget
::
currentItem
());
}
// TODO: port to Qt4
#if 0
Q3DragObject *CoverIconView::dragObject()
{
#if 0
// Temporarily disabled pending conversion of the cover manager icon view
// to Qt 4 ish stuff.
CoverIconViewItem *item = currentItem();
if(item)
return new CoverDrag(item->id(), this);
#endif
return 0;
}
#endif
// vim: set et sw=4 tw=0 sta:
covericonview.h
View file @
d5603e9a
/**
* Copyright (C) 2005 Michael Pyne <mpyne@kde.org>
* Copyright (C) 2014 Arnold Dumas <contact@arnolddumas.com>
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
...
...
@@ -17,7 +18,7 @@
#ifndef COVERICONVIEW_H
#define COVERICONVIEW_H
#include <k
3iconview
.h>
#include <k
listwidget
.h>
#include "covermanager.h"
...
...
@@ -28,10 +29,10 @@
namespace
CoverUtility
{
class
CoverIconViewItem
:
public
K3IconView
Item
class
CoverIconViewItem
:
public
QListWidget
Item
{
public:
CoverIconViewItem
(
coverKey
id
,
Q3IconView
*
parent
);
CoverIconViewItem
(
coverKey
id
,
KListWidget
*
parent
);
coverKey
id
()
const
{
return
m_id
;
}
...
...
@@ -43,12 +44,12 @@ namespace CoverUtility
using
CoverUtility
::
CoverIconViewItem
;
/**
* This class subclasses
K3IconView
in order to provide cover drag-and-drop
* This class subclasses
QListWidget
in order to provide cover drag-and-drop
* support.
*
* @author Michael Pyne <mpyne@kde.org>
*/
class
CoverIconView
:
public
K
3IconView
class
CoverIconView
:
public
K
ListWidget
{
public:
explicit
CoverIconView
(
QWidget
*
parent
,
const
char
*
name
=
0
);
...
...
@@ -56,7 +57,7 @@ public:
CoverIconViewItem
*
currentItem
()
const
;
protected:
virtual
Q3DragObject
*
dragObject
();
//
virtual Q3DragObject *dragObject();
};
#endif
/* COVERICONVIEW_H */
...
...
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