diff --git a/cdatabase.cpp b/cdatabase.cpp index 9f2ab5a..06e8351 100644 --- a/cdatabase.cpp +++ b/cdatabase.cpp @@ -1,4 +1,6 @@ #include "cdatabase.h" +#include "common.h" + #include #include @@ -47,91 +49,89 @@ int cDatabase::createDB() if(!query.exec("CREATE TABLE version\n" "(version integer)")) + { + myDebug << query.lastError().text(); return(0); + } + if(!query.exec("INSERT INTO version (version) VALUES (1)")) + { + myDebug << query.lastError().text(); return(0); + } - if(!query.exec("CREATE TABLE file\n" - "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - " filename TEXT NOT NULL,\n" - " filetype INTEGER DEFAULT (0),\n" - " length INTEGER DEFAULT (-1),\n" - " bitrate INTEGER DEFAULT (-1),\n" - " samplerate INTEGER DEFAULT (-1),\n" - " channels INTEGER DEFAULT (-1),\n" - " bitspersample INTEGER DEFAULT (-1),\n" - " layer INTEGER DEFAULT (-1),\n" - " version INTEGER DEFAULT (-1),\n" - " samplewidth INTEGER DEFAULT (-1),\n" - " sampleframes INTEGER DEFAULT (0),\n" - " isencrypted INTEGER DEFAULT (0),\n" - " trackgain INTEGER DEFAULT (-1),\n" - " albumgain INTEGER DEFAULT (-1),\n" - " trackpeak INTEGER DEFAULT (-1),\n" - " albumpeak INTEGER DEFAULT (-1),\n" - " protectionenabled INTEGER DEFAULT (0),\n" - " channelmode INTEGER DEFAULT (0),\n" - " iscopyrighted INTEGER DEFAULT (0),\n" - " isoriginal INTEGER DEFAULT (0),\n" - " album TEXT,\n" - " comment TEXT,\n" - " title TEXT\n," - " rating TEXT,\n" - " copyright TEXT,\n" - " track TEXT,\n" - " year INTEGER)")) - return(0); - - if(!query.exec("CREATE TABLE id3v1artist\n" - "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - " fileid INTEGER NOT NULL,\n" - " person TEXT NOT NULL)")) - return(0); - - if(!query.exec("CREATE TABLE id3v1genre\n" - "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - " fileid INTEGER NOT NULL,\n" - " genre TEXT NOT NULL)")) - return(0); - - if(!query.exec("CREATE TABLE id3v2\n" - "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - " fileid INTEGER NOT NULL,\n" - " version INTEGER DEFAULT (-1),\n" - " revision INTEGER DEFAULT (-1),\n" - " size INTEGER DEFAULT (-1))")) - return(0); - - if(!query.exec("CREATE TABLE id3v2tag\n" - "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - " id3v2id INTEGER NOT NULL,\n" - " tag TEXT NOT NULL,\n" - " value TEXT)")) - return(0); - - if(!query.exec("CREATE TABLE ape\n" - "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - " fileid INTEGER NOT NULL\n)")) - return(0); - - if(!query.exec("CREATE TABLE apetag\n" - "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - " apeid INTEGER NOT NULL,\n" - " tag TEXT NOT NULL,\n" - " value TEXT)")) - return(0); - - if(!query.exec("CREATE TABLE properties\n" - "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - " fileid INTEGER NOT NULL)")) - return(0); - - if(!query.exec("CREATE TABLE propertiestag\n" - "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - " propertiesid INTEGER NOT NULL,\n" - " tag TEXT NOT NULL,\n" - " value TEXT)")) + if(!query.exec("CREATE TABLE file " + "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " + " fileName TEXT, " + " fileSize INTEGER, " + " fileDate DATE, " + " fileType1 INTEGER, " + " fileType TEXT, " + " length1 INTEGER, " + " length INTEGER, " + " bitrate INTEGER, " + " sampleRate INTEGER, " + " channels INTEGER, " + " bitsPerSample INTEGER, " + " layer INTEGER, " + " version INTEGER, " + " sampleWidth INTEGER, " + " sampleFrames INTEGER, " + " isEncrypted BOOL, " + " trackGain INTEGER, " + " albumGain INTEGER, " + " trackPeak INTEGER, " + " albumPeak INTEGER, " + " protectionEnabled BOOL, " + " channelMode INTEGER, " + " isCopyrighted BOOL, " + " isOriginal BOOL, " + " album TEXT, " + " title TEXT, " + " copyright TEXT, " + " tracknumber TEXT, " + " contentGroupDescription TEXT, " + " subTitle TEXT, " + " originalAlbum TEXT, " + " partOfSet TEXT, " + " subTitleOfSet TEXT, " + " internationalStandardRecordingCode TEXT, " + " leadArtist TEXT, " + " band TEXT, " + " conductor TEXT, " + " interpret TEXT, " + " originalArtist TEXT, " + " textWriter TEXT, " + " originalTextWriter TEXT, " + " composer TEXT, " + " encodedBy TEXT, " + " beatsPerMinute INTEGER, " + " language TEXT, " + " contentType TEXT, " + " mediaType TEXT, " + " mood TEXT, " + " producedNotice TEXT, " + " publisher TEXT, " + " fileOwner TEXT, " + " internetRadioStationName TEXT, " + " internetRadioStationOwner TEXT, " + " originalFilename TEXT, " + " playlistDelay TEXT, " + " encodingTime INTEGER, " + " originalReleaseTime DATE, " + " recordingTime DATE, " + " releaseTime DATE, " + " taggingTime DATE, " + " swhwSettings TEXT, " + " albumSortOrder TEXT, " + " performerSortOrder TEXT, " + " titleSortOrder TEXT, " + " synchronizedLyrics TEXT, " + " unsynchronizedLyrics TEXT)")) + { + myDebug << query.lastError().text(); return(0); + } return(1); } diff --git a/cimage.cpp b/cimage.cpp index b16d411..babd9a5 100644 --- a/cimage.cpp +++ b/cimage.cpp @@ -1,13 +1,21 @@ #include "cimage.h" +#include "common.h" -cImage::cImage() : - QImage() +cImage::cImage() +{ +} + +cImage::cImage(const QImage& image, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription) : + m_image(image), + m_szFileName(szFileName), + m_ImageType(imageType), + m_szDescription(szDescription) { } cImage::cImage(const QByteArray& array, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription) : - QImage(QImage::fromData(array)), + m_image(QImage::fromData(array)), m_szFileName(szFileName), m_ImageType(imageType), m_szDescription(szDescription) @@ -18,9 +26,22 @@ cImageList::cImageList() { } -cImage* cImageList::add(const QByteArray& array, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription) +cImage* cImageList::add(const QImage& image, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription) { - cImage* lpNew = new cImage(array, szFileName, imageType, szDescription); + cImage* lpNew = new cImage(image, szFileName, imageType, szDescription); + + if(!lpNew) + return(0); + append(lpNew); + return(lpNew); +} + +cImage* cImageList::add(const QByteArray& array, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription) +{ + cImage* lpNew = new cImage(array, szFileName, imageType, szDescription); + + if(!lpNew) + return(0); append(lpNew); return(lpNew); } diff --git a/cimage.h b/cimage.h index be72145..2dfbea4 100644 --- a/cimage.h +++ b/cimage.h @@ -6,7 +6,7 @@ #include -class cImage : public QImage +class cImage { public: enum ImageType @@ -33,17 +33,15 @@ public: BandLogo = 0x13, PublisherLogo = 0x14 }; - explicit cImage(); - explicit cImage(const QByteArray& array, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription); + cImage(); + cImage(const QImage& image, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription); + cImage(const QByteArray& array, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription); protected: + QImage m_image; QString m_szFileName; ImageType m_ImageType; QString m_szDescription; -signals: - -public slots: - }; Q_DECLARE_METATYPE(cImage) @@ -52,6 +50,7 @@ class cImageList : public QList { public: cImageList(); + cImage* add(const QImage& image, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription); cImage* add(const QByteArray& array, const QString& szFileName, const cImage::ImageType& imageType, const QString& szDescription); }; diff --git a/cmainwindow.cpp b/cmainwindow.cpp index c574d3c..30b785e 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -7,18 +7,19 @@ #include "cmediainfo.h" -void addFile(const QString& szFile, const QSqlDatabase db) +void addFile(const QString& szFile) { if(szFile.isEmpty()) return; + cMediaInfo* lpMediaInfo = new cMediaInfo; lpMediaInfo->readFromFile(szFile); - if(lpMediaInfo->isValid()) - lpMediaInfo->writeToDB(db); +// if(lpMediaInfo->isValid()) +// lpMediaInfo->writeToDB(); delete lpMediaInfo; } -void addPath(const QString& szPath, const QSqlDatabase db) +void addPath(const QString& szPath) { QDir Dir(szPath); QStringList Dirs = Dir.entryList(QDir::Dirs); @@ -28,7 +29,7 @@ void addPath(const QString& szPath, const QSqlDatabase db) if(!Files.isEmpty()) { for(z = 0;z < Files.count();z++) - addFile(szPath + QString("/") + Files.at(z), db); + addFile(szPath + QString("/") + Files.at(z)); } Dirs.removeAll("."); @@ -37,7 +38,7 @@ void addPath(const QString& szPath, const QSqlDatabase db) if(!Dirs.isEmpty()) { for(z = 0;z < Dirs.count();z++) - addPath(szPath + QString("/") + Dirs.at(z), db); + addPath(szPath + QString("/") + Dirs.at(z)); } } @@ -52,142 +53,109 @@ cMainWindow::cMainWindow(QWidget *parent) : cDatabase* lpDatabase; lpDatabase = new cDatabase(this); -/* + bool bRet; bRet = lpDatabase->getDB().transaction(); - addPath("C:\\Users\\birkeh\\Music", lpDatabase->getDB()); +// addPath("C:/Users/vet0572/Music"); +// addPath("C:/Users/vet0572/Music/Bee Gees"); + addPath("C:/Users/vet0572/Music/Ambros, Tauchen, Prokopetz"); + addPath("C:/Users/vet0572/Music/Amy MacDonald"); + addPath("C:/Users/vet0572/Music/Amy Winehouse"); + addPath("C:/Users/vet0572/Music/Andreas Bourani"); + addPath("C:/Users/vet0572/Music/Angus & Julia Stone"); + addPath("C:/Users/vet0572/Music/Anna Maria Kaufmann and Joey Tempest"); + + addPath("C:/Users/vet0572/Music/Bee Gees/2 Years On"); + addPath("C:/Users/vet0572/Music/Bee Gees/Bee Gees Story"); + addPath("C:/Users/vet0572/Music/Bee Gees/Best of Bee Gees"); + addPath("C:/Users/vet0572/Music/Bee Gees/Brillant Front Birth"); + addPath("C:/Users/vet0572/Music/Bee Gees/Children of the World"); + addPath("C:/Users/vet0572/Music/Bee Gees/Cucumber Castle"); + addPath("C:/Users/vet0572/Music/Bee Gees/E.S.P"); + addPath("C:/Users/vet0572/Music/Bee Gees/First"); + addPath("C:/Users/vet0572/Music/Bee Gees/Greatest"); + addPath("C:/Users/vet0572/Music/Bee Gees/Here at Last...Bee Gees...Live"); + addPath("C:/Users/vet0572/Music/Bee Gees/High Civilization"); + addPath("C:/Users/vet0572/Music/Bee Gees/Horizontal"); + addPath("C:/Users/vet0572/Music/Bee Gees/Idea"); + addPath("C:/Users/vet0572/Music/Bee Gees/In the beginning"); + addPath("C:/Users/vet0572/Music/Bee Gees/Inception And Nostalgia"); + addPath("C:/Users/vet0572/Music/Bee Gees/Instrumental & Other Rarities"); + addPath("C:/Users/vet0572/Music/Bee Gees/Kick In The Head"); + addPath("C:/Users/vet0572/Music/Bee Gees/Life In A Tin Can"); + addPath("C:/Users/vet0572/Music/Bee Gees/Live At The Beeb"); + addPath("C:/Users/vet0572/Music/Bee Gees/Living Eyes"); + addPath("C:/Users/vet0572/Music/Bee Gees/Love Songs"); + addPath("C:/Users/vet0572/Music/Bee Gees/Main Course"); + addPath("C:/Users/vet0572/Music/Bee Gees/Melody"); + addPath("C:/Users/vet0572/Music/Bee Gees/Mr. Natural"); + addPath("C:/Users/vet0572/Music/Bee Gees/Number Ones"); + addPath("C:/Users/vet0572/Music/Bee Gees/Odessa"); + addPath("C:/Users/vet0572/Music/Bee Gees/One"); + addPath("C:/Users/vet0572/Music/Bee Gees/One Night Only"); + addPath("C:/Users/vet0572/Music/Bee Gees/Rare Precious And Beautiful"); + addPath("C:/Users/vet0572/Music/Bee Gees/Rare precious and beautiful - Vol 3"); + addPath("C:/Users/vet0572/Music/Bee Gees/Rare, Precious & Beautiful 2"); + addPath("C:/Users/vet0572/Music/Bee Gees/Saturday night fever"); + addPath("C:/Users/vet0572/Music/Bee Gees/Sayonara Tokyo"); + addPath("C:/Users/vet0572/Music/Bee Gees/Sing And Play 14 Barry Gibb Songs"); + addPath("C:/Users/vet0572/Music/Bee Gees/Size Isn't Everything"); + addPath("C:/Users/vet0572/Music/Bee Gees/Spicks and Specks"); + addPath("C:/Users/vet0572/Music/Bee Gees/Spirits Having Flown"); + addPath("C:/Users/vet0572/Music/Bee Gees/Staying Alive"); + addPath("C:/Users/vet0572/Music/Bee Gees/Still Waters"); + addPath("C:/Users/vet0572/Music/Bee Gees/The best of Volume 02"); + addPath("C:/Users/vet0572/Music/Bee Gees/The Very Best"); + addPath("C:/Users/vet0572/Music/Bee Gees/This is where I came in"); + addPath("C:/Users/vet0572/Music/Bee Gees/To Whom It May Concern"); + addPath("C:/Users/vet0572/Music/Bee Gees/Tomorrow The World"); + addPath("C:/Users/vet0572/Music/Bee Gees/Trafalgar"); + addPath("C:/Users/vet0572/Music/Bee Gees/Turn Around, Look At Me"); + addPath("C:/Users/vet0572/Music/Bee Gees/Turn around, look at us"); + + addPath("C:/Users/vet0572/Music/Ambros, Tauchen, Prokopetz"); + addPath("C:/Users/vet0572/Music/Amy MacDonald"); + addPath("C:/Users/vet0572/Music/Amy Winehouse"); + addPath("C:/Users/vet0572/Music/Andreas Bourani"); + addPath("C:/Users/vet0572/Music/Angus & Julia Stone"); + addPath("C:/Users/vet0572/Music/Anna Maria Kaufmann and Joey Tempest"); + addPath("C:/Users/vet0572/Music/Boney M"); + addPath("C:/Users/vet0572/Music/Delta Moon"); + addPath("C:/Users/vet0572/Music/Dire Straits"); + addPath("C:/Users/vet0572/Music/Erste Allgemeine Verunsicherung"); + addPath("C:/Users/vet0572/Music/Flogging Molly"); + addPath("C:/Users/vet0572/Music/Frank Zander"); + addPath("C:/Users/vet0572/Music/Game Of Thrones"); + addPath("C:/Users/vet0572/Music/Game Of Thrones- Season 4"); + addPath("C:/Users/vet0572/Music/Heartbeat"); + addPath("C:/Users/vet0572/Music/Hubert von Goisern"); + addPath("C:/Users/vet0572/Music/Hugh Laurie"); + addPath("C:/Users/vet0572/Music/Jon Lord"); + addPath("C:/Users/vet0572/Music/Karthago"); + addPath("C:/Users/vet0572/Music/Legend of The Seeker"); + addPath("C:/Users/vet0572/Music/Ludwig Hirsch"); + addPath("C:/Users/vet0572/Music/Mass Effect"); + addPath("C:/Users/vet0572/Music/Matt Simons"); + addPath("C:/Users/vet0572/Music/Mike Krüger - 79er Motzbeutel"); + addPath("C:/Users/vet0572/Music/Mike Oldfield"); + addPath("C:/Users/vet0572/Music/Ostbahn Kurti & Die Chefpartie"); + addPath("C:/Users/vet0572/Music/Papermoon"); + addPath("C:/Users/vet0572/Music/Passenger"); + addPath("C:/Users/vet0572/Music/Ramin Djawadi"); + addPath("C:/Users/vet0572/Music/Roger Hodgson"); + addPath("C:/Users/vet0572/Music/Shadow Of The Beast"); + addPath("C:/Users/vet0572/Music/Simon & Garfunkel"); + addPath("C:/Users/vet0572/Music/Stars On 45"); + addPath("C:/Users/vet0572/Music/STS"); + addPath("C:/Users/vet0572/Music/The Piano Guys"); + addPath("C:/Users/vet0572/Music/The Pogues"); + addPath("C:/Users/vet0572/Music/The Stand"); + addPath("C:/Users/vet0572/Music/Tracy Chapman"); + addPath("C:/Users/vet0572/Music/Vienna Symphony Orchestra"); + addPath("C:/Users/vet0572/Music/Wig"); + addPath("C:/Users/vet0572/Music/Wolfgang Ambros"); bRet = lpDatabase->getDB().commit(); -*/ - cMediaInfo* lpMediaInfo; - lpMediaInfo = new cMediaInfo(this); -// lpMediaInfo->readFromFile("C:\\Users\\birkeh\\Music\\Wig\\A Day In The Life\\CD1\\Wig - A Day In The Life - Part 1 - Wake Up.mp3"); -// lpMediaInfo->readFromFile("C:\\Users\\birkeh\\Music\\Amy MacDonald\\Life In A Beautiful Light\\CD1\\Amy Macdonald - Life In A Beautiful Light - 05 - The Game.mp3"); -// lpMediaInfo->readFromFile("C:\\Users\\birkeh\\Music\\Amy MacDonald\\A Curious Thing\\CD1\\Amy MacDonald - A Curious Thing - 01 - Don't tell me it's over.mp3"); -// lpMediaInfo->readFromFile("C:\\Users\\birkeh\\Music\\id3v1\\id3v1_140_genre_W.mp3"); -// lpMediaInfo->readFromFile("C:\\Users\\vet0572\\Music\\Heartbeat\\Strong\\CD1\\Heartbeat - Strong - 01 - Strong.mp3"); - lpMediaInfo->readFromFile("C:\\Users\\vet0572\\Music\\Amy MacDonald\\Under Stars (Deluxe)\\02 - Under Stars.mp3"); - QString sz; - QStringList szL; - qint16 i; - qint32 i32; - qint64 i64; - QDateTime dt; - bool b; - cImageList images; - cStringTimeList szTL; - cMediaInfo::MEDIA_TYPE mt; - cMediaInfo::CHANNEL_MODE cm; - - sz = lpMediaInfo->fileName(); - mt = lpMediaInfo->fileType1(); - sz = lpMediaInfo->fileType1Text(); - - i32 = lpMediaInfo->length1(); - sz = lpMediaInfo->length1Text(); - i = lpMediaInfo->bitrate(); - sz = lpMediaInfo->bitrateText(); - i32 = lpMediaInfo->sampleRate(); - sz = lpMediaInfo->sampleRateText(); - i = lpMediaInfo->channels(); - sz = lpMediaInfo->channelsText(); - i = lpMediaInfo->bitsPerSample(); - sz = lpMediaInfo->bitsPerSampleText(); - i = lpMediaInfo->layer(); - sz = lpMediaInfo->layerText(); - i = lpMediaInfo->version(); - sz = lpMediaInfo->versionText(); - i = lpMediaInfo->sampleWidth(); - sz = lpMediaInfo->sampleWidthText(); - i64 = lpMediaInfo->sampleFrames(); - sz = lpMediaInfo->sampleFramesText(); - b = lpMediaInfo->isEncrypted(); - i = lpMediaInfo->trackGain(); - i = lpMediaInfo->albumGain(); - i = lpMediaInfo->trackPeak(); - i = lpMediaInfo->albumPeak(); - b = lpMediaInfo->protectionEnabled(); - cm = lpMediaInfo->channelMode(); - sz = lpMediaInfo->channelModeText(); - b = lpMediaInfo->isCopyrighted(); - b = lpMediaInfo->isOriginal(); - - sz = lpMediaInfo->contentGroupDescription(); - sz = lpMediaInfo->title(); - sz = lpMediaInfo->subTitle(); - sz = lpMediaInfo->album(); - sz = lpMediaInfo->originalAlbum(); - sz = lpMediaInfo->trackNumber(); - sz = lpMediaInfo->partOfSet(); - sz = lpMediaInfo->subTitleOfSet(); - sz = lpMediaInfo->internationalStandardRecordingCode(); - - sz = lpMediaInfo->leadArtist(); - sz = lpMediaInfo->band(); - sz = lpMediaInfo->conductor(); - szL = lpMediaInfo->interpret(); - sz = lpMediaInfo->originalArtist(); - sz = lpMediaInfo->textWriter(); - sz = lpMediaInfo->originalTextWriter(); - sz = lpMediaInfo->composer(); - sz = lpMediaInfo->encodedBy(); - - i = lpMediaInfo->beatsPerMinute(); - i = lpMediaInfo->length(); - szL = lpMediaInfo->language(); - szL = lpMediaInfo->contentType(); - sz = lpMediaInfo->fileType(); - szL = lpMediaInfo->mediaType(); - sz = lpMediaInfo->mood(); - - sz = lpMediaInfo->copyright(); - sz = lpMediaInfo->producedNotice(); - sz = lpMediaInfo->publisher(); - sz = lpMediaInfo->fileOwner(); - sz = lpMediaInfo->internetRadioStationName(); - sz = lpMediaInfo->internetRadioStationOwner(); - - sz = lpMediaInfo->originalFilename(); - i = lpMediaInfo->playlistDelay(); - dt = lpMediaInfo->encodingTime(); - dt = lpMediaInfo->originalReleaseTime(); - dt = lpMediaInfo->recordingTime(); - dt = lpMediaInfo->releaseTime(); - dt = lpMediaInfo->taggingTime(); - szL = lpMediaInfo->swhwSettings(); - sz = lpMediaInfo->albumSortOrder(); - sz = lpMediaInfo->performerSortOrder(); - sz = lpMediaInfo->titleSortOrder(); - - szL = lpMediaInfo->unsynchronizedLyrics(); - szTL = lpMediaInfo->synchronizedLyrics(); - - images = lpMediaInfo->images(); - -// lpMediaInfo->writeToDB(lpDatabase->getDB()); - delete lpMediaInfo; - -/* - lpMediaInfo = new cMediaInfo(this); - lpMediaInfo->readFromFile("/data/Musik/MP3/Wig/First/CD1/Wig - First - 01 - Arie.flac"); - lpMediaInfo->writeToDB(lpDatabase->getDB()); - delete lpMediaInfo; - - lpMediaInfo = new cMediaInfo(this); - lpMediaInfo->readFromFile("/data/Musik/MP3/Wig/First/CD1/Wig - First - 01 - Arie.m4a"); - lpMediaInfo->writeToDB(lpDatabase->getDB()); - delete lpMediaInfo; - - lpMediaInfo = new cMediaInfo(this); - lpMediaInfo->readFromFile("/data/Musik/MP3/Wig/First/CD1/Wig - First - 01 - Arie.mp3"); - lpMediaInfo->writeToDB(lpDatabase->getDB()); - delete lpMediaInfo; - - lpMediaInfo = new cMediaInfo(this); - lpMediaInfo->readFromFile("/data/Musik/MP3/Wig/First/CD1/sh3.ape"); - lpMediaInfo->writeToDB(lpDatabase->getDB()); - delete lpMediaInfo; -*/ ui->setupUi(this); delete (lpDatabase); diff --git a/cmediainfo.cpp b/cmediainfo.cpp index 64936ca..ebb3ec6 100644 --- a/cmediainfo.cpp +++ b/cmediainfo.cpp @@ -1,17 +1,22 @@ #include "cmediainfo.h" +#include "common.h" + #include #include +#include + #include #include #include +#include #include cMediaInfo::cMediaInfo(bool bAPE, bool bID3V1, bool bID3V2, bool bProperties, QObject *parent) : - QObject(parent), m_bAPE(bAPE), m_bID3V1(bID3V1), m_bID3V2(bID3V2), m_bProperties(bProperties), m_bIsValid(false), m_FileType(MEDIA_TYPE_UNKNOWN) + QObject(parent), m_bAPE(bAPE), m_bID3V1(bID3V1), m_bID3V2(bID3V2), m_bProperties(bProperties), m_bIsValid(false), m_fileType(MEDIA_TYPE_UNKNOWN) { } @@ -23,7 +28,7 @@ cMediaInfo::~cMediaInfo() void cMediaInfo::clear() { m_szFileName = ""; - m_FileType = MEDIA_TYPE_UNKNOWN; + m_fileType = MEDIA_TYPE_UNKNOWN; m_bIsValid = false; m_iLength = -1; @@ -126,47 +131,49 @@ void cMediaInfo::clear() m_TAGPropertiesList.clear(); m_imageList.clear(); + m_images.clear(); } bool cMediaInfo::readFromFile(const QString& szFileName) { clear(); - QFileInfo FileInfo(szFileName); - if(!FileInfo.exists()) + QFileInfo fileInfo(szFileName); + if(!fileInfo.exists()) return(false); - if(!FileInfo.suffix().compare("APE", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_APE; - else if(!FileInfo.suffix().compare("WMA", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_ASF; - else if(!FileInfo.suffix().compare("FLAC", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_FLAC; - else if(!FileInfo.suffix().compare("AAC", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_MP4; - else if(!FileInfo.suffix().compare("MP4", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_MP4; - else if(!FileInfo.suffix().compare("M4A", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_MP4; - else if(!FileInfo.suffix().compare("MPC", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_MPC; - else if(!FileInfo.suffix().compare("MP1", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_MPEG; - else if(!FileInfo.suffix().compare("MP2", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_MPEG; - else if(!FileInfo.suffix().compare("MP3", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_MPEG; - else if(!FileInfo.suffix().compare("TTA", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_TRUEAUDIO; - else if(!FileInfo.suffix().compare("WV", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_WAVPACK; - else if(!FileInfo.suffix().compare("WAV", Qt::CaseInsensitive)) - m_FileType = MEDIA_TYPE_WAV; + if(!fileInfo.suffix().compare("APE", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_APE; + else if(!fileInfo.suffix().compare("WMA", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_ASF; + else if(!fileInfo.suffix().compare("FLAC", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_FLAC; + else if(!fileInfo.suffix().compare("AAC", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_MP4; + else if(!fileInfo.suffix().compare("MP4", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_MP4; + else if(!fileInfo.suffix().compare("M4A", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_MP4; + else if(!fileInfo.suffix().compare("MPC", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_MPC; + else if(!fileInfo.suffix().compare("MP1", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_MPEG; + else if(!fileInfo.suffix().compare("MP2", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_MPEG; + else if(!fileInfo.suffix().compare("MP3", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_MPEG; + else if(!fileInfo.suffix().compare("TTA", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_TRUEAUDIO; + else if(!fileInfo.suffix().compare("WV", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_WAVPACK; + else if(!fileInfo.suffix().compare("WAV", Qt::CaseInsensitive)) + m_fileType = MEDIA_TYPE_WAV; - if(m_FileType == MEDIA_TYPE_UNKNOWN) + if(m_fileType == MEDIA_TYPE_UNKNOWN) return(false); m_szFileName = szFileName; + ID3v1::Tag* lpTagV1 = 0; ID3v2::Tag* lpTagV2 = 0; APE::Tag* lpTagAPE = 0; @@ -179,11 +186,12 @@ bool cMediaInfo::readFromFile(const QString& szFileName) TrueAudio::File* lpTrueAudio = 0; WavPack::File* lpWavPack = 0; RIFF::WAV::File* lpWav = 0; + TagLib::PropertyMap tags; QString szTmp; - switch(m_FileType) + switch(m_fileType) { case MEDIA_TYPE_APE: { @@ -296,6 +304,7 @@ bool cMediaInfo::readFromFile(const QString& szFileName) case MEDIA_TYPE_MPEG: { lpMPEG = new MPEG::File(m_szFileName.toLocal8Bit().data()); + lpTagV1 = lpMPEG->ID3v1Tag(); lpTagV2 = lpMPEG->ID3v2Tag(); lpTagAPE = lpMPEG->APETag(); @@ -337,6 +346,7 @@ bool cMediaInfo::readFromFile(const QString& szFileName) } m_bIsCopyrighted = lpAudioProperties->isCopyrighted(); m_bIsOriginal = lpAudioProperties->isOriginal(); + break; } case MEDIA_TYPE_TRUEAUDIO: @@ -423,207 +433,127 @@ bool cMediaInfo::readFromFile(const QString& szFileName) return(true); } -bool cMediaInfo::readFromDB(const QSqlDatabase& db) +bool cMediaInfo::readFromDB() { return(true); } -/* -qint32 cMediaInfo::writeFilename(const QSqlDatabase& db) + +qint32 cMediaInfo::writeFilename() { - QSqlQuery query(db); - QString sz; + QSqlQuery query; - sz = QString("SELECT id FROM file WHERE filename = \"%1\"").arg(m_szFileName); - if(!query.exec(sz)) - return(-1); - query.first(); - if(query.isValid()) - return(-1); + query.prepare("SELECT id FROM file WHERE fileName=:fileName AND fileSize=:fileSize AND fileDate=:fileDate;"); + query.bindValue(":fileName", fileName()); + query.bindValue(":fileSize", fileSize()); + query.bindValue(":fileDate", fileDate()); - sz = QString("INSERT INTO file (filename, filetype, length, bitrate, samplerate, channels, bitspersample, layer, version, samplewidth, sampleframes, isencrypted, trackgain, albumgain, trackpeak, albumpeak, protectionenabled, channelmode, iscopyrighted, isoriginal, album, comment, title, rating, copyright, track, year)\n" - "values\n" - "(\"%1\", %2, %3, %4, %5, %6, %7, %8, %9, %10,\n" - " %11, %12, %13, %14, %15, %16, %17, %18, %19, %20, \"%21\", \"%22\", \"%23\", \"%24\", \"%25\", \"%26\", %27)").arg(m_szFileName).arg(m_FileType).arg(m_iLength).arg(m_iBitrate).arg(m_iSampleRate).arg(m_iChannels).arg(m_iBitsPerSample).arg(m_iLayer).arg(m_iVersion).arg(m_iSampleWidth).arg(m_ullSampleFrames).arg(m_bIsEncrypted).arg(m_iTrackGain).arg(m_iAlbumGain).arg(m_iTrackPeak).arg(m_iAlbumPeak).arg(m_bProtectionEnabled).arg(m_channelMode).arg(m_bIsCopyrighted).arg(m_bIsOriginal).arg(m_szAlbum).arg(m_szComment).arg(m_szTitle).arg(m_szRating).arg(m_szCopyright).arg(m_szTrackNumber).arg(m_iYear); + if(!query.exec()) + { + myDebug << query.lastError().text(); + return(-1); + } - if(!query.exec(sz)) - return(-1); + if(query.next()) + query.prepare("UPDATE file SET fileType1=:fileType1, fileType=:fileType, length1=:length1, length=:length, bitrate=:bitrate, sampleRate=:sampleRate, channels=:channels, bitsPerSample=:bitsPerSample, layer=:layer, version=:version, sampleWidth=:sampleWidth, sampleFrames=:sampleFrames, isEncrypted=:isEncrypted, trackGain=:trackGain, albumGain=:albumGain, trackPeak=:trackPeak, albumPeak=:albumPeak, protectionEnabled=:protectionEnabled, channelMode=:channelMode, isCopyrighted=:isCopyrighted, isOriginal=:isOriginal, album=:album, title=:title, copyright=:copyright, tracknumber=:tracknumber, contentGroupDescription=:contentGroupDescription, subTitle=:subTitle, originalAlbum=:originalAlbum, partOfSet=:partOfSet, subTitleOfSet=:subTitleOfSet, internationalStandardRecordingCode=:internationalStandardRecordingCode, leadArtist=:leadArtist, band=:band, conductor=:conductor, interpret=:interpret, originalArtist=:originalArtist, textWriter=:textWriter, originalTextWriter=:originalTextWriter, composer=:composer, encodedBy=:encodedBy, beatsPerMinute=:beatsPerMinute, language=:language, contentType=:contentType, mediaType=:mediaType, mood=:mood, producedNotice=:producedNotice, publisher=:publisher, fileOwner=:fileOwner, internetRadioStationName=:internetRadioStationName, internetRadioStationOwner=:internetRadioStationOwner, originalFilename=:originalFilename, playlistDelay=:playlistDelay, encodingTime=:encodingTime, originalReleaseTime=:originalReleaseTime, recordingTime=:recordingTime, releaseTime=:releaseTime, taggingTime=:taggingTime, swhwSettings=:swhwSettings, albumSortOrder=:albumSortOrder, performerSortOrder=:performerSortOrder, titleSortOrder=:titleSortOrder, synchronizedLyrics=:synchronizedLyrics, unsynchronizedLyrics=:unsynchronizedLyrics WHERE filename=:filename AND filesize=:filesize AND filedate=:filedate;"); + else + query.prepare("INSERT INTO file (fileName, fileSize, fileDate, fileType1, fileType, length1, length, bitrate, sampleRate, channels, bitsPerSample, layer, version, sampleWidth, sampleFrames, isEncrypted, trackGain, albumGain, trackPeak, albumPeak, protectionEnabled, channelMode, isCopyrighted, isOriginal, album, title, copyright, tracknumber, contentGroupDescription, subTitle, originalAlbum, partOfSet, subTitleOfSet, internationalStandardRecordingCode, leadArtist, band, conductor, interpret, originalArtist, textWriter, originalTextWriter, composer, encodedBy, beatsPerMinute, language, contentType, mediaType, mood, producedNotice, publisher, fileOwner, internetRadioStationName, internetRadioStationOwner, originalFilename, playlistDelay, encodingTime, originalReleaseTime, recordingTime, releaseTime, taggingTime, swhwSettings, albumSortOrder, performerSortOrder, titleSortOrder, synchronizedLyrics, unsynchronizedLyrics) VALUES (:fileName, :fileSize, :fileDate, :fileType1, :fileType, :length1, :length, :bitrate, :sampleRate, :channels, :bitsPerSample, :layer, :version, :sampleWidth, :sampleFrames, :isEncrypted, :trackGain, :albumGain, :trackPeak, :albumPeak, :protectionEnabled, :channelMode, :isCopyrighted, :isOriginal, :album, :title, :copyright, :tracknumber, :contentGroupDescription, :subTitle, :originalAlbum, :partOfSet, :subTitleOfSet, :internationalStandardRecordingCode, :leadArtist, :band, :conductor, :interpret, :originalArtist, :textWriter, :originalTextWriter, :composer, :encodedBy, :beatsPerMinute, :language, :contentType, :mediaType, :mood, :producedNotice, :publisher, :fileOwner, :internetRadioStationName, :internetRadioStationOwner, :originalFilename, :playlistDelay, :encodingTime, :originalReleaseTime, :recordingTime, :releaseTime, :taggingTime, :swhwSettings, :albumSortOrder, :performerSortOrder, :titleSortOrder, :synchronizedLyrics, :unsynchronizedLyrics);"); - sz = QString("SELECT id FROM file WHERE filename = \"%1\"").arg(m_szFileName); - if(!query.exec(sz)) + query.bindValue(":fileName", fileName()); + query.bindValue(":fileSize", fileSize()); + query.bindValue(":fileDate", fileDate()); + query.bindValue(":fileType1", fileType1()); + query.bindValue(":fileType", fileType()); + query.bindValue(":length1", length1()); + query.bindValue(":length", length()); + query.bindValue(":bitrate", bitrate()); + query.bindValue(":sampleRate", sampleRate()); + query.bindValue(":channels", channels()); + query.bindValue(":bitsPerSample", bitsPerSample()); + query.bindValue(":layer", layer()); + query.bindValue(":version", version()); + query.bindValue(":sampleWidth", sampleWidth()); + query.bindValue(":sampleFrames", sampleFrames()); + query.bindValue(":isEncrypted", isEncrypted()); + query.bindValue(":trackGain", trackGain()); + query.bindValue(":albumGain", albumGain()); + query.bindValue(":trackPeak", trackPeak()); + query.bindValue(":albumPeak", albumPeak()); + query.bindValue(":protectionEnabled", protectionEnabled()); + query.bindValue(":channelMode", channelMode()); + query.bindValue(":isCopyrighted", isCopyrighted()); + query.bindValue(":isOriginal", isOriginal()); + query.bindValue(":album", album()); + query.bindValue(":title", title()); + query.bindValue(":copyright", copyright()); + query.bindValue(":tracknumber", trackNumber()); + query.bindValue(":contentGroupDescription", contentGroupDescription()); + query.bindValue(":subTitle", subTitle()); + query.bindValue(":originalAlbum", originalAlbum()); + query.bindValue(":partOfSet", partOfSet()); + query.bindValue(":subTitleOfSet", subTitleOfSet()); + query.bindValue(":internationalStandardRecordingCode", internationalStandardRecordingCode()); + query.bindValue(":leadArtist", leadArtist()); + query.bindValue(":band", band()); + query.bindValue(":conductor", conductor()); + query.bindValue(":interpret", interpret().join(", ")); + query.bindValue(":originalArtist", originalArtist()); + query.bindValue(":textWriter", textWriter()); + query.bindValue(":originalTextWriter", originalTextWriter()); + query.bindValue(":composer", composer()); + query.bindValue(":encodedBy", encodedBy()); + query.bindValue(":beatsPerMinute", beatsPerMinute()); + query.bindValue(":language", language().join(", ")); + query.bindValue(":contentType", contentType().join(", ")); + query.bindValue(":mediaType", mediaType().join(", ")); + query.bindValue(":mood", mood()); + query.bindValue(":producedNotice", producedNotice()); + query.bindValue(":publisher", publisher()); + query.bindValue(":fileOwner", fileOwner()); + query.bindValue(":internetRadioStationName", internetRadioStationName()); + query.bindValue(":internetRadioStationOwner", internetRadioStationOwner()); + query.bindValue(":originalFilename", originalFilename()); + query.bindValue(":playlistDelay", playlistDelay()); + query.bindValue(":encodingTime", encodingTime()); + query.bindValue(":originalReleaseTime", originalReleaseTime()); + query.bindValue(":recordingTime", recordingTime()); + query.bindValue(":releaseTime", releaseTime()); + query.bindValue(":taggingTime", taggingTime()); + query.bindValue(":swhwSettings", swhwSettings().join(", ")); + query.bindValue(":albumSortOrder", albumSortOrder()); + query.bindValue(":performerSortOrder", performerSortOrder()); + query.bindValue(":titleSortOrder", titleSortOrder()); + query.bindValue(":synchronizedLyrics", synchronizedLyrics().join()); + query.bindValue(":unsynchronizedLyrics", unsynchronizedLyrics().join("||")); + + if(!query.exec()) + { + myDebug << query.lastError().text(); return(-1); - query.first(); - if(!query.isValid()) + } + + query.prepare("SELECT id FROM file WHERE fileName=:fileName AND fileSize=:fileSize AND fileDate=:fileDate;"); + query.bindValue(":fileName", fileName()); + query.bindValue(":fileSize", fileSize()); + query.bindValue(":fileDate", fileDate()); + + if(!query.exec()) + { + myDebug << query.lastError().text(); return(-1); - return(query.value(0).toInt()); + } + + if(query.next()) + return(query.value("id").toInt()); + + return(-1); + +// cImageList images(); } -qint32 cMediaInfo::writeArtist(const QSqlDatabase& db, qint32 idFile, const QString& szArtist) +bool cMediaInfo::writeToDB() { - QSqlQuery query(db); - QString sz; + qint32 idFile = writeFilename(); - sz = QString("SELECT id FROM id3v1artist WHERE fileid = %1 AND person = \"%2\"").arg(idFile).arg(szArtist); - if(!query.exec(sz)) - return(-1); - query.first(); - if(query.isValid()) - return(-1); - - for(int z = 0;z < m_szArtistList.count();z++) - { - QString szArtist = m_szArtistList.at(z); - sz = QString("INSERT INTO id3v1artist (fileid, person) VALUES (%1, \"%2\")").arg(idFile).arg(szArtist); - if(!query.exec(sz)) - return(-1); - } -} -*/ -bool cMediaInfo::writeToDB(const QSqlDatabase& db) -{ -/* - QSqlQuery query(db); - QString sz; - qint32 idFile; - qint32 id3v2; - qint32 idAPE; - qint32 idProperties; - - idFile = writeFilename(db); - if(idFile == -1) - return(false); - - if(m_szArtistList.count()) - { - sz = QString("SELECT id FROM id3v1artist WHERE fileid = %1").arg(idFile); - if(!query.exec(sz)) - return(false); - query.first(); - if(query.isValid()) - return(false); - - for(int z = 0;z < m_szArtistList.count();z++) - { - QString szArtist = m_szArtistList.at(z); - sz = QString("INSERT INTO id3v1artist (fileid, person) VALUES (%1, \"%2\")").arg(idFile).arg(szArtist); - if(!query.exec(sz)) - return(false); - } - } - - if(m_szGenreList.count()) - { - sz = QString("SELECT id FROM id3v1genre WHERE fileid = %1").arg(idFile); - if(!query.exec(sz)) - return(false); - query.first(); - if(query.isValid()) - return(false); - - for(int z = 0;z < m_szGenreList.count();z++) - { - QString szGenre = m_szGenreList.at(z); - sz = QString("INSERT INTO id3v1genre (fileid, genre) VALUES (%1, \"%2\")").arg(idFile).arg(szGenre); - if(!query.exec(sz)) - return(false); - } - } - - if(m_TAGv2List.count()) - { - sz = QString("SELECT id FROM id3v2 WHERE fileid = %1").arg(idFile); - if(!query.exec(sz)) - return(false); - query.first(); - if(query.isValid()) - return(false); - - sz = QString("INSERT INTO id3v2 (fileid, version, revision, size) VALUES (%1, %2, %3, %4)").arg(idFile).arg(m_iID3v2Version).arg(m_iID3v2Revision).arg(m_iID3v2Size); - if(!query.exec(sz)) - return(false); - sz = QString("SELECT id FROM id3v2 WHERE fileid = %1").arg(idFile); - if(!query.exec(sz)) - return(false); - query.first(); - id3v2 = query.value(0).toInt(); - - for(int z = 0;z < m_TAGv2List.count();z++) - { - cTAG* lpTag = m_TAGv2List.at(z); - QString szTag = lpTag->tag(); - QStringList szValue = lpTag->valueList(); - for(int y = 0;y < szValue.count();y++) - { - sz = QString("INSERT INTO id3v2tag (id3v2id, tag, value) VALUES (%1, \"%2\", \"%3\")").arg(id3v2).arg(szTag).arg(szValue.at(y)); - if(!query.exec(sz)) - return(false); - } - } - } - - if(m_TAGAPEList.count()) - { - sz = QString("SELECT id FROM ape WHERE fileid = %1").arg(idFile); - if(!query.exec(sz)) - return(false); - query.first(); - if(query.isValid()) - return(false); - - sz = QString("INSERT INTO ape (fileid) VALUES (%1)").arg(idFile); - if(!query.exec(sz)) - return(false); - sz = QString("SELECT id FROM ape WHERE fileid = %1").arg(idFile); - if(!query.exec(sz)) - return(false); - query.first(); - idAPE = query.value(0).toInt(); - - for(int z = 0;z < m_TAGAPEList.count();z++) - { - cTAG* lpTag = m_TAGAPEList.at(z); - QString szTag = lpTag->tag(); - QStringList szValue = lpTag->valueList(); - for(int y = 0;y < szValue.count();y++) - { - sz = QString("INSERT INTO apetag (apeid, tag, value) VALUES (%1, \"%2\", \"%3\")").arg(idAPE).arg(szTag).arg(szValue.at(y)); - if(!query.exec(sz)) - return(false); - } - } - } - - if(m_TAGPropertiesList.count()) - { - sz = QString("SELECT id FROM properties WHERE fileid = %1").arg(idFile); - if(!query.exec(sz)) - return(false); - query.first(); - if(query.isValid()) - return(false); - - sz = QString("INSERT INTO properties (fileid) VALUES (%1)").arg(idFile); - if(!query.exec(sz)) - return(false); - sz = QString("SELECT id FROM properties WHERE fileid = %1").arg(idFile); - if(!query.exec(sz)) - return(false); - query.first(); - idProperties = query.value(0).toInt(); - - for(int z = 0;z < m_TAGPropertiesList.count();z++) - { - cTAG* lpTag = m_TAGPropertiesList.at(z); - QString szTag = lpTag->tag(); - QStringList szValue = lpTag->valueList(); - for(int y = 0;y < szValue.count();y++) - { - sz = QString("INSERT INTO propertiestag (propertiesid, tag, value) VALUES (%1, \"%2\", \"%3\")").arg(idProperties).arg(szTag).arg(szValue.at(y)); - if(!query.exec(sz)) - return(false); - } - } - } -*/ return(true); } @@ -721,15 +651,15 @@ void cMediaInfo::readTagV2(ID3v2::Tag* lpTag) else if(!szID.compare("TDLY")) m_iPlaylistDelay = QString((*it)->toString().toCString()).toInt(); else if(!szID.compare("TDEN")) - m_EncodingTime = str2TS((*it)->toString().toCString()); + m_encodingTime = str2TS((*it)->toString().toCString()); else if(!szID.compare("TDOR")) - m_OriginalReleaseTime = str2TS((*it)->toString().toCString()); + m_originalReleaseTime = str2TS((*it)->toString().toCString()); else if(!szID.compare("TDRC")) - m_RecordingTime = str2TS((*it)->toString().toCString()); + m_recordingTime = str2TS((*it)->toString().toCString()); else if(!szID.compare("TDRL")) - m_ReleaseTime = str2TS((*it)->toString().toCString()); + m_releaseTime = str2TS((*it)->toString().toCString()); else if(!szID.compare("TDTG")) - m_TaggingTime = str2TS((*it)->toString().toCString()); + m_taggingTime = str2TS((*it)->toString().toCString()); else if(!szID.compare("TSSE")) m_szswhwSettings = QString((*it)->toString().toCString()).split("\r\n"); else if(!szID.compare("TSOA")) @@ -779,7 +709,11 @@ void cMediaInfo::readTagV2(ID3v2::Tag* lpTag) szDescription = lpPicture->description().toCString(); QByteArray pictureData = QByteArray(lpPicture->picture().data(), lpPicture->picture().size()); - m_imageList.add(pictureData, "", (cImage::ImageType)t, szDescription); +// QPixmap pixmap; +// pixmap.loadFromData(pictureData); +// m_imageList.add(pictureData, m_szFileName, (cImage::ImageType)t, szDescription); + QImage image = QImage::fromData(pictureData); + m_images.append(image); } } } @@ -866,14 +800,26 @@ QString cMediaInfo::fileName() return(m_szFileName); } +qint64 cMediaInfo::fileSize() +{ + QFileInfo fileInfo(m_szFileName); + return(fileInfo.size()); +} + +QDateTime cMediaInfo::fileDate() +{ + QFileInfo fileInfo(m_szFileName); + return(fileInfo.created()); +} + cMediaInfo::MEDIA_TYPE cMediaInfo::fileType1() { - return(m_FileType); + return(m_fileType); } QString cMediaInfo::fileType1Text() { - switch(m_FileType) + switch(m_fileType) { case MEDIA_TYPE_APE: return("APE"); @@ -1217,27 +1163,27 @@ qint32 cMediaInfo::playlistDelay() QDateTime cMediaInfo::encodingTime() { - return(m_EncodingTime); + return(m_encodingTime); } QDateTime cMediaInfo::originalReleaseTime() { - return(m_OriginalReleaseTime); + return(m_originalReleaseTime); } QDateTime cMediaInfo::recordingTime() { - return(m_RecordingTime); + return(m_recordingTime); } QDateTime cMediaInfo::releaseTime() { - return(m_ReleaseTime); + return(m_releaseTime); } QDateTime cMediaInfo::taggingTime() { - return(m_TaggingTime); + return(m_taggingTime); } QStringList cMediaInfo::swhwSettings() diff --git a/cmediainfo.h b/cmediainfo.h index f840f87..6c85ed2 100644 --- a/cmediainfo.h +++ b/cmediainfo.h @@ -69,13 +69,15 @@ public: ~cMediaInfo(); bool readFromFile(const QString& szFileName); - bool readFromDB(const QSqlDatabase& db); - bool writeToDB(const QSqlDatabase& db); + bool readFromDB(); + bool writeToDB(); bool isValid(); // QString fileName(); + qint64 fileSize(); + QDateTime fileDate(); MEDIA_TYPE fileType1(); QString fileType1Text(); @@ -179,7 +181,7 @@ protected: bool m_bProperties; bool m_bIsValid; QString m_szFileName; - MEDIA_TYPE m_FileType; + MEDIA_TYPE m_fileType; qint32 m_iLength; qint16 m_iBitrate; @@ -231,7 +233,7 @@ protected: QString m_szComposer; // TCOM QString m_szEncodedBy; // TENC - // Derived and subjective properties frames + // Derrived and subjective properties frames qint16 m_iBeatsPerMinute; // TBPM // qint16 m_iLength; // TLEN // TKEY @@ -252,11 +254,11 @@ protected: // Other text frames QString m_szOriginalFilename; // TOFN qint32 m_iPlaylistDelay; // TDLY - QDateTime m_EncodingTime; // TDEN - QDateTime m_OriginalReleaseTime; // TDOR - QDateTime m_RecordingTime; // TDRC - QDateTime m_ReleaseTime; // TDRL - QDateTime m_TaggingTime; // TDTG + QDateTime m_encodingTime; // TDEN + QDateTime m_originalReleaseTime; // TDOR + QDateTime m_recordingTime; // TDRC + QDateTime m_releaseTime; // TDRL + QDateTime m_taggingTime; // TDTG QStringList m_szswhwSettings; // TSSE QString m_szAlbumSortOrder; // TSOA QString m_szPerformerSortOrder; // TSOP @@ -278,6 +280,7 @@ protected: cTAGList m_TAGPropertiesList; cImageList m_imageList; + QList m_images; void clear(); @@ -287,6 +290,8 @@ protected: void readTagProperties(TagLib::PropertyMap& tags); QDateTime str2TS(const QString& sz); + + qint32 writeFilename(); }; #endif // CMEDIAINFO_H diff --git a/common.cpp b/common.cpp new file mode 100644 index 0000000..67c02a2 --- /dev/null +++ b/common.cpp @@ -0,0 +1 @@ +#include "common.h" diff --git a/common.h b/common.h new file mode 100644 index 0000000..d4e2cb9 --- /dev/null +++ b/common.h @@ -0,0 +1,11 @@ +#ifndef COMMON_H +#define COMMON_H + + +#include + + +#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":" + + +#endif // COMMON_H diff --git a/cstring.cpp b/cstring.cpp index dea0148..88604b1 100644 --- a/cstring.cpp +++ b/cstring.cpp @@ -11,6 +11,16 @@ cStringTime::cStringTime(const qint32& iTime, const QString& szString) : { } +qint32 cStringTime::time() +{ + return(m_iTime); +} + +QString cStringTime::string() +{ + return(m_szString); +} + cStringTimeList::cStringTimeList() { } @@ -22,6 +32,19 @@ cStringTime* cStringTimeList::add(const qint32& iTime, const QString& szString) return(lpNew); } +QString cStringTimeList::join() +{ + QStringList szList; + QString str; + + for(int x = 0;x < count();x++) + { + str = QString::number(at(x)->time()) + "|" + at(x)->string(); + szList.append(str); + } + return(szList.join("||")); +} + cString21::cString21() : m_szLeft(QStringList()), m_szRight("") diff --git a/cstring.h b/cstring.h index 0853035..4b0514a 100644 --- a/cstring.h +++ b/cstring.h @@ -12,6 +12,9 @@ class cStringTime public: explicit cStringTime(); explicit cStringTime(const qint32& iTime, const QString& szString); + + qint32 time(); + QString string(); protected: qint32 m_iTime; QString m_szString; @@ -27,6 +30,7 @@ class cStringTimeList : public QList public: cStringTimeList(); cStringTime* add(const qint32& iTime, const QString& szString); + QString join(); }; diff --git a/qtJukeBox.pro b/qtJukeBox.pro index 3324bc5..69ec4f7 100644 --- a/qtJukeBox.pro +++ b/qtJukeBox.pro @@ -22,14 +22,16 @@ SOURCES += main.cpp\ ctag.cpp \ cdatabase.cpp \ cstring.cpp \ - cimage.cpp + cimage.cpp \ + common.cpp HEADERS += cmainwindow.h \ cmediainfo.h \ ctag.h \ cdatabase.h \ cstring.h \ - cimage.h + cimage.h \ + common.h FORMS += cmainwindow.ui