blob: d4ee70d61e08d00db0dbd16f6aaaf5f882bf4128 (
plain)
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
79
80
81
82
|
// traktorfeature.h
// Created 9/26/2010 by Tobias Rafreider
#ifndef TRAKTOR_FEATURE_H
#define TRAKTOR_FEATURE_H
#include <QStringListModel>
#include <QtSql>
#include <QXmlStreamReader>
#include <QFuture>
#include <QtConcurrentRun>
#include <QFutureWatcher>
#include "library/baseexternallibraryfeature.h"
#include "library/baseexternaltrackmodel.h"
#include "library/baseexternalplaylistmodel.h"
#include "library/treeitemmodel.h"
class TraktorTrackModel : public BaseExternalTrackModel {
public:
TraktorTrackModel(QObject* parent,
TrackCollectionManager* pTrackCollectionManager,
QSharedPointer<BaseTrackCache> trackSource);
virtual bool isColumnHiddenByDefault(int column);
};
class TraktorPlaylistModel : public BaseExternalPlaylistModel {
public:
TraktorPlaylistModel(QObject* parent,
TrackCollectionManager* pTrackCollectionManager,
QSharedPointer<BaseTrackCache> trackSource);
virtual bool isColumnHiddenByDefault(int column);
};
class TraktorFeature : public BaseExternalLibraryFeature {
Q_OBJECT
public:
TraktorFeature(Library* pLibrary, UserSettingsPointer pConfig);
virtual ~TraktorFeature();
QVariant title() override;
QIcon getIcon() override;
static bool isSupported();
TreeItemModel* getChildModel();
public slots:
void activate();
void activateChild(const QModelIndex& index);
void refreshLibraryModels();
void onTrackCollectionLoaded();
private:
virtual BaseSqlTableModel* getPlaylistModelForPlaylist(QString playlist);
TreeItem* importLibrary(QString file);
// parses a track in the music collection
void parseTrack(QXmlStreamReader &xml, QSqlQuery &query);
// Iterates over all playliost and folders and constructs the childmodel
TreeItem* parsePlaylists(QXmlStreamReader &xml);
// processes a particular playlist
void parsePlaylistEntries(QXmlStreamReader &xml, QString playlist_path,
QSqlQuery query_insert_into_playlist, QSqlQuery query_insert_into_playlisttracks);
void clearTable(QString table_name);
static QString getTraktorMusicDatabase();
// private fields
TreeItemModel m_childModel;
// A separate db connection for the worker parsing thread
QSqlDatabase m_database;
TraktorTrackModel* m_pTraktorTableModel;
TraktorPlaylistModel* m_pTraktorPlaylistModel;
bool m_isActivated;
bool m_cancelImport;
QFutureWatcher<TreeItem*> m_future_watcher;
QFuture<TreeItem*> m_future;
QString m_title;
QSharedPointer<BaseTrackCache> m_trackSource;
QIcon m_icon;
};
#endif // TRAKTOR_FEATURE_H
|