Commit 59a684a1 authored by Scott Wheeler's avatar Scott Wheeler

Removed more autogenerated files. I also added the feature that double

clicking on a playlist starts playing the first item in the list.

svn path=/trunk/kdemultimedia/juk/; revision=180393
parent 6b4b559b
This diff is collapsed.
......@@ -76,7 +76,7 @@ private:
bool trackPositionDragging;
bool noSeek;
const static int pollInterval = 800;
static const int pollInterval = 800;
private slots:
void playlistChanged(Playlist *list);
......
......@@ -42,13 +42,18 @@
Playlist::Playlist(QWidget *parent, const char *name) : KListView(parent, name)
{
setup();
internalFile = true;
fileName = QString::null;
}
Playlist::Playlist(const QFileInfo &playlistFile, QWidget *parent, const char *name) : KListView(parent, name)
{
setup();
QFile file(playlistFile.absFilePath());
internalFile = false;
fileName = playlistFile.absFilePath();
QFile file(fileName);
file.open(IO_ReadOnly);
QTextStream stream(&file);
......@@ -180,6 +185,16 @@ PlaylistItem *Playlist::nextItem(PlaylistItem *current, bool random)
return(i);
}
bool Playlist::isInternalFile() const
{
return(internalFile);
}
QString Playlist::file() const
{
return(fileName);
}
////////////////////////////////////////////////////////////////////////////////
// protected members
////////////////////////////////////////////////////////////////////////////////
......
......@@ -33,6 +33,8 @@ public:
Playlist(const QFileInfo &playlistFile, QWidget *parent = 0, const char *name = 0);
virtual ~Playlist();
// "File Menu" like operations. "Open" is the constructor above.
virtual void save();
virtual void saveAs();
......@@ -59,6 +61,9 @@ public:
of PlaylistItems virtual. */
virtual PlaylistItem *createItem(const QFileInfo &file);
bool isInternalFile() const;
QString file() const;
protected:
virtual QDragObject *dragObject();
virtual void contentsDropEvent(QDropEvent *e);
......@@ -71,6 +76,14 @@ private:
int processed;
bool allowDuplicates;
// If a file is "internal" it is not one that the user has yet chosen to
// save. However for the purposes of being able to restore a user's
// loaded playlists it will be saved "internally" in:
// $KDEHOME/share/apps/juk/playlists.
bool internalFile;
QString fileName;
private slots:
void emitSelected();
......
......@@ -17,9 +17,11 @@
#include <kiconloader.h>
#include <kurldrag.h>
#include <kmessagebox.h>
#include <klocale.h>
#include <kdebug.h>
#include <qfile.h>
#include <qdrawutil.h>
#include <qinputdialog.h>
......@@ -49,7 +51,10 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const char *name) : KListBox(
setAcceptDrops(true);
connect(this, SIGNAL(currentChanged(QListBoxItem *)),
this, SLOT(currentItemChanged(QListBoxItem *)));
this, SLOT(playlistChanged(QListBoxItem *)));
connect(this, SIGNAL(doubleClicked(QListBoxItem *)),
this, SLOT(playlistDoubleClicked(QListBoxItem *)));
}
PlaylistBox::~PlaylistBox()
......@@ -137,7 +142,28 @@ void PlaylistBox::deleteItem()
void PlaylistBox::deleteItem(PlaylistBoxItem *item)
{
if(item) {
if(item && item->playlist()) {
// If the file is "internal" (not loaded from a file and not yet saved),
// or the file name is null, or the user specifically chooses to delete
// the file then delete it. Otherwise, just remove the file from the
// PlaylistBox.
if(item->playlist()->file() != QString::null) {
if(item->playlist()->isInternalFile())
QFile::remove(item->playlist()->file());
else {
int remove = KMessageBox::warningYesNoCancel(this, i18n("Do you want to delete this file from the disk as well?"));
if(remove == KMessageBox::Yes) {
if(!QFile::remove(item->playlist()->file()))
KMessageBox::sorry(this, i18n("Could not delete the specified file."));
}
else if(remove == KMessageBox::Cancel)
return;
}
}
nameList.remove(item->text());
delete(item->playlist());
delete(item);
......@@ -233,13 +259,20 @@ void PlaylistBox::addName(const QString &name)
// PlaylistBox private slots
////////////////////////////////////////////////////////////////////////////////
void PlaylistBox::currentItemChanged(QListBoxItem *item)
void PlaylistBox::playlistChanged(QListBoxItem *item)
{
PlaylistBoxItem *i = dynamic_cast<PlaylistBoxItem *>(item);
if(i)
emit(currentChanged(i));
}
void PlaylistBox::playlistDoubleClicked(QListBoxItem *item)
{
PlaylistBoxItem *i = dynamic_cast<PlaylistBoxItem *>(item);
if(i)
emit(doubleClicked(i));
}
void PlaylistBox::drawContextMenu(QListBoxItem *item, const QPoint &point)
{
PlaylistBoxItem *i = static_cast<PlaylistBoxItem *>(item);
......
......@@ -76,7 +76,8 @@ private:
private slots:
/** Catches QListBox::currentChanged(QListBoxItem *), does a cast and then re-emits
the signal as currentChanged(PlaylistBoxItem *). */
void currentItemChanged(QListBoxItem *item);
void playlistChanged(QListBoxItem *item);
void playlistDoubleClicked(QListBoxItem *item);
void drawContextMenu(QListBoxItem *item, const QPoint &point);
// context menu entries
void contextSave();
......@@ -88,6 +89,7 @@ private slots:
signals:
void currentChanged(PlaylistBoxItem *);
void doubleClicked(PlaylistBoxItem *);
#if QT_VERSION < 0x031000
......
......@@ -36,7 +36,7 @@ void processEvents()
static int processed = 0;
if(processed == 0)
kapp->processEvents();
processed = ( processed + 1 ) % 10;
processed = (processed + 1) % 10;
}
////////////////////////////////////////////////////////////////////////////////
......@@ -259,6 +259,7 @@ PlaylistSplitter::~PlaylistSplitter()
{
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
......@@ -283,7 +284,11 @@ void PlaylistSplitter::setupLayout()
// Make the connection that will update the selected playlist when a
// selection is made in the playlist box.
connect(playlistBox, SIGNAL(currentChanged(PlaylistBoxItem *)), this, SLOT(changePlaylist(PlaylistBoxItem *)));
connect(playlistBox, SIGNAL(currentChanged(PlaylistBoxItem *)),
this, SLOT(changePlaylist(PlaylistBoxItem *)));
connect(playlistBox, SIGNAL(doubleClicked(PlaylistBoxItem *)),
this, SLOT(playlistBoxDoubleClicked(PlaylistBoxItem *)));
// Create the collection list; this should always exist. This has a
// slightly different creation process than normal playlists (since it in
......@@ -345,4 +350,10 @@ void PlaylistSplitter::changePlaylist(PlaylistBoxItem *item)
}
}
void PlaylistSplitter::playlistBoxDoubleClicked(PlaylistBoxItem *item)
{
if(item && item->playlist() && item->playlist()->firstChild())
emit(playlistDoubleClicked(item->playlist()->firstChild()));
}
#include "playlistsplitter.moc"
......@@ -105,6 +105,7 @@ private:
private slots:
// playlist box slots
void changePlaylist(PlaylistBoxItem *item);
void playlistBoxDoubleClicked(PlaylistBoxItem *item);
signals:
void playlistDoubleClicked(QListViewItem *);
......
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