Added table "episode"
This commit is contained in:
@@ -98,7 +98,7 @@ void cEdit::setSerie(cSerie* lpSerie)
|
||||
{
|
||||
cSeason* lpSeason = seasonList.at(x);
|
||||
|
||||
m_lpGroupBox = new QGroupBox(QString("Season %1").arg(lpSeason->number()), ui->m_lpScrollAreaWidget);
|
||||
m_lpGroupBox = new QGroupBox(QString("Season %1").arg(lpSeason->seasonNumber()), ui->m_lpScrollAreaWidget);
|
||||
lpSeason->setGroupBox(m_lpGroupBox);
|
||||
m_lpGridLayout = new QGridLayout(m_lpGroupBox);
|
||||
lpSeason->setGridLayout(m_lpGridLayout);
|
||||
@@ -275,7 +275,7 @@ void cEdit::on_m_lpTabWidget_tabBarClicked(int index)
|
||||
{
|
||||
cSeason* lpSeason = m_lpSerie->seasonList().at(x);
|
||||
cSeasonDetails* lpSeasonDetails = new cSeasonDetails(ui->m_lpDetailsSeasonTab);
|
||||
ui->m_lpDetailsSeasonTab->addTab(lpSeasonDetails, QString("Season %1").arg(lpSeason->number()));
|
||||
ui->m_lpDetailsSeasonTab->addTab(lpSeasonDetails, QString("Season %1").arg(lpSeason->seasonNumber()));
|
||||
lpSeasonDetails->setSeason(lpSeason);
|
||||
}
|
||||
|
||||
|
||||
+34
-11
@@ -214,6 +214,19 @@ void cMainWindow::initDB()
|
||||
" cliffhanger BOOL);");
|
||||
}
|
||||
|
||||
if(!m_db.tables().contains("season"))
|
||||
{
|
||||
query.exec("CREATE TABLE season ("
|
||||
" _id INTEGER,"
|
||||
" airDate DATE,"
|
||||
" name STRING,"
|
||||
" overview TEXT,"
|
||||
" id INTEGER,"
|
||||
" posterPath STRING,"
|
||||
" seasonNumber INTEGER,"
|
||||
" seriesID INTEGER);");
|
||||
}
|
||||
|
||||
if(!m_db.tables().contains("episode"))
|
||||
{
|
||||
query.exec("CREATE TABLE episode ("
|
||||
@@ -234,6 +247,7 @@ void cMainWindow::initDB()
|
||||
" state INT);");
|
||||
|
||||
}
|
||||
|
||||
if(!m_db.tables().contains("movie"))
|
||||
{
|
||||
query.exec("CREATE TABLE movie ("
|
||||
@@ -328,6 +342,15 @@ void cMainWindow::convertSeries()
|
||||
lpSerie = 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
qint16 _id();
|
||||
QDate airDate();
|
||||
QString name();
|
||||
QString overview();
|
||||
qint16 id();
|
||||
QString posterPath();
|
||||
qint16 seasonNumber();
|
||||
*/
|
||||
|
||||
void cMainWindow::loadSeriesDB()
|
||||
{
|
||||
@@ -525,7 +548,7 @@ void cMainWindow::displaySeries()
|
||||
QString szDone = "";
|
||||
|
||||
cSeason* lpSeason = seasonList.at(season);
|
||||
lpItems.at(lpSeason->number()+3-iMin)->setData(QVariant::fromValue(lpSeason), Qt::UserRole);
|
||||
lpItems.at(lpSeason->seasonNumber()+3-iMin)->setData(QVariant::fromValue(lpSeason), Qt::UserRole);
|
||||
|
||||
for(int y = 0;y < lpSeason->episodeList().count();y++)
|
||||
{
|
||||
@@ -538,7 +561,7 @@ void cMainWindow::displaySeries()
|
||||
else
|
||||
szInit.append(QString(", %1").arg(lpSeason->episodeList().at(y)->episodeNumber()));
|
||||
|
||||
if(lpSeason->number())
|
||||
if(lpSeason->seasonNumber())
|
||||
bHasInit = true;
|
||||
}
|
||||
else if(lpSeason->episodeList().at(y)->state() == cEpisode::StateProgress)
|
||||
@@ -548,7 +571,7 @@ void cMainWindow::displaySeries()
|
||||
else
|
||||
szProg.append(QString(", %1").arg(lpSeason->episodeList().at(y)->episodeNumber()));
|
||||
|
||||
if(lpSeason->number())
|
||||
if(lpSeason->seasonNumber())
|
||||
bHasProg = true;
|
||||
}
|
||||
else if(lpSeason->episodeList().at(y)->state() == cEpisode::StateDone)
|
||||
@@ -558,7 +581,7 @@ void cMainWindow::displaySeries()
|
||||
else
|
||||
szDone.append(QString(", %1").arg(lpSeason->episodeList().at(y)->episodeNumber()));
|
||||
|
||||
if(lpSeason->number())
|
||||
if(lpSeason->seasonNumber())
|
||||
bHasDone = true;
|
||||
}
|
||||
}
|
||||
@@ -570,15 +593,15 @@ void cMainWindow::displaySeries()
|
||||
else
|
||||
szTooltip.append("open: " + szInit + "\n");
|
||||
|
||||
if(lpSeason->number())
|
||||
if(lpSeason->seasonNumber())
|
||||
{
|
||||
if(szOpen.length())
|
||||
szOpen += "\n";
|
||||
|
||||
if(szInit.isEmpty())
|
||||
szOpen += QString("Season %1: none").arg(lpSeason->number(), 2, 10, QChar('0'));
|
||||
szOpen += QString("Season %1: none").arg(lpSeason->seasonNumber(), 2, 10, QChar('0'));
|
||||
else
|
||||
szOpen += QString("Season %1: %2").arg(lpSeason->number(), 2, 10, QChar('0')).arg(szInit);
|
||||
szOpen += QString("Season %1: %2").arg(lpSeason->seasonNumber(), 2, 10, QChar('0')).arg(szInit);
|
||||
}
|
||||
|
||||
if(szProg.isEmpty())
|
||||
@@ -592,9 +615,9 @@ void cMainWindow::displaySeries()
|
||||
szTooltip.append("done: " + szDone);
|
||||
|
||||
if(szTooltip.isEmpty())
|
||||
lpItems.at(lpSeason->number()+3-iMin)->setToolTip(szTooltip);
|
||||
lpItems.at(lpSeason->seasonNumber()+3-iMin)->setToolTip(szTooltip);
|
||||
else
|
||||
lpItems.at(lpSeason->number()+3-iMin)->setToolTip(szTooltip);
|
||||
lpItems.at(lpSeason->seasonNumber()+3-iMin)->setToolTip(szTooltip);
|
||||
}
|
||||
|
||||
if(lpSerie->status().compare("Ended", Qt::CaseInsensitive) &&
|
||||
@@ -997,7 +1020,7 @@ void cMainWindow::onActionAdd()
|
||||
|
||||
cTheMovieDBV3 movieDB3;
|
||||
|
||||
lpSerie = movieDB3.loadSerie(id, "de-AT");
|
||||
lpSerie = movieDB3.loadSerie(id, "de-DE");
|
||||
if(!lpSerie)
|
||||
lpSerie = movieDB3.loadSerie(id, "en");
|
||||
|
||||
@@ -1091,7 +1114,7 @@ void cMainWindow::onActionMovieAdd()
|
||||
|
||||
cTheMovieDBV3 movieDB3;
|
||||
|
||||
lpMovie = movieDB3.loadMovie(id, "de-AT");
|
||||
lpMovie = movieDB3.loadMovie(id, "de-DE");
|
||||
if(!lpMovie)
|
||||
lpMovie = movieDB3.loadMovie(id, "en");
|
||||
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ void cMovieSearch::on_m_lpSearchButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
QList<cMovie*> movieList = theMovieDBV3.searchMovie(szSearchText, iYear, "de-AT");
|
||||
QList<cMovie*> movieList = theMovieDBV3.searchMovie(szSearchText, iYear, "de-DE");
|
||||
|
||||
ui->m_lpResults->clear();
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ void cPicturesThread::run()
|
||||
cSeason* lpSeason;
|
||||
lpSeason = lpSerie->seasonList().at(y);
|
||||
|
||||
emit picturesMessage(QString("%1 - Season %2").arg(lpSerie->seriesName()).arg(lpSeason->number()), iCurrent);
|
||||
emit picturesMessage(QString("%1 - Season %2").arg(lpSerie->seriesName()).arg(lpSeason->seasonNumber()), iCurrent);
|
||||
|
||||
for(int x = 0;x < lpSeason->episodeList().count();x++)
|
||||
{
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ void cSearch::on_m_lpSearchButton_clicked()
|
||||
|
||||
cTheMovieDBV3 theMovieDBV3;
|
||||
|
||||
QList<cSerie*> serieList3 = theMovieDBV3.searchSerie(ui->m_lpSearch->text(), -1, "de-AT");
|
||||
QList<cSerie*> serieList3 = theMovieDBV3.searchSerie(ui->m_lpSearch->text(), -1, "de-DE");
|
||||
|
||||
ui->m_lpResults->clear();
|
||||
|
||||
|
||||
+75
-5
@@ -3,7 +3,13 @@
|
||||
#define DELETE(x) { if(x) delete x; x=0; }
|
||||
|
||||
cSeason::cSeason() :
|
||||
m_iNumber(-1),
|
||||
m_i_ID(-1),
|
||||
m_airDate(QDate(1900, 1, 1)),
|
||||
m_szName(""),
|
||||
m_szOverview(""),
|
||||
m_iID(-1),
|
||||
m_szPosterPath(""),
|
||||
m_iSeasonNumber(-1),
|
||||
m_lpGroupBox(0),
|
||||
m_lpGridLayout(0),
|
||||
m_lpGrid(0),
|
||||
@@ -22,14 +28,78 @@ cSeason::~cSeason()
|
||||
deleteResources();
|
||||
}
|
||||
|
||||
void cSeason::setNumber(const qint16& iNumber)
|
||||
void cSeason::set_ID(const qint16& _iID)
|
||||
{
|
||||
m_iNumber = iNumber;
|
||||
m_i_ID = _iID;
|
||||
}
|
||||
qint16 cSeason::_id()
|
||||
{
|
||||
return(m_i_ID);
|
||||
}
|
||||
|
||||
qint16 cSeason::number()
|
||||
void cSeason::setAirDate(const QString& szAirDate)
|
||||
{
|
||||
return(m_iNumber);
|
||||
m_airDate = QDate::fromString(szAirDate, "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
void cSeason::setAirDate(const QDate& airDate)
|
||||
{
|
||||
m_airDate = airDate;
|
||||
}
|
||||
|
||||
QDate cSeason::airDate()
|
||||
{
|
||||
return(m_airDate);
|
||||
}
|
||||
|
||||
void cSeason::setName(const QString& szName)
|
||||
{
|
||||
m_szName = szName;
|
||||
}
|
||||
|
||||
QString cSeason::name()
|
||||
{
|
||||
return(m_szName);
|
||||
}
|
||||
|
||||
void cSeason::setOverview(const QString& szOverview)
|
||||
{
|
||||
m_szOverview = szOverview;
|
||||
}
|
||||
|
||||
QString cSeason::overview()
|
||||
{
|
||||
return(m_szOverview);
|
||||
}
|
||||
|
||||
void cSeason::setID(const qint16& iID)
|
||||
{
|
||||
m_iID = iID;
|
||||
}
|
||||
|
||||
qint16 cSeason::id()
|
||||
{
|
||||
return(m_iID);
|
||||
}
|
||||
|
||||
void cSeason::setPosterPath(const QString& szPosterPath)
|
||||
{
|
||||
m_szPosterPath = szPosterPath;
|
||||
}
|
||||
|
||||
QString cSeason::posterPath()
|
||||
{
|
||||
return(m_szPosterPath);
|
||||
}
|
||||
|
||||
void cSeason::setSeasonNumber(const qint16& iSeasonNumber)
|
||||
{
|
||||
m_iSeasonNumber = iSeasonNumber;
|
||||
}
|
||||
|
||||
qint16 cSeason::seasonNumber()
|
||||
{
|
||||
return(m_iSeasonNumber);
|
||||
}
|
||||
|
||||
void cSeason::setSerie(cSerie* lpSerie)
|
||||
|
||||
@@ -22,8 +22,27 @@ public:
|
||||
cSeason();
|
||||
~cSeason();
|
||||
|
||||
void setNumber(const qint16& iNumber);
|
||||
qint16 number();
|
||||
void set_ID(const qint16& _iID);
|
||||
qint16 _id();
|
||||
|
||||
void setAirDate(const QString& szAirDate);
|
||||
void setAirDate(const QDate& airDate);
|
||||
QDate airDate();
|
||||
|
||||
void setName(const QString& szName);
|
||||
QString name();
|
||||
|
||||
void setOverview(const QString& szOverview);
|
||||
QString overview();
|
||||
|
||||
void setID(const qint16& iID);
|
||||
qint16 id();
|
||||
|
||||
void setPosterPath(const QString& szPosterPath);
|
||||
QString posterPath();
|
||||
|
||||
void setSeasonNumber(const qint16& iSeasonNumber);
|
||||
qint16 seasonNumber();
|
||||
|
||||
void setSerie(cSerie* lpSerie);
|
||||
cSerie* serie();
|
||||
@@ -55,7 +74,13 @@ public:
|
||||
QPushButton* allProgressButton();
|
||||
QPushButton* allDoneButton();
|
||||
private:
|
||||
qint16 m_iNumber;
|
||||
qint16 m_i_ID;
|
||||
QDate m_airDate;
|
||||
QString m_szName;
|
||||
QString m_szOverview;
|
||||
qint16 m_iID;
|
||||
QString m_szPosterPath;
|
||||
qint16 m_iSeasonNumber;
|
||||
QList<cEpisode*> m_episodeList;
|
||||
QGroupBox* m_lpGroupBox;
|
||||
QGridLayout* m_lpGridLayout;
|
||||
@@ -70,5 +95,4 @@ private:
|
||||
|
||||
Q_DECLARE_METATYPE(cSeason*)
|
||||
|
||||
|
||||
#endif // CSEASON_H
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ QSize cSeasonDelegate::sizeHint(const QStyleOptionViewItem &option, const QModel
|
||||
iTotal = lpEpisode->episodeNumber();
|
||||
}
|
||||
}
|
||||
if(iTotal > 0 && lpSeason->number() != 0)
|
||||
if(iTotal > 0 && lpSeason->seasonNumber() != 0)
|
||||
return(QSize((iTotal+1)*FIELD_STEP, HEIGHT));
|
||||
//return(QSize((iTotal+1)*FIELD_STEP, FIELD_HEIGHT));
|
||||
else
|
||||
|
||||
+26
-8
@@ -344,7 +344,7 @@ bool cSerie::cliffhanger()
|
||||
cSeason* cSerie::addSeason(const qint16& iSeason)
|
||||
{
|
||||
cSeason* lpNew = new cSeason;
|
||||
lpNew->setNumber(iSeason);
|
||||
lpNew->setSeasonNumber(iSeason);
|
||||
lpNew->setSerie(this);
|
||||
m_seasonList.append(lpNew);
|
||||
return(lpNew);
|
||||
@@ -354,7 +354,7 @@ cSeason* cSerie::findSeason(const qint16& iSeason)
|
||||
{
|
||||
for(int z = 0;z < m_seasonList.count();z++)
|
||||
{
|
||||
if(m_seasonList.at(z)->number() == iSeason)
|
||||
if(m_seasonList.at(z)->seasonNumber() == iSeason)
|
||||
return(m_seasonList.at(z));
|
||||
}
|
||||
return(0);
|
||||
@@ -370,8 +370,8 @@ qint16 cSerie::minSeason()
|
||||
qint16 iMin = 9999;
|
||||
for(int z = 0;z < m_seasonList.count();z++)
|
||||
{
|
||||
if(m_seasonList.at(z)->number() < iMin)
|
||||
iMin = m_seasonList.at(z)->number();
|
||||
if(m_seasonList.at(z)->seasonNumber() < iMin)
|
||||
iMin = m_seasonList.at(z)->seasonNumber();
|
||||
}
|
||||
if(iMin == 9999)
|
||||
return(-1);
|
||||
@@ -383,8 +383,8 @@ qint16 cSerie::maxSeason()
|
||||
qint16 iMax = -1;
|
||||
for(int z = 0;z < m_seasonList.count();z++)
|
||||
{
|
||||
if(m_seasonList.at(z)->number() > iMax)
|
||||
iMax = m_seasonList.at(z)->number();
|
||||
if(m_seasonList.at(z)->seasonNumber() > iMax)
|
||||
iMax = m_seasonList.at(z)->seasonNumber();
|
||||
}
|
||||
return(iMax);
|
||||
}
|
||||
@@ -427,13 +427,14 @@ bool cSerie::save(QSqlDatabase &db)
|
||||
{
|
||||
QSqlQuery query;
|
||||
QSqlQuery querySerie;
|
||||
QSqlQuery querySeason;
|
||||
QSqlQuery queryEpisode;
|
||||
|
||||
querySerie.prepare("INSERT INTO serie (seriesID,seriesName,originalName,backdropPath,createdBy,homepage,lastAired,languages,networks,nrEpisodes,nrSeasons,originCountries,originalLanguage,popularity,posterPath,productionCompanies,type,voteAverage,voteCount,overview,firstAired,cast,crew,genre,status,download,cliffhanger)"
|
||||
" VALUES (:seriesID,:seriesName,:originalName,:backdropPath,:createdBy,:homepage,:lastAired,:languages,:networks,:nrEpisodes,:nrSeasons,:originCountries,:originalLanguage,:popularity,:posterPath,:productionCompanies,:type,:voteAverage,:voteCount,:overview,:firstAired,:cast,:crew,:genre,:status,:download,:cliffhanger);");
|
||||
querySeason.prepare("INSERT INTO season (_id,airDate,name,overview,id,posterPath,seasonNumber,seriesID) VALUES (:_id,:airDate,:name,:overview,:id,:posterPath,:seasonNumber,:seriesID);");
|
||||
queryEpisode.prepare("INSERT INTO episode (id,name,episodeNumber,airDate,guestStars,overview,productioncode,seasonNumber,seasonID,seriesID,stillPath,voteAverage,voteCount,crew,state)"
|
||||
" VALUES (:id,:name,:episodeNumber,:airDate,:guestStars,:overview,:productioncode,:seasonNumber,:seasonID,:seriesID,:stillPath,:voteAverage,:voteCount,:crew,:state);");
|
||||
|
||||
db.transaction();
|
||||
query.exec(QString("SELECT seriesID FROM serie WHERE seriesID=%1;").arg(seriesID()));
|
||||
if(!query.next())
|
||||
@@ -472,7 +473,20 @@ bool cSerie::save(QSqlDatabase &db)
|
||||
QList<cSeason*> seasonList1 = seasonList();
|
||||
for(int season = 0;season < seasonList1.count();season++)
|
||||
{
|
||||
QList<cEpisode*> episodeList = seasonList1.at(season)->episodeList();
|
||||
cSeason* lpSeason = seasonList1.at(season);
|
||||
|
||||
querySeason.bindValue(":_id", lpSeason->_id());
|
||||
querySeason.bindValue(":airDate", lpSeason->airDate());
|
||||
querySeason.bindValue(":name", lpSeason->name());
|
||||
querySeason.bindValue(":overview", lpSeason->overview());
|
||||
querySeason.bindValue(":id", lpSeason->id());
|
||||
querySeason.bindValue(":posterPath", lpSeason->posterPath());
|
||||
querySeason.bindValue(":seasonNumber", lpSeason->seasonNumber());
|
||||
querySeason.bindValue(":seriesID", seriesID());
|
||||
if(!querySeason.exec())
|
||||
qDebug() << querySeason.lastError().text();
|
||||
|
||||
QList<cEpisode*> episodeList = lpSeason->episodeList();
|
||||
for(int episode = 0;episode < episodeList.count();episode++)
|
||||
{
|
||||
cEpisode* lpEpisode = episodeList.at(episode);
|
||||
@@ -520,6 +534,10 @@ bool cSerie::del(QSqlDatabase& db)
|
||||
query.bindValue(":seriesID", seriesID());
|
||||
query.exec();
|
||||
|
||||
query.prepare("DELETE FROM season WHERE seriesID=:seriesID;");
|
||||
query.bindValue(":seriesID", seriesID());
|
||||
query.exec();
|
||||
|
||||
query.prepare("DELETE FROM serie WHERE seriesID=:seriesID;");
|
||||
query.bindValue(":seriesID", seriesID());
|
||||
query.exec();
|
||||
|
||||
+9
-2
@@ -314,7 +314,7 @@ cSerie* cTheMovieDBV3::loadSerie(const QString& szIMDBID)
|
||||
tmpObj = tmpArray.at(0).toObject();
|
||||
iID = tmpObj["id"].toInt();
|
||||
|
||||
return(loadSerie(iID, "de-AT"));
|
||||
return(loadSerie(iID, "de-DE"));
|
||||
}
|
||||
else
|
||||
qDebug() << reply->errorString();
|
||||
@@ -325,7 +325,7 @@ cSerie* cTheMovieDBV3::loadSerie(const qint32 &iID, const QString& szLanguage)
|
||||
{
|
||||
cSerie* lpSerie = 0;
|
||||
QNetworkAccessManager networkManager;
|
||||
QNetworkRequest request(QUrl(QString("https://api.themoviedb.org/3/tv/%1?api_key=%2&language=%3&append_to_response=credits,episodes").arg(iID).arg(m_szToken).arg(szLanguage)));
|
||||
QNetworkRequest request(QUrl(QString("https://api.themoviedb.org/3/tv/%1?api_key=%2&language=%3&append_to_response=credits").arg(iID).arg(m_szToken).arg(szLanguage)));
|
||||
|
||||
request.setRawHeader("Content-Type", "application/json");
|
||||
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_szToken).toUtf8());
|
||||
@@ -460,6 +460,13 @@ cSerie* cTheMovieDBV3::loadSerie(const qint32 &iID, const QString& szLanguage)
|
||||
|
||||
delete reply;
|
||||
|
||||
lpSeason->set_ID(jsonEpisodes["_id"].toInt());
|
||||
lpSeason->setAirDate(jsonEpisodes["air_date"].toString());
|
||||
lpSeason->setName(jsonEpisodes["name"].toString());
|
||||
lpSeason->setOverview(jsonEpisodes["overview"].toString());
|
||||
lpSeason->setID(jsonEpisodes["id"].toInt());
|
||||
lpSeason->setPosterPath(jsonEpisodes["poster_path"].toString());
|
||||
|
||||
for(int x = 0;x < jsonArrayEpisodes.count();x++)
|
||||
{
|
||||
tmpObj = jsonArrayEpisodes.at(x).toObject();
|
||||
|
||||
+2
-2
@@ -37,9 +37,9 @@ void cUpdateThread::run()
|
||||
cTheMovieDBV3 theMovieDB;
|
||||
cSerie* lpSerieNew;
|
||||
|
||||
if(lpSerie->seriesID() != -1)
|
||||
if(lpSerie->seriesID() != -1 && lpSerie->seriesID() < 1000000)
|
||||
{
|
||||
lpSerieNew = theMovieDB.loadSerie(lpSerie->seriesID(), "de-AT");
|
||||
lpSerieNew = theMovieDB.loadSerie(lpSerie->seriesID(), "de-DE");
|
||||
if(!lpSerieNew)
|
||||
lpSerieNew = theMovieDB.loadSerie(lpSerie->seriesID(), "en");
|
||||
if(!lpSerieNew)
|
||||
|
||||
Reference in New Issue
Block a user