blob: 0f43266b63d52bb1c5b86c6b10c78b1b5a34ba58 (
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
83
|
#ifndef INDEXERWIDGET_H
#define INDEXERWIDGET_H
#include <QWidget>
#include <QThread>
#include <QMutex>
#include <QSqlDatabase>
#include "taglib/fileref.h"
class QMenu;
class QAction;
class QTextEdit;
class BeetReader;
struct BeetObject;
class IndexerWidget : public QWidget {
Q_OBJECT
public:
explicit IndexerWidget(QWidget *parent = 0);
public slots:
void startIndexing();
void stopIndexing();
void addToLog(QString msg);
void addToError(QString msg);
private:
QTextEdit *mLog;
QTextEdit *mError;
QVector<QMenu*> mMenus;
QAction *mStartIndexingA;
QAction *mStopIndexingA;
BeetReader *mReader;
};
class BeetReader : public QThread {
Q_OBJECT
public:
explicit BeetReader();
virtual void run();
void cancel();
signals:
void message(const QString &msg);
void errorMsg(const QString &msg);
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);
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;
};
struct BeetObject {
QString artist;
QString album;
quint16 year;
QString genre;
quint16 pos;
QString title;
QString fullpath;
};
#endif // INDEXERWIDGET_H
|