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 eae8d7ee authored by Scott Wheeler's avatar Scott Wheeler

Make the history playlist actually do something when the items are clicked on.

svn path=/trunk/kdemultimedia/juk/; revision=379281
parent 3643ff9f
......@@ -400,8 +400,11 @@ void CollectionListItem::refresh()
emit CollectionList::instance()->signalCollectionChanged();
}
PlaylistItem *CollectionListItem::itemForPlaylist(const Playlist *playlist) const
PlaylistItem *CollectionListItem::itemForPlaylist(const Playlist *playlist)
{
if(playlist == CollectionList::instance())
return this;
PlaylistItemList::ConstIterator it;
for(it = m_children.begin(); it != m_children.end(); ++it)
if((*it)->playlist() == playlist)
......
......@@ -167,7 +167,7 @@ class CollectionListItem : public PlaylistItem
public:
virtual void refresh();
PlaylistItem *itemForPlaylist(const Playlist *playlist) const;
PlaylistItem *itemForPlaylist(const Playlist *playlist);
void updateCollectionDict(const QString &oldPath, const QString &newPath);
void repaint() const;
......
......@@ -30,6 +30,8 @@
#include "playermanager.h"
#include "coverinfo.h"
#include "tag.h"
#include "playlistitem.h"
#include "collectionlist.h"
static const int imageSize = 64;
......@@ -238,21 +240,21 @@ HistoryItem::HistoryItem(NowPlaying *parent) :
void HistoryItem::update(const FileHandle &file)
{
if(file.isNull() || (!m_history.isEmpty() && m_history.front() == file))
if(file.isNull() || (!m_history.isEmpty() && m_history.front().file == file))
return;
if(m_history.count() >= 10)
m_history.remove(m_history.fromLast());
QString format = "<br /><a href=\"#\"><font size=\"-2\">%1</font></a>";
QString format = "<br /><a href=\"%1\"><font size=\"-2\">%2</font></a>";
QString current = QString("<b>%1</b>").arg(i18n("History"));
QString previous;
for(FileHandleList::ConstIterator it = m_history.begin();
for(QValueList<Item>::ConstIterator it = m_history.begin();
it != m_history.end(); ++it)
{
previous = current;
current.append(format.arg(QStyleSheet::escape((*it).tag()->title())));
current.append(format.arg((*it).anchor).arg(QStyleSheet::escape((*it).file.tag()->title())));
setText(current);
if(heightForWidth(width()) > imageSize) {
setText(previous);
......@@ -260,7 +262,28 @@ void HistoryItem::update(const FileHandle &file)
}
}
m_history.prepend(file);
m_history.prepend(Item(KApplication::randomString(20),
file, Playlist::playingItem()->playlist()));
}
void HistoryItem::openLink(const QString &link)
{
for(QValueList<Item>::ConstIterator it = m_history.begin();
it != m_history.end(); ++it)
{
if((*it).anchor == link) {
if((*it).playlist) {
CollectionListItem *collectionItem =
CollectionList::instance()->lookup((*it).file.absFilePath());
PlaylistItem *item = collectionItem->itemForPlaylist((*it).playlist);
(*it).playlist->clearSelection();
(*it).playlist->setSelected(item, true);
(*it).playlist->ensureItemVisible(item);
NowPlayingItem::parent()->collection()->raise((*it).playlist);
}
break;
}
}
}
#include "nowplaying.moc"
......
......@@ -20,11 +20,14 @@
#include <qhbox.h>
#include <qlabel.h>
#include <qguardedptr.h>
#include "filehandle.h"
#include "playlist.h"
class NowPlayingItem;
class PlaylistCollection;
class Playlist;
/**
* This is the widget that holds all of the other items and handles updating them
......@@ -125,9 +128,21 @@ class HistoryItem : public LinkLabel, public NowPlayingItem
public:
HistoryItem(NowPlaying *parent);
virtual void update(const FileHandle &file);
virtual void openLink(const QString &link);
private:
FileHandleList m_history;
struct Item
{
Item() {}
Item(const QString &a, const FileHandle &f, Playlist *p)
: anchor(a), file(f), playlist(p) {}
QString anchor;
FileHandle file;
QGuardedPtr<Playlist> playlist;
};
QValueList<Item> m_history;
LinkLabel *m_label;
};
......
......@@ -567,6 +567,13 @@ Playlist *PlaylistCollection::visiblePlaylist() const
return static_cast<Playlist *>(m_playlistStack->visibleWidget());
}
void PlaylistCollection::raise(Playlist *playlist)
{
playlist->setSearchEnabled(m_searchEnabled);
m_playlistStack->raiseWidget(playlist);
dataChanged();
}
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
......@@ -576,13 +583,6 @@ QWidgetStack *PlaylistCollection::playlistStack() const
return m_playlistStack;
}
void PlaylistCollection::raise(Playlist *playlist)
{
playlist->setSearchEnabled(m_searchEnabled);
m_playlistStack->raiseWidget(playlist);
dataChanged();
}
void PlaylistCollection::setupPlaylist(Playlist *playlist, const QString &)
{
if(!playlist->fileName().isNull())
......
......@@ -138,11 +138,15 @@ public:
*/
virtual Playlist *visiblePlaylist() const;
/**
* Makes \a playlist the currently visible playlist.
*/
virtual void raise(Playlist *playlist);
class ActionHandler;
protected:
virtual QWidgetStack *playlistStack() const;
virtual void raise(Playlist *playlist);
virtual void setupPlaylist(Playlist *playlist, const QString &iconName);
bool importPlaylists() const;
......
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