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