1
/****************************************************************************************
2
 * Copyright (c) 2008 Ian Monroe <ian@monroe.nu>                                        *
3
 *                                                                                      *
4
 * This program is free software; you can redistribute it and/or modify it under        *
5
 * the terms of the GNU General Public License as published by the Free Software        *
6
 * Foundation; either version 2 of the License, or (at your option) version 3 or        *
7
 * any later version accepted by the membership of KDE e.V. (or its successor approved  *
8
 * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of  *
9
 * version 3 of the license.                                                            *
10
 *                                                                                      *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
12
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
13
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
14
 *                                                                                      *
15
 * You should have received a copy of the GNU General Public License along with         *
16
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
17
 ****************************************************************************************/
18
19
#ifndef AMAROK_DIRECTORYLOADER_H
20
#define AMAROK_DIRECTORYLOADER_H
21
22
#include <QObject>
23
24
#include "core/meta/Meta.h"
25
26
#include <KFileItem>
27
28
class KJob;
29
namespace KIO {
30
    class Job;
31
    class UDSEntry;
32
    typedef QList< UDSEntry >  UDSEntryList;
33
    typedef QList< KFileItem > KFileItemList;
34
}
35
36
37
38
class DirectoryLoader : public QObject
39
{
40
    Q_OBJECT
41
    public:
42
        DirectoryLoader();
43
        ~DirectoryLoader();
44
45
        void insertAtRow( int row ); // call before init to tell the loader the row to start inserting tracks
46
        void init( const QList<KUrl>& urls ); //!< list all
47
        void init( const QList<QUrl>& urls ); //!< convience
48
49
    signals:
50
        void finished( const Meta::TrackList& );
51
52
    private slots:
53
        void directoryListResults( KIO::Job *job, const KIO::UDSEntryList &list );
54
        void listJobFinished( KJob* );
55
        void doInsertAtRow();
56
57
    private:
58
        void finishUrlList();
59
        static bool directorySensitiveLessThan( const KFileItem& item1, const KFileItem& item2 );
60
        /**
61
         * the number of directory list operations. this is used so that
62
         * the last directory operations knows its the last */
63
        int m_listOperations;
64
        bool m_localConnection; //!< was insertAtRow called? otherwise finishUrlList should deleteLater
65
        int m_row; //!< for insertAtRow
66
        KIO::KFileItemList m_expanded;
67
        Meta::TrackList m_tracks; //!< the tracks found. they get all sorted at the end.
68
};
69
#endif