~ubuntu-branches/ubuntu/quantal/juk/quantal-updates

« back to all changes in this revision

Viewing changes to folderplaylist.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-06-14 17:25:43 UTC
  • Revision ID: package-import@ubuntu.com-20120614172543-nha6jki61ckag3cn
Tags: upstream-4.8.90+repack
ImportĀ upstreamĀ versionĀ 4.8.90+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    copyright            : (C) 2004 by Scott Wheeler
 
3
    email                : wheeler@kde.org
 
4
 ***************************************************************************/
 
5
 
 
6
/***************************************************************************
 
7
 *                                                                         *
 
8
 *   This program is free software; you can redistribute it and/or modify  *
 
9
 *   it under the terms of the GNU General Public License as published by  *
 
10
 *   the Free Software Foundation; either version 2 of the License, or     *
 
11
 *   (at your option) any later version.                                   *
 
12
 *                                                                         *
 
13
 ***************************************************************************/
 
14
 
 
15
#include "folderplaylist.h"
 
16
#include "playlistcollection.h"
 
17
#include "juk-exception.h"
 
18
 
 
19
#include <QTimer>
 
20
 
 
21
////////////////////////////////////////////////////////////////////////////////
 
22
// public methods
 
23
////////////////////////////////////////////////////////////////////////////////
 
24
 
 
25
FolderPlaylist::FolderPlaylist(PlaylistCollection *collection, const QString &folder,
 
26
                               const QString &name) :
 
27
    Playlist(collection, name, "folder"),
 
28
    m_folder(folder)
 
29
{
 
30
    QTimer::singleShot(0, this, SLOT(slotReload()));
 
31
}
 
32
 
 
33
FolderPlaylist::~FolderPlaylist()
 
34
{
 
35
 
 
36
}
 
37
 
 
38
QString FolderPlaylist::folder() const
 
39
{
 
40
    return m_folder;
 
41
}
 
42
 
 
43
void FolderPlaylist::setFolder(const QString &s)
 
44
{
 
45
    m_folder = s;
 
46
    QTimer::singleShot(0, this, SLOT(slotReload()));
 
47
}
 
48
 
 
49
////////////////////////////////////////////////////////////////////////////////
 
50
// private slots
 
51
////////////////////////////////////////////////////////////////////////////////
 
52
 
 
53
void FolderPlaylist::slotReload()
 
54
{
 
55
    if(!m_folder.isEmpty())
 
56
        addFiles(QStringList(m_folder));
 
57
}
 
58
 
 
59
////////////////////////////////////////////////////////////////////////////////
 
60
// helper functions
 
61
////////////////////////////////////////////////////////////////////////////////
 
62
 
 
63
QDataStream &operator<<(QDataStream &s, const FolderPlaylist &p)
 
64
{
 
65
    s << p.name()
 
66
      << p.folder();
 
67
    return s;
 
68
}
 
69
 
 
70
QDataStream &operator>>(QDataStream &s, FolderPlaylist &p)
 
71
{
 
72
    QString name;
 
73
    QString folder;
 
74
    s >> name
 
75
      >> folder;
 
76
 
 
77
    if(folder.isEmpty() || name.isEmpty())
 
78
        throw BICStreamException();
 
79
 
 
80
    p.setFolder(folder);
 
81
    p.setName(name);
 
82
    return s;
 
83
}
 
84
 
 
85
#include "folderplaylist.moc"
 
86
 
 
87
// vim: set et sw=4 tw=0 sta: