diff --git a/ckoditextureslibrary.cpp b/ckoditextureslibrary.cpp index f39c484..28c90cd 100644 --- a/ckoditextureslibrary.cpp +++ b/ckoditextureslibrary.cpp @@ -34,7 +34,9 @@ qint16 cKodiTexturesLibrary::init() return(-1); QSqlQuery query(m_db); - if(!query.exec("SELECT idVersion FROM version;")) + query.prepare("SELECT idVersion " + "FROM version;"); + if(!query.exec()) { m_db.close(); return(-1); @@ -62,7 +64,13 @@ qint16 cKodiTexturesLibrary::version() bool cKodiTexturesLibrary::texture(const QString& szURL, qint32& id, QString& szCachedURL) { QSqlQuery query(m_db); - query.exec(QString("SELECT id, url, cachedurl FROM texture WHERE url='%1';").arg(szURL)); + query.prepare("SELECT id, " + " url, " + " cachedurl " + "FROM texture " + "WHERE url=:url;"); + query.bindValue(":url", szURL); + query.exec(); if(query.next()) { id = query.value("id").toInt(); diff --git a/ckodivideolibrary.cpp b/ckodivideolibrary.cpp index 6ff75d9..ecbbb09 100644 --- a/ckodivideolibrary.cpp +++ b/ckodivideolibrary.cpp @@ -39,7 +39,9 @@ qint16 cKodiVideoLibrary::init() return(-1); QSqlQuery query(m_db); - if(!query.exec("SELECT idVersion FROM version;")) + query.prepare("SELECT idVersion " + "FROM version;"); + if(!query.exec()) { m_db.close(); return(-1); @@ -128,7 +130,12 @@ qint32 cKodiVideoLibrary::loadActors() { QSqlQuery query(m_db); - query.exec("SELECT actor_id, name, art_urls FROM actor ORDER BY name;"); + query.prepare("SELECT actor_id, " + " name, " + " art_urls " + "FROM actor " + "ORDER BY name;"); + query.exec(); while(query.next()) { m_videosActorList.add( @@ -144,7 +151,11 @@ qint32 cKodiVideoLibrary::loadCountries() { QSqlQuery query(m_db); - query.exec("SELECT country_id, name FROM country ORDER BY name;"); + query.prepare("SELECT country_id, " + " name " + "FROM country " + "ORDER BY name;"); + query.exec(); while(query.next()) { m_videosCountryList.add( @@ -159,7 +170,11 @@ qint32 cKodiVideoLibrary::loadGenres() { QSqlQuery query(m_db); - query.exec("SELECT genre_id, name FROM genre ORDER BY name;"); + query.prepare("SELECT genre_id, " + " name " + "FROM genre " + "ORDER BY name;"); + query.exec(); while(query.next()) { m_videosGenreList.add( @@ -174,7 +189,11 @@ qint32 cKodiVideoLibrary::loadStudios() { QSqlQuery query(m_db); - query.exec("SELECT studio_id, name FROM studio ORDER BY name;"); + query.prepare("SELECT studio_id, " + " name " + "FROM studio " + "ORDER BY name;"); + query.exec(); while(query.next()) { m_videosStudioList.add( @@ -189,7 +208,12 @@ qint32 cKodiVideoLibrary::loadSets() { QSqlQuery query(m_db); - query.exec("SELECT idSet, strSet, strOverview FROM sets ORDER BY strSet;"); + query.prepare("SELECT idSet, " + " strSet, " + " strOverview " + "FROM sets " + "ORDER BY strSet;"); + query.exec(); while(query.next()) { m_videosSetList.add(query.value("idSet").toInt(), @@ -203,52 +227,53 @@ qint32 cKodiVideoLibrary::loadVideos() { QSqlQuery query(m_db); - query.exec("SELECT idMovie," - " idFile," - " c00," - " c01," - " c02," - " c03," - " c04," - " c05," - " c06," - " c07," - " c08," - " c09," - " c10," - " c11," - " c12," - " c13," - " c14," - " c15," - " c16," - " c17," - " c18," - " c19," - " c20," - " c21," - " c22," - " c23," - " idSet," - " userrating," - " strSet," - " strSetOverview," - " strFileName," - " strPath," - " playCount," - " lastPlayed," - " dateAdded," - " resumeTimeInSeconds," - " totalTimeInSeconds," - " sortText" - " FROM" - " (" - " SELECT *," - " ifnull(strSet, c00) as sortText" - " FROM movie_view" - " )" - " ORDER BY sortText," - " CAST(c07 AS INTEGER);"); + query.prepare("SELECT idMovie, " + " idFile, " + " c00, " + " c01, " + " c02, " + " c03, " + " c04, " + " c05, " + " c06, " + " c07, " + " c08, " + " c09, " + " c10, " + " c11, " + " c12, " + " c13, " + " c14, " + " c15, " + " c16, " + " c17, " + " c18, " + " c19, " + " c20, " + " c21, " + " c22, " + " c23, " + " idSet, " + " userrating, " + " strSet, " + " strSetOverview, " + " strFileName, " + " strPath, " + " playCount, " + " lastPlayed, " + " dateAdded, " + " resumeTimeInSeconds, " + " totalTimeInSeconds, " + " sortText " + "FROM " + " ( " + " SELECT *, " + " ifnull(strSet, c00) as sortText " + " FROM movie_view " + " ) " + "ORDER BY sortText, " + " CAST(c07 AS INTEGER);"); + query.exec(); while(query.next()) { m_videosList.add( @@ -294,41 +319,43 @@ qint32 cKodiVideoLibrary::loadTVShows() { QSqlQuery query(m_db); - query.exec("SELECT idEpisode," - " idFile," - " c00," - " c01," - " c03," - " c04," - " c05," - " c06," - " c09," - " c10," - " c12," - " c13," - " c15," - " c16," - " c17," - " c18," - " idShow," - " userrating," - " idSeason," - " strFileName," - " strPath," - " playCount," - " lastPlayed," - " dateAdded," - " strTitle," - " genre," - " studio," - " premiered," - " mpaa," - " resumeTimeInSeconds," - " totalTimeInSeconds" - " FROM episode_view" - " ORDER BY strTitle," - " CAST(c12 AS INTEGER)," - " CAST(c13 AS INTEGER);"); + query.prepare("SELECT idEpisode, " + " idFile, " + " c00, " + " c01, " + " c03, " + " c04, " + " c05, " + " c06, " + " c09, " + " c10, " + " c12, " + " c13, " + " c15, " + " c16, " + " c17, " + " c18, " + " idShow, " + " userrating, " + " idSeason, " + " strFileName, " + " strPath, " + " playCount, " + " lastPlayed, " + " dateAdded, " + " strTitle, " + " genre, " + " studio, " + " premiered, " + " mpaa, " + " resumeTimeInSeconds, " + " totalTimeInSeconds " + "FROM episode_view " + "ORDER BY strTitle, " + " CAST(c12 AS INTEGER), " + " CAST(c13 AS INTEGER);"); + + query.exec(); while(query.next()) { m_tvShowsList.add( @@ -370,7 +397,19 @@ qint32 cKodiVideoLibrary::loadTVShows() bool cKodiVideoLibrary::art(const QString& szMediaType, const QString& szType, qint32 idMovie, qint32& artID, QString& szURL) { QSqlQuery query(m_db); - query.exec(QString("SELECT art_id, media_id, media_type, type, url FROM art WHERE media_type='%1' AND type='%2' AND media_id=%3;").arg(szMediaType).arg(szType).arg(idMovie)); + query.prepare("SELECT art_id, " + " media_id, " + " media_type, " + " type, " + " url " + "FROM art " + "WHERE media_type=:media_type AND " + " type=:type AND " + " media_id=:media_id;"); + query.bindValue(":media_type", szMediaType); + query.bindValue(":type", szType); + query.bindValue(":media_id", idMovie); + query.exec(); if(query.next()) { artID = query.value("art_id").toInt(); diff --git a/cmainwindow.cpp b/cmainwindow.cpp index fa06a0e..8ae2215 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -42,6 +42,8 @@ cMainWindow::~cMainWindow() void cMainWindow::initUI(QSplashScreen* lpSplashScreen) { + QSettings settings; + ui->setupUi(this); lpSplashScreen->showMessage("initializing UI ...", Qt::AlignLeft | Qt::AlignBottom, Qt::white); @@ -52,14 +54,20 @@ void cMainWindow::initUI(QSplashScreen* lpSplashScreen) m_lpMusicWidget = new cMusicWidget(this); m_lpMusicVideoWidget = new cMusicVideosWidget(this); - ui->m_lpMainTab->addTab(m_lpVideoWidget, QIcon(":/icons/Videos.ico"), "Movies"); - ui->m_lpMainTab->addTab(m_lpTVShowWidget, QIcon(":/icons/TV Shows.ico"), "TV Shows"); - ui->m_lpMainTab->addTab(m_lpMusicWidget, QIcon(":/icons/Musics.ico"), "Music"); - ui->m_lpMainTab->addTab(m_lpMusicVideoWidget, QIcon(":/icons/Videos.ico"), "Music Videos"); -// ui->m_lpMainTab->addTab(m_lpVideoWidget, QIcon(":/icons/empty.ico"), tr("Movies")); -// ui->m_lpMainTab->addTab(m_lpTVShowWidget, QIcon(":/icons/empty.ico"), tr("TV Shows")); -// ui->m_lpMainTab->addTab(m_lpMusicWidget, QIcon(":/icons/empty.ico"), tr("Music")); -// ui->m_lpMainTab->addTab(m_lpMusicVideoWidget, QIcon(":/icons/empty.ico"), tr("Music Videos")); + if(settings.value("icons").toBool()) + { + ui->m_lpMainTab->addTab(m_lpVideoWidget, QIcon(":/icons/Videos.ico"), "Movies"); + ui->m_lpMainTab->addTab(m_lpTVShowWidget, QIcon(":/icons/TV Shows.ico"), "TV Shows"); + ui->m_lpMainTab->addTab(m_lpMusicWidget, QIcon(":/icons/Musics.ico"), "Music"); + ui->m_lpMainTab->addTab(m_lpMusicVideoWidget, QIcon(":/icons/Videos.ico"), "Music Videos"); + } + else + { + ui->m_lpMainTab->addTab(m_lpVideoWidget, QIcon(":/icons/empty.ico"), tr("Movies")); + ui->m_lpMainTab->addTab(m_lpTVShowWidget, QIcon(":/icons/empty.ico"), tr("TV Shows")); + ui->m_lpMainTab->addTab(m_lpMusicWidget, QIcon(":/icons/empty.ico"), tr("Music")); + ui->m_lpMainTab->addTab(m_lpMusicVideoWidget, QIcon(":/icons/empty.ico"), tr("Music Videos")); + } ui->m_lpMainTab->setCurrentIndex(0); @@ -69,7 +77,7 @@ void cMainWindow::initUI(QSplashScreen* lpSplashScreen) void cMainWindow::initDB(QSplashScreen* lpSplashScreen) { QSettings settings; - QString szKodiRoot = settings.value("lastDB", "").toString(); + QString szKodiRoot = settings.value("kodiRoot", "").toString(); if(szKodiRoot.isEmpty()) return; diff --git a/cmyvideos.cpp b/cmyvideos.cpp index 53ae7b6..b683cd8 100644 --- a/cmyvideos.cpp +++ b/cmyvideos.cpp @@ -1207,7 +1207,15 @@ void cMyVideos::loadActors(QSqlDatabase& m_db, cMyVideosActorList videosActorLis return; QSqlQuery query(m_db); - query.exec(QString("SELECT actor_id, role, cast_order FROM actor_link WHERE media_id=%1 AND media_type='movie' ORDER BY cast_order;").arg(m_values.m_idMovie)); + query.prepare("SELECT actor_id, " + " role, " + " cast_order " + "FROM actor_link " + "WHERE media_id=:media_id AND " + " media_type='movie' " + "ORDER BY cast_order;"); + query.bindValue(":media_id", m_values.m_idMovie); + query.exec(); while(query.next()) { cMyVideosActor* lpActor = videosActorList.find(query.value("actor_id").toInt()); @@ -1223,7 +1231,12 @@ void cMyVideos::loadDirectors(QSqlDatabase& m_db, cMyVideosActorList videosActor return; QSqlQuery query(m_db); - query.exec(QString("SELECT actor_id FROM director_link WHERE media_id=%1 AND media_type='movie';").arg(m_values.m_idMovie)); + query.prepare("SELECT actor_id " + "FROM director_link " + "WHERE media_id=:media_id AND " + " media_type='movie';"); + query.bindValue(":media_id", m_values.m_idMovie); + query.exec(); while(query.next()) { cMyVideosActor* lpActor = videosActorList.find(query.value("actor_id").toInt()); @@ -1239,7 +1252,12 @@ void cMyVideos::loadWriters(QSqlDatabase& m_db, cMyVideosActorList videosActorLi return; QSqlQuery query(m_db); - query.exec(QString("SELECT actor_id FROM writer_link WHERE media_id=%1 AND media_type='movie';").arg(m_values.m_idMovie)); + query.prepare("SELECT actor_id " + "FROM writer_link " + "WHERE media_id=:media_id AND " + " media_type='movie';"); + query.bindValue(":media_id", m_values.m_idMovie); + query.exec(); while(query.next()) { cMyVideosActor* lpActor = videosActorList.find(query.value("actor_id").toInt()); @@ -1255,7 +1273,12 @@ void cMyVideos::loadCountries(QSqlDatabase& m_db, cMyVideosCountryList videosCou return; QSqlQuery query(m_db); - query.exec(QString("SELECT country_id FROM country_link WHERE media_id=%1 AND media_type='movie';").arg(m_values.m_idMovie)); + query.prepare("SELECT country_id " + "FROM country_link " + "WHERE media_id=:media_id AND " + " media_type='movie';"); + query.bindValue(":media_id", m_values.m_idMovie); + query.exec(); while(query.next()) { cMyVideosCountry* lpCountry = videosCountryList.find(query.value("country_id").toInt()); @@ -1271,7 +1294,12 @@ void cMyVideos::loadGenres(QSqlDatabase& m_db, cMyVideosGenreList videosGenreLis return; QSqlQuery query(m_db); - query.exec(QString("SELECT genre_id FROM genre_link WHERE media_id=%1 AND media_type='movie';").arg(m_values.m_idMovie)); + query.prepare("SELECT genre_id " + "FROM genre_link " + "WHERE media_id=:media_id AND " + " media_type='movie';"); + query.bindValue(":media_id", m_values.m_idMovie); + query.exec(); while(query.next()) { cMyVideosGenre* lpGenre = videosGenreList.find(query.value("genre_id").toInt()); @@ -1287,7 +1315,12 @@ void cMyVideos::loadStudios(QSqlDatabase& m_db, cMyVideosStudioList videosStudio return; QSqlQuery query(m_db); - query.exec(QString("SELECT studio_id FROM studio_link WHERE media_id=%1 AND media_type='movie';").arg(m_values.m_idMovie)); + query.prepare("SELECT studio_id " + "FROM studio_link " + "WHERE media_id=:media_id AND " + " media_type='movie';"); + query.bindValue(":media_id", m_values.m_idMovie); + query.exec(); while(query.next()) { cMyVideosStudio* lpStudio = videosStudioList.find(query.value("studio_id").toInt()); @@ -1303,7 +1336,16 @@ void cMyVideos::loadVideoStream(QSqlDatabase& m_db) return; QSqlQuery query(m_db); - query.exec(QString("SELECT strVideoCodec, fVideoAspect, iVideoWidth, iVideoHeight, iVideoDuration FROM streamdetails WHERE idFile=%1 AND iStreamType=0;").arg(m_values.m_idFile)); + query.prepare("SELECT strVideoCodec, " + " fVideoAspect, " + " iVideoWidth, " + " iVideoHeight, " + " iVideoDuration " + "FROM streamdetails " + "WHERE idFile=:idFile AND " + " iStreamType=0;"); + query.bindValue(":idFile", m_values.m_idFile); + query.exec(); while(query.next()) { m_values.m_streamVideo.add(query.value("strVideoCodec").toString(), query.value("fVideoAspect").toDouble(), query.value("iVideoWidth").toInt(), query.value("iVideoHeight").toInt()); @@ -1320,7 +1362,15 @@ void cMyVideos::loadAudioStream(QSqlDatabase& m_db) return; QSqlQuery query(m_db); - query.exec(QString("SELECT strAudioCodec, iAudioChannels, strAudioLanguage, strStereoMode FROM streamdetails WHERE idFile=%1 AND iStreamType=1;").arg(m_values.m_idFile)); + query.prepare("SELECT strAudioCodec, " + " iAudioChannels, " + " strAudioLanguage, " + " strStereoMode " + "FROM streamdetails " + "WHERE idFile=:idFile AND " + " iStreamType=1;"); + query.bindValue(":idFile", m_values.m_idFile); + query.exec(); while(query.next()) m_values.m_streamAudio.add(query.value("strAudioCodec").toString(), query.value("iAudioChannels").toInt(), query.value("strAudioLanguage").toString(), query.value("strStereoMode").toString()); @@ -1333,7 +1383,12 @@ void cMyVideos::loadSubtitleStream(QSqlDatabase& m_db) return; QSqlQuery query(m_db); - query.exec(QString("SELECT strSubtitleLanguage FROM streamdetails WHERE idFile=%1 AND iStreamType=2;").arg(m_values.m_idFile)); + query.prepare("SELECT strSubtitleLanguage " + "FROM streamdetails " + "WHERE idFile=:idFile AND " + " iStreamType=2;"); + query.bindValue(":idFile", m_values.m_idFile); + query.exec(); while(query.next()) m_values.m_streamSubtitle.add(query.value("strSubtitleLanguage").toString());