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