added preview to movie search
This commit is contained in:
+1
-1
@@ -2478,7 +2478,7 @@ void cMainWindow::onActionMovieDiscover()
|
||||
{
|
||||
cMovieDiscover* lpMovieDiscover;
|
||||
|
||||
lpMovieDiscover = new cMovieDiscover(this);
|
||||
lpMovieDiscover = new cMovieDiscover(m_movieList, this);
|
||||
lpMovieDiscover->exec();
|
||||
|
||||
delete lpMovieDiscover;
|
||||
|
||||
@@ -120,11 +120,8 @@ private:
|
||||
QString m_szOldSelected;
|
||||
|
||||
cMessageDialog* m_lpMessageDialog;
|
||||
// cUpdateThread* m_lpUpdateThread;
|
||||
cPicturesThread* m_lpPicturesThread;
|
||||
|
||||
// QTime m_timer;
|
||||
|
||||
QStandardItemModel* m_lpSeriesListModel;
|
||||
QStandardItemModel* m_lpMoviesListModel;
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "cmoviedetails.h"
|
||||
#include "ui_cmoviedetails.h"
|
||||
|
||||
#include "cmovieimage.h"
|
||||
|
||||
|
||||
cMovieDetails::cMovieDetails(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::cMovieDetails)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
cMovieDetails::~cMovieDetails()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cMovieDetails::setMovie(cMovie* lpMovie)
|
||||
{
|
||||
ui->m_lpName->setText(lpMovie->movieTitle());
|
||||
ui->m_lpFirstAired->setDate(lpMovie->releaseDate());
|
||||
|
||||
ui->m_lpDetailsBanner->clear();
|
||||
if(!lpMovie->backdropPath().isEmpty())
|
||||
{
|
||||
cMovieImage image;
|
||||
QPixmap banner = image.getImage(lpMovie->backdropPath());
|
||||
ui->m_lpDetailsBanner->setPixmap(banner);
|
||||
}
|
||||
|
||||
ui->m_lpDetailsOverview->setText(lpMovie->overview());
|
||||
|
||||
ui->m_lpDetailsActors->clear();
|
||||
QTreeWidgetItem* lpItem;
|
||||
for(int x = 0;x < lpMovie->cast().count();x++)
|
||||
{
|
||||
QStringList str = lpMovie->cast().at(x).split(",");
|
||||
lpItem = new QTreeWidgetItem(ui->m_lpDetailsActors);
|
||||
lpItem->setText(0, str.at(0));
|
||||
lpItem->setText(1, str.at(1));
|
||||
ui->m_lpDetailsActors->addTopLevelItem(lpItem);
|
||||
}
|
||||
ui->m_lpDetailsActors->resizeColumnToContents(0);
|
||||
|
||||
ui->m_lpDetailsGenre->clear();
|
||||
for(int x = 0;x < lpMovie->genres().count();x++)
|
||||
{
|
||||
lpItem = new QTreeWidgetItem(ui->m_lpDetailsGenre);
|
||||
lpItem->setText(0, lpMovie->genres().at(x));
|
||||
ui->m_lpDetailsGenre->addTopLevelItem(lpItem);
|
||||
}
|
||||
ui->m_lpDetailsGenre->resizeColumnToContents(0);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef CMOVIEDETAILS_H
|
||||
#define CMOVIEDETAILS_H
|
||||
|
||||
|
||||
#include "cmovie.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cMovieDetails;
|
||||
}
|
||||
|
||||
class cMovieDetails : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cMovieDetails(QWidget *parent = 0);
|
||||
~cMovieDetails();
|
||||
|
||||
void setMovie(cMovie* lpMovie);
|
||||
private:
|
||||
Ui::cMovieDetails* ui;
|
||||
};
|
||||
|
||||
#endif // CMOVIEDETAILS_H
|
||||
@@ -0,0 +1,21 @@
|
||||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>cMovieDetails</class>
|
||||
<widget class="QWidget" name="cMovieDetails">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+39
-16
@@ -68,8 +68,11 @@ void cMovieSearch::on_m_lpSearchButton_clicked()
|
||||
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()));
|
||||
lpNew->setText(1, QString("%1").arg(lpMovie->releaseDate().year()));
|
||||
lpNew->setData(0, Qt::UserRole, QVariant::fromValue(lpMovie));
|
||||
lpNew->setData(1, Qt::UserRole, QVariant::fromValue(lpMovie));
|
||||
lpNew->setCheckState(0, Qt::Unchecked);
|
||||
|
||||
ui->m_lpResults->addTopLevelItem(lpNew);
|
||||
}
|
||||
ui->m_lpResults->resizeColumnToContents(0);
|
||||
@@ -84,18 +87,22 @@ QList<qint32> cMovieSearch::id()
|
||||
{
|
||||
QList<qint32> idList;
|
||||
|
||||
if(!ui->m_lpResults->selectedItems().count())
|
||||
for(int x = 0;x < ui->m_lpResults->topLevelItemCount();x++)
|
||||
{
|
||||
if(ui->m_lpResults->topLevelItem(x)->checkState(0) == Qt::Checked)
|
||||
{
|
||||
cMovie* lpMovie = ui->m_lpResults->topLevelItem(x)->data(0, Qt::UserRole).value<cMovie*>();
|
||||
idList.append(lpMovie->movieID());
|
||||
}
|
||||
}
|
||||
|
||||
if(idList.isEmpty())
|
||||
{
|
||||
qint32 iID = ui->m_lpSearch->text().toInt();
|
||||
if(iID)
|
||||
idList.append(iID);
|
||||
return(idList);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int x = 0;x < ui->m_lpResults->selectedItems().count();x++)
|
||||
idList.append(ui->m_lpResults->selectedItems().at(x)->data(0, Qt::UserRole).toInt());
|
||||
}
|
||||
return(idList);
|
||||
}
|
||||
|
||||
@@ -133,11 +140,15 @@ void cMovieSearch::setButtonBox()
|
||||
{
|
||||
if(ui->m_lpTabWidget->currentIndex() == 0)
|
||||
{
|
||||
if(ui->m_lpResults->selectedItems().count())
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
else
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
return;
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
for(int x = 0;x < ui->m_lpResults->topLevelItemCount();x++)
|
||||
{
|
||||
if(ui->m_lpResults->topLevelItem(x)->checkState(0) == Qt::Checked)
|
||||
{
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ui->m_lpPlaceholderName->text().isEmpty())
|
||||
@@ -155,8 +166,20 @@ void cMovieSearch::setButtonBox()
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
|
||||
void cMovieSearch::on_m_lpResults_doubleClicked(const QModelIndex &index)
|
||||
//void cMovieSearch::on_m_lpResults_doubleClicked(const QModelIndex &index)
|
||||
//{
|
||||
// if(index.isValid())
|
||||
// accept();
|
||||
//}
|
||||
|
||||
void cMovieSearch::on_m_lpResults_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
if(index.isValid())
|
||||
accept();
|
||||
cMovie* lpMovie = current->data(0, Qt::UserRole).value<cMovie*>();
|
||||
|
||||
if(lpMovie->cast().isEmpty())
|
||||
{
|
||||
cTheMovieDBV3 theMovieDB;
|
||||
theMovieDB.loadCastMovie(lpMovie);
|
||||
}
|
||||
ui->m_lpMovieDetails->setMovie(lpMovie);
|
||||
}
|
||||
|
||||
+4
-1
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
@@ -31,7 +32,9 @@ private slots:
|
||||
void on_m_lpYear_valueChanged(int arg1);
|
||||
|
||||
void on_m_lpResults_clicked(const QModelIndex &index);
|
||||
void on_m_lpResults_doubleClicked(const QModelIndex &index);
|
||||
// void on_m_lpResults_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void on_m_lpResults_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
||||
private:
|
||||
Ui::cMovieSearch *ui;
|
||||
|
||||
+50
-17
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>334</width>
|
||||
<height>460</height>
|
||||
<width>900</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -35,27 +35,30 @@
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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>
|
||||
<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>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,2">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="m_lpResults">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>3</number>
|
||||
@@ -80,6 +83,28 @@
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="m_lpMovieDetailsScroller">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>563</width>
|
||||
<height>372</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="cMovieDetails" name="m_lpMovieDetails" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -145,6 +170,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>cMovieDetails</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cmoviedetails.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_lpSearch</tabstop>
|
||||
<tabstop>m_lpSearchButton</tabstop>
|
||||
|
||||
+78
-2
@@ -10,6 +10,8 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
//using std::pair;
|
||||
|
||||
|
||||
@@ -18,8 +20,15 @@ cTheMovieDBV3::cTheMovieDBV3()
|
||||
m_szToken = "a33271b9e54cdcb9a80680eaf5522f1b";
|
||||
}
|
||||
|
||||
cTheMovieDBV3::~cTheMovieDBV3()
|
||||
{
|
||||
}
|
||||
|
||||
QList<cMovie*> cTheMovieDBV3::searchMovie(const QString& szMovie, const qint16& year, const QString& szLanguage)
|
||||
{
|
||||
if(m_genres.isEmpty())
|
||||
m_genres = genresMovie("de-DE");
|
||||
|
||||
QList<cMovie*> movieList;
|
||||
QNetworkAccessManager networkManager;
|
||||
QString szRequest = QString("https://api.themoviedb.org/3/search/movie?api_key=%1").arg(m_szToken);
|
||||
@@ -60,6 +69,24 @@ QList<cMovie*> cTheMovieDBV3::searchMovie(const QString& szMovie, const qint16&
|
||||
lpMovie->setMovieID(movie["id"].toInt());
|
||||
lpMovie->setOriginalTitle(movie["original_title"].toString());
|
||||
lpMovie->setReleaseDate(movie["release_date"].toString());
|
||||
lpMovie->setVoteCount(movie["vote_count"].toInt());
|
||||
lpMovie->setVideo(movie["video"].toBool());
|
||||
lpMovie->setVoteAverage(movie["vote_average"].toDouble());
|
||||
lpMovie->setPopularity(movie["popularity"].toDouble());
|
||||
lpMovie->setPosterPath(movie["poster_path"].toString());
|
||||
lpMovie->setOriginalLanguage(movie["original_language"].toString());
|
||||
|
||||
QJsonArray genresArray = movie["genre_ids"].toArray();
|
||||
QList<qint32> genresIDs;
|
||||
for(int y = 0;y < genresArray.count();y++)
|
||||
genresIDs.append(genresArray[y].toInt());
|
||||
if(genresIDs.count())
|
||||
lpMovie->setGenres(genresFromID(genresIDs));
|
||||
lpMovie->setBackdropPath(movie["backdrop_path"].toString());
|
||||
lpMovie->setAdult(movie["adult"].toBool());
|
||||
lpMovie->setOverview(movie["overview"].toString());
|
||||
lpMovie->setReleaseDate(movie["release_date"].toString());
|
||||
|
||||
movieList.append(lpMovie);
|
||||
}
|
||||
if(jsonObj["total_pages"].toInt() == page)
|
||||
@@ -595,8 +622,6 @@ QList<cMovie*> cTheMovieDBV3::discoverMovie(const QString& szText, const bool& b
|
||||
szRequest.append(QString("&vote_average.gte=%1").arg(voteMin));
|
||||
szRequest.append(QString("&vote_average.lte=%1").arg(voteMax));
|
||||
|
||||
szRequest.append("&include_adult=false");
|
||||
|
||||
for(;;)
|
||||
{
|
||||
QNetworkRequest request(QUrl(QString("%1&page=%2").arg(szRequest).arg(page)));
|
||||
@@ -657,6 +682,7 @@ QList<cMovie*> cTheMovieDBV3::discoverMovie(const QString& szText, const bool& b
|
||||
delete reply;
|
||||
}
|
||||
}
|
||||
|
||||
return(movieList);
|
||||
}
|
||||
|
||||
@@ -723,3 +749,53 @@ QStringList cTheMovieDBV3::genresFromID(QList<qint32> genres)
|
||||
|
||||
return(szGenres);
|
||||
}
|
||||
|
||||
void cTheMovieDBV3::loadCastMovie(cMovie* lpMovie)
|
||||
{
|
||||
QNetworkAccessManager networkManager;
|
||||
QNetworkRequest request(QUrl(QString("https://api.themoviedb.org/3/movie/%1/credits?api_key=%2").arg(lpMovie->movieID()).arg(m_szToken)));
|
||||
|
||||
request.setRawHeader("Content-Type", "application/json");
|
||||
// if(!szLanguage.contains("all"))
|
||||
// request.setRawHeader("Accept-Language", szLanguage.toUtf8());
|
||||
// else
|
||||
// request.setRawHeader("Accept-Language", "en");
|
||||
request.setRawHeader("Accept-Language", "de");
|
||||
|
||||
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 jsonCast = jsonResponse.object();
|
||||
QJsonArray jsonArrayCast = jsonCast["cast"].toArray();
|
||||
QJsonArray jsonArrayCrew = jsonCast["crew"].toArray();
|
||||
QJsonObject tmpObj;
|
||||
|
||||
QStringList szCast;
|
||||
QStringList szCrew;
|
||||
|
||||
delete reply;
|
||||
|
||||
for(int x = 0;x < jsonArrayCast.count();x++)
|
||||
{
|
||||
tmpObj = jsonArrayCast.at(x).toObject();
|
||||
szCast.append(QString("%1,%2").arg(tmpObj["name"].toString()).arg(tmpObj["character"].toString()));
|
||||
}
|
||||
if(szCast.count())
|
||||
lpMovie->setCast(szCast);
|
||||
|
||||
for(int x = 0;x < jsonArrayCrew.count();x++)
|
||||
{
|
||||
tmpObj = jsonArrayCrew.at(x).toObject();
|
||||
szCrew.append(QString("%1,%2").arg(tmpObj["name"].toString()).arg(tmpObj["job"].toString()));
|
||||
}
|
||||
if(szCrew.count())
|
||||
lpMovie->setCrew(szCrew);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@ class cTheMovieDBV3
|
||||
{
|
||||
public:
|
||||
cTheMovieDBV3();
|
||||
~cTheMovieDBV3();
|
||||
|
||||
QList<cMovie*> searchMovie(const QString& szMovie, const qint16& year = -1, const QString& szLanguage = "all");
|
||||
cMovie* loadMovie(const qint32 &iID, const QString& szLanguage);
|
||||
QMap<qint32, QString> genresMovie(const QString& szLanguage = "all");
|
||||
QList<cMovie*> discoverMovie(const QString& szText, const bool& bAdult, const qint16& iYear, const QList<qint32>& genres, const qreal& voteMin, const qreal& voteMax, const QString& szLanguage = "all");
|
||||
void loadCastMovie(cMovie* lpMovie);
|
||||
|
||||
QList<cSerie*> searchSerie(const QString& szSerie, const qint16& year = -1, const QString& szLanguage = "all");
|
||||
cSerie* loadSerie(const qint32 &iID, const QString& szLanguage);
|
||||
|
||||
+6
-3
@@ -43,7 +43,8 @@ SOURCES += main.cpp\
|
||||
cdiscover.cpp \
|
||||
cmoviediscover.cpp \
|
||||
qxtspanslider.cpp \
|
||||
ccheckboxitemdelegate.cpp
|
||||
ccheckboxitemdelegate.cpp \
|
||||
cmoviedetails.cpp
|
||||
|
||||
HEADERS += cmainwindow.h \
|
||||
cserie.h \
|
||||
@@ -76,7 +77,8 @@ HEADERS += cmainwindow.h \
|
||||
cmoviediscover.h \
|
||||
qxtspanslider.h \
|
||||
qxtspanslider_p.h \
|
||||
ccheckboxitemdelegate.h
|
||||
ccheckboxitemdelegate.h \
|
||||
cmoviedetails.h
|
||||
|
||||
FORMS += cmainwindow.ui \
|
||||
csearch.ui \
|
||||
@@ -89,7 +91,8 @@ FORMS += cmainwindow.ui \
|
||||
cmovieedit.ui \
|
||||
cexportdialog.ui \
|
||||
cdiscover.ui \
|
||||
cmoviediscover.ui
|
||||
cmoviediscover.ui \
|
||||
cmoviedetails.ui
|
||||
|
||||
DISTFILES += \
|
||||
qtMovies.ico
|
||||
|
||||
Reference in New Issue
Block a user