Commit b03587e5 authored by Scott Wheeler's avatar Scott Wheeler

Added playlist count thing-a-ma-bob.

svn path=/trunk/kdemultimedia/juk/; revision=193152
parent 391bf34a
......@@ -17,6 +17,7 @@
#include <kurl.h>
#include <kurldrag.h>
#include <klocale.h>
#include <kdebug.h>
#include "collectionlist.h"
......@@ -75,7 +76,7 @@ PlaylistItem *CollectionList::createItem(const QFileInfo &file, QListViewItem *)
// protected methods
////////////////////////////////////////////////////////////////////////////////
CollectionList::CollectionList(PlaylistSplitter *s, QWidget *parent) : Playlist(s, parent, "collectionList")
CollectionList::CollectionList(PlaylistSplitter *s, QWidget *parent) : Playlist(s, parent, i18n("Collection List"))
{
}
......
......@@ -20,6 +20,7 @@
#include <kiconloader.h>
#include <kcmdlineargs.h>
#include <kstatusbar.h>
#include <kconfig.h>
#include <kdebug.h>
#include <qinputdialog.h>
......@@ -76,6 +77,8 @@ void JuK::setupLayout()
statusLabel = new StatusLabel(statusBar());
statusBar()->addWidget(statusLabel, 1);
connect(splitter, SIGNAL(selectedPlaylistCountChanged(int)), statusLabel, SLOT(setPlaylistCount(int)));
splitter->setFocus();
}
......@@ -258,6 +261,14 @@ void JuK::playlistChanged(Playlist *list)
renamePlaylistAction->setEnabled(true);
deleteItemPlaylistAction->setEnabled(true);
}
updatePlaylistInfo();
}
void JuK::updatePlaylistInfo()
{
statusLabel->setPlaylistName(splitter->selectedPlaylistName());
statusLabel->setPlaylistCount(splitter->selectedPlaylistCount());
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -96,6 +96,7 @@ private:
private slots:
void playlistChanged(Playlist *list);
void updatePlaylistInfo();
// file menu
void remove();
......
......@@ -16,6 +16,7 @@
***************************************************************************/
#include <kapplication.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include <kurl.h>
#include <kurldrag.h>
......@@ -186,6 +187,7 @@ void Playlist::clearItems(const PlaylistItemList &items)
delete(it.current());
++it;
}
emit(numberOfItemsChanged(this));
}
QStringList Playlist::files() const
......@@ -245,6 +247,7 @@ void Playlist::remove(const PlaylistItemList &items)
}
}
emit(numberOfItemsChanged(this));
}
}
......@@ -403,10 +406,13 @@ PlaylistItem *Playlist::createItem(const QFileInfo &file, QListViewItem *after)
if(item && members.contains(file.absFilePath()) == 0 || allowDuplicates) {
members.append(file.absFilePath());
PlaylistItem *i;
if(after)
return(new PlaylistItem(item, this, after));
i = new PlaylistItem(item, this, after);
else
return(new PlaylistItem(item, this));
i = new PlaylistItem(item, this);
emit(numberOfItemsChanged(this));
return(i);
}
else
return(0);
......
......@@ -108,6 +108,7 @@ public:
* extension. If playlistName does have a value, this returns that.
*/
QString name() const;
/**
* This sets a name for the playlist that is \e different from the file name.
*/
......@@ -184,6 +185,8 @@ signals:
* playlist's name has changed.
*/
void nameChanged(const QString &fileName);
void numberOfItemsChanged(Playlist *);
};
#endif
......@@ -15,12 +15,15 @@
* *
***************************************************************************/
#include <kfiledialog.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kapplication.h>
#include <klocale.h>
#include <kdebug.h>
#include <qinputdialog.h>
#include <qwidgetstack.h>
#include "playlistsplitter.h"
#include "playlist.h"
......@@ -43,10 +46,9 @@ void processEvents()
// public methods
////////////////////////////////////////////////////////////////////////////////
PlaylistSplitter::PlaylistSplitter(QWidget *parent, bool restoreOnLoad, const char *name) : QSplitter(Qt::Horizontal, parent, name)
PlaylistSplitter::PlaylistSplitter(QWidget *parent, bool restoreOnLoad, const char *name) : QSplitter(Qt::Horizontal, parent, name),
restore(restoreOnLoad)
{
restore = restoreOnLoad;
setupLayout();
readConfig();
mediaExtensions.append("mp3");
......@@ -121,6 +123,24 @@ QString PlaylistSplitter::extensionsString(const QStringList &extensions, const
return(s);
}
QString PlaylistSplitter::selectedPlaylistName() const
{
if(playlistStack->visibleWidget()) {
Playlist *p = static_cast<Playlist *>(playlistStack->visibleWidget());
return(p->name());
}
return(QString::null);
}
int PlaylistSplitter::selectedPlaylistCount() const
{
if(playlistStack->visibleWidget()) {
Playlist *p = static_cast<Playlist *>(playlistStack->visibleWidget());
return(p->childCount());
}
return(0);
}
QStringList PlaylistSplitter::playlistExtensions() const
{
return(listExtensions);
......@@ -260,6 +280,7 @@ Playlist *PlaylistSplitter::createPlaylist(const QString &name)
connect(p, SIGNAL(selectionChanged(const PlaylistItemList &)), editor, SLOT(setItems(const PlaylistItemList &)));
connect(p, SIGNAL(doubleClicked(QListViewItem *)), this, SIGNAL(playlistDoubleClicked(QListViewItem *)));
connect(p, SIGNAL(collectionChanged()), editor, SLOT(updateCollection()));
connect(p, SIGNAL(numberOfItemsChanged(Playlist *)), this, SLOT(playlistCountChanged(Playlist *)));
playlistBox->sort();
return(p);
}
......@@ -284,6 +305,7 @@ Playlist *PlaylistSplitter::openPlaylist(const QString &playlistFile)
connect(p, SIGNAL(selectionChanged(const PlaylistItemList &)), editor, SLOT(setItems(const PlaylistItemList &)));
connect(p, SIGNAL(doubleClicked(QListViewItem *)), this, SIGNAL(playlistDoubleClicked(QListViewItem *)));
connect(p, SIGNAL(collectionChanged()), editor, SLOT(updateCollection()));
connect(p, SIGNAL(numberOfItemsChanged(Playlist *)), this, SLOT(playlistCountChanged(Playlist *)));
PlaylistBoxItem *i = new PlaylistBoxItem(playlistBox, SmallIcon("midi", 32), p->name(), p);
p->setPlaylistBoxItem(i);
playlistBox->sort();
......@@ -357,6 +379,7 @@ void PlaylistSplitter::setupLayout()
editor, SLOT(setItems(const PlaylistItemList &)));
connect(collection, SIGNAL(doubleClicked(QListViewItem *)), this, SIGNAL(playlistDoubleClicked(QListViewItem *)));
connect(collection, SIGNAL(collectionChanged()), editor, SLOT(updateCollection()));
connect(collection, SIGNAL(numberOfItemsChanged(Playlist *)), this, SLOT(playlistCountChanged(Playlist *)));
// Show the collection on startup.
playlistBox->setSelected(collectionBoxItem, true);
......@@ -448,6 +471,7 @@ void PlaylistSplitter::changePlaylist(PlaylistBoxItem *item)
playlistStack->raiseWidget(item->playlist());
editor->setItems(playlistSelection());
emit(playlistChanged(item->playlist()));
emit(playlistChanged());
}
}
......@@ -457,4 +481,10 @@ void PlaylistSplitter::playlistBoxDoubleClicked(PlaylistBoxItem *item)
emit(playlistDoubleClicked(item->playlist()->firstChild()));
}
void PlaylistSplitter::playlistCountChanged(Playlist *p)
{
if(p && p == playlistStack->visibleWidget())
emit(selectedPlaylistCountChanged(p->childCount()));
}
#include "playlistsplitter.moc"
......@@ -18,15 +18,13 @@
#ifndef PLAYLISTSPLITTER_H
#define PLAYLISTSPLITTER_H
#include <kfiledialog.h>
#include <klocale.h>
#include <qsplitter.h>
#include <qwidgetstack.h>
#include "playlistitem.h"
#include "playlistbox.h"
class QWidgetStack;
class Playlist;
class PlaylistBoxItem;
class CollectionList;
......@@ -71,6 +69,16 @@ public:
*/
QStringList playlistExtensions() const;
/**
* Returns the name of the currently selected playlist.
*/
QString selectedPlaylistName() const;
/**
* Returns the number of items in the currently selected playlist.
*/
int selectedPlaylistCount() const;
// static methods
/**
......@@ -182,10 +190,13 @@ private slots:
// playlist box slots
void changePlaylist(PlaylistBoxItem *item);
void playlistBoxDoubleClicked(PlaylistBoxItem *item);
void playlistCountChanged(Playlist *p);
signals:
void playlistDoubleClicked(QListViewItem *);
void playlistChanged(Playlist *);
void playlistChanged();
void selectedPlaylistCountChanged(int);
};
#endif
......@@ -17,6 +17,7 @@
#include <kpushbutton.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kdebug.h>
#include <qevent.h>
......@@ -120,6 +121,20 @@ void StatusLabel::setPlayingItem(PlaylistItem *item)
clear();
}
void StatusLabel::setPlaylistName(const QString &t)
{
playlistName = t;
if(!playingItem)
playlistLabel->setText(playlistName);
}
void StatusLabel::setPlaylistCount(int c)
{
playlistCount = c;
if(!playingItem)
trackLabel->setText(QString::number(playlistCount) + " " + i18n("Item(s)"));
}
void StatusLabel::clear()
{
playlistLabel->clear();
......@@ -127,6 +142,9 @@ void StatusLabel::clear()
playingItem = 0;
setItemTotalTime(0);
setItemCurrentTime(0);
setPlaylistName(playlistName);
setPlaylistCount(playlistCount);
}
void StatusLabel::setItemTotalTime(int time)
......
......@@ -32,7 +32,20 @@ public:
StatusLabel(QWidget *parent = 0, const char *name = 0);
virtual ~StatusLabel();
public slots:
void setPlayingItem(PlaylistItem *item);
/**
* Set the playlist name. This text will only be used when there is not an
* item playing.
*/
void setPlaylistName(const QString &t);
void setPlaylistCount(int c);
/**
* This clears the information about the playing items and frees that status
* bar up for playlist information.
*/
void clear();
/**
......@@ -47,6 +60,8 @@ private:
void updateTime();
virtual bool eventFilter(QObject *o, QEvent *e);
QString playlistName;
int playlistCount;
QLabel *playlistLabel;
QLabel *trackLabel;
QLabel *itemTimeLabel;
......
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