From ccf95999e5ccb84ddc361b3bf94adfa70dfea0d3 Mon Sep 17 00:00:00 2001 From: birkeh Date: Tue, 18 Oct 2016 19:54:55 +0200 Subject: [PATCH] Init --- ckodilibrary.cpp | 62 +++++++++++++++++++++++++++++++++++++++ ckodilibrary.h | 30 +++++++++++++++++++ ckodivideolibrary.cpp | 11 +++++-- ckodivideolibrary.h | 3 +- cmainwindow.cpp | 4 ++- cmainwindow.h | 5 ++-- cmainwindow.ui | 68 ++++++++++++++++++++++++++++++++++++------- qtKodiDB.pro | 6 ++-- qtKodiDB.pro.user | 2 +- 9 files changed, 171 insertions(+), 20 deletions(-) create mode 100644 ckodilibrary.cpp create mode 100644 ckodilibrary.h diff --git a/ckodilibrary.cpp b/ckodilibrary.cpp new file mode 100644 index 0000000..b16bbe9 --- /dev/null +++ b/ckodilibrary.cpp @@ -0,0 +1,62 @@ +#include "ckodilibrary.h" + + +#include +#include +#include + + +cKodiLibrary::cKodiLibrary() : + m_szPath(""), + m_szAddons(""), + m_szADSP(""), + m_szEpg(""), + m_szMyMusic(""), + m_szMyVideos(""), + m_szTextures(""), + m_szTV(""), + m_szViewModes("") +{ +} + +cKodiLibrary::~cKodiLibrary() +{ +} + +QString cKodiLibrary::findFile(const QString& szPath, const QString& szFile) +{ + QDir fileList(szPath + QDir::separator() + QString("Userdata") + QDir::separator() + QString("Database"), szFile + QString("*.*")); + QString fileName(""); + QStringList files = fileList.entryList(QDir::Files); + qint16 iVersion = -1; + + for(int x = 0;x < files.count();x++) + { + QString tmp = files.at(x); + tmp = tmp.left(tmp.lastIndexOf(".")); + tmp = tmp.mid(szFile.length()); + if(iVersion < tmp.toInt()) + { + fileName = files.at(x); + iVersion = tmp.toInt(); + } + } + if(fileName.length()) + return(fileList.cleanPath(fileList.absoluteFilePath(fileName))); + return(fileName); +} + +bool cKodiLibrary::init(const QString& szPath) +{ + m_szAddons = findFile(szPath, "Addons"); + m_szADSP = findFile(szPath, "ADSP"); + m_szEpg = findFile(szPath, "Epg"); + m_szMyMusic = findFile(szPath, "MyMusic"); + m_szMyVideos = findFile(szPath, "MyVideos"); + m_szTextures = findFile(szPath, "Textures"); + m_szTV = findFile(szPath, "TV"); + m_szViewModes = findFile(szPath, "ViewModes"); + + m_kodiVideoLibrary.init(m_szMyVideos); + return(true); +} diff --git a/ckodilibrary.h b/ckodilibrary.h new file mode 100644 index 0000000..89fae93 --- /dev/null +++ b/ckodilibrary.h @@ -0,0 +1,30 @@ +#ifndef CKODILIBRARY_H +#define CKODILIBRARY_H + + +#include "ckodivideolibrary.h" + + +class cKodiLibrary +{ +public: + cKodiLibrary(); + ~cKodiLibrary(); + + bool init(const QString &szPath); +private: + QString m_szPath; + QString m_szAddons; + QString m_szADSP; + QString m_szEpg; + QString m_szMyMusic; + QString m_szMyVideos; + QString m_szTextures; + QString m_szTV; + QString m_szViewModes; + cKodiVideoLibrary m_kodiVideoLibrary; + + QString findFile(const QString& szPath, const QString& szFile); +}; + +#endif // CKODILIBRARY_H diff --git a/ckodivideolibrary.cpp b/ckodivideolibrary.cpp index a41563e..23b3fa7 100644 --- a/ckodivideolibrary.cpp +++ b/ckodivideolibrary.cpp @@ -17,10 +17,10 @@ cKodiVideoLibrary::~cKodiVideoLibrary() m_db.close(); } -qint16 cKodiVideoLibrary::connect(const QString& szFileName) +qint16 cKodiVideoLibrary::init(const QString& szFileName) { if(m_bConnected) - return(true); + return(m_iVersion); if(!QFile(szFileName).exists()) return(-1); @@ -50,3 +50,10 @@ qint16 cKodiVideoLibrary::connect(const QString& szFileName) m_bConnected = true; return(m_iVersion); } + +qint16 cKodiVideoLibrary::version() +{ + if(!m_bConnected) + return(-1); + return(m_iVersion); +} diff --git a/ckodivideolibrary.h b/ckodivideolibrary.h index 222d26f..8155785 100644 --- a/ckodivideolibrary.h +++ b/ckodivideolibrary.h @@ -11,7 +11,8 @@ public: cKodiVideoLibrary(); ~cKodiVideoLibrary(); - qint16 connect(const QString& szFileName); + qint16 init(const QString& szFileName); + qint16 version(); private: QSqlDatabase m_db; bool m_bConnected; diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 4eb7c8a..9c150c6 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -7,8 +7,10 @@ cMainWindow::cMainWindow(QWidget *parent) : ui(new Ui::cMainWindow) { ui->setupUi(this); + ui->m_lpMainTab->setCurrentIndex(0); - m_kodiVideoLibrary.connect("C:\\Users\\birkeh\\.kodi\\userdata\\Database\\MyVideos99.db"); + setWindowTitle("qtKodiAdmin"); + m_kodiLibrary.init("C:\\Users\\birkeh\\.kodi"); } cMainWindow::~cMainWindow() diff --git a/cmainwindow.h b/cmainwindow.h index fa60c36..5cec3a7 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -1,7 +1,8 @@ #ifndef CMAINWINDOW_H #define CMAINWINDOW_H -#include "ckodivideolibrary.h" + +#include "ckodilibrary.h" #include @@ -21,7 +22,7 @@ public: private: Ui::cMainWindow* ui; - cKodiVideoLibrary m_kodiVideoLibrary; + cKodiLibrary m_kodiLibrary; }; #endif // CMAINWINDOW_H diff --git a/cmainwindow.ui b/cmainwindow.ui index 2f025dc..69a54ba 100644 --- a/cmainwindow.ui +++ b/cmainwindow.ui @@ -1,24 +1,70 @@ + cMainWindow - - + + 0 0 - 400 - 300 + 785 + 575 - + cMainWindow - - - - + + + + + + 3 + + + + Movies + + + + + TV Shows + + + + + Music + + + + + Music Shows + + + + + + + + + + 0 + 0 + 785 + 21 + + + + + + TopToolBarArea + + + false + + + - - + diff --git a/qtKodiDB.pro b/qtKodiDB.pro index 2782be5..d4d8a35 100644 --- a/qtKodiDB.pro +++ b/qtKodiDB.pro @@ -14,9 +14,11 @@ TEMPLATE = app SOURCES += main.cpp\ cmainwindow.cpp \ - ckodivideolibrary.cpp + ckodivideolibrary.cpp \ + ckodilibrary.cpp HEADERS += cmainwindow.h \ - ckodivideolibrary.h + ckodivideolibrary.h \ + ckodilibrary.h FORMS += cmainwindow.ui diff --git a/qtKodiDB.pro.user b/qtKodiDB.pro.user index 93bb219..e0150a1 100644 --- a/qtKodiDB.pro.user +++ b/qtKodiDB.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId