This commit is contained in:
2017-10-18 13:11:26 +02:00
parent d56bccb43d
commit 7a29d1d26d
14 changed files with 926 additions and 86 deletions
+152 -44
View File
@@ -4,6 +4,7 @@
#include "cthetvdbv2.h"
#include "cseasondelegate.h"
#include "csearch.h"
#include "cmoviesearch.h"
#include "cmessageanimatedialog.h"
#include "cmessagedialog.h"
#include "cedit.h"
@@ -579,52 +580,27 @@ void cMainWindow::displaySeries()
void cMainWindow::on_m_lpSeriesList1_customContextMenuRequested(const QPoint &pos)
{
QMenu* lpMenu = new QMenu(this);
lpMenu->addAction("add", this, SLOT(onActionAdd()));
if(ui->m_lpSeriesList1->selectionModel()->selectedRows().count() == 1)
{
cSerie* lpSerie = m_lpSeriesListModel->itemFromIndex(ui->m_lpSeriesList1->selectionModel()->selectedRows().at(0))->data(Qt::UserRole).value<cSerie*>();
if(lpSerie)
{
lpMenu->addAction("update", this, SLOT(onActionUpdate()));
lpMenu->addAction("delete", this, SLOT(onActionDelete()));
lpMenu->addAction("edit", this, SLOT(onActionEdit()));
lpMenu->addSeparator();
if(!lpSerie->imdbID().isEmpty())
lpMenu->addAction("open IMDB", this, SLOT(onActionGotoIMDB()));
if(!lpSerie->download().isEmpty())
{
lpMenu->addAction("open download link", this, SLOT(onActionGotoDownload()));
lpMenu->addAction("copy download link", this, SLOT(onActionCopyDownload()));
}
lpMenu->addSeparator();
lpMenu->addAction("load images", this, SLOT(onActionLoadPictures()));
}
}
else if(ui->m_lpSeriesList1->selectionModel()->selectedRows().count())
{
lpMenu->addAction("update", this, SLOT(onActionUpdate()));
lpMenu->addAction("delete", this, SLOT(onActionDelete()));
lpMenu->addSeparator();
lpMenu->addAction("load images", this, SLOT(onActionLoadPictures()));
}
lpMenu->popup(ui->m_lpSeriesList1->viewport()->mapToGlobal(pos));
showSeriesContextMenu(ui->m_lpSeriesList1, pos);
}
void cMainWindow::on_m_lpSeriesList2_customContextMenuRequested(const QPoint &pos)
{
showSeriesContextMenu(ui->m_lpSeriesList2, pos);
}
void cMainWindow::showSeriesContextMenu(QTreeView* lpTreeView, const QPoint &pos)
{
QMenu* lpMenu = new QMenu(this);
lpMenu->addAction("add", this, SLOT(onActionAdd()));
if(ui->m_lpSeriesList2->selectionModel()->selectedRows().count() == 1)
lpMenu->addAction("update all", this, SLOT(onActionUpdateAll()));
lpMenu->addAction("update unfinished", this, SLOT(onActionUpdateUnfinished()));
lpMenu->addSeparator();
if(lpTreeView->selectionModel()->selectedRows().count() == 1)
{
cSerie* lpSerie = m_lpSeriesListModel->itemFromIndex(ui->m_lpSeriesList2->selectionModel()->selectedRows().at(0))->data(Qt::UserRole).value<cSerie*>();
cSerie* lpSerie = m_lpSeriesListModel->itemFromIndex(lpTreeView->selectionModel()->selectedRows().at(0))->data(Qt::UserRole).value<cSerie*>();
if(lpSerie)
{
lpMenu->addAction("update", this, SLOT(onActionUpdate()));
@@ -644,15 +620,29 @@ void cMainWindow::on_m_lpSeriesList2_customContextMenuRequested(const QPoint &po
lpMenu->addAction("load images", this, SLOT(onActionLoadPictures()));
}
}
else if(ui->m_lpSeriesList2->selectionModel()->selectedRows().count())
else if(lpTreeView->selectionModel()->selectedRows().count())
{
lpMenu->addAction("update", this, SLOT(onActionUpdate()));
lpMenu->addAction("delete", this, SLOT(onActionDelete()));
lpMenu->addAction("update selected", this, SLOT(onActionUpdate()));
lpMenu->addAction("delete selected", this, SLOT(onActionDelete()));
lpMenu->addSeparator();
lpMenu->addAction("load images", this, SLOT(onActionLoadPictures()));
}
lpMenu->popup(ui->m_lpSeriesList2->viewport()->mapToGlobal(pos));
lpMenu->popup(lpTreeView->viewport()->mapToGlobal(pos));
}
void cMainWindow::on_m_lpMoviesList_customContextMenuRequested(const QPoint &pos)
{
showMoviesContextMenu(ui->m_lpMoviesList, pos);
}
void cMainWindow::showMoviesContextMenu(QTreeView* lpTreeView, const QPoint &pos)
{
QMenu* lpMenu = new QMenu(this);
lpMenu->addAction("add", this, SLOT(onActionMovieAdd()));
lpMenu->popup(lpTreeView->viewport()->mapToGlobal(pos));
}
static bool serieSort(cSerie* s1, cSerie* s2)
@@ -811,9 +801,127 @@ void cMainWindow::onActionAdd()
delete lpDialog;
}
void cMainWindow::onActionMovieAdd()
{
cMovieSearch* lpSearch = new cMovieSearch(this);
if(lpSearch->exec() == QDialog::Rejected)
{
delete lpSearch;
return;
}
qint32 id = lpSearch->id();
QString szPlaceholder = lpSearch->placeholderName();
bool bPlaceholder = lpSearch->placeholder();
qint16 iYear = lpSearch->year();
delete lpSearch;
cMovie* lpMovie = 0;
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Refresh");
lpDialog->setMessage("Loading");
lpDialog->show();
if(!bPlaceholder)
{
if(id == -1)
return;
cTheMovieDBV3 movieDB3;
lpMovie = movieDB3.load(id, "de");
if(!lpMovie)
lpMovie = movieDB3.load(id, "en");
delete lpDialog;
/*
QString szDownload;
if(!runEdit(lpSerie, szDownload))
return;
lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Update");
lpDialog->setMessage("Updating");
lpDialog->show();
lpSerie->save(m_db);
*/
}
else
{
/*
lpSerie = new cSerie;
lpSerie->setSeriesName(szPlaceholder);
qint32 iMax = 0;
QSqlQuery query;
if(query.exec("SELECT MAX(id) FROM serie;"))
{
query.next();
if(query.isValid())
iMax = query.value(0).toInt();
}
if(iMax < 1000000)
iMax = 1000000;
else
iMax++;
lpSerie->setID(iMax);
lpSerie->setFirstAired(QDate(iYear, 1, 1));
lpSerie->save(m_db);
*/
}
/*
m_serieList.add(lpSerie);
std::sort(m_serieList.begin(), m_serieList.end(), serieSort);
m_szOldSelected = lpSerie->seriesName();
displaySeries();
delete lpDialog;
*/
}
void cMainWindow::onActionUpdateAll()
{
cSerieList serieList = m_serieList;
if(serieList.count())
doUpdate(serieList);
}
void cMainWindow::onActionUpdateUnfinished()
{
cSerieList serieList;
for(int x = 0;x < m_serieList.count();x++)
{
cSerie* lpSerie = m_serieList.at(x);
if(lpSerie->status().compare("Ended", Qt::CaseInsensitive))
serieList.add(lpSerie);
}
if(serieList.count())
doUpdate(serieList);
}
void cMainWindow::onActionUpdate()
{
if(ui->m_lpSeriesList1->selectionModel()->selectedRows().count())
cSerieList serieList;
for(int x = 0;x < ui->m_lpSeriesList1->selectionModel()->selectedRows().count();x++)
{
cSerie* lpSerie = ui->m_lpSeriesList1->selectionModel()->selectedRows().at(x).data(Qt::UserRole).value<cSerie*>();
serieList.add(lpSerie);
}
if(serieList.count())
doUpdate(serieList);
}
void cMainWindow::doUpdate(cSerieList& serieList)
{
if(serieList.count())
{
if(ui->m_lpSeriesList1->selectionModel()->selectedRows().count() == 1)
m_szOldSelected = m_lpSeriesListModel->itemFromIndex(ui->m_lpSeriesList1->selectionModel()->selectedIndexes().at(1))->text();
@@ -821,11 +929,11 @@ void cMainWindow::onActionUpdate()
m_lpMessageDialog = new cMessageDialog(this);
m_lpMessageDialog->setWindowTitle("Update");
m_lpMessageDialog->setMessage("Updating");
m_lpMessageDialog->setProgress(0, ui->m_lpSeriesList1->selectionModel()->selectedRows().count());
m_lpMessageDialog->setProgress(0, serieList.count());
m_lpMessageDialog->show();
m_lpUpdateThread = new cUpdateThread;
m_lpUpdateThread->setData(m_lpMessageDialog, ui->m_lpSeriesList1->selectionModel()->selectedRows(), m_db);
m_lpUpdateThread->setData(m_lpMessageDialog, serieList, m_db);
connect(m_lpUpdateThread, SIGNAL(finished()), this, SLOT(updateDone()));
connect(m_lpUpdateThread, SIGNAL(updateMessage(QString,qint32)), this, SLOT(updateMessage(QString,qint32)));
+13
View File
@@ -19,6 +19,8 @@
#include <QStandardItemModel>
#include <QItemSelection>
#include <QTreeView>
namespace Ui {
class cMainWindow;
@@ -42,7 +44,11 @@ private slots:
void on_m_lpSeriesList2_doubleClicked(const QModelIndex &index);
void on_m_lpSeriesList2_pressed(const QModelIndex &index);
void on_m_lpMoviesList_customContextMenuRequested(const QPoint &pos);
void onActionAdd();
void onActionUpdateAll();
void onActionUpdateUnfinished();
void onActionUpdate();
void onActionDelete();
void onActionEdit();
@@ -51,6 +57,8 @@ private slots:
void onActionCopyDownload();
void onActionLoadPictures();
void onActionMovieAdd();
void updateMessage(const QString& szMessage, const qint32 &iProgress);
void updateAppendMessage(const QString& szMessage);
void updateDone();
@@ -91,6 +99,11 @@ private:
void displaySeries();
bool runEdit(cSerie *lpSerie, QString& szDownload);
void showSeriesContextMenu(QTreeView* lpTreeView, const QPoint &pos);
void doUpdate(cSerieList& serieList);
void showMoviesContextMenu(QTreeView* lpTreeView, const QPoint &pos);
protected:
void closeEvent(QCloseEvent *event);
};
+25 -1
View File
@@ -18,7 +18,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="m_lpMainTab">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="m_lpTVShowsTab">
<attribute name="title">
@@ -114,6 +114,30 @@
<attribute name="title">
<string>Movies</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QTreeView" name="m_lpMoviesList">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
+230
View File
@@ -45,3 +45,233 @@ QDate cMovie::releaseDate()
{
return(m_releaseDate);
}
void cMovie::setAdult(const bool bAdult)
{
m_bAdult = bAdult;
}
bool cMovie::adult()
{
return(m_bAdult);
}
void cMovie::setBackdropPath(const QString& szBackdropPath)
{
m_szBackdropPath = szBackdropPath;
}
QString cMovie::backdropPath()
{
return(m_szBackdropPath);
}
void cMovie::setBelongsToCollection(const QString& szBelongsToCollection)
{
m_szBelongsToCollection = szBelongsToCollection;
}
QString cMovie::belongsToCollection()
{
return(m_szBelongsToCollection);
}
void cMovie::setButget(const qreal dBudget)
{
m_dBudget = dBudget;
}
qreal cMovie::budget()
{
return(m_dBudget);
}
void cMovie::setGenres(const QString& szGenres)
{
m_szGenres = szGenres.split(",");
}
void cMovie::setGenres(const QStringList& szGenres)
{
m_szGenres = szGenres;
}
QStringList cMovie::genres()
{
return(m_szGenres);
}
void cMovie::setHomepage(const QString& szHomepage)
{
m_szHomepage = szHomepage;
}
QString cMovie::homepage()
{
return(m_szHomepage);
}
void cMovie::setIMDBID(const QString &szIMDBID)
{
m_szIMDBID = szIMDBID;
}
QString cMovie::imdbID()
{
return(m_szIMDBID);
}
void cMovie::setOriginalLanguage(const QString& szOriginalLanguage)
{
m_szOriginalLanguage = szOriginalLanguage;
}
QString cMovie::originalLanguage()
{
return(m_szOriginalLanguage);
}
void cMovie::setOverview(const QString& szOverview)
{
m_szOverview = szOverview;
}
QString cMovie::overview()
{
return(m_szOverview);
}
void cMovie::setPopularity(const qreal dPopularity)
{
m_dPopularity = dPopularity;
}
qreal cMovie::popularity()
{
return(m_dPopularity);
}
void cMovie::setPosterPath(const QString& szPosterPath)
{
m_szPosterPath = szPosterPath;
}
QString cMovie::posterPath()
{
return(m_szPosterPath);
}
void cMovie::setProductionCompanies(const QString& szProductionCompanies)
{
m_szProductionCompanies = szProductionCompanies.split(",");
}
void cMovie::setProductionCompanies(const QStringList& szProductionCompanies)
{
m_szProductionCompanies = szProductionCompanies;
}
QStringList cMovie::productionCompanies()
{
return(m_szProductionCompanies);
}
void cMovie::setProductionCountries(const QString& szProductionCountries)
{
m_szProductionCountries = szProductionCountries.split(",");
}
void cMovie::setProductionCountries(const QStringList& szProductionCountries)
{
m_szProductionCountries = szProductionCountries;
}
QStringList cMovie::productionCountries()
{
return(m_szProductionCountries);
}
void cMovie::setRevenue(const qreal dRevenue)
{
m_dRevenue = dRevenue;
}
qreal cMovie::revenue()
{
return(m_dRevenue);
}
void cMovie::setRuntime(const qint32 iRuntime)
{
m_iRuntime = iRuntime;
}
qint32 cMovie::runtime()
{
return(m_iRuntime);
}
void cMovie::setSpokenLanguages(const QString& szSpokenLanguages)
{
m_szSpokenLanguages = szSpokenLanguages.split(",");
}
void cMovie::setSpokenLanguages(const QStringList& szSpokenLanguages)
{
m_szSpokenLanguages = szSpokenLanguages;
}
QStringList cMovie::spokenLanguages()
{
return(m_szSpokenLanguages);
}
void cMovie::setStatus(const QString& szStatus)
{
m_szStatus = szStatus;
}
QString cMovie::status()
{
return(m_szStatus);
}
void cMovie::setTagline(const QString& szTagline)
{
m_szTagline = szTagline;
}
QString cMovie::tagline()
{
return(m_szTagline);
}
void cMovie::setVideo(const bool bVideo)
{
m_bVideo = bVideo;
}
bool cMovie::video()
{
return(m_bVideo);
}
void cMovie::setVoteAverage(const qreal dVoteAverage)
{
m_dVoteAverage = dVoteAverage;
}
qreal cMovie::voteAverage()
{
return(m_dVoteAverage);
}
void cMovie::setVoteCount(const qint32 iVoteCount)
{
m_iVoteCount = iVoteCount;
}
qint32 cMovie::voteCount()
{
return(m_iVoteCount);
}
+90
View File
@@ -5,6 +5,7 @@
#include <QMetaType>
#include <QDate>
#include <QSqlDatabase>
#include <QStringList>
class cMovie
@@ -23,11 +24,100 @@ public:
void setReleaseDate(const QString& szDate);
QDate releaseDate();
void setAdult(const bool bAdult);
bool adult();
void setBackdropPath(const QString& szBackdropPath);
QString backdropPath();
void setBelongsToCollection(const QString& szBelongsToCollection);
QString belongsToCollection();
void setButget(const qreal dBudget);
qreal budget();
void setGenres(const QString& szGenres);
void setGenres(const QStringList& szGenres);
QStringList genres();
void setHomepage(const QString& szHomepage);
QString homepage();
void setIMDBID(const QString& szIMDBID);
QString imdbID();
void setOriginalLanguage(const QString& szOriginalLanguage);
QString originalLanguage();
void setOverview(const QString& szOverview);
QString overview();
void setPopularity(const qreal dPopularity);
qreal popularity();
void setPosterPath(const QString& szPosterPath);
QString posterPath();
void setProductionCompanies(const QString& szProductionCompanies);
void setProductionCompanies(const QStringList& szProductionCompanies);
QStringList productionCompanies();
void setProductionCountries(const QString& szProductionCountries);
void setProductionCountries(const QStringList& szProductionCountries);
QStringList productionCountries();
void setRevenue(const qreal dRevenue);
qreal revenue();
void setRuntime(const qint32 iRuntime);
qint32 runtime();
void setSpokenLanguages(const QString& szSpokenLanguages);
void setSpokenLanguages(const QStringList& szSpokenLanguages);
QStringList spokenLanguages();
void setStatus(const QString& szStatus);
QString status();
void setTagline(const QString& szTagline);
QString tagline();
void setVideo(const bool bVideo);
bool video();
void setVoteAverage(const qreal dVoteAverage);
qreal voteAverage();
void setVoteCount(const qint32 iVoteCount);
qint32 voteCount();
private:
QString m_szMovieTitle;
qint32 m_iID;
QString m_szOriginalTitle;
QDate m_releaseDate;
bool m_bAdult;
QString m_szBackdropPath;
QString m_szBelongsToCollection;
qreal m_dBudget;
QStringList m_szGenres;
QString m_szHomepage;
QString m_szIMDBID;
QString m_szOriginalLanguage;
QString m_szOverview;
qreal m_dPopularity;
QString m_szPosterPath;
QStringList m_szProductionCompanies;
QStringList m_szProductionCountries;
qreal m_dRevenue;
qint32 m_iRuntime;
QStringList m_szSpokenLanguages;
QString m_szStatus;
QString m_szTagline;
bool m_bVideo;
qreal m_dVoteAverage;
qint32 m_iVoteCount;
};
Q_DECLARE_METATYPE(cMovie*)
+89
View File
@@ -0,0 +1,89 @@
#include "cmoviesearch.h"
#include "ui_cmoviesearch.h"
#include "cthemoviedbv3.h"
#include "cmovie.h"
#include "cmessageanimatedialog.h"
#include <QList>
cMovieSearch::cMovieSearch(QWidget *parent) :
QDialog(parent),
ui(new Ui::cMovieSearch)
{
ui->setupUi(this);
ui->m_lpSearchButton->setEnabled(false);
ui->m_lpTabWidget->setCurrentIndex(0);
}
cMovieSearch::~cMovieSearch()
{
delete ui;
}
void cMovieSearch::on_m_lpSearch_textChanged(const QString &arg1)
{
if(ui->m_lpSearch->text().isEmpty())
ui->m_lpSearchButton->setEnabled(false);
else
ui->m_lpSearchButton->setEnabled(true);
}
void cMovieSearch::on_m_lpSearchButton_clicked()
{
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Search");
lpDialog->setMessage("Searching");
lpDialog->show();
cTheMovieDBV3 theMovieDBV3;
QList<cMovie*> movieList = theMovieDBV3.search(ui->m_lpSearch->text());
ui->m_lpResults->clear();
for(int z = 0;z < movieList.count();z++)
{
cMovie* lpMovie = movieList.at(z);
QTreeWidgetItem* lpNew = new QTreeWidgetItem(ui->m_lpResults);
lpNew->setText(0, lpMovie->movieTitle());
lpNew->setText(2, QString("%1").arg(lpMovie->releaseDate().year()));
lpNew->setData(0, Qt::UserRole, QVariant::fromValue(lpMovie->movieID()));
ui->m_lpResults->addTopLevelItem(lpNew);
}
ui->m_lpResults->resizeColumnToContents(0);
ui->m_lpResults->resizeColumnToContents(1);
ui->m_lpResults->sortItems(0, Qt::AscendingOrder);
delete lpDialog;
}
qint32 cMovieSearch::id()
{
if(!ui->m_lpResults->selectedItems().count())
{
qint32 iID = ui->m_lpSearch->text().toInt();
if(iID)
return(iID);
return(-1);
}
return(ui->m_lpResults->selectedItems().at(0)->data(0, Qt::UserRole).toInt());
}
QString cMovieSearch::placeholderName()
{
return(ui->m_lpPlaceholderName->text());
}
bool cMovieSearch::placeholder()
{
return(ui->m_lpTabWidget->currentIndex() == 1);
}
qint16 cMovieSearch::year()
{
return(ui->m_lpYear->value());
}
+33
View File
@@ -0,0 +1,33 @@
#ifndef CMOVIESEARCH_H
#define CMOVIESEARCH_H
#include <QDialog>
namespace Ui {
class cMovieSearch;
}
class cMovieSearch : public QDialog
{
Q_OBJECT
public:
explicit cMovieSearch(QWidget *parent = 0);
~cMovieSearch();
qint32 id();
QString placeholderName();
bool placeholder();
qint16 year();
private slots:
void on_m_lpSearchButton_clicked();
void on_m_lpSearch_textChanged(const QString &arg1);
private:
Ui::cMovieSearch *ui;
};
#endif // CMOVIESEARCH_H
+180
View File
@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cMovieSearch</class>
<widget class="QDialog" name="cMovieSearch">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>334</width>
<height>460</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QDialogButtonBox" name="m_lpButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="m_lpTabWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="Search">
<attribute name="title">
<string>Search</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="m_lpSearch"/>
</item>
<item>
<widget class="QPushButton" name="m_lpSearchButton">
<property name="text">
<string>Search</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="m_lpResults">
<property name="columnCount">
<number>3</number>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
<column>
<property name="text">
<string notr="true">2</string>
</property>
</column>
<column>
<property name="text">
<string notr="true">3</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="Add">
<attribute name="title">
<string>Add Placeholder</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="m_lpPlaceholderName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Year:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="m_lpYear">
<property name="minimum">
<number>1800</number>
</property>
<property name="maximum">
<number>2100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>m_lpButtonBox</sender>
<signal>accepted()</signal>
<receiver>cMovieSearch</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_lpButtonBox</sender>
<signal>rejected()</signal>
<receiver>cMovieSearch</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+1
View File
@@ -20,6 +20,7 @@ public:
bool placeholder();
qint16 year();
private slots:
void on_m_lpSearchButton_clicked();
void on_m_lpSearch_textChanged(const QString &arg1);
+98 -30
View File
@@ -14,33 +14,6 @@
cTheMovieDBV3::cTheMovieDBV3()
{
m_szToken = "a33271b9e54cdcb9a80680eaf5522f1b";
/*
QNetworkAccessManager networkManager;
QNetworkRequest request(QUrl(QString("https://api.themoviedb.org/3/authentication/token/new?api_key=a33271b9e54cdcb9a80680eaf5522f1b")));
QNetworkReply* reply = networkManager.get(request);
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
if (reply->error() == QNetworkReply::NoError)
{
QString strReply = (QString)reply->readAll();
QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
QJsonObject jsonObj = jsonResponse.object();
bool success = jsonObj["success"].toBool();
m_szToken = jsonObj["request_token"].toString();
delete reply;
}
else
{
qDebug() << reply->errorString();
delete reply;
}
*/
}
QList<cMovie*> cTheMovieDBV3::search(const QString& szMovie, const qint16& year, const QString& szLanguage)
@@ -81,9 +54,6 @@ QList<cMovie*> cTheMovieDBV3::search(const QString& szMovie, const qint16& year,
{
QJsonObject movie = jsonArray[z].toObject();
cMovie* lpMovie = new cMovie;
// lpSerie->setID(serie["id"].toInt());
// lpSerie->setSeriesName(serie["seriesName"].toString());
// lpSerie->setFirstAired(serie["firstAired"].toString());
lpMovie->setMovieTitle(movie["title"].toString());
lpMovie->setMovieID(movie["id"].toInt());
lpMovie->setOriginalTitle(movie["original_title"].toString());
@@ -104,3 +74,101 @@ QList<cMovie*> cTheMovieDBV3::search(const QString& szMovie, const qint16& year,
}
return(movieList);
}
cMovie* cTheMovieDBV3::load(const qint32 &iID, const QString &szLanguage)
{
cMovie* lpMovie = 0;
QNetworkAccessManager networkManager;
QNetworkRequest request(QUrl(QString("https://api.themoviedb.org/3/movie/%1?api_key=%2&language=%3").arg(iID).arg(m_szToken).arg(szLanguage)));
request.setRawHeader("Content-Type", "application/json");
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_szToken).toUtf8());
if(!szLanguage.contains("all"))
request.setRawHeader("Accept-Language", szLanguage.toUtf8());
else
request.setRawHeader("Accept-Language", "en");
QNetworkReply* reply = networkManager.get(request);
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
if (reply->error() == QNetworkReply::NoError)
{
QString strReply = (QString)reply->readAll();
QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
QJsonObject jsonObj = jsonResponse.object();
QJsonArray genreArray = jsonObj["genres"].toArray();
QStringList genreList;
QJsonArray productionCompaniesArray = jsonObj["production_companies"].toArray();
QStringList productionCompaniesList;
QJsonArray productionCountriesArray = jsonObj["production_countries"].toArray();
QStringList productionCountriesList;
QJsonArray spokenLanguagesArray = jsonObj["spoken_languages"].toArray();
QStringList spokenLanguagesList;
QJsonObject tmpObj;
delete reply;
lpMovie = new cMovie;
lpMovie->setMovieTitle(jsonObj["title"].toString());
lpMovie->setMovieID(jsonObj["id"].toInt());
lpMovie->setOriginalTitle(jsonObj["original_title"].toString());
lpMovie->setReleaseDate(jsonObj["release_date"].toString());
lpMovie->setAdult(jsonObj["adult"].toBool());
lpMovie->setBackdropPath(jsonObj["backdrop_path"].toString());
tmpObj = jsonObj["belongs_to_collection"].toObject();
lpMovie->setBelongsToCollection(tmpObj["name"].toString());
lpMovie->setButget(jsonObj["budget"].toDouble());
for(int z = 0;z < genreArray.count();z++)
{
tmpObj = genreArray[z].toObject();
genreList.append(tmpObj["name"].toString());
}
lpMovie->setGenres(genreList);
lpMovie->setHomepage(jsonObj["homepage"].toString());
lpMovie->setIMDBID(jsonObj["imdb_id"].toString());
lpMovie->setOriginalLanguage(jsonObj["original_language"].toString());
lpMovie->setOverview(jsonObj["overview"].toString());
lpMovie->setPopularity(jsonObj["popularity"].toDouble());
lpMovie->setPosterPath(jsonObj["poster_path"].toString());
for(int z = 0;z < productionCompaniesArray.count();z++)
{
tmpObj = productionCompaniesArray[z].toObject();
productionCompaniesList.append(tmpObj["name"].toString());
}
lpMovie->setProductionCompanies(productionCompaniesList);
for(int z = 0;z < productionCountriesArray.count();z++)
{
tmpObj = productionCountriesArray[z].toObject();
productionCountriesList.append(tmpObj["name"].toString());
}
lpMovie->setProductionCountries(productionCountriesList);
lpMovie->setRevenue(jsonObj["revenue"].toDouble());
lpMovie->setRuntime(jsonObj["runtime"].toInt());
for(int z = 0;z < spokenLanguagesArray.count();z++)
{
tmpObj = spokenLanguagesArray[z].toObject();
spokenLanguagesList.append(tmpObj["name"].toString());
}
lpMovie->setSpokenLanguages(spokenLanguagesList);
lpMovie->setStatus(jsonObj["status"].toString());
lpMovie->setTagline(jsonObj["tagline"].toString());
lpMovie->setVideo(jsonObj["video"].toBool());
lpMovie->setVoteAverage(jsonObj["vote_average"].toDouble());
lpMovie->setVoteCount(jsonObj["vote_count"].toInt());
}
else
{
qDebug() << reply->errorString();
delete reply;
}
return(lpMovie);
}
+1 -1
View File
@@ -15,7 +15,7 @@ public:
cTheMovieDBV3();
QList<cMovie*> search(const QString& szMovie, const qint16& year = -1, const QString& szLanguage = "all");
// cSerie* load(const qint32 &iID, const QString& szLanguage);
cMovie* load(const qint32 &iID, const QString& szLanguage);
private:
QString m_szToken;
// QStringList getActors(const qint32& iID);
+4 -5
View File
@@ -1,5 +1,4 @@
#include "cupdatethread.h"
#include "cserie.h"
#include "cseason.h"
#include "cepisode.h"
#include "cthetvdbv2.h"
@@ -28,9 +27,9 @@ void cUpdateThread::run()
timer.restart();
QString szFailed;
for(int x = 0;x < m_indexList.count();x++)
for(int x = 0;x < m_serieList.count();x++)
{
cSerie* lpSerie = m_indexList.at(x).data(Qt::UserRole).value<cSerie*>();
cSerie* lpSerie = m_serieList.at(x);
if(lpSerie)
{
emit updateMessage(lpSerie->seriesName(), x);
@@ -82,9 +81,9 @@ void cUpdateThread::run()
*/
}
void cUpdateThread::setData(cMessageDialog* lpMessageDialog, const QModelIndexList &indexList, const QSqlDatabase& db)
void cUpdateThread::setData(cMessageDialog* lpMessageDialog, const cSerieList &serieList, const QSqlDatabase& db)
{
connect(lpMessageDialog->cancelButton(), SIGNAL(clicked()), this, SLOT(stop()));
m_indexList = indexList;
m_serieList = serieList;
m_db = db;
}
+4 -2
View File
@@ -4,6 +4,8 @@
#include "cmessagedialog.h"
#include "cserie.h"
#include <QThread>
#include <QMutexLocker>
#include <QList>
@@ -18,7 +20,7 @@ class cUpdateThread : public QThread
public:
explicit cUpdateThread();
void setData(cMessageDialog *lpMessageDialog, const QModelIndexList& indexList, const QSqlDatabase& db);
void setData(cMessageDialog *lpMessageDialog, const cSerieList& serieList, const QSqlDatabase& db);
public slots:
void stop();
@@ -29,7 +31,7 @@ signals:
private:
QMutex m_mutex;
bool m_bStop;
QModelIndexList m_indexList;
cSerieList m_serieList;
QSqlDatabase m_db;
QWidget* m_lpParent;
+6 -3
View File
@@ -30,7 +30,8 @@ SOURCES += main.cpp\
cpicturesthread.cpp \
cthetvdbv2.cpp \
cthemoviedbv3.cpp \
cmovie.cpp
cmovie.cpp \
cmoviesearch.cpp
HEADERS += cmainwindow.h \
cserie.h \
@@ -49,7 +50,8 @@ HEADERS += cmainwindow.h \
cpicturesthread.h \
cthetvdbv2.h \
cthemoviedbv3.h \
cmovie.h
cmovie.h \
cmoviesearch.h
FORMS += cmainwindow.ui \
csearch.ui \
@@ -57,7 +59,8 @@ FORMS += cmainwindow.ui \
cedit.ui \
cseasondetails.ui \
cepisodedetails.ui \
cmessagedialog.ui
cmessagedialog.ui \
cmoviesearch.ui
DISTFILES +=