Commit 8e33c743 authored by Scott Wheeler's avatar Scott Wheeler

Made it so that clicking on the label in the status bar finds the playlist

and item and ensures that they are visible.

svn path=/trunk/kdemultimedia/juk/; revision=184508
parent f63cf17e
......@@ -124,6 +124,44 @@ QStringList PlaylistSplitter::playlistExtensions() const
return(listExtensions);
}
void PlaylistSplitter::setSelected(PlaylistItem *i)
{
// Hu hu! See how much crap I can pack into just one pointer to a
// PlaylistItem! Sensitive viewers may want to close their eyes for the
// next few lines.
if(i) {
// Get the playlist associated with the playing item and make set the
// playing item to be both selected and visible.
Playlist *l = dynamic_cast<Playlist *>(i->listView());
if(l) {
l->clearSelection();
l->setSelected(i, true);
l->ensureItemVisible(i);
// Now move on to the PlaylistBox. The Playlist knows which
// PlaylistBoxItem that it is associated with, so we'll just get
// that and then figure out the PlaylistBox from there.
//
// Once we have that we can set the appropriate Playlist to be
// visible.
if(l->playlistBoxItem() && l->playlistBoxItem()->listBox()) {
QListBox *b = l->playlistBoxItem()->listBox();
b->clearSelection();
b->setSelected(l->playlistBoxItem(), true);
b->setCurrentItem(l->playlistBoxItem());
b->ensureCurrentVisible();
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
......
......@@ -66,18 +66,24 @@ public:
*/
PlaylistItem *playlistFirstItem() const;
// static (non-initialization) methods
/**
* Returns a lif of the extensions that are used for playlists.
*/
QStringList playlistExtensions() const;
// static methods
/**
* Merges a list of file extensions, and a description of those types into a
* format that makes sense to KFileDialog. If type = QString::null then no
* description is appended.
*/
static QString extensionsString(const QStringList &extensions, const QString &type = QString::null);
/**
* Set the selection to the specified item (for both the PlaylistBox and
* Playlist) and ensure that those selections are visible.
*/
static void setSelected(PlaylistItem *i);
public slots:
void open();
......
......@@ -15,14 +15,24 @@
* *
***************************************************************************/
#include <kdebug.h>
#include <qevent.h>
#include "statuslabel.h"
#include "playlistitem.h"
#include "playlist.h"
#include "playlistbox.h"
#include "playlistsplitter.h"
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
StatusLabel::StatusLabel(QWidget *parent, const char *name) : QHBox(parent, name)
{
trackLabel = new QLabel(this, "trackLabel");
trackLabel->installEventFilter(this);
}
StatusLabel::~StatusLabel()
......@@ -38,8 +48,8 @@ void StatusLabel::setPlayingItem(PlaylistItem *item)
Playlist *p = static_cast<Playlist *>(item->listView());
if(p && p->playlistBoxItem()) {
QString label = p->playlistBoxItem()->text()
+ " / " + item->text(PlaylistItem::ArtistColumn)
+ " - " + item->text(PlaylistItem::TrackColumn);
+ " / " + item->text(PlaylistItem::ArtistColumn)
+ " - <i>" + item->text(PlaylistItem::TrackColumn) + "</i>";
trackLabel->setText(label);
}
else
......@@ -52,6 +62,22 @@ void StatusLabel::setPlayingItem(PlaylistItem *item)
void StatusLabel::clear()
{
trackLabel->clear();
playingItem = 0;
}
////////////////////////////////////////////////////////////////////////////////
// private methods
////////////////////////////////////////////////////////////////////////////////
bool StatusLabel::eventFilter(QObject *o, QEvent *e)
{
if(o && o == trackLabel &&
e && e->type() == QEvent::MouseButtonPress) {
PlaylistSplitter::setSelected(playingItem);
return(true);
}
return(false);
}
#include "statuslabel.moc"
......@@ -36,6 +36,8 @@ public:
void clear();
private:
virtual bool eventFilter(QObject *o, QEvent *e);
QLabel *trackLabel;
PlaylistItem *playingItem;
};
......
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