added resolution field

This commit is contained in:
2019-02-20 12:16:15 +01:00
parent 8915a0a216
commit 44fda299d2
11 changed files with 164 additions and 122 deletions
+19 -8
View File
@@ -19,6 +19,8 @@
#include <QLabel>
#include <QButtonGroup>
#include <QSqlQuery>
#include <QDebug>
#include <QTime>
@@ -50,6 +52,15 @@ cEdit::cEdit(QWidget *parent) :
{
ui->setupUi(this);
QSqlQuery query;
query.prepare("SELECT resolution FROM resolution ORDER BY sort;");
if(query.exec())
{
while(query.next())
ui->m_lpResolution->addItem(query.value("resolution").toString());
}
QPalette palette = ui->m_lpDownloadLinkLabel->palette();
QColor col = palette.color(QPalette::Window);
QString color = QString("background-color: rgb(%1,%2,%3,%4);").arg(col.red()).arg(col.green()).arg(col.blue()).arg(95);
@@ -84,9 +95,9 @@ cEdit::~cEdit()
cEpisode* lpEpisode = episodeList.at(y);
if(lpEpisode)
{
lpEpisode->setButton1(0);
lpEpisode->setButton2(0);
lpEpisode->setButton3(0);
lpEpisode->setButton1(nullptr);
lpEpisode->setButton2(nullptr);
lpEpisode->setButton3(nullptr);
}
}
}
@@ -109,7 +120,7 @@ void cEdit::setSerie(cSerie* lpSerie)
ui->m_lpCliffhanger->setChecked(lpSerie->cliffhanger());
ui->m_lpDownloadLink->setText(lpSerie->download());
ui->m_lpLocalPath->setText(lpSerie->localPath());
ui->m_lpResolution->setText(lpSerie->resolution());
ui->m_lpResolution->setCurrentText(lpSerie->resolution());
QString szBanner = lpSerie->fanartBanner();
{
@@ -245,19 +256,19 @@ void cEdit::lpAllDone_clicked()
void cEdit::allInit_clicked()
{
QPushButton* lpButton = (QPushButton*)sender();
QPushButton* lpButton = static_cast<QPushButton*>(sender());
m_lpSerie->seasonInit(lpButton);
}
void cEdit::allProgress_clicked()
{
QPushButton* lpButton = (QPushButton*)sender();
QPushButton* lpButton = static_cast<QPushButton*>(sender());
m_lpSerie->seasonProgress(lpButton);
}
void cEdit::allDone_clicked()
{
QPushButton* lpButton = (QPushButton*)sender();
QPushButton* lpButton = static_cast<QPushButton*>(sender());
m_lpSerie->seasonDone(lpButton);
}
@@ -273,7 +284,7 @@ QString cEdit::localPath()
QString cEdit::resolution()
{
return(ui->m_lpResolution->text());
return(ui->m_lpResolution->currentText());
}
void cEdit::on_m_lpTabWidget_tabBarClicked(int index)
+2 -2
View File
@@ -66,7 +66,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,4,0,2,0,1">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,4,0,2,0,0">
<item>
<widget class="QLabel" name="m_lpDownloadLinkLabel">
<property name="text">
@@ -95,7 +95,7 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_lpResolution"/>
<widget class="QComboBox" name="m_lpResolution"/>
</item>
</layout>
</item>
+14 -56
View File
@@ -235,7 +235,10 @@ void cMainWindow::initDB()
m_db.setHostName("localhost");
m_db.setDatabaseName(szDBPath);
if(!m_db.open())
{
qDebug() << m_db.lastError().text();
return;
}
QSqlQuery query;
@@ -359,71 +362,24 @@ void cMainWindow::initDB()
" cast TEXT,"
" crew TEXT,"
" localPath STRING,"
" resolution STRING,"
" state INTEGER);");
}
if(!m_db.tables().contains("resolution"))
{
query.exec("CREATE TABLE resolution ("
" resolution STRING,"
" SORT INTEGER);");
}
}
void cMainWindow::loadDB()
{
// convertSeries();
loadSeriesDB();
loadMoviesDB();
}
void cMainWindow::convertSeries()
{
QSqlQuery query;
QString szOldIMDBID = "";
cTheMovieDBV3 theMovieDB;
cSerie* lpSerie = nullptr;
if(query.exec("SELECT s.imdbid, s.download, s.cliffhanger, e.episodeNumber, e.seasonNumber, e.state FROM serie_old s LEFT JOIN episode_old e ON s.id = e.seriesID WHERE s.imdbid IS NOT NULL AND s.imdbid <> \"\" ORDER BY s.imdbid, e.seasonNumber, e.episodeNumber;"))
{
while(query.next())
{
QString szIMDBID = query.value("imdbid").toString();
if(!szIMDBID.isEmpty())
{
if(szIMDBID != szOldIMDBID)
{
if(lpSerie)
{
lpSerie->save(m_db);
delete lpSerie;
lpSerie = nullptr;
}
szOldIMDBID = szIMDBID;
lpSerie = theMovieDB.loadSerie(szIMDBID);
if(lpSerie)
{
lpSerie->setDownload(query.value("download").toString());
lpSerie->setCliffhanger(query.value("cliffhanger").toBool());
}
}
if(lpSerie)
{
cSeason* lpSeason = lpSerie->findSeason(query.value("seasonNumber").toInt());
if(lpSeason)
{
cEpisode* lpEpisode = lpSeason->findEpisode(query.value("episodeNumber").toInt());
if(lpEpisode)
lpEpisode->setState(query.value("state").value<cEpisode::State>());
}
}
}
}
}
if(lpSerie)
{
lpSerie->save(m_db);
delete lpSerie;
lpSerie = nullptr;
}
}
void cMainWindow::loadSeriesDB()
{
m_serieList.clear();
@@ -628,7 +584,7 @@ void cMainWindow::loadMoviesDB()
QSqlQuery query;
qint32 iMovieID;
if(query.exec("SELECT movieID, movieTitle, originalTitle, backdropPath, posterPath, overview, releaseDate, genre, imdbid, originalLanguage, popularity, productionCompanies, productionCountries, voteAverage, voteCount, adult, belongsToCollection, budget, homepage, revenue, runtime, spokenLanguages, status, tagline, video, `cast`, crew, state, sortText FROM (SELECT *, IFNULL(belongsToCollection, movieTitle) AS sortText FROM movie) ORDER BY sortText, releaseDate;"))
if(query.exec("SELECT movieID, movieTitle, originalTitle, backdropPath, posterPath, overview, releaseDate, genre, imdbid, originalLanguage, popularity, productionCompanies, productionCountries, voteAverage, voteCount, adult, belongsToCollection, budget, homepage, revenue, runtime, spokenLanguages, status, tagline, video, `cast`, crew, state, sortText, localPath, resolution FROM (SELECT *, IFNULL(belongsToCollection, movieTitle) AS sortText FROM movie) ORDER BY sortText, releaseDate;"))
{
while(query.next())
{
@@ -662,6 +618,8 @@ void cMainWindow::loadMoviesDB()
lpMovie->setCast(query.value("cast").toString().split("|"));
lpMovie->setCrew(query.value("crew").toString().split("|"));
lpMovie->setState(query.value("state").value<cMovie::State>());
lpMovie->setLocalPath(query.value("localPath").toString());
lpMovie->setResolution(query.value("resolution").toString());
}
qint32 iOldMovieID = -1;
-7
View File
@@ -494,13 +494,6 @@ private:
*/
void loadDB();
/*!
\brief
\fn convertSeries
*/
void convertSeries();
/*!
\brief
+29 -5
View File
@@ -23,7 +23,9 @@ cMovie::cMovie() :
m_bVideo(false),
m_dVoteAverage(0.0),
m_iVoteCount(0),
m_iState(StateInit)
m_iState(StateInit),
m_szLocalPath(""),
m_szResolution("")
{
}
@@ -327,6 +329,26 @@ cMovie::State cMovie::state()
return(m_iState);
}
void cMovie::setLocalPath(const QString& szLocalPath)
{
m_szLocalPath = szLocalPath;
}
QString cMovie::localPath()
{
return(m_szLocalPath);
}
void cMovie::setResolution(const QString& szResolution)
{
m_szResolution = szResolution;
}
QString cMovie::resolution()
{
return(m_szResolution);
}
void cMovie::loadFanart()
{
cFanartTV fanartTV;
@@ -349,8 +371,8 @@ bool cMovie::save(QSqlDatabase &db)
QSqlQuery queryMovie;
QSqlQuery queryFanart;
queryMovie.prepare("INSERT INTO movie (movieID,movieTitle,originalTitle,backdropPath,posterPath,overview,releaseDate,genre,imdbid,originalLanguage,popularity,productionCompanies,productionCountries,voteAverage,voteCount,adult,belongsToCollection,budget,homepage,revenue,runtime,spokenLanguages,status,tagline,video,cast,crew,state)"
" VALUES (:movieID,:movieTitle,:originalTitle,:backdropPath,:posterPath,:overview,:releaseDate,:genre,:imdbid,:originalLanguage,:popularity,:productionCompanies,:productionCountries,:voteAverage,:voteCount,:adult,:belongsToCollection,:budget,:homepage,:revenue,:runtime,:spokenLanguages,:status,:tagline,:video,:cast,:crew,:state);");
queryMovie.prepare("INSERT INTO movie (movieID,movieTitle,originalTitle,backdropPath,posterPath,overview,releaseDate,genre,imdbid,originalLanguage,popularity,productionCompanies,productionCountries,voteAverage,voteCount,adult,belongsToCollection,budget,homepage,revenue,runtime,spokenLanguages,status,tagline,video,cast,crew,state,localPath,resolution)"
" VALUES (:movieID,:movieTitle,:originalTitle,:backdropPath,:posterPath,:overview,:releaseDate,:genre,:imdbid,:originalLanguage,:popularity,:productionCompanies,:productionCountries,:voteAverage,:voteCount,:adult,:belongsToCollection,:budget,:homepage,:revenue,:runtime,:spokenLanguages,:status,:tagline,:video,:cast,:crew,:state,:localPath,:resolution);");
queryFanart.prepare("INSERT INTO fanart (id,type,url,language,likes,discType,disc,active,movieID) VALUES (:id,:type,:url,:language,:likes,:discType,:disc,:active,:movieID);");
db.transaction();
@@ -385,6 +407,8 @@ bool cMovie::save(QSqlDatabase &db)
queryMovie.bindValue(":cast", cast().join("|"));
queryMovie.bindValue(":crew", crew().join("|"));
queryMovie.bindValue(":state", state());
queryMovie.bindValue(":localPath", localPath());
queryMovie.bindValue(":resolution", resolution());
if(queryMovie.exec())
{
@@ -452,7 +476,7 @@ cMovie* cMovieList::add(cMovie* lpMovie)
for(int z = 0;z < count();z++)
{
if(at(z) == lpMovie)
return(0);
return(nullptr);
}
append(lpMovie);
return(lpMovie);
@@ -465,5 +489,5 @@ cMovie* cMovieList::find(const qint32& iID)
if(at(z)->movieID() == iID)
return(at(z));
}
return(0);
return(nullptr);
}
+32
View File
@@ -482,6 +482,36 @@ public:
*/
State state();
/*!
\brief
\fn setLocalPath
\param szLocalPath
*/
void setLocalPath(const QString& szLocalPath);
/*!
\brief
\fn localPath
\return QString
*/
QString localPath();
/*!
\brief
\fn setResolution
\param szResolution
*/
void setResolution(const QString& szResolution);
/*!
\brief
\fn resolution
\return QString
*/
QString resolution();
/*!
\brief
@@ -549,6 +579,8 @@ private:
QStringList m_szCast; /*!< TODO: describe */
QStringList m_szCrew; /*!< TODO: describe */
State m_iState; /*!< TODO: describe */
QString m_szLocalPath; /*!< TODO: describe */
QString m_szResolution; /*!< TODO: describe */
cFanartList m_fanartList; /*!< TODO: describe */
};
+25 -14
View File
@@ -3,16 +3,27 @@
#include "ui_cmovieedit.h"
#include <QSqlQuery>
cMovieEdit::cMovieEdit(QWidget *parent) :
QDialog(parent),
ui(new Ui::cMovieEdit),
m_lpMovie(0),
m_lpActorsModel(0),
m_lpGenreModel(0)
m_lpMovie(nullptr),
m_lpActorsModel(nullptr),
m_lpGenreModel(nullptr)
{
ui->setupUi(this);
QSqlQuery query;
query.prepare("SELECT resolution FROM resolution ORDER BY sort;");
if(query.exec())
{
while(query.next())
ui->m_lpResolution->addItem(query.value("resolution").toString());
}
m_lpActorsModel = new QStandardItemModel(0, 0);
ui->m_lpDetailsActors->setModel(m_lpActorsModel);
@@ -37,6 +48,8 @@ void cMovieEdit::setMovie(cMovie *lpMovie)
ui->m_lpName->setText(lpMovie->movieTitle());
ui->m_lpFirstAired->setDate(lpMovie->releaseDate());
ui->m_lpLocalPath->setText(lpMovie->localPath());
ui->m_lpResolution->setCurrentText(lpMovie->resolution());
switch(lpMovie->state())
{
@@ -78,17 +91,15 @@ void cMovieEdit::setMovie(cMovie *lpMovie)
ui->m_lpDetailsGenre->resizeColumnToContents(0);
}
void cMovieEdit::on_m_lpInit_clicked()
void cMovieEdit::on_buttonBox_accepted()
{
m_lpMovie->setState(cMovie::StateInit);
}
m_lpMovie->setLocalPath(ui->m_lpLocalPath->text());
m_lpMovie->setResolution(ui->m_lpResolution->currentText());
void cMovieEdit::on_m_lpProgress_clicked()
{
m_lpMovie->setState(cMovie::StateProgress);
}
void cMovieEdit::on_m_lpDone_clicked()
{
m_lpMovie->setState(cMovie::StateDone);
if(ui->m_lpInit->isChecked())
m_lpMovie->setState(cMovie::StateInit);
else if(ui->m_lpProgress->isChecked())
m_lpMovie->setState(cMovie::StateProgress);
else
m_lpMovie->setState(cMovie::StateDone);
}
+7 -21
View File
@@ -28,7 +28,7 @@ public:
\fn cMovieEdit
\param parent
*/
explicit cMovieEdit(QWidget *parent = 0);
explicit cMovieEdit(QWidget *parent = nullptr);
/*!
\brief
@@ -47,29 +47,15 @@ private slots:
/*!
\brief
\fn on_m_lpInit_clicked
\fn on_buttonBox_accepted
*/
void on_m_lpInit_clicked();
/*!
\brief
\fn on_m_lpProgress_clicked
*/
void on_m_lpProgress_clicked();
/*!
\brief
\fn on_m_lpDone_clicked
*/
void on_m_lpDone_clicked();
void on_buttonBox_accepted();
private:
Ui::cMovieEdit* ui; /*!< TODO: describe */
cMovie* m_lpMovie; /*!< TODO: describe */
QStandardItemModel* m_lpActorsModel;
QStandardItemModel* m_lpGenreModel;
Ui::cMovieEdit* ui; /*!< TODO: describe */
cMovie* m_lpMovie; /*!< TODO: describe */
QStandardItemModel* m_lpActorsModel; /*!< TODO: describe */
QStandardItemModel* m_lpGenreModel; /*!< TODO: describe */
};
#endif // CMOVIEEDIT_H
+24
View File
@@ -43,6 +43,30 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Local Path:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_lpLocalPath"/>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Resolution:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_lpResolution"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
+12 -2
View File
@@ -398,6 +398,16 @@ QString cSerie::localPath()
return(m_szLocalPath);
}
void cSerie::setResolution(const QString& szResolution)
{
m_szResolution = szResolution;
}
QString cSerie::resolution()
{
return(m_szResolution);
}
void cSerie::setCliffhanger(const bool& bCliffhanger)
{
m_bCliffhanger = bCliffhanger;
@@ -424,7 +434,7 @@ cSeason* cSerie::findSeason(const qint32& iSeason)
if(m_seasonList.at(z)->seasonNumber() == iSeason)
return(m_seasonList.at(z));
}
return(0);
return(nullptr);
}
QList<cSeason*> cSerie::seasonList()
@@ -468,7 +478,7 @@ cEpisode* cSerie::findEpisode(const qint32& id)
return(lpEpisode);
}
}
return(0);
return(nullptr);
}
bool cSerie::isValid()
-7
View File
@@ -556,13 +556,6 @@ public:
*/
QString localPath();
/*!
\brief
\fn setCliffhanger
\param bCliffhanger
*/
/*!
\brief