![]() |
Mixxx
|
00001 /* 00002 * browsethread.h (C) 2011 Tobias Rafreider 00003 */ 00004 00005 #ifndef BROWSETHREAD_H 00006 #define BROWSETHREAD_H 00007 00008 #include <QThread> 00009 #include <QMutex> 00010 #include <QWaitCondition> 00011 #include <QStandardItem> 00012 #include <QList> 00013 00014 /* 00015 * This class is a singleton and represents a thread 00016 * that is used to read ID3 metadata 00017 * from a particular folder. 00018 * 00019 * The BroseTableModel uses this class. 00020 * Note: Don't call getInstance() from places 00021 * other than the GUI thread. 00022 */ 00023 class BrowseTableModel; 00024 00025 class BrowseThread : public QThread { 00026 Q_OBJECT 00027 public: 00028 void executePopulation(QString& path, BrowseTableModel* client); 00029 void run(); 00030 static BrowseThread* getInstance(); 00031 static void destroyInstance(); 00032 00033 signals: 00034 void rowsAppended(const QList< QList<QStandardItem*> >&, BrowseTableModel*); 00035 void clearModel(BrowseTableModel*); 00036 00037 private: 00038 BrowseThread(QObject *parent = 0); 00039 virtual ~BrowseThread(); 00040 00041 void populateModel(); 00042 00043 QMutex m_mutex; 00044 QWaitCondition m_locationUpdated; 00045 volatile bool m_bStopThread; 00046 00047 // You must hold m_path_mutex to touch m_path or m_model_observer 00048 QMutex m_path_mutex; 00049 QString m_path; 00050 BrowseTableModel* m_model_observer; 00051 00052 static BrowseThread* m_instance; 00053 }; 00054 00055 #endif // BROWSETHREAD_H