summaryrefslogtreecommitdiffstats
path: root/indexerwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indexerwidget.cpp')
-rw-r--r--indexerwidget.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/indexerwidget.cpp b/indexerwidget.cpp
index f30de80..49b221a 100644
--- a/indexerwidget.cpp
+++ b/indexerwidget.cpp
@@ -12,6 +12,8 @@
#include <QProgressBar>
#include "taglib/tag.h"
+#include "taglib/audioproperties.h"
+
#include "indexerwidget.h"
#include "globals.h"
@@ -91,7 +93,7 @@ BeetReader::BeetReader() : mCanceled(false){
mCurAlbumQ = new QSqlQuery(mDb);
mCurAlbumQ->prepare("SELECT currval('albums_ialbums_id__seq')");
mInsertSongQ = new QSqlQuery(mDb);
- mInsertSongQ->prepare("INSERT INTO songs (ialbums_id, sipos, ttitle, iartists_id, igenres_id, tfullpath) VALUES(:aid, :pos, :title, :iartistid, :igenid, :tfp)");
+ mInsertSongQ->prepare("INSERT INTO songs (ialbums_id, sipos, ttitle, iartists_id, igenres_id, tfullpath, ilength) VALUES(:aid, :pos, :title, :iartistid, :igenid, :tfp, :len)");
}
void BeetReader::run(){
@@ -124,6 +126,7 @@ void BeetReader::run(){
QString album = toQString(file.tag()->album());
QString title = toQString(file.tag()->title());
QString genre = toQString(file.tag()->genre());
+ int length = file.audioProperties()->lengthInSeconds();
quint16 track = file.tag()->track();
quint16 year = file.tag()->year();
@@ -131,7 +134,7 @@ void BeetReader::run(){
int artistId = doArtist(artist);
int genreId = doGenre(genre);
int albumId = doAlbum(album, year);
- doSong(title, track, albumId, genreId, artistId, s);
+ doSong(title, track, albumId, genreId, artistId, s, length);
if(ctr % 100 == 0){
emit progress(ctr);
@@ -229,7 +232,7 @@ int BeetReader::doAlbum(QString name, int year){
return retval;
}
-void BeetReader::doSong(QString title, int pos, int album, int genre, int artist, QString fullpath){
+void BeetReader::doSong(QString title, int pos, int album, int genre, int artist, QString fullpath, int length){
mDb.transaction();
mInsertSongQ->bindValue(":title", title);
mInsertSongQ->bindValue(":pos", pos);
@@ -237,6 +240,7 @@ void BeetReader::doSong(QString title, int pos, int album, int genre, int artist
mInsertSongQ->bindValue(":iartistid", artist);
mInsertSongQ->bindValue(":igenid", genre);
mInsertSongQ->bindValue(":tfp", fullpath);
+ mInsertSongQ->bindValue(":len", length);
mInsertSongQ->exec();
mDb.commit();
}