1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// itunesfeaturefeature.h
// Created 8/23/2009 by RJ Ryan (rryan@mit.edu)
#ifndef ITUNESFEATURE_H
#define ITUNESFEATURE_H
#include <QStringListModel>
#include <QtSql>
#include <QFuture>
#include <QtConcurrentRun>
#include <QFutureWatcher>
#include "library/baseexternallibraryfeature.h"
#include "library/trackcollection.h"
#include "library/treeitemmodel.h"
#include "library/treeitem.h"
//class ITunesPlaylistModel;
class ITunesTrackModel;
class ITunesPlaylistModel;
class ITunesFeature : public BaseExternalLibraryFeature {
Q_OBJECT
public:
ITunesFeature(QObject* parent, TrackCollection* pTrackCollection);
virtual ~ITunesFeature();
static bool isSupported();
QVariant title();
QIcon getIcon();
bool dropAccept(QUrl url);
bool dropAcceptChild(const QModelIndex& index, QUrl url);
bool dragMoveAccept(QUrl url);
bool dragMoveAcceptChild(const QModelIndex& index, QUrl url);
TreeItemModel* getChildModel();
public slots:
void activate();
void activate(bool forceReload);
void activateChild(const QModelIndex& index);
virtual void onRightClick(const QPoint& globalPos);
void onLazyChildExpandation(const QModelIndex& index);
void onTrackCollectionLoaded();
private:
virtual BaseSqlTableModel* getPlaylistModelForPlaylist(QString playlist);
static QString getiTunesMusicPath();
//returns the invisible rootItem for the sidebar model
TreeItem* importLibrary();
void parseTracks(QXmlStreamReader &xml);
void parseTrack(QXmlStreamReader &xml, QSqlQuery &query);
TreeItem* parsePlaylists(QXmlStreamReader &xml);
void parsePlaylist(QXmlStreamReader &xml, QSqlQuery &query1, QSqlQuery &query2, TreeItem*);
void clearTable(QString table_name);
bool readNextStartElement(QXmlStreamReader& xml);
ITunesTrackModel* m_pITunesTrackModel;
ITunesPlaylistModel* m_pITunesPlaylistModel;
TreeItemModel m_childModel;
QStringList m_playlists;
TrackCollection* m_pTrackCollection;
//a new DB connection for the worker thread
QSqlDatabase m_database;
bool m_cancelImport;
bool m_isActivated;
QString m_dbfile;
QFutureWatcher<TreeItem*> m_future_watcher;
QFuture<TreeItem*> m_future;
QString m_title;
static const QString ITDB_PATH_KEY;
};
#endif /* ITUNESFEATURE_H */
|