folderplaylist.cpp 2.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/***************************************************************************
    copyright            : (C) 2004 by Scott Wheeler
    email                : wheeler@kde.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "folderplaylist.h"
16 17 18
#include "playlistcollection.h"

#include <qtimer.h>
19 20 21 22 23 24 25

////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////

FolderPlaylist::FolderPlaylist(PlaylistCollection *collection, const QString &folder,
                               const QString &name) :
26
    Playlist(collection, name, "folder"),
27 28
    m_folder(folder)
{
29
    QTimer::singleShot(0, this, SLOT(slotReload()));
30 31 32 33 34 35 36
}

FolderPlaylist::~FolderPlaylist()
{

}

37 38 39 40 41 42 43 44
QString FolderPlaylist::folder() const
{
    return m_folder;
}

void FolderPlaylist::setFolder(const QString &s)
{
    m_folder = s;
45
    QTimer::singleShot(0, this, SLOT(slotReload()));
46 47 48 49 50 51
}

////////////////////////////////////////////////////////////////////////////////
// private slots
////////////////////////////////////////////////////////////////////////////////

52
void FolderPlaylist::slotReload()
53 54
{
    if(!m_folder.isNull())
55
        addFiles(m_folder);
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
}

////////////////////////////////////////////////////////////////////////////////
// helper functions
////////////////////////////////////////////////////////////////////////////////

QDataStream &operator<<(QDataStream &s, const FolderPlaylist &p)
{
    s << p.name()
      << p.folder();
    return s;
}

QDataStream &operator>>(QDataStream &s, FolderPlaylist &p)
{
    QString name;
    QString folder;
    s >> name
      >> folder;

    p.setFolder(folder);
    p.setName(name);
    return s;
}

81
#include "folderplaylist.moc"