blob: 7b907f5192de9f62bed6fc474161ed58dc233401 (
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
|
#ifndef INDEXERWIDGET_H
#define INDEXERWIDGET_H
#include <QWidget>
#include <QThread>
#include <QMutex>
#include <QSqlDatabase>
#include "taglib/fileref.h"
class QTextEdit;
class QProgressBar;
class QLabel;
class BeetReader;
class IndexerWidget : public QWidget {
Q_OBJECT
public:
explicit IndexerWidget(QWidget *parent = 0);
public slots:
void startIndexing();
void stopIndexing();
void addToError(QString msg);
void setupProgress(int max);
void progress(int cur);
private:
QTextEdit *mError;
QProgressBar *mProgress;
QLabel *mProgressCount;
int mMax;
BeetReader *mReader;
};
class BeetReader : public QThread {
Q_OBJECT
public:
explicit BeetReader();
virtual void run();
void cancel();
signals:
void errorMsg(const QString &msg);
void totalCount(int count);
void progress(int cur);
void cleared();
private:
QString toQString(TagLib::String string);
void clearAll();
int doArtist(QString name);
int doGenre(QString name);
int doAlbum(QString name, int year);
void doSong(QString title, int pos, int album, int genre, int artist, QString fullpath, int length);
QMutex mCancelMx;
bool mCanceled;
QSqlDatabase mDb;
QHash<QString, int> mArtistH;
QHash<QString, int> mGenreH;
QHash<QString, int> mAlbumH;
QSqlQuery *mInsertArtistsQ;
QSqlQuery *mCurArtistQ;
QSqlQuery *mInsertGenresQ;
QSqlQuery *mCurGenresQ;
QSqlQuery *mInsertAlbumQ;
QSqlQuery *mCurAlbumQ;
QSqlQuery *mInsertSongQ;
};
#endif // INDEXERWIDGET_H
|