![]() |
Mixxx
|
00001 // itunesfeaturefeature.h 00002 // Created 8/23/2009 by RJ Ryan (rryan@mit.edu) 00003 00004 #ifndef ITUNESFEATURE_H 00005 #define ITUNESFEATURE_H 00006 00007 #include <QStringListModel> 00008 #include <QtSql> 00009 #include <QFuture> 00010 #include <QtConcurrentRun> 00011 #include <QFutureWatcher> 00012 00013 #include "library/libraryfeature.h" 00014 #include "library/trackcollection.h" 00015 #include "library/treeitemmodel.h" 00016 #include "library/treeitem.h" 00017 00018 //class ITunesPlaylistModel; 00019 class ITunesTrackModel; 00020 class ITunesPlaylistModel; 00021 00022 00023 class ITunesFeature : public LibraryFeature { 00024 Q_OBJECT 00025 public: 00026 ITunesFeature(QObject* parent, TrackCollection* pTrackCollection); 00027 virtual ~ITunesFeature(); 00028 static bool isSupported(); 00029 00030 QVariant title(); 00031 QIcon getIcon(); 00032 00033 bool dropAccept(QUrl url); 00034 bool dropAcceptChild(const QModelIndex& index, QUrl url); 00035 bool dragMoveAccept(QUrl url); 00036 bool dragMoveAcceptChild(const QModelIndex& index, QUrl url); 00037 00038 TreeItemModel* getChildModel(); 00039 00040 public slots: 00041 void activate(); 00042 void activate(bool forceReload); 00043 void activateChild(const QModelIndex& index); 00044 void onRightClick(const QPoint& globalPos); 00045 void onRightClickChild(const QPoint& globalPos, QModelIndex index); 00046 void onLazyChildExpandation(const QModelIndex& index); 00047 void onTrackCollectionLoaded(); 00048 00049 private: 00050 static QString getiTunesMusicPath(); 00051 //returns the invisible rootItem for the sidebar model 00052 TreeItem* importLibrary(); 00053 void parseTracks(QXmlStreamReader &xml); 00054 void parseTrack(QXmlStreamReader &xml, QSqlQuery &query); 00055 TreeItem* parsePlaylists(QXmlStreamReader &xml); 00056 void parsePlaylist(QXmlStreamReader &xml, QSqlQuery &query1, QSqlQuery &query2, TreeItem*); 00057 void clearTable(QString table_name); 00058 bool readNextStartElement(QXmlStreamReader& xml); 00059 00060 ITunesTrackModel* m_pITunesTrackModel; 00061 ITunesPlaylistModel* m_pITunesPlaylistModel; 00062 TreeItemModel m_childModel; 00063 QStringList m_playlists; 00064 TrackCollection* m_pTrackCollection; 00065 //a new DB connection for the worker thread 00066 QSqlDatabase m_database; 00067 bool m_cancelImport; 00068 bool m_isActivated; 00069 QString m_dbfile; 00070 00071 QFutureWatcher<TreeItem*> m_future_watcher; 00072 QFuture<TreeItem*> m_future; 00073 QString m_title; 00074 00075 static const QString ITDB_PATH_KEY; 00076 }; 00077 00078 #endif /* ITUNESFEATURE_H */