Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 23235c93 authored by Scott Wheeler's avatar Scott Wheeler

I have the "Show More" stuff mostly working here. It still needs a thing

to clear the search (without changing playlists), and it seems that the
playing item sharing isn't quite working, but more there later.

svn path=/trunk/kdemultimedia/juk/; revision=362838
parent a867577d
......@@ -26,6 +26,7 @@
#include <qimage.h>
#include "nowplaying.h"
#include "playlistcollection.h"
#include "playermanager.h"
#include "coverinfo.h"
#include "tag.h"
......@@ -41,8 +42,9 @@ struct Line : public QFrame
// NowPlaying
////////////////////////////////////////////////////////////////////////////////
NowPlaying::NowPlaying(QWidget *parent, const char *name) :
QHBox(parent, name)
NowPlaying::NowPlaying(QWidget *parent, PlaylistCollection *collection, const char *name) :
QHBox(parent, name),
m_collection(collection)
{
layout()->setMargin(5);
layout()->setSpacing(3);
......@@ -64,6 +66,11 @@ void NowPlaying::addItem(NowPlayingItem *item)
m_items.append(item);
}
PlaylistCollection *NowPlaying::collection() const
{
return m_collection;
}
void NowPlaying::slotUpdate()
{
FileHandle file = PlayerManager::instance()->playingFile();
......@@ -172,10 +179,15 @@ TrackItem::TrackItem(NowPlaying *parent) :
layout->addStretch();
layout->addWidget(m_label);
layout->addStretch();
connect(m_label, SIGNAL(linkClicked(const QString &)), this,
SLOT(slotOpenLink(const QString &)));
}
void TrackItem::update(const FileHandle &file)
{
m_file = file;
QString title = QStyleSheet::escape(file.tag()->title());
QString artist = QStyleSheet::escape(file.tag()->artist());
QString album = QStyleSheet::escape(file.tag()->album());
......@@ -187,7 +199,7 @@ void TrackItem::update(const FileHandle &file)
QString format =
"<font size=\"+%1\"><b>%2</b></font>"
"<br />"
"<font size=\"+%3\"><b><a href=\"#\">%4</a>%5<a href=\"#\">%6</a></b></font>";
"<font size=\"+%3\"><b><a href=\"artist\">%4</a>%5<a href=\"album\">%6</a></b></font>";
do {
m_label->setText(format.arg(size).arg(title).arg(size - 2)
......@@ -198,6 +210,16 @@ void TrackItem::update(const FileHandle &file)
m_label->setFixedHeight(QMIN(imageSize, m_label->heightForWidth(m_label->width())));
}
void TrackItem::slotOpenLink(const QString &link)
{
PlaylistCollection *collection = NowPlayingItem::parent()->collection();
if(link == "artist")
collection->showMore(m_file.tag()->artist());
else if(link == "album")
collection->showMore(m_file.tag()->artist(), m_file.tag()->album());
}
////////////////////////////////////////////////////////////////////////////////
// HistoryItem
////////////////////////////////////////////////////////////////////////////////
......
......@@ -24,6 +24,7 @@
#include "filehandle.h"
class NowPlayingItem;
class PlaylistCollection;
/**
* This is the widget that holds all of the other items and handles updating them
......@@ -35,13 +36,16 @@ class NowPlaying : public QHBox
Q_OBJECT
public:
NowPlaying(QWidget *parent, const char *name = 0);
NowPlaying(QWidget *parent, PlaylistCollection *collection,
const char *name = 0);
void addItem(NowPlayingItem *item);
PlaylistCollection *collection() const;
private slots:
void slotUpdate();
private:
PlaylistCollection *m_collection;
QValueList<NowPlayingItem *> m_items;
};
......@@ -53,9 +57,11 @@ class NowPlayingItem
{
public:
virtual void update(const FileHandle &file) = 0;
NowPlaying *parent() const { return m_parent; }
protected:
NowPlayingItem(NowPlaying *parent) { parent->addItem(this); }
NowPlayingItem(NowPlaying *parent) : m_parent(parent) { parent->addItem(this); }
private:
NowPlaying *m_parent;
};
/**
......@@ -96,11 +102,17 @@ public:
class TrackItem : public QWidget, public NowPlayingItem
{
Q_OBJECT
public:
TrackItem(NowPlaying *parent);
virtual void update(const FileHandle &file);
private slots:
void slotOpenLink(const QString &link);
private:
FileHandle m_file;
LinkLabel *m_label;
};
......
......@@ -56,8 +56,7 @@ PlaylistBox::PlaylistBox(QWidget *parent, QWidgetStack *playlistStack,
m_doingMultiSelect(false),
m_treeViewSetup(false),
m_dropItem(0),
m_showTimer(0),
m_dynamicPlaylist(0)
m_showTimer(0)
{
readConfig();
addColumn("Playlists", width());
......@@ -179,11 +178,16 @@ void PlaylistBox::raise(Playlist *playlist)
Item *i = m_playlistDict.find(playlist);
clearSelection();
setSelected(i, true);
if(i) {
clearSelection();
setSelected(i, true);
setSingleItem(i);
ensureItemVisible(currentItem());
setSingleItem(i);
ensureItemVisible(currentItem());
}
else
PlaylistCollection::raise(playlist);
slotPlaylistChanged();
}
......@@ -386,7 +390,7 @@ void PlaylistBox::slotShowDropTarget()
return;
}
playlistStack()->raiseWidget(m_dropItem->playlist());
raise(m_dropItem->playlist());
}
// For the following two function calls, we can forward the slot*Item calls
......@@ -640,9 +644,6 @@ void PlaylistBox::slotPlaylistChanged()
TrackSequenceManager::instance()->setCurrentPlaylist(playlists.front());
dataChanged(); // Update the status bar
delete m_dynamicPlaylist;
m_dynamicPlaylist = 0;
if(playlists.front() == upcomingPlaylist())
action("deleteItemPlaylist")->setText(i18n("Hid&e"));
else
......@@ -653,11 +654,8 @@ void PlaylistBox::slotPlaylistChanged()
new DynamicPlaylist(playlists, this, i18n("Dynamic List"), "midi", false, true);
p->applySharedSettings();
playlistStack()->raiseWidget(p);
delete m_dynamicPlaylist;
m_dynamicPlaylist = p;
TrackSequenceManager::instance()->setCurrentPlaylist(m_dynamicPlaylist);
TrackSequenceManager::instance()->setCurrentPlaylist(p);
connect(playlistStack(), SIGNAL(aboutToShow(int)), p, SLOT(deleteLater()));
}
}
......
......@@ -24,7 +24,6 @@
class Playlist;
class PlaylistItem;
class DynamicPlaylist;
class ViewMode;
class PlaylistSearch;
class SearchPlaylist;
......@@ -129,7 +128,6 @@ private:
bool m_treeViewSetup;
Item *m_dropItem;
QTimer *m_showTimer;
DynamicPlaylist *m_dynamicPlaylist;
};
......
......@@ -142,6 +142,44 @@ void PlaylistCollection::createPlaylist(const QString &name)
raise(new Playlist(this, name));
}
void PlaylistCollection::showMore(const QString &artist, const QString &album)
{
PlaylistList playlists;
PlaylistSearch::ComponentList components;
playlists.append(CollectionList::instance());
if(currentPlaylist() != CollectionList::instance() &&
currentPlaylist() != m_showMore)
playlists.append(currentPlaylist());
{ // Just setting off the artist stuff in its own block.
ColumnList columns;
columns.append(PlaylistItem::ArtistColumn);
PlaylistSearch::Component c(artist, false, columns,
PlaylistSearch::Component::Exact);
components.append(c);
}
if(!album.isNull()) {
ColumnList columns;
columns.append(PlaylistItem::AlbumColumn);
PlaylistSearch::Component c(album, false, columns,
PlaylistSearch::Component::Exact);
components.append(c);
}
PlaylistSearch search(playlists, components, PlaylistSearch::MatchAll);
m_showMore = new SearchPlaylist(this, search, i18n("Now Playing"), false, true);
m_showMore->applySharedSettings();
m_playlistStack->raiseWidget(m_showMore);
QObject::connect(m_playlistStack, SIGNAL(aboutToShow(int)), m_showMore, SLOT(deleteLater()));
}
void PlaylistCollection::removeTrack(const QString &playlist, const QStringList &files)
{
Playlist *p = playlistByName(playlist);
......@@ -534,6 +572,11 @@ bool PlaylistCollection::containsPlaylistFile(const QString &file) const
return m_playlistFiles.contains(file);
}
bool PlaylistCollection::showMoreActive() const
{
return bool(m_showMore);
}
void PlaylistCollection::enableDirWatch(bool enable)
{
QObject *collection = CollectionList::instance();
......
......@@ -24,6 +24,8 @@
#include <klocale.h>
#include <kdirlister.h>
#include <qguardedptr.h>
class QWidgetStack;
class KAction;
class Playlist;
......@@ -56,6 +58,7 @@ public:
virtual QStringList playlists() const;
virtual void createPlaylist(const QString &name);
virtual void showMore(const QString &artist, const QString &album = QString::null);
virtual void removeTrack(const QString &playlist, const QStringList &files);
virtual QString playlist() const;
......@@ -76,6 +79,8 @@ public:
virtual void editSearch();
virtual void setCanDeletePlaylist(bool);
bool showMoreActive() const;
void enableDirWatch(bool enable);
void removeItems();
......@@ -166,6 +171,8 @@ private:
bool m_importPlaylists;
bool m_searchEnabled;
bool m_playing;
QGuardedPtr<Playlist> m_showMore;
};
/**
......
......@@ -118,7 +118,7 @@ void PlaylistSplitter::setupLayout()
connect(CollectionList::instance(), SIGNAL(signalCollectionChanged()),
m_editor, SLOT(slotUpdateCollection()));
NowPlaying *nowPlaying = new NowPlaying(top);
NowPlaying *nowPlaying = new NowPlaying(top, m_playlistBox);
// Create the search widget -- this must be done after the CollectionList is created.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment