Init
This commit is contained in:
+122
-44
@@ -1,4 +1,5 @@
|
||||
#include "ckodivideolibrary.h"
|
||||
#include "cimage.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QVariant>
|
||||
@@ -63,62 +64,139 @@ qint32 cKodiVideoLibrary::load()
|
||||
{
|
||||
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 FROM movie_view ORDER BY c00;");
|
||||
//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 FROM movie_view ORDER BY c00;");
|
||||
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,"
|
||||
" c07;");
|
||||
while(query.next())
|
||||
{
|
||||
cMyVideos* lpNew = m_videosList.add(
|
||||
query.value("idMovie").toInt(),
|
||||
query.value("idFile").toInt(),
|
||||
query.value("c00").toString(),
|
||||
query.value("c01").toString(),
|
||||
query.value("c02").toString(),
|
||||
query.value("c03").toString(),
|
||||
query.value("c04").toInt(),
|
||||
query.value("c05").toDouble(),
|
||||
query.value("c06").toString(),
|
||||
query.value("c07").toInt(),
|
||||
query.value("c08").toString(),
|
||||
query.value("c09").toString(),
|
||||
query.value("c10").toString(),
|
||||
query.value("c11").toInt(),
|
||||
query.value("c12").toString(),
|
||||
query.value("c13").toString(),
|
||||
query.value("c14").toString(),
|
||||
query.value("c15").toString(),
|
||||
query.value("c16").toString(),
|
||||
query.value("c18").toString(),
|
||||
query.value("c19").toString(),
|
||||
query.value("c20").toString(),
|
||||
query.value("c21").toString(),
|
||||
query.value("c22").toString(),
|
||||
query.value("c23").toInt(),
|
||||
query.value("idSet").toInt(),
|
||||
query.value("userrating").toInt(),
|
||||
query.value("strSet").toString(),
|
||||
query.value("strSetOverview").toString(),
|
||||
query.value("strFileName").toString(),
|
||||
query.value("strPath").toString(),
|
||||
query.value("playCount").toInt(),
|
||||
QDateTime::fromString(query.value("lastPlayed").toString(), "yyyy-MM-dd HH:mm:ss"),
|
||||
QDateTime::fromString(query.value("dateAdded").toString(), "yyyy-MM-dd HH:mm:ss"),
|
||||
query.value("resumeTimeInSeconds").toDouble(),
|
||||
query.value("totalTimeInSeconds").toDouble());
|
||||
m_videosList.add(
|
||||
query.value("idMovie").toInt(),
|
||||
query.value("idFile").toInt(),
|
||||
query.value("c00").toString(),
|
||||
query.value("c01").toString(),
|
||||
query.value("c02").toString(),
|
||||
query.value("c03").toString(),
|
||||
query.value("c04").toInt(),
|
||||
query.value("c05").toDouble(),
|
||||
query.value("c06").toString(),
|
||||
query.value("c07").toInt(),
|
||||
query.value("c08").toString(),
|
||||
query.value("c09").toString(),
|
||||
query.value("c10").toString(),
|
||||
query.value("c11").toInt(),
|
||||
query.value("c12").toString(),
|
||||
query.value("c13").toString(),
|
||||
query.value("c14").toString(),
|
||||
query.value("c15").toString(),
|
||||
query.value("c16").toString(),
|
||||
query.value("c18").toString(),
|
||||
query.value("c19").toString(),
|
||||
query.value("c20").toString(),
|
||||
query.value("c21").toString(),
|
||||
query.value("c22").toString(),
|
||||
query.value("c23").toInt(),
|
||||
query.value("idSet").toInt(),
|
||||
query.value("userrating").toInt(),
|
||||
query.value("strSet").toString(),
|
||||
query.value("strSetOverview").toString(),
|
||||
query.value("strFileName").toString(),
|
||||
query.value("strPath").toString(),
|
||||
query.value("playCount").toInt(),
|
||||
QDateTime::fromString(query.value("lastPlayed").toString(), "yyyy-MM-dd HH:mm:ss"),
|
||||
QDateTime::fromString(query.value("dateAdded").toString(), "yyyy-MM-dd HH:mm:ss"),
|
||||
query.value("resumeTimeInSeconds").toDouble(),
|
||||
query.value("totalTimeInSeconds").toDouble());
|
||||
|
||||
lpNew = 0;
|
||||
}
|
||||
return(m_videosList.count());
|
||||
}
|
||||
|
||||
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));
|
||||
if(query.next())
|
||||
{
|
||||
artID = query.value("art_id").toInt();
|
||||
szURL = query.value("url").toString();
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
void cKodiVideoLibrary::fillVideoList(QStandardItemModel* lpModel)
|
||||
{
|
||||
QStandardItem* lpRoot = 0;
|
||||
QString szOldSet("");
|
||||
|
||||
for(int z = 0;z < m_videosList.count();z++)
|
||||
{
|
||||
cMyVideos* lpVideos = m_videosList.at(z);
|
||||
|
||||
QStandardItem* lpItem = new QStandardItem(lpVideos->localMovieTitle());
|
||||
// QVariant v = qVariantFromValue(lpMovie);
|
||||
// lpItem->setData(v, Qt::UserRole);
|
||||
lpModel->appendRow(lpItem);
|
||||
if(lpVideos->set().length())
|
||||
{
|
||||
if(szOldSet != lpVideos->set())
|
||||
{
|
||||
szOldSet = lpVideos->set();
|
||||
lpRoot = new QStandardItem(QString("<b><i>%1</i></b>").arg(lpVideos->set()));
|
||||
QVariant v = qVariantFromValue(lpVideos);
|
||||
lpRoot->setData(v, Qt::UserRole);
|
||||
lpModel->appendRow(lpRoot);
|
||||
}
|
||||
}
|
||||
else
|
||||
lpRoot = 0;
|
||||
|
||||
QStandardItem* lpItem = new QStandardItem(QString("<b>%1</b><br><font color='blue'>%2</font> <i>%3</i>").arg(lpVideos->localMovieTitle()).arg(lpVideos->yearReleased()).arg(lpVideos->movieTagline()));
|
||||
QVariant v = qVariantFromValue(lpVideos);
|
||||
lpItem->setData(v, Qt::UserRole);
|
||||
if(lpRoot)
|
||||
lpRoot->appendRow(lpItem);
|
||||
else
|
||||
lpModel->appendRow(lpItem);
|
||||
}
|
||||
// ui->m_lpMovies->sortByColumn(0, Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user