Compare commits
41 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
464f546cfe | 3 years ago |
|
|
824238b995 | 7 years ago |
|
|
217fac56e4 | 7 years ago |
|
|
44fda299d2 | 7 years ago |
|
|
8915a0a216 | 7 years ago |
|
|
445ec6e3ba | 7 years ago |
|
|
b0f5698610 | 7 years ago |
|
|
6defbf5e83 | 7 years ago |
|
|
5d55ee6dc4 | 7 years ago |
|
|
7c79287e17 | 7 years ago |
|
|
1790ec58e6 | 7 years ago |
|
|
a1d8412143 | 7 years ago |
|
|
a9cce71939 | 7 years ago |
|
|
8b17ebe2b5 | 7 years ago |
|
|
b8c816af8d | 7 years ago |
|
|
775e183721 | 7 years ago |
|
|
a568a7d985 | 7 years ago |
|
|
b057e1d73a | 7 years ago |
|
|
8f63d174f3 | 7 years ago |
|
|
1fb97e1891 | 7 years ago |
|
|
ae35df6499 | 7 years ago |
|
|
0d610927ae | 7 years ago |
|
|
29feba342c | 7 years ago |
|
|
f7d4f14b28 | 7 years ago |
|
|
1a5d4ad0ba | 7 years ago |
|
|
ddcb197a6b | 8 years ago |
|
|
8c484e4739 | 8 years ago |
|
|
9bac9843b6 | 8 years ago |
|
|
395005b9fb | 8 years ago |
|
|
940a51080e | 8 years ago |
|
|
65abda249c | 8 years ago |
|
|
cfc76f257f | 8 years ago |
|
|
86ef83024b | 8 years ago |
|
|
0cb0e3516c | 8 years ago |
|
|
a28d2587f5 | 8 years ago |
|
|
7ab6d2eb2a | 8 years ago |
|
|
1b76553f2a | 8 years ago |
|
|
4caa5f7eb7 | 8 years ago |
|
|
e010208520 | 8 years ago |
|
|
dbb113e0da | 8 years ago |
|
|
b9116dc732 | 8 years ago |
@ -0,0 +1,378 @@
|
||||
#include "cartist.h"
|
||||
|
||||
|
||||
cArtist::cArtist() :
|
||||
m_iArtistID(0),
|
||||
m_szArtist(QString("")),
|
||||
m_szArtistStripped(QString("")),
|
||||
m_szArtistAlernate(QString("")),
|
||||
m_szLabel(QString("")),
|
||||
m_iLabelID(0),
|
||||
m_iFormedYear(0),
|
||||
m_iBornYear(0),
|
||||
m_iDiedYear(0),
|
||||
m_szDisbanded(QString("")),
|
||||
m_szStyle(QString("")),
|
||||
m_szGenre(QString("")),
|
||||
m_szMood(QString("")),
|
||||
m_szWebsite(QString("")),
|
||||
m_szFacebook(QString("")),
|
||||
m_szTwitter(QString("")),
|
||||
m_szBiography(QString("")),
|
||||
m_szGender(QString("")),
|
||||
m_iMembers(0),
|
||||
m_szCountry(QString("")),
|
||||
m_szCountryCode(QString("")),
|
||||
m_szArtistThumb(QString("")),
|
||||
m_szArtistLogo(QString("")),
|
||||
m_szArtistClearart(QString("")),
|
||||
m_szArtistWideThumb(QString("")),
|
||||
m_szArtistFanart(QString("")),
|
||||
m_szArtistFanart2(QString("")),
|
||||
m_szArtistFanart3(QString("")),
|
||||
m_szArtistBanner(QString("")),
|
||||
m_szMusicBrainzID(QString("")),
|
||||
m_szLastFMChart(QString(""))
|
||||
{
|
||||
}
|
||||
|
||||
void cArtist::setArtistID(const qint32& iArtistID)
|
||||
{
|
||||
m_iArtistID = iArtistID;
|
||||
}
|
||||
|
||||
qint32 cArtist::artistID()
|
||||
{
|
||||
return(m_iArtistID);
|
||||
}
|
||||
|
||||
void cArtist::setArtist(const QString& szArtist)
|
||||
{
|
||||
m_szArtist = szArtist;
|
||||
}
|
||||
|
||||
QString cArtist::artist()
|
||||
{
|
||||
return(m_szArtist);
|
||||
}
|
||||
|
||||
void cArtist::setArtistStripped(const QString& szArtistStripped)
|
||||
{
|
||||
m_szArtistStripped = szArtistStripped;
|
||||
}
|
||||
|
||||
QString cArtist::artistStripped()
|
||||
{
|
||||
return(m_szArtistStripped);
|
||||
}
|
||||
|
||||
void cArtist::setArtistAlernate(const QString& szArtistAlernate)
|
||||
{
|
||||
m_szArtistAlernate = szArtistAlernate;
|
||||
}
|
||||
|
||||
QString cArtist::artistAlernate()
|
||||
{
|
||||
return(m_szArtistAlernate);
|
||||
}
|
||||
|
||||
void cArtist::setLabel(const QString& szLabel)
|
||||
{
|
||||
m_szLabel = szLabel;
|
||||
}
|
||||
|
||||
QString cArtist::label()
|
||||
{
|
||||
return(m_szLabel);
|
||||
}
|
||||
|
||||
void cArtist::setLabelID(const qint32& iLabelID)
|
||||
{
|
||||
m_iLabelID = iLabelID;
|
||||
}
|
||||
|
||||
qint32 cArtist::labelID()
|
||||
{
|
||||
return(m_iLabelID);
|
||||
}
|
||||
|
||||
void cArtist::setFormedYear(const qint32& iFormedYear)
|
||||
{
|
||||
m_iFormedYear = iFormedYear;
|
||||
}
|
||||
|
||||
qint32 cArtist::formedYear()
|
||||
{
|
||||
return(m_iFormedYear);
|
||||
}
|
||||
|
||||
void cArtist::setBornYear(const qint32& iBornYear)
|
||||
{
|
||||
m_iBornYear = iBornYear;
|
||||
}
|
||||
|
||||
qint32 cArtist::bornYear()
|
||||
{
|
||||
return(m_iBornYear);
|
||||
}
|
||||
|
||||
void cArtist::setDiedYear(const qint32& iDiedYear)
|
||||
{
|
||||
m_iDiedYear = iDiedYear;
|
||||
}
|
||||
|
||||
qint32 cArtist::diedYear()
|
||||
{
|
||||
return(m_iDiedYear);
|
||||
}
|
||||
|
||||
void cArtist::setDisbanded(const QString& szDisbanded)
|
||||
{
|
||||
m_szDisbanded = szDisbanded;
|
||||
}
|
||||
|
||||
QString cArtist::disbanded()
|
||||
{
|
||||
return(m_szDisbanded);
|
||||
}
|
||||
|
||||
void cArtist::setStyle(const QString& szStyle)
|
||||
{
|
||||
m_szStyle = szStyle;
|
||||
}
|
||||
|
||||
QString cArtist::style()
|
||||
{
|
||||
return(m_szStyle);
|
||||
}
|
||||
|
||||
void cArtist::setGenre(const QString& szGenre)
|
||||
{
|
||||
m_szGenre = szGenre;
|
||||
}
|
||||
|
||||
QString cArtist::genre()
|
||||
{
|
||||
return(m_szGenre);
|
||||
}
|
||||
|
||||
void cArtist::setMood(const QString& szMood)
|
||||
{
|
||||
m_szMood = szMood;
|
||||
}
|
||||
|
||||
QString cArtist::mood()
|
||||
{
|
||||
return(m_szMood);
|
||||
}
|
||||
|
||||
void cArtist::setWebsite(const QString& szWebsite)
|
||||
{
|
||||
m_szWebsite = szWebsite;
|
||||
}
|
||||
|
||||
QString cArtist::website()
|
||||
{
|
||||
return(m_szWebsite);
|
||||
}
|
||||
|
||||
void cArtist::setFacebook(const QString& szFacebook)
|
||||
{
|
||||
m_szFacebook = szFacebook;
|
||||
}
|
||||
|
||||
QString cArtist::facebook()
|
||||
{
|
||||
return(m_szFacebook);
|
||||
}
|
||||
|
||||
void cArtist::setTwitter(const QString& szTwitter)
|
||||
{
|
||||
m_szTwitter = szTwitter;
|
||||
}
|
||||
|
||||
QString cArtist::twitter()
|
||||
{
|
||||
return(m_szTwitter);
|
||||
}
|
||||
|
||||
void cArtist::setBiography(const QString& szBiography)
|
||||
{
|
||||
m_szBiography = szBiography;
|
||||
}
|
||||
|
||||
QString cArtist::biography()
|
||||
{
|
||||
return(m_szBiography);
|
||||
}
|
||||
|
||||
void cArtist::setGender(const QString& szGender)
|
||||
{
|
||||
m_szGender = szGender;
|
||||
}
|
||||
|
||||
QString cArtist::gender()
|
||||
{
|
||||
return(m_szGender);
|
||||
}
|
||||
|
||||
void cArtist::setMembers(const qint32& iMembers)
|
||||
{
|
||||
m_iMembers = iMembers;
|
||||
}
|
||||
|
||||
qint32 cArtist::members()
|
||||
{
|
||||
return(m_iMembers);
|
||||
}
|
||||
|
||||
void cArtist::setCountry(const QString& szCountry)
|
||||
{
|
||||
m_szCountry = szCountry;
|
||||
}
|
||||
|
||||
QString cArtist::country()
|
||||
{
|
||||
return(m_szCountry);
|
||||
}
|
||||
|
||||
void cArtist::setCountryCode(const QString& szCountryCode)
|
||||
{
|
||||
m_szCountryCode = szCountryCode;
|
||||
}
|
||||
|
||||
QString cArtist::countryCode()
|
||||
{
|
||||
return(m_szCountryCode);
|
||||
}
|
||||
|
||||
void cArtist::setArtistThumb(const QString& szArtistThumb)
|
||||
{
|
||||
m_szArtistThumb = szArtistThumb;
|
||||
}
|
||||
|
||||
QString cArtist::artistThumb()
|
||||
{
|
||||
return(m_szArtistThumb);
|
||||
}
|
||||
|
||||
void cArtist::setArtistLogo(const QString& szArtistLogo)
|
||||
{
|
||||
m_szArtistLogo = szArtistLogo;
|
||||
}
|
||||
|
||||
QString cArtist::artistLogo()
|
||||
{
|
||||
return(m_szArtistLogo);
|
||||
}
|
||||
|
||||
void cArtist::setArtistClearart(const QString& szArtistClearart)
|
||||
{
|
||||
m_szArtistClearart = szArtistClearart;
|
||||
}
|
||||
|
||||
QString cArtist::artistClearart()
|
||||
{
|
||||
return(m_szArtistClearart);
|
||||
}
|
||||
|
||||
void cArtist::setArtistWideThumb(const QString& szArtistWideThumb)
|
||||
{
|
||||
m_szArtistWideThumb = szArtistWideThumb;
|
||||
}
|
||||
|
||||
QString cArtist::artistWideThumb()
|
||||
{
|
||||
return(m_szArtistWideThumb);
|
||||
}
|
||||
|
||||
void cArtist::setArtistFanart(const QString& szArtistFanart)
|
||||
{
|
||||
m_szArtistFanart = szArtistFanart;
|
||||
}
|
||||
|
||||
QString cArtist::artistFanart()
|
||||
{
|
||||
return(m_szArtistFanart);
|
||||
}
|
||||
|
||||
void cArtist::setArtistFanart2(const QString& szArtistFanart2)
|
||||
{
|
||||
m_szArtistFanart2 = szArtistFanart2;
|
||||
}
|
||||
|
||||
QString cArtist::artistFanart2()
|
||||
{
|
||||
return(m_szArtistFanart2);
|
||||
}
|
||||
|
||||
void cArtist::setArtistFanart3(const QString& szArtistFanart3)
|
||||
{
|
||||
m_szArtistFanart3 = szArtistFanart3;
|
||||
}
|
||||
|
||||
QString cArtist::artistFanart3()
|
||||
{
|
||||
return(m_szArtistFanart3);
|
||||
}
|
||||
|
||||
void cArtist::setArtistBanner(const QString& szArtistBanner)
|
||||
{
|
||||
m_szArtistBanner = szArtistBanner;
|
||||
}
|
||||
|
||||
QString cArtist::artistBanner()
|
||||
{
|
||||
return(m_szArtistBanner);
|
||||
}
|
||||
|
||||
void cArtist::setMusicBrainzID(const QString& szMusicBrainzID)
|
||||
{
|
||||
m_szMusicBrainzID = szMusicBrainzID;
|
||||
}
|
||||
|
||||
QString cArtist::musicBrainzID()
|
||||
{
|
||||
return(m_szMusicBrainzID);
|
||||
}
|
||||
|
||||
void cArtist::setLastFMChart(const QString& szLastFMChart)
|
||||
{
|
||||
m_szLastFMChart = szLastFMChart;
|
||||
}
|
||||
|
||||
QString cArtist::lastFMChart()
|
||||
{
|
||||
return(m_szLastFMChart);
|
||||
}
|
||||
|
||||
cArtist* cArtistList::add(const qint32& iID)
|
||||
{
|
||||
cArtist* lpNew = find(iID);
|
||||
if(!lpNew)
|
||||
lpNew = new cArtist;
|
||||
lpNew->setArtistID(iID);
|
||||
append(lpNew);
|
||||
return(lpNew);
|
||||
}
|
||||
|
||||
cArtist* cArtistList::add(cArtist* lpArtist)
|
||||
{
|
||||
for(int z = 0;z < count();z++)
|
||||
{
|
||||
if(at(z) == lpArtist)
|
||||
return(0);
|
||||
}
|
||||
append(lpArtist);
|
||||
return(lpArtist);
|
||||
}
|
||||
|
||||
cArtist* cArtistList::find(const qint32& iID)
|
||||
{
|
||||
for(int z = 0;z < count();z++)
|
||||
{
|
||||
if(at(z)->artistID() == iID)
|
||||
return(at(z));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
#ifndef CARTIST_H
|
||||
#define CARTIST_H
|
||||
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QDate>
|
||||
#include <QSqlDatabase>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
class cArtist
|
||||
{
|
||||
public:
|
||||
cArtist();
|
||||
|
||||
void setArtistID(const qint32& iArtistID);
|
||||
qint32 artistID();
|
||||
void setArtist(const QString& szArtist);
|
||||
QString artist();
|
||||
void setArtistStripped(const QString& szArtistStripped);
|
||||
QString artistStripped();
|
||||
void setArtistAlernate(const QString& szArtistAlernate);
|
||||
QString artistAlernate();
|
||||
void setLabel(const QString& szLabel);
|
||||
QString label();
|
||||
void setLabelID(const qint32& iLabelID);
|
||||
qint32 labelID();
|
||||
void setFormedYear(const qint32& iFormedYear);
|
||||
qint32 formedYear();
|
||||
void setBornYear(const qint32& iBornYear);
|
||||
qint32 bornYear();
|
||||
void setDiedYear(const qint32& iDiedYear);
|
||||
qint32 diedYear();
|
||||
void setDisbanded(const QString& szDisbanded);
|
||||
QString disbanded();
|
||||
void setStyle(const QString& szStyle);
|
||||
QString style();
|
||||
void setGenre(const QString& szGenre);
|
||||
QString genre();
|
||||
void setMood(const QString& szMood);
|
||||
QString mood();
|
||||
void setWebsite(const QString& szWebsite);
|
||||
QString website();
|
||||
void setFacebook(const QString& szFacebook);
|
||||
QString facebook();
|
||||
void setTwitter(const QString& szTwitter);
|
||||
QString twitter();
|
||||
void setBiography(const QString& szBiography);
|
||||
QString biography();
|
||||
void setGender(const QString& szGender);
|
||||
QString gender();
|
||||
void setMembers(const qint32& iMembers);
|
||||
qint32 members();
|
||||
void setCountry(const QString& szCountry);
|
||||
QString country();
|
||||
void setCountryCode(const QString& szCountryCode);
|
||||
QString countryCode();
|
||||
void setArtistThumb(const QString& szArtistThumb);
|
||||
QString artistThumb();
|
||||
void setArtistLogo(const QString& szArtistLogo);
|
||||
QString artistLogo();
|
||||
void setArtistClearart(const QString& szArtistClearart);
|
||||
QString artistClearart();
|
||||
void setArtistWideThumb(const QString& szArtistWideThumb);
|
||||
QString artistWideThumb();
|
||||
void setArtistFanart(const QString& szArtistFanart);
|
||||
QString artistFanart();
|
||||
void setArtistFanart2(const QString& szArtistFanart2);
|
||||
QString artistFanart2();
|
||||
void setArtistFanart3(const QString& szArtistFanart3);
|
||||
QString artistFanart3();
|
||||
void setArtistBanner(const QString& szArtistBanner);
|
||||
QString artistBanner();
|
||||
void setMusicBrainzID(const QString& szMusicBrainzID);
|
||||
QString musicBrainzID();
|
||||
void setLastFMChart(const QString& szLastFMChart);
|
||||
QString lastFMChart();
|
||||
|
||||
private:
|
||||
qint32 m_iArtistID;
|
||||
QString m_szArtist;
|
||||
QString m_szArtistStripped;
|
||||
QString m_szArtistAlernate;
|
||||
QString m_szLabel;
|
||||
qint32 m_iLabelID;
|
||||
qint32 m_iFormedYear;
|
||||
qint32 m_iBornYear;
|
||||
qint32 m_iDiedYear;
|
||||
QString m_szDisbanded;
|
||||
QString m_szStyle;
|
||||
QString m_szGenre;
|
||||
QString m_szMood;
|
||||
QString m_szWebsite;
|
||||
QString m_szFacebook;
|
||||
QString m_szTwitter;
|
||||
QString m_szBiography;
|
||||
QString m_szGender;
|
||||
qint32 m_iMembers;
|
||||
QString m_szCountry;
|
||||
QString m_szCountryCode;
|
||||
QString m_szArtistThumb;
|
||||
QString m_szArtistLogo;
|
||||
QString m_szArtistClearart;
|
||||
QString m_szArtistWideThumb;
|
||||
QString m_szArtistFanart;
|
||||
QString m_szArtistFanart2;
|
||||
QString m_szArtistFanart3;
|
||||
QString m_szArtistBanner;
|
||||
QString m_szMusicBrainzID;
|
||||
QString m_szLastFMChart;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cArtist*)
|
||||
|
||||
class cArtistList : public QList<cArtist*>
|
||||
{
|
||||
public:
|
||||
cArtist* add(const qint32& iArtistID);
|
||||
cArtist* add(cArtist* lpArtist);
|
||||
cArtist* find(const qint32& iArtistID);
|
||||
};
|
||||
|
||||
#endif // CARTIST_H
|
||||
@ -0,0 +1,29 @@
|
||||
/* */
|
||||
#include "ccheckboxitemdelegate.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QTextDocument>
|
||||
#include <QAbstractTextDocumentLayout>
|
||||
#include <QFont>
|
||||
|
||||
|
||||
void cCheckBoxItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem & option, const QModelIndex &index) const
|
||||
{
|
||||
QStyleOptionViewItem options = option;
|
||||
initStyleOption(&options, index);
|
||||
|
||||
if(index.data(Qt::CheckStateRole) == Qt::Checked)
|
||||
options.font.setBold(true);
|
||||
QStyledItemDelegate::paint(painter, options, index);
|
||||
}
|
||||
|
||||
QSize cCheckBoxItemDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
|
||||
{
|
||||
QStyleOptionViewItem options = option;
|
||||
initStyleOption(&options, index);
|
||||
|
||||
//if(index.data(Qt::CheckStateRole) == Qt::Checked)
|
||||
options.font.setBold(true);
|
||||
|
||||
return(QStyledItemDelegate::sizeHint(options, index));
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
#ifndef CCHECKBOXITEMDELEGATE_H
|
||||
#define CCHECKBOXITEMDELEGATE_H
|
||||
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cCheckBoxItemDelegate ccheckboxitemdelegate.h "ccheckboxitemdelegate.h"
|
||||
*/
|
||||
class cCheckBoxItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn paint
|
||||
\param painter
|
||||
\param option
|
||||
\param index
|
||||
*/
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn sizeHint
|
||||
\param option
|
||||
\param index
|
||||
\return QSize
|
||||
*/
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
};
|
||||
|
||||
#endif // CCHECKBOXITEMDELEGATE_H
|
||||
@ -0,0 +1,160 @@
|
||||
#include "cdiscover.h"
|
||||
#include "ui_cdiscover.h"
|
||||
|
||||
#include "ccheckboxitemdelegate.h"
|
||||
#include "cthemoviedbv3.h"
|
||||
|
||||
#include <QStandardItem>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
cDiscover::cDiscover(const cSerieList serieList, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::cDiscover),
|
||||
m_serieList(serieList)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_lpGenresModel = new QStandardItemModel(0, 1);
|
||||
QStringList headerLabels = QStringList() << tr("Name");
|
||||
m_lpGenresModel->setHorizontalHeaderLabels(headerLabels);
|
||||
ui->m_lpGenres->setModel(m_lpGenresModel);
|
||||
ui->m_lpGenres->setItemDelegate(new cCheckBoxItemDelegate());
|
||||
ui->m_lpGenres->setWrapping(true);
|
||||
|
||||
m_lpSeriesModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpSeries->setModel(m_lpSeriesModel);
|
||||
|
||||
headerLabels = QStringList() << tr("Title") << tr("Year") << tr("Voting");
|
||||
m_lpSeriesModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
connect(ui->m_lpVoting, &QxtSpanSlider::spanChanged, this, &cDiscover::spanChanged);
|
||||
|
||||
ui->m_lpVoting->setRange(0, 100);
|
||||
ui->m_lpVoting->setLowerValue(0);
|
||||
ui->m_lpVoting->setUpperValue(100);
|
||||
|
||||
cTheMovieDBV3 movieDB3;
|
||||
QMap<qint32, QString> genres;
|
||||
|
||||
genres = movieDB3.genresSerie("de-DE");
|
||||
|
||||
QMapIterator<qint32, QString> iterator(genres);
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
iterator.next();
|
||||
QStandardItem* lpItem = new QStandardItem(iterator.value());
|
||||
lpItem->setData(iterator.key());
|
||||
lpItem->setCheckable(true);
|
||||
|
||||
m_lpGenresModel->appendRow(lpItem);
|
||||
}
|
||||
}
|
||||
|
||||
cDiscover::~cDiscover()
|
||||
{
|
||||
delete ui;
|
||||
delete m_lpGenresModel;
|
||||
}
|
||||
|
||||
void cDiscover::spanChanged(int lower, int upper)
|
||||
{
|
||||
ui->m_lpVotingFrom->setText(QString::number((qreal)lower/10));
|
||||
ui->m_lpVotingTo->setText(QString::number((qreal)upper/10));
|
||||
}
|
||||
|
||||
void cDiscover::on_m_lpDiscover_clicked()
|
||||
{
|
||||
QString szText = ui->m_lpText->text();
|
||||
qint32 iYear = ui->m_lpYear->value();
|
||||
qreal voteMin = (qreal)ui->m_lpVoting->lowerValue()/10;
|
||||
qreal voteMax = (qreal)ui->m_lpVoting->upperValue()/10;
|
||||
|
||||
QList<qint32> genres;
|
||||
|
||||
if(!ui->m_lpYearEnable->isChecked())
|
||||
iYear = -1;
|
||||
|
||||
for(int x = 0;x < m_lpGenresModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpItem = m_lpGenresModel->item(x);
|
||||
|
||||
if(lpItem->checkState() == Qt::Checked)
|
||||
genres.append(lpItem->data().toInt());
|
||||
}
|
||||
|
||||
setCursor(Qt::WaitCursor);
|
||||
|
||||
cTheMovieDBV3 movieDB3;
|
||||
QList<cSerie*> serieList = movieDB3.discoverSerie(m_serieList, szText, iYear, genres, voteMin, voteMax, "de-DE");
|
||||
|
||||
m_lpSeriesModel->clear();
|
||||
|
||||
QStringList headerLabels = QStringList() << tr("Title") << tr("Year") << tr("Voting");
|
||||
m_lpSeriesModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
for(int x = 0; x < serieList.count();x++)
|
||||
{
|
||||
cSerie* lpSerie = serieList[x];
|
||||
|
||||
if(m_serieList.find(lpSerie->seriesID()))
|
||||
continue;
|
||||
QList<QStandardItem*> items;
|
||||
|
||||
items.append(new QStandardItem(lpSerie->seriesName()));
|
||||
items.append(new QStandardItem(QString::number(lpSerie->firstAired().year())));
|
||||
items.append(new QStandardItem(QString::number(lpSerie->voteAverage())));
|
||||
items[0]->setData(QVariant::fromValue(lpSerie));
|
||||
items[1]->setData(QVariant::fromValue(lpSerie));
|
||||
items[2]->setData(QVariant::fromValue(lpSerie));
|
||||
items[0]->setCheckable(true);
|
||||
|
||||
m_lpSeriesModel->appendRow(items);
|
||||
}
|
||||
|
||||
for(int x = 0;x < headerLabels.count();x++)
|
||||
ui->m_lpSeries->resizeColumnToContents(x);
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void cDiscover::on_m_lpYearEnable_clicked(bool checked)
|
||||
{
|
||||
ui->m_lpYear->setEnabled(checked);
|
||||
}
|
||||
|
||||
void cDiscover::on_m_lpSeries_clicked(const QModelIndex &index)
|
||||
{
|
||||
setCursor(Qt::WaitCursor);
|
||||
|
||||
QStandardItem* lpItem = m_lpSeriesModel->itemFromIndex(index);
|
||||
cSerie* lpSerie = lpItem->data().value<cSerie*>();
|
||||
|
||||
if(lpSerie->cast().isEmpty())
|
||||
{
|
||||
cTheMovieDBV3 theMovieDB;
|
||||
theMovieDB.loadCastSerie(lpSerie);
|
||||
}
|
||||
ui->m_lpSerieDetails->setSerie(lpSerie);
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
QList<qint32> cDiscover::id()
|
||||
{
|
||||
QList<qint32> idList;
|
||||
|
||||
for(int x = 0;x < m_lpSeriesModel->rowCount();x++)
|
||||
{
|
||||
if(m_lpSeriesModel->item(x, 0)->checkState() == Qt::Checked)
|
||||
{
|
||||
cSerie* lpSerie = m_lpSeriesModel->item(x, 0)->data().value<cSerie*>();
|
||||
idList.append(lpSerie->seriesID());
|
||||
}
|
||||
}
|
||||
|
||||
return(idList);
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
#ifndef CDISCOVER_H
|
||||
#define CDISCOVER_H
|
||||
|
||||
|
||||
#include <QDialog>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include "cserie.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cDiscover;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cDiscover cdiscover.h "cdiscover.h"
|
||||
*/
|
||||
class cDiscover : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn cDiscover
|
||||
\param serieList
|
||||
\param parent
|
||||
*/
|
||||
explicit cDiscover(const cSerieList serieList, QWidget *parent = 0);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn ~cDiscover
|
||||
*/
|
||||
~cDiscover();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn id
|
||||
\return QList<qint32>
|
||||
*/
|
||||
QList<qint32> id();
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn spanChanged
|
||||
\param lower
|
||||
\param upper
|
||||
*/
|
||||
void spanChanged(int lower, int upper);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn on_m_lpDiscover_clicked
|
||||
*/
|
||||
void on_m_lpDiscover_clicked();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn on_m_lpYearEnable_clicked
|
||||
\param checked
|
||||
*/
|
||||
void on_m_lpYearEnable_clicked(bool checked);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn on_m_lpSeries_clicked
|
||||
\param index
|
||||
*/
|
||||
void on_m_lpSeries_clicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::cDiscover* ui; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpGenresModel; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpSeriesModel; /*!< TODO: describe */
|
||||
cSerieList m_serieList; /*!< TODO: describe */
|
||||
};
|
||||
|
||||
#endif // CDISCOVER_H
|
||||
@ -0,0 +1,233 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cDiscover</class>
|
||||
<widget class="QDialog" name="cDiscover">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>900</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Discover Series</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,10">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Text:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpText"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_lpYearEnable">
|
||||
<property name="text">
|
||||
<string>Erscheinungsjahr:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="m_lpYear">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1800</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Voting:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="m_lpVotingFrom">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="m_lpVotingTo">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QxtSpanSlider" name="m_lpVoting">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Genre</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QListView" name="m_lpGenres">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flow">
|
||||
<enum>QListView::TopToBottom</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_lpDiscover">
|
||||
<property name="text">
|
||||
<string>Discover</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTreeView" name="m_lpSeries">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<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>90</width>
|
||||
<height>304</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="cSerieDetails" name="m_lpSerieDetails" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QxtSpanSlider</class>
|
||||
<extends>QSlider</extends>
|
||||
<header>qxtspanslider.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>cSerieDetails</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cseriedetails.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>cDiscover</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>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>cDiscover</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>
|
||||
@ -0,0 +1,58 @@
|
||||
#include "cexportdialog.h"
|
||||
#include "ui_cexportdialog.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
cExportDialog::cExportDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::cExportDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QSettings settings;
|
||||
QString szExportSerie = settings.value("exportSeriePath", QString("%1%2series.xml").arg(QDir::homePath()).arg(QDir::separator())).toString();
|
||||
QString szExportMovie = settings.value("exportMoviePath", QString("%1%2movies.xml").arg(QDir::homePath()).arg(QDir::separator())).toString();
|
||||
bool bExportSerie = settings.value("exportSerie", QDir::homePath()).toBool();
|
||||
bool bExportMovie = settings.value("exportMovie", QDir::homePath()).toBool();
|
||||
|
||||
ui->m_lpExportSeries->setChecked(bExportSerie);
|
||||
ui->m_lpExportMovies->setChecked(bExportMovie);
|
||||
ui->m_lpSeriesPath->setText(szExportSerie);
|
||||
ui->m_lpMoviesPath->setText(szExportMovie);
|
||||
}
|
||||
|
||||
cExportDialog::~cExportDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cExportDialog::on_m_lpSeriesPathSelect_clicked()
|
||||
{
|
||||
QString szFile = QFileDialog::getSaveFileName(this, tr("export Serie"), ui->m_lpSeriesPath->text(), tr("XML Files (*.xml)"));
|
||||
|
||||
if(szFile.isEmpty())
|
||||
return;
|
||||
|
||||
ui->m_lpSeriesPath->setText(szFile);
|
||||
}
|
||||
|
||||
void cExportDialog::on_m_lpMoviesPathSelect_clicked()
|
||||
{
|
||||
QString szFile = QFileDialog::getSaveFileName(this, tr("export Serie"), ui->m_lpMoviesPath->text(), tr("XML Files (*.xml)"));
|
||||
|
||||
if(szFile.isEmpty())
|
||||
return;
|
||||
|
||||
ui->m_lpMoviesPath->setText(szFile);
|
||||
}
|
||||
|
||||
void cExportDialog::values(bool& bSeries, QString& szSeriesPath, bool& bMovies, QString& szMoviesPath)
|
||||
{
|
||||
bSeries = ui->m_lpExportSeries->checkState() == Qt::Checked;
|
||||
szSeriesPath = ui->m_lpSeriesPath->text();
|
||||
bMovies = ui->m_lpExportMovies->checkState() == Qt::Checked;
|
||||
szMoviesPath = ui->m_lpMoviesPath->text();
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
#ifndef CEXPORTDIALOG_H
|
||||
#define CEXPORTDIALOG_H
|
||||
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cExportDialog;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cExportDialog cexportdialog.h "cexportdialog.h"
|
||||
*/
|
||||
class cExportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn cExportDialog
|
||||
\param parent
|
||||
*/
|
||||
explicit cExportDialog(QWidget *parent = 0);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn ~cExportDialog
|
||||
*/
|
||||
~cExportDialog();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn values
|
||||
\param bSeries
|
||||
\param szSeriesPath
|
||||
\param bMovies
|
||||
\param szMoviesPath
|
||||
*/
|
||||
void values(bool& bSeries, QString& szSeriesPath, bool& bMovies, QString& szMoviesPath);
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn on_m_lpSeriesPathSelect_clicked
|
||||
*/
|
||||
void on_m_lpSeriesPathSelect_clicked();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn on_m_lpMoviesPathSelect_clicked
|
||||
*/
|
||||
void on_m_lpMoviesPathSelect_clicked();
|
||||
|
||||
private:
|
||||
Ui::cExportDialog *ui; /*!< TODO: describe */
|
||||
};
|
||||
|
||||
#endif // CEXPORTDIALOG_H
|
||||
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cExportDialog</class>
|
||||
<widget class="QDialog" name="cExportDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>99</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Export</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_lpExportSeries">
|
||||
<property name="text">
|
||||
<string>Series</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_lpSeriesPath"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="m_lpSeriesPathSelect">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_lpExportMovies">
|
||||
<property name="text">
|
||||
<string>Movies</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_lpMoviesPath"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="m_lpMoviesPathSelect">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>cExportDialog</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>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>cExportDialog</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>
|
||||
@ -0,0 +1,150 @@
|
||||
#include "cfanart.h"
|
||||
|
||||
|
||||
cFanart::cFanart(Type type) :
|
||||
m_type(type),
|
||||
m_iID(-1),
|
||||
m_szURL(""),
|
||||
m_szLanguage(""),
|
||||
m_iLikes(0),
|
||||
m_iSeason(-1),
|
||||
m_szDisc(""),
|
||||
m_szDiscType(""),
|
||||
m_bActive(false)
|
||||
{
|
||||
}
|
||||
|
||||
void cFanart::setType(const Type& type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
cFanart::Type cFanart::type()
|
||||
{
|
||||
return(m_type);
|
||||
}
|
||||
|
||||
void cFanart::setID(const qint32& iID)
|
||||
{
|
||||
m_iID = iID;
|
||||
}
|
||||
|
||||
qint32 cFanart::id()
|
||||
{
|
||||
return(m_iID);
|
||||
}
|
||||
|
||||
void cFanart::setURL(const QString& szURL)
|
||||
{
|
||||
m_szURL = szURL;
|
||||
}
|
||||
|
||||
QString cFanart::url()
|
||||
{
|
||||
return(m_szURL);
|
||||
}
|
||||
|
||||
void cFanart::setLanguage(const QString& szLanguage)
|
||||
{
|
||||
m_szLanguage = szLanguage;
|
||||
}
|
||||
|
||||
QString cFanart::language()
|
||||
{
|
||||
return(m_szLanguage);
|
||||
}
|
||||
|
||||
void cFanart::setLikes(const qint32& iLikes)
|
||||
{
|
||||
m_iLikes = iLikes;
|
||||
}
|
||||
|
||||
qint32 cFanart::likes()
|
||||
{
|
||||
return(m_iLikes);
|
||||
}
|
||||
|
||||
void cFanart::setSeason(const qint32& iSeason)
|
||||
{
|
||||
m_iSeason = iSeason;
|
||||
}
|
||||
|
||||
qint32 cFanart::season()
|
||||
{
|
||||
return(m_iSeason);
|
||||
}
|
||||
|
||||
void cFanart::setDisc(const QString& szDisc)
|
||||
{
|
||||
m_szDisc = szDisc;
|
||||
}
|
||||
|
||||
QString cFanart::disc()
|
||||
{
|
||||
return(m_szDisc);
|
||||
}
|
||||
|
||||
void cFanart::setDiscType(const QString& szDiscType)
|
||||
{
|
||||
m_szDiscType = szDiscType;
|
||||
}
|
||||
|
||||
QString cFanart::discType()
|
||||
{
|
||||
return(m_szDiscType);
|
||||
}
|
||||
|
||||
void cFanart::setActive(const bool& bActive)
|
||||
{
|
||||
m_bActive = bActive;
|
||||
}
|
||||
|
||||
bool cFanart::active()
|
||||
{
|
||||
return(m_bActive);
|
||||
}
|
||||
|
||||
cFanart* cFanartList::add(const cFanart::Type& type)
|
||||
{
|
||||
cFanart* lpNew = new cFanart(type);
|
||||
append(lpNew);
|
||||
return(lpNew);
|
||||
}
|
||||
|
||||
cFanart* cFanartList::search(const cFanart::Type& type, const QString& szLanguage)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(szLanguage.length())
|
||||
{
|
||||
if(at(x)->type() == type && !at(x)->language().compare(szLanguage, Qt::CaseInsensitive))
|
||||
return(at(x));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(at(x)->type() == type)
|
||||
return(at(x));
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
cFanart* cFanartList::search(const cFanart::Type& type, const bool bActive, const QString& szLanguage)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(szLanguage.length())
|
||||
{
|
||||
if(at(x)->type() == type &&
|
||||
!at(x)->language().compare(szLanguage, Qt::CaseInsensitive) &&
|
||||
at(x)->active() == bActive)
|
||||
return(at(x));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(at(x)->type() == type && at(x)->active() == bActive)
|
||||
return(at(x));
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@ -0,0 +1,237 @@
|
||||
#ifndef CFANART_H
|
||||
#define CFANART_H
|
||||
|
||||
|
||||
#include <QString>
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cFanart cfanart.h "cfanart.h"
|
||||
*/
|
||||
class cFanart
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\enum Type
|
||||
*/
|
||||
enum Type
|
||||
{
|
||||
TypeUnknown = 0,
|
||||
TypeHDTVLogo = 1,
|
||||
TypeClearLogo = 2,
|
||||
TypeTVPoster = 3,
|
||||
TypeClearArt = 4,
|
||||
TypeHDClearArt = 5,
|
||||
TypeShowBackground = 6,
|
||||
TypeSeasonPoster = 7,
|
||||
TypeTVThumb = 8,
|
||||
TypeSeasonBanner = 9,
|
||||
TypeCharacterArt = 10,
|
||||
TypeSeasonThumb = 11,
|
||||
TypeTVBanner = 12,
|
||||
TypeHDMovieLogo = 13,
|
||||
TypeMovieDisc = 14,
|
||||
TypeMovieLogo = 15,
|
||||
TypeMoviePoster = 16,
|
||||
TypeHDMovieClearArt = 17,
|
||||
TypeMovieArt = 18,
|
||||
TypeMovieBackground = 19,
|
||||
TypeMovieBanner = 20,
|
||||
TypeMovieThumb = 21,
|
||||
};
|
||||
|
||||
cFanart(Type type = TypeUnknown);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setType
|
||||
\param type
|
||||
*/
|
||||
void setType(const Type& type);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn type
|
||||
\return Type
|
||||
*/
|
||||
Type type();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setID
|
||||
\param iID
|
||||
*/
|
||||
void setID(const qint32& iID);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn id
|
||||
\return qint32
|
||||
*/
|
||||
qint32 id();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setURL
|
||||
\param szURL
|
||||
*/
|
||||
void setURL(const QString& szURL);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn url
|
||||
\return QString
|
||||
*/
|
||||
QString url();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setLanguage
|
||||
\param szLanguage
|
||||
*/
|
||||
void setLanguage(const QString& szLanguage);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn language
|
||||
\return QString
|
||||
*/
|
||||
QString language();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setLikes
|
||||
\param iLikes
|
||||
*/
|
||||
void setLikes(const qint32& iLikes);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn likes
|
||||
\return qint32
|
||||
*/
|
||||
qint32 likes();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setSeason
|
||||
\param iSeason
|
||||
*/
|
||||
void setSeason(const qint32& iSeason);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn season
|
||||
\return qint32
|
||||
*/
|
||||
qint32 season();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setDisc
|
||||
\param szDisc
|
||||
*/
|
||||
void setDisc(const QString& szDisc);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn disc
|
||||
\return QString
|
||||
*/
|
||||
QString disc();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setDiscType
|
||||
\param szDiscType
|
||||
*/
|
||||
void setDiscType(const QString& szDiscType);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn discType
|
||||
\return QString
|
||||
*/
|
||||
QString discType();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setActive
|
||||
\param bActive
|
||||
*/
|
||||
void setActive(const bool& bActive);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn active
|
||||
\return bool
|
||||
*/
|
||||
bool active();
|
||||
private:
|
||||
Type m_type; /*!< TODO: describe */
|
||||
qint32 m_iID; /*!< TODO: describe */
|
||||
QString m_szURL; /*!< TODO: describe */
|
||||
QString m_szLanguage; /*!< TODO: describe */
|
||||
qint32 m_iLikes; /*!< TODO: describe */
|
||||
qint32 m_iSeason; /*!< TODO: describe */
|
||||
QString m_szDisc; /*!< TODO: describe */
|
||||
QString m_szDiscType; /*!< TODO: describe */
|
||||
bool m_bActive; /*!< TODO: describe */
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cFanart*)
|
||||
Q_DECLARE_METATYPE(cFanart::Type)
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cFanartList cfanart.h "cfanart.h"
|
||||
*/
|
||||
class cFanartList : public QList<cFanart*>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn add
|
||||
\param type
|
||||
\return cFanart
|
||||
*/
|
||||
cFanart* add(const cFanart::Type& type);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn search
|
||||
\param type
|
||||
\param szLanguage
|
||||
\return cFanart
|
||||
*/
|
||||
cFanart* search(const cFanart::Type& type, const QString& szLanguage = "");
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn search
|
||||
\param type
|
||||
\param bActive
|
||||
\param szLanguage
|
||||
\return cFanart
|
||||
*/
|
||||
cFanart* search(const cFanart::Type& type, const bool bActive, const QString& szLanguage = "");
|
||||
};
|
||||
|
||||
#endif // CFANART_H
|
||||
@ -0,0 +1,36 @@
|
||||
#ifndef CFANARTIMAGE_H
|
||||
#define CFANARTIMAGE_H
|
||||
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cFanartImage cfanartimage.h "cfanartimage.h"
|
||||
*/
|
||||
class cFanartImage
|
||||
{
|
||||
public:
|
||||
cFanartImage();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn getImage
|
||||
\param szFileName
|
||||
\return QPixmap
|
||||
*/
|
||||
QPixmap getImage(const QString& szFileName);
|
||||
private:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn downloadFile
|
||||
\param szFileName
|
||||
\return QPixmap
|
||||
*/
|
||||
QPixmap downloadFile(const QString& szFileName);
|
||||
};
|
||||
|
||||
#endif // CFANARTIMAGE_H
|
||||
@ -0,0 +1,163 @@
|
||||
#include "cfanarttv.h"
|
||||
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QEventLoop>
|
||||
#include <QByteArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
|
||||
cFanartTV::cFanartTV() :
|
||||
m_szAPIKey("5c31661038de56f110b5f2fc4d49a7d1")
|
||||
{
|
||||
}
|
||||
|
||||
void cFanartTV::processArray(const QJsonArray& array, cFanartList& fanartList, cFanart::Type type)
|
||||
{
|
||||
cFanart* lpFanart;
|
||||
|
||||
for(int x = 0;x < array.count();x++)
|
||||
{
|
||||
QJsonObject obj = array.at(x).toObject();
|
||||
lpFanart = fanartList.add(type);
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case cFanart::TypeHDTVLogo:
|
||||
case cFanart::TypeClearLogo:
|
||||
case cFanart::TypeTVPoster:
|
||||
case cFanart::TypeClearArt:
|
||||
case cFanart::TypeHDClearArt:
|
||||
case cFanart::TypeTVThumb:
|
||||
case cFanart::TypeCharacterArt:
|
||||
case cFanart::TypeTVBanner:
|
||||
lpFanart->setID(obj["id"].toString().toInt());
|
||||
lpFanart->setLanguage(obj["lang"].toString());
|
||||
lpFanart->setLikes(obj["likes"].toString().toInt());
|
||||
lpFanart->setURL(obj["url"].toString());
|
||||
break;
|
||||
case cFanart::TypeShowBackground:
|
||||
case cFanart::TypeSeasonPoster:
|
||||
case cFanart::TypeSeasonBanner:
|
||||
case cFanart::TypeSeasonThumb:
|
||||
lpFanart->setID(obj["id"].toString().toInt());
|
||||
lpFanart->setLanguage(obj["lang"].toString());
|
||||
lpFanart->setLikes(obj["likes"].toString().toInt());
|
||||
lpFanart->setURL(obj["url"].toString());
|
||||
if(!obj["season"].toString().compare("all"))
|
||||
lpFanart->setSeason(-1);
|
||||
else
|
||||
lpFanart->setSeason(obj["season"].toString().toInt());
|
||||
break;
|
||||
case cFanart::TypeHDMovieLogo:
|
||||
case cFanart::TypeMovieLogo:
|
||||
case cFanart::TypeMoviePoster:
|
||||
case cFanart::TypeHDMovieClearArt:
|
||||
case cFanart::TypeMovieArt:
|
||||
case cFanart::TypeMovieBackground:
|
||||
case cFanart::TypeMovieBanner:
|
||||
case cFanart::TypeMovieThumb:
|
||||
lpFanart->setID(obj["id"].toString().toInt());
|
||||
lpFanart->setLanguage(obj["lang"].toString());
|
||||
lpFanart->setLikes(obj["likes"].toString().toInt());
|
||||
lpFanart->setURL(obj["url"].toString());
|
||||
break;
|
||||
case cFanart::TypeMovieDisc:
|
||||
lpFanart->setID(obj["id"].toString().toInt());
|
||||
lpFanart->setLanguage(obj["lang"].toString());
|
||||
lpFanart->setLikes(obj["likes"].toString().toInt());
|
||||
lpFanart->setURL(obj["url"].toString());
|
||||
lpFanart->setDisc(obj["disc"].toString());
|
||||
lpFanart->setDiscType(obj["disc_type"].toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cFanartList cFanartTV::loadFanartSerie(const qint32 &iID)
|
||||
{
|
||||
cFanartList fanartList;
|
||||
QNetworkAccessManager networkManager;
|
||||
QNetworkRequest request(QUrl(QString("http://webservice.fanart.tv/v3/tv/%1?api_key=%2").arg(iID).arg(m_szAPIKey)));
|
||||
|
||||
request.setRawHeader("Content-Type", "application/json");
|
||||
|
||||
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();
|
||||
|
||||
delete reply;
|
||||
|
||||
processArray(jsonObj["hdtvlogo"].toArray(), fanartList, cFanart::TypeHDTVLogo);
|
||||
processArray(jsonObj["clearlogo"].toArray(), fanartList, cFanart::TypeClearLogo);
|
||||
processArray(jsonObj["tvposter"].toArray(), fanartList, cFanart::TypeTVPoster);
|
||||
processArray(jsonObj["clearart"].toArray(), fanartList, cFanart::TypeClearArt);
|
||||
processArray(jsonObj["hdclearart"].toArray(), fanartList, cFanart::TypeHDClearArt);
|
||||
processArray(jsonObj["showbackground"].toArray(), fanartList, cFanart::TypeShowBackground);
|
||||
processArray(jsonObj["seasonposter"].toArray(), fanartList, cFanart::TypeSeasonPoster);
|
||||
processArray(jsonObj["tvthumb"].toArray(), fanartList, cFanart::TypeTVThumb);
|
||||
processArray(jsonObj["seasonbanner"].toArray(), fanartList, cFanart::TypeSeasonBanner);
|
||||
processArray(jsonObj["characterart"].toArray(), fanartList, cFanart::TypeCharacterArt);
|
||||
processArray(jsonObj["seasonthumb"].toArray(), fanartList, cFanart::TypeSeasonThumb);
|
||||
processArray(jsonObj["tvbanner"].toArray(), fanartList, cFanart::TypeTVBanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << reply->errorString();
|
||||
delete reply;
|
||||
}
|
||||
return(fanartList);
|
||||
}
|
||||
|
||||
cFanartList cFanartTV::loadFanartMovie(const QString &szIMDBID)
|
||||
{
|
||||
cFanartList fanartList;
|
||||
QNetworkAccessManager networkManager;
|
||||
QNetworkRequest request(QUrl(QString("http://webservice.fanart.tv/v3/movies/%1?api_key=%2").arg(szIMDBID).arg(m_szAPIKey)));
|
||||
|
||||
request.setRawHeader("Content-Type", "application/json");
|
||||
|
||||
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();
|
||||
|
||||
delete reply;
|
||||
|
||||
processArray(jsonObj["hdmovielogo"].toArray(), fanartList, cFanart::TypeHDMovieLogo);
|
||||
processArray(jsonObj["movielogo"].toArray(), fanartList, cFanart::TypeMovieLogo);
|
||||
processArray(jsonObj["movieposter"].toArray(), fanartList, cFanart::TypeMoviePoster);
|
||||
processArray(jsonObj["hdmovieclearart"].toArray(), fanartList, cFanart::TypeHDMovieClearArt);
|
||||
processArray(jsonObj["movieart"].toArray(), fanartList, cFanart::TypeMovieArt);
|
||||
processArray(jsonObj["moviebackground"].toArray(), fanartList, cFanart::TypeMovieBackground);
|
||||
processArray(jsonObj["moviebanner"].toArray(), fanartList, cFanart::TypeMovieBanner);
|
||||
processArray(jsonObj["moviethumb"].toArray(), fanartList, cFanart::TypeMovieThumb);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << reply->errorString();
|
||||
delete reply;
|
||||
}
|
||||
return(fanartList);
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
#ifndef CFANARTTV_H
|
||||
#define CFANARTTV_H
|
||||
|
||||
|
||||
#include "cfanart.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cFanartTV cfanarttv.h "cfanarttv.h"
|
||||
*/
|
||||
class cFanartTV
|
||||
{
|
||||
public:
|
||||
cFanartTV();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn loadFanartSerie
|
||||
\param iID
|
||||
\return cFanartList
|
||||
*/
|
||||
cFanartList loadFanartSerie(const qint32 &iID);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn loadFanartMovie
|
||||
\param szIMDBID
|
||||
\return cFanartList
|
||||
*/
|
||||
cFanartList loadFanartMovie(const QString& szIMDBID);
|
||||
private:
|
||||
QString m_szAPIKey; /*!< TODO: describe */
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn processArray
|
||||
\param array
|
||||
\param fanartList
|
||||
\param type
|
||||
*/
|
||||
void processArray(const QJsonArray& array, cFanartList& fanartList, cFanart::Type type);
|
||||
};
|
||||
|
||||
#endif // CFANARTTV_H
|
||||
@ -1,17 +0,0 @@
|
||||
#ifndef CIMAGE_H
|
||||
#define CIMAGE_H
|
||||
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
class cImage
|
||||
{
|
||||
public:
|
||||
cImage();
|
||||
QPixmap getImage(const QString& szFileName);
|
||||
private:
|
||||
QPixmap downloadFile(const QString& szFileName);
|
||||
};
|
||||
|
||||
#endif // CIMAGE_H
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,63 @@
|
||||
#include "cmoviedetails.h"
|
||||
#include "ui_cmoviedetails.h"
|
||||
|
||||
#include "cmovieimage.h"
|
||||
|
||||
|
||||
cMovieDetails::cMovieDetails(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::cMovieDetails),
|
||||
m_lpActorsModel(0),
|
||||
m_lpGenreModel(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_lpActorsModel = new QStandardItemModel(0, 0);
|
||||
ui->m_lpDetailsActors->setModel(m_lpActorsModel);
|
||||
|
||||
m_lpGenreModel = new QStandardItemModel(0, 9);
|
||||
ui->m_lpDetailsGenre->setModel(m_lpGenreModel);
|
||||
}
|
||||
|
||||
cMovieDetails::~cMovieDetails()
|
||||
{
|
||||
delete m_lpActorsModel;
|
||||
delete m_lpGenreModel;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cMovieDetails::setMovie(cMovie* lpMovie)
|
||||
{
|
||||
ui->m_lpName->setText(lpMovie->movieTitle());
|
||||
ui->m_lpFirstAired->setDate(lpMovie->releaseDate());
|
||||
ui->m_lpVoting->setText(QString::number(lpMovie->voteAverage()));
|
||||
|
||||
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());
|
||||
|
||||
m_lpActorsModel->clear();
|
||||
for(int x = 0;x < lpMovie->cast().count();x++)
|
||||
{
|
||||
QList<QStandardItem*> items;
|
||||
QStringList str = lpMovie->cast().at(x).split(",");
|
||||
|
||||
items.append(new QStandardItem(str.at(0)));
|
||||
items.append(new QStandardItem(str.at(1)));
|
||||
m_lpActorsModel->appendRow(items);
|
||||
}
|
||||
ui->m_lpDetailsActors->resizeColumnToContents(0);
|
||||
|
||||
m_lpGenreModel->clear();
|
||||
for(int x = 0;x < lpMovie->genres().count();x++)
|
||||
m_lpGenreModel->appendRow(new QStandardItem(lpMovie->genres().at(x)));
|
||||
|
||||
ui->m_lpDetailsGenre->resizeColumnToContents(0);
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
#ifndef CMOVIEDETAILS_H
|
||||
#define CMOVIEDETAILS_H
|
||||
|
||||
|
||||
#include "cmovie.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cMovieDetails;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cMovieDetails cmoviedetails.h "cmoviedetails.h"
|
||||
*/
|
||||
class cMovieDetails : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn cMovieDetails
|
||||
\param parent
|
||||
*/
|
||||
explicit cMovieDetails(QWidget *parent = 0);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn ~cMovieDetails
|
||||
*/
|
||||
~cMovieDetails();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setMovie
|
||||
\param lpMovie
|
||||
*/
|
||||
void setMovie(cMovie* lpMovie);
|
||||
private:
|
||||
Ui::cMovieDetails* ui; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpActorsModel;
|
||||
QStandardItemModel* m_lpGenreModel;
|
||||
};
|
||||
|
||||
#endif // CMOVIEDETAILS_H
|
||||
@ -0,0 +1,206 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cMovieDetails</class>
|
||||
<widget class="QWidget" name="cMovieDetails">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>781</width>
|
||||
<height>596</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpName">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Year:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateEdit" name="m_lpFirstAired">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Voting:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpVoting">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</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>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_lpDetailsBanner">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>310</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>761</width>
|
||||
<height>310</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="m_lpDetailsOverview">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="2,1">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="cVerticalLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Actors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="m_lpDetailsActors">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="cVerticalLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Genre</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="m_lpDetailsGenre">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>cVerticalLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>cverticallabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -0,0 +1,159 @@
|
||||
#include "cmoviediscover.h"
|
||||
#include "ui_cmoviediscover.h"
|
||||
|
||||
#include "ccheckboxitemdelegate.h"
|
||||
#include "cthemoviedbv3.h"
|
||||
|
||||
#include <QStandardItem>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
cMovieDiscover::cMovieDiscover(const cMovieList movieList, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::cMovieDiscover),
|
||||
m_movieList(movieList)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_lpGenresModel = new QStandardItemModel(0, 1);
|
||||
QStringList headerLabels = QStringList() << tr("Name");
|
||||
m_lpGenresModel->setHorizontalHeaderLabels(headerLabels);
|
||||
ui->m_lpGenres->setModel(m_lpGenresModel);
|
||||
ui->m_lpGenres->setItemDelegate(new cCheckBoxItemDelegate());
|
||||
ui->m_lpGenres->setWrapping(true);
|
||||
|
||||
m_lpMoviesModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpMovies->setModel(m_lpMoviesModel);
|
||||
|
||||
headerLabels = QStringList() << tr("Title") << tr("Year") << tr("Voting");
|
||||
m_lpMoviesModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
connect(ui->m_lpVoting, &QxtSpanSlider::spanChanged, this, &cMovieDiscover::spanChanged);
|
||||
|
||||
ui->m_lpVoting->setRange(0, 100);
|
||||
ui->m_lpVoting->setLowerValue(0);
|
||||
ui->m_lpVoting->setUpperValue(100);
|
||||
|
||||
cTheMovieDBV3 movieDB3;
|
||||
QMap<qint32, QString> genres;
|
||||
|
||||
genres = movieDB3.genresMovie("de-DE");
|
||||
|
||||
QMapIterator<qint32, QString> iterator(genres);
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
iterator.next();
|
||||
QStandardItem* lpItem = new QStandardItem(iterator.value());
|
||||
lpItem->setData(iterator.key());
|
||||
lpItem->setCheckable(true);
|
||||
|
||||
m_lpGenresModel->appendRow(lpItem);
|
||||
}
|
||||
}
|
||||
|
||||
cMovieDiscover::~cMovieDiscover()
|
||||
{
|
||||
delete ui;
|
||||
delete m_lpGenresModel;
|
||||
}
|
||||
|
||||
void cMovieDiscover::spanChanged(int lower, int upper)
|
||||
{
|
||||
ui->m_lpVotingFrom->setText(QString::number((qreal)lower/10));
|
||||
ui->m_lpVotingTo->setText(QString::number((qreal)upper/10));
|
||||
}
|
||||
|
||||
void cMovieDiscover::on_m_lpDiscover_clicked()
|
||||
{
|
||||
QString szText = ui->m_lpText->text();
|
||||
bool bAdult = ui->m_lpIncludeAdult->isChecked();
|
||||
qint32 iYear = ui->m_lpYear->value();
|
||||
qreal voteMin = (qreal)ui->m_lpVoting->lowerValue()/10;
|
||||
qreal voteMax = (qreal)ui->m_lpVoting->upperValue()/10;
|
||||
|
||||
QList<qint32> genres;
|
||||
|
||||
if(!ui->m_lpYearEnable->isChecked())
|
||||
iYear = -1;
|
||||
|
||||
for(int x = 0;x < m_lpGenresModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpItem = m_lpGenresModel->item(x);
|
||||
|
||||
if(lpItem->checkState() == Qt::Checked)
|
||||
genres.append(lpItem->data().toInt());
|
||||
}
|
||||
|
||||
setCursor(Qt::WaitCursor);
|
||||
|
||||
cTheMovieDBV3 movieDB3;
|
||||
QList<cMovie*> movieList = movieDB3.discoverMovie(m_movieList, szText, bAdult, iYear, genres, voteMin, voteMax, "de-DE");
|
||||
|
||||
m_lpMoviesModel->clear();
|
||||
|
||||
QStringList headerLabels = QStringList() << tr("Title") << tr("Year") << tr("Voting");
|
||||
m_lpMoviesModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
for(int x = 0; x < movieList.count();x++)
|
||||
{
|
||||
cMovie* lpMovie = movieList[x];
|
||||
|
||||
QList<QStandardItem*> items;
|
||||
|
||||
items.append(new QStandardItem(lpMovie->movieTitle()));
|
||||
items.append(new QStandardItem(QString::number(lpMovie->releaseDate().year())));
|
||||
items.append(new QStandardItem(QString::number(lpMovie->voteAverage())));
|
||||
items[0]->setData(QVariant::fromValue(lpMovie));
|
||||
items[1]->setData(QVariant::fromValue(lpMovie));
|
||||
items[2]->setData(QVariant::fromValue(lpMovie));
|
||||
items[0]->setCheckable(true);
|
||||
|
||||
m_lpMoviesModel->appendRow(items);
|
||||
}
|
||||
|
||||
for(int x = 0;x < headerLabels.count();x++)
|
||||
ui->m_lpMovies->resizeColumnToContents(x);
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void cMovieDiscover::on_m_lpYearEnable_clicked(bool checked)
|
||||
{
|
||||
ui->m_lpYear->setEnabled(checked);
|
||||
}
|
||||
|
||||
void cMovieDiscover::on_m_lpMovies_clicked(const QModelIndex &index)
|
||||
{
|
||||
setCursor(Qt::WaitCursor);
|
||||
|
||||
QStandardItem* lpItem = m_lpMoviesModel->itemFromIndex(index);
|
||||
cMovie* lpMovie = lpItem->data().value<cMovie*>();
|
||||
|
||||
if(lpMovie->cast().isEmpty())
|
||||
{
|
||||
cTheMovieDBV3 theMovieDB;
|
||||
theMovieDB.loadCastMovie(lpMovie);
|
||||
}
|
||||
ui->m_lpMovieDetails->setMovie(lpMovie);
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
QList<qint32> cMovieDiscover::id()
|
||||
{
|
||||
QList<qint32> idList;
|
||||
|
||||
for(int x = 0;x < m_lpMoviesModel->rowCount();x++)
|
||||
{
|
||||
if(m_lpMoviesModel->item(x, 0)->checkState() == Qt::Checked)
|
||||
{
|
||||
cMovie* lpMovie = m_lpMoviesModel->item(x, 0)->data().value<cMovie*>();
|
||||
idList.append(lpMovie->movieID());
|
||||
}
|
||||
}
|
||||
|
||||
return(idList);
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
#ifndef CMOVIEDISCOVER_H
|
||||
#define CMOVIEDISCOVER_H
|
||||
|
||||
|
||||
#include "cmovie.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cMovieDiscover;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cMovieDiscover cmoviediscover.h "cmoviediscover.h"
|
||||
*/
|
||||
class cMovieDiscover : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn cMovieDiscover
|
||||
\param movieList
|
||||
\param parent
|
||||
*/
|
||||
explicit cMovieDiscover(const cMovieList movieList, QWidget *parent = nullptr);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn ~cMovieDiscover
|
||||
*/
|
||||
~cMovieDiscover();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn id
|
||||
\return QList<qint32>
|
||||
*/
|
||||
QList<qint32> id();
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn spanChanged
|
||||
\param lower
|
||||
\param upper
|
||||
*/
|
||||
void spanChanged(int lower, int upper);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn on_m_lpDiscover_clicked
|
||||
*/
|
||||
void on_m_lpDiscover_clicked();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn on_m_lpYearEnable_clicked
|
||||
\param checked
|
||||
*/
|
||||
void on_m_lpYearEnable_clicked(bool checked);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn on_m_lpMovies_clicked
|
||||
\param index
|
||||
*/
|
||||
void on_m_lpMovies_clicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::cMovieDiscover* ui; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpGenresModel; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpMoviesModel; /*!< TODO: describe */
|
||||
cMovieList m_movieList; /*!< TODO: describe */
|
||||
};
|
||||
|
||||
#endif // CMOVIEDISCOVER_H
|
||||
@ -0,0 +1,241 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cMovieDiscover</class>
|
||||
<widget class="QDialog" name="cMovieDiscover">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>900</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Discover Movie</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,10">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Text:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpText"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_lpIncludeAdult">
|
||||
<property name="text">
|
||||
<string>inklusive Erotik</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_lpYearEnable">
|
||||
<property name="text">
|
||||
<string>Erscheinungsjahr:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="m_lpYear">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1800</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Voting:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="m_lpVotingFrom">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="m_lpVotingTo">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QxtSpanSlider" name="m_lpVoting">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Genre</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QListView" name="m_lpGenres">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flow">
|
||||
<enum>QListView::TopToBottom</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_lpDiscover">
|
||||
<property name="text">
|
||||
<string>Discover</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,2">
|
||||
<item>
|
||||
<widget class="QTreeView" name="m_lpMovies">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</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>579</width>
|
||||
<height>284</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="cMovieDetails" name="m_lpMovieDetails" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QxtSpanSlider</class>
|
||||
<extends>QSlider</extends>
|
||||
<header>qxtspanslider.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>cMovieDetails</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cmoviedetails.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>cMovieDiscover</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>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>cMovieDiscover</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>
|
||||
@ -0,0 +1,24 @@
|
||||
#include "cpixmapwidget.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
cPixmapWidget::cPixmapWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void cPixmapWidget::setPixmap(const QPixmap& pixmap)
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
}
|
||||
|
||||
void cPixmapWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
if(!m_pixmap.isNull())
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.drawPixmap(0, 0, m_pixmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
|
||||
}
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
#ifndef CPIXMAPWIDGET_H
|
||||
#define CPIXMAPWIDGET_H
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cPixmapWidget cpixmapwidget.h "cpixmapwidget.h"
|
||||
*/
|
||||
class cPixmapWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn cPixmapWidget
|
||||
\param parent
|
||||
*/
|
||||
explicit cPixmapWidget(QWidget *parent = nullptr);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setPixmap
|
||||
\param pixmap
|
||||
*/
|
||||
void setPixmap(const QPixmap& pixmap);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
QPixmap m_pixmap; /*!< TODO: describe */
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn paintEvent
|
||||
\param event
|
||||
*/
|
||||
void paintEvent(QPaintEvent *event);
|
||||
};
|
||||
|
||||
#endif // CPIXMAPWIDGET_H
|
||||
@ -0,0 +1,74 @@
|
||||
#include "cpreferences.h"
|
||||
#include "ui_cpreferences.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
cPreferences::cPreferences(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::cPreferences)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QSettings settings;
|
||||
|
||||
ui->m_lpExportSeries->setChecked(settings.value("exportSerie", QDir::homePath()).toBool());
|
||||
ui->m_lpExportMovies->setChecked(settings.value("exportMovie", QDir::homePath()).toBool());
|
||||
ui->m_lpSeriesPath->setText(settings.value("exportSeriePath", QString("%1%2series.xml").arg(QDir::homePath()).arg(QDir::separator())).toString());
|
||||
ui->m_lpMoviesPath->setText(settings.value("exportMoviePath", QString("%1%2movies.xml").arg(QDir::homePath()).arg(QDir::separator())).toString());
|
||||
|
||||
ui->m_lpDiscoverResultsSerie->setValue(settings.value("serieDiscover/results", 100).toInt());
|
||||
ui->m_lpSearchResultsSerie->setValue(settings.value("serieSearch/results", 100).toInt());
|
||||
ui->m_lpDiscoverResultsMovie->setValue(settings.value("movieDiscover/results", 100).toInt());
|
||||
ui->m_lpSearchResultsMovie->setValue(settings.value("movieSearch/results", 100).toInt());
|
||||
|
||||
ui->m_lpDisplaySeason0->setChecked(settings.value("displaySeason0", true).toBool());
|
||||
|
||||
m_bDisplaySeason0 = settings.value("displaySeason0", true).toBool();
|
||||
}
|
||||
|
||||
cPreferences::~cPreferences()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
settings.setValue("exportSeriePath", ui->m_lpSeriesPath->text());
|
||||
settings.setValue("exportMoviePath", ui->m_lpMoviesPath->text());
|
||||
settings.setValue("exportSerie", ui->m_lpExportSeries->isChecked());
|
||||
settings.setValue("exportMovie", ui->m_lpExportMovies->isChecked());
|
||||
|
||||
settings.setValue("serieDiscover/results", ui->m_lpDiscoverResultsSerie->value());
|
||||
settings.setValue("serieSearch/results", ui->m_lpSearchResultsSerie->value());
|
||||
settings.setValue("movieDiscover/results", ui->m_lpDiscoverResultsMovie->value());
|
||||
settings.setValue("movieSearch/results", ui->m_lpSearchResultsMovie->value());
|
||||
|
||||
settings.setValue("displaySeason0", ui->m_lpDisplaySeason0->isChecked());
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool cPreferences::displaySeason0Changed()
|
||||
{
|
||||
return(m_bDisplaySeason0 != ui->m_lpDisplaySeason0->isChecked());
|
||||
}
|
||||
|
||||
void cPreferences::on_m_lpSeriesPathSelect_clicked()
|
||||
{
|
||||
QString szFile = QFileDialog::getSaveFileName(this, tr("export Serie"), ui->m_lpSeriesPath->text(), tr("XML Files (*.xml)"));
|
||||
|
||||
if(szFile.isEmpty())
|
||||
return;
|
||||
|
||||
ui->m_lpSeriesPath->setText(szFile);
|
||||
}
|
||||
|
||||
void cPreferences::on_m_lpMoviesPathSelect_clicked()
|
||||
{
|
||||
QString szFile = QFileDialog::getSaveFileName(this, tr("export Serie"), ui->m_lpMoviesPath->text(), tr("XML Files (*.xml)"));
|
||||
|
||||
if(szFile.isEmpty())
|
||||
return;
|
||||
|
||||
ui->m_lpMoviesPath->setText(szFile);
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
#ifndef CPREFERENCES_H
|
||||
#define CPREFERENCES_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class cPreferences;
|
||||
}
|
||||
|
||||
class cPreferences : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cPreferences(QWidget *parent = nullptr);
|
||||
~cPreferences();
|
||||
|
||||
bool displaySeason0Changed();
|
||||
private slots:
|
||||
void on_m_lpSeriesPathSelect_clicked();
|
||||
|
||||
void on_m_lpMoviesPathSelect_clicked();
|
||||
|
||||
private:
|
||||
Ui::cPreferences* ui;
|
||||
bool m_bDisplaySeason0;
|
||||
};
|
||||
|
||||
#endif // CPREFERENCES_H
|
||||
@ -0,0 +1,207 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cPreferences</class>
|
||||
<widget class="QDialog" name="cPreferences">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>494</width>
|
||||
<height>317</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Preferences</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>General</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Series</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_lpSeriesPath"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="m_lpSeriesPathSelect">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>number of discover results</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_lpExportSeries">
|
||||
<property name="text">
|
||||
<string>enable export</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="m_lpDiscoverResultsSerie">
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_lpDisplaySeason0">
|
||||
<property name="text">
|
||||
<string>display season "0"</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>number of search results</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="m_lpSearchResultsMovie">
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Movies</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_lpExportMovies">
|
||||
<property name="text">
|
||||
<string>enable export</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>number of discover results</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="m_lpDiscoverResultsMovie">
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="m_lpMoviesPathSelect">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_lpMoviesPath"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>number of search results</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="m_lpSearchResultsSerie">
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>cPreferences</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>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>cPreferences</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>
|
||||
@ -0,0 +1,23 @@
|
||||
#include "cscrollarea.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
cScrollArea::cScrollArea(QWidget* parent) :
|
||||
QScrollArea(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void cScrollArea::setPixmap(const QPixmap& pixmap)
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
}
|
||||
|
||||
void cScrollArea::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
if(!m_pixmap.isNull())
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.drawPixmap(0, 0, m_pixmap);
|
||||
}
|
||||
QScrollArea::paintEvent(event);
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
#ifndef CSCROLLAREA_H
|
||||
#define CSCROLLAREA_H
|
||||
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cScrollArea cscrollarea.h "cscrollarea.h"
|
||||
*/
|
||||
class cScrollArea : public QScrollArea
|
||||
{
|
||||
public:
|
||||
cScrollArea(QWidget* parent = 0);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setPixmap
|
||||
\param pixmap
|
||||
*/
|
||||
void setPixmap(const QPixmap& pixmap);
|
||||
protected:
|
||||
QPixmap m_pixmap; /*!< TODO: describe */
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn paintEvent
|
||||
\param event
|
||||
*/
|
||||
void paintEvent(QPaintEvent *event);
|
||||
};
|
||||
|
||||
#endif // CSCROLLAREA_H
|
||||
@ -0,0 +1,63 @@
|
||||
#include "cseriedetails.h"
|
||||
#include "ui_cseriedetails.h"
|
||||
|
||||
#include "cmovieimage.h"
|
||||
|
||||
|
||||
cSerieDetails::cSerieDetails(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::cSerieDetails),
|
||||
m_lpActorsModel(0),
|
||||
m_lpGenreModel(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_lpActorsModel = new QStandardItemModel(0, 0);
|
||||
ui->m_lpDetailsActors->setModel(m_lpActorsModel);
|
||||
|
||||
m_lpGenreModel = new QStandardItemModel(0, 0);
|
||||
ui->m_lpDetailsGenre->setModel(m_lpGenreModel);
|
||||
}
|
||||
|
||||
cSerieDetails::~cSerieDetails()
|
||||
{
|
||||
delete m_lpActorsModel;
|
||||
delete m_lpGenreModel;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cSerieDetails::setSerie(cSerie* lpSerie)
|
||||
{
|
||||
ui->m_lpName->setText(lpSerie->seriesName());
|
||||
ui->m_lpFirstAired->setDate(lpSerie->firstAired());
|
||||
ui->m_lpVoting->setText(QString::number(lpSerie->voteAverage()));
|
||||
|
||||
ui->m_lpDetailsBanner->clear();
|
||||
if(!lpSerie->backdropPath().isEmpty())
|
||||
{
|
||||
cMovieImage image;
|
||||
QPixmap banner = image.getImage(lpSerie->backdropPath());
|
||||
ui->m_lpDetailsBanner->setPixmap(banner);
|
||||
}
|
||||
|
||||
ui->m_lpDetailsOverview->setText(lpSerie->overview());
|
||||
|
||||
m_lpActorsModel->clear();
|
||||
for(int x = 0;x < lpSerie->cast().count();x++)
|
||||
{
|
||||
QList<QStandardItem*> items;
|
||||
QStringList str = lpSerie->cast().at(x).split(",");
|
||||
|
||||
items.append(new QStandardItem(str.at(0)));
|
||||
items.append(new QStandardItem(str.at(1)));
|
||||
m_lpActorsModel->appendRow(items);
|
||||
}
|
||||
ui->m_lpDetailsActors->resizeColumnToContents(0);
|
||||
|
||||
m_lpGenreModel->clear();
|
||||
for(int x = 0;x < lpSerie->genre().count();x++)
|
||||
m_lpGenreModel->appendRow(new QStandardItem(lpSerie->genre().at(x)));
|
||||
|
||||
ui->m_lpDetailsGenre->resizeColumnToContents(0);
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
#ifndef CSERIEDETAILS_H
|
||||
#define CSERIEDETAILS_H
|
||||
|
||||
|
||||
#include "cserie.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cSerieDetails;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class cSerieDetails cseriedetails.h "cseriedetails.h"
|
||||
*/
|
||||
class cSerieDetails : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn cSerieDetails
|
||||
\param parent
|
||||
*/
|
||||
explicit cSerieDetails(QWidget *parent = 0);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn ~cSerieDetails
|
||||
*/
|
||||
~cSerieDetails();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setSerie
|
||||
\param lpSerie
|
||||
*/
|
||||
void setSerie(cSerie* lpSerie);
|
||||
private:
|
||||
Ui::cSerieDetails* ui; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpActorsModel; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpGenreModel; /*!< TODO: describe */
|
||||
};
|
||||
|
||||
#endif // CSERIEDETAILS_H
|
||||
@ -0,0 +1,206 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cSerieDetails</class>
|
||||
<widget class="QWidget" name="cSerieDetails">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>860</width>
|
||||
<height>516</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpName">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Year:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateEdit" name="m_lpFirstAired">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Voting:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_lpVoting">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</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>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_lpDetailsBanner">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>310</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>840</width>
|
||||
<height>288</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="m_lpDetailsOverview">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="2,1">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="cVerticalLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Actors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="m_lpDetailsActors">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="cVerticalLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Genre</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="m_lpDetailsGenre">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>cVerticalLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>cverticallabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -0,0 +1,35 @@
|
||||
#include "csplashscreen.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
cSplashScreen::cSplashScreen(const QPixmap& pixmap, QFont& font) :
|
||||
QSplashScreen(pixmap)
|
||||
{
|
||||
setFont(font);
|
||||
m_textDocument.setDefaultFont(font);
|
||||
}
|
||||
|
||||
void cSplashScreen::drawContents(QPainter *painter)
|
||||
{
|
||||
painter->translate(m_rect.topLeft());
|
||||
m_textDocument.setHtml(m_szMessage);
|
||||
m_textDocument.drawContents(painter);
|
||||
}
|
||||
|
||||
void cSplashScreen::showStatusMessage(const QString& message)
|
||||
{
|
||||
m_szMessage = message;
|
||||
showMessage(m_szMessage);
|
||||
}
|
||||
|
||||
void cSplashScreen::addStatusMessage(const QString& message)
|
||||
{
|
||||
m_szMessage.append(message);
|
||||
showMessage(m_szMessage);
|
||||
}
|
||||
|
||||
void cSplashScreen::setMessageRect(QRect rect)
|
||||
{
|
||||
m_rect = rect;
|
||||
m_textDocument.setTextWidth(rect.width());
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
#ifndef CSPLASHSCREEN_H
|
||||
#define CSPLASHSCREEN_H
|
||||
|
||||
|
||||
#include <QSplashScreen>
|
||||
#include <QPainter>
|
||||
#include <QTextDocument>
|
||||
|
||||
|
||||
class cSplashScreen : public QSplashScreen
|
||||
{
|
||||
public:
|
||||
cSplashScreen(const QPixmap& pixmap, QFont &font);
|
||||
|
||||
virtual void drawContents(QPainter *painter);
|
||||
void showStatusMessage(const QString &message);
|
||||
void addStatusMessage(const QString &message);
|
||||
void setMessageRect(QRect rect);
|
||||
|
||||
private:
|
||||
QTextDocument m_textDocument;
|
||||
QString m_szMessage;
|
||||
QRect m_rect;
|
||||
};
|
||||
|
||||
#endif // CSPLASHSCREEN_H
|
||||
@ -0,0 +1,96 @@
|
||||
#include "ctheaudiodbv1.h"
|
||||
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QEventLoop>
|
||||
#include <QByteArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
cTheAudioDBV1::cTheAudioDBV1()
|
||||
{
|
||||
m_szToken = "1";
|
||||
}
|
||||
|
||||
cTheAudioDBV1::~cTheAudioDBV1()
|
||||
{
|
||||
}
|
||||
|
||||
QList<cArtist*> cTheAudioDBV1::searchArtist(const QString& szArtist)
|
||||
{
|
||||
QList<cArtist*> artistList;
|
||||
QNetworkAccessManager networkManager;
|
||||
// QString szRequest = QString("theaudiodb.com/api/v1/json/%1/search.php?s=%2").arg(m_szToken).arg(szArtist);
|
||||
|
||||
QNetworkRequest request(QUrl(QString("https://www.theaudiodb.com/api/v1/json/%1/search.php?s=%2").arg(m_szToken).arg(szArtist)));
|
||||
|
||||
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 jsonArray = jsonObj["artists"].toArray();
|
||||
|
||||
for(int z = 0;z < jsonArray.count();z++)
|
||||
{
|
||||
QJsonObject artist = jsonArray[z].toObject();
|
||||
cArtist* lpArtist = new cArtist;
|
||||
|
||||
lpArtist->setArtistID(artist["idArtist"].toInt());
|
||||
lpArtist->setArtist(artist["strArtist"].toString());
|
||||
lpArtist->setArtistStripped(artist["strArtistStripped"].toString());
|
||||
lpArtist->setArtistAlernate(artist["strArtistAlternate"].toString());
|
||||
lpArtist->setLabel(artist["strLabel"].toString());
|
||||
lpArtist->setLabelID(artist["idLabel"].toInt());
|
||||
lpArtist->setFormedYear(artist["intFormedYear"].toInt());
|
||||
lpArtist->setBornYear(artist["intBornYear"].toInt());
|
||||
lpArtist->setDiedYear(artist["intDiedYear"].toInt());
|
||||
lpArtist->setDisbanded(artist["strDisbanded"].toString());
|
||||
lpArtist->setStyle(artist["strStyle"].toString());
|
||||
lpArtist->setGenre(artist["strGenre"].toString());
|
||||
lpArtist->setMood(artist["strMood"].toString());
|
||||
lpArtist->setWebsite(artist["strWebsite"].toString());
|
||||
lpArtist->setFacebook(artist["strFacebook"].toString());
|
||||
lpArtist->setTwitter(artist["strTwitter"].toString());
|
||||
lpArtist->setBiography(artist["strBiographyDE"].toString());
|
||||
if(lpArtist->biography().isEmpty())
|
||||
lpArtist->setBiography(artist["strBiographyEN"].toString());
|
||||
lpArtist->setGender(artist["strGender"].toString());
|
||||
lpArtist->setMembers(artist["intMembers"].toInt());
|
||||
lpArtist->setCountry(artist["strCountry"].toString());
|
||||
lpArtist->setCountryCode(artist["strCountryCode"].toString());
|
||||
lpArtist->setArtistThumb(artist["strArtistThumb"].toString());
|
||||
lpArtist->setArtistLogo(artist["strArtistLogo"].toString());
|
||||
lpArtist->setArtistClearart(artist["strArtistClearart"].toString());
|
||||
lpArtist->setArtistWideThumb(artist["strArtistWideThumb"].toString());
|
||||
lpArtist->setArtistFanart(artist["strArtistFanart"].toString());
|
||||
lpArtist->setArtistFanart2(artist["strArtistFanart2"].toString());
|
||||
lpArtist->setArtistFanart3(artist["strArtistFanart3"].toString());
|
||||
lpArtist->setArtistBanner(artist["strArtistBanner"].toString());
|
||||
lpArtist->setMusicBrainzID(artist["strMusicBrainzID"].toString());
|
||||
lpArtist->setLastFMChart(artist["strLastFMChart"].toString());
|
||||
|
||||
artistList.append(lpArtist);
|
||||
}
|
||||
delete reply;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << reply->errorString();
|
||||
delete reply;
|
||||
}
|
||||
|
||||
return(artistList);
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
#ifndef CTHEAUDIODBV1_H
|
||||
#define CTHEAUDIODBV1_H
|
||||
|
||||
|
||||
#include "cartist.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
class cTheAudioDBV1
|
||||
{
|
||||
public:
|
||||
cTheAudioDBV1();
|
||||
~cTheAudioDBV1();
|
||||
|
||||
QList<cArtist*> searchArtist(const QString& szArtist);
|
||||
private:
|
||||
QString m_szToken;
|
||||
};
|
||||
|
||||
#endif // CTHEAUDIODBV1_H
|
||||
@ -1,88 +0,0 @@
|
||||
#include "cupdatethread.h"
|
||||
#include "cseason.h"
|
||||
#include "cepisode.h"
|
||||
#include "cmessagedialog.h"
|
||||
#include "cthemoviedbv3.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTime>
|
||||
|
||||
|
||||
cUpdateThread::cUpdateThread() :
|
||||
m_bStop(false)
|
||||
{
|
||||
}
|
||||
|
||||
void cUpdateThread::stop()
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
m_bStop = true;
|
||||
emit updateAppendMessage(" - cancel pending ...");
|
||||
}
|
||||
|
||||
void cUpdateThread::run()
|
||||
{
|
||||
QTime timer;
|
||||
timer.restart();
|
||||
QString szFailed;
|
||||
|
||||
for(int x = 0;x < m_serieList.count();x++)
|
||||
{
|
||||
cSerie* lpSerie = m_serieList.at(x);
|
||||
if(lpSerie)
|
||||
{
|
||||
emit updateMessage(lpSerie->seriesName(), x);
|
||||
cTheMovieDBV3 theMovieDB;
|
||||
cSerie* lpSerieNew;
|
||||
|
||||
if(lpSerie->seriesID() != -1 && lpSerie->seriesID() < 1000000)
|
||||
{
|
||||
lpSerieNew = theMovieDB.loadSerie(lpSerie->seriesID(), "de-DE");
|
||||
if(!lpSerieNew)
|
||||
lpSerieNew = theMovieDB.loadSerie(lpSerie->seriesID(), "en");
|
||||
if(!lpSerieNew)
|
||||
{
|
||||
if(szFailed.length())
|
||||
szFailed += ", ";
|
||||
szFailed += lpSerie->seriesName();
|
||||
continue;
|
||||
}
|
||||
lpSerieNew->setDownload(lpSerie->download());
|
||||
for(int x = 0;x < lpSerieNew->seasonList().count();x++)
|
||||
{
|
||||
cSeason* lpSeasonNew = lpSerieNew->seasonList().at(x);
|
||||
for(int y = 0;y < lpSeasonNew->episodeList().count();y++)
|
||||
{
|
||||
cEpisode* lpEpisodeNew = lpSeasonNew->episodeList().at(y);
|
||||
cEpisode* lpEpisode = lpSerie->findEpisode(lpEpisodeNew->id());
|
||||
if(lpEpisode)
|
||||
lpEpisodeNew->setState(lpEpisode->state());
|
||||
}
|
||||
}
|
||||
lpSerieNew->setCliffhanger(lpSerie->cliffhanger());
|
||||
lpSerie->del(m_db);
|
||||
lpSerieNew->save(m_db);
|
||||
}
|
||||
}
|
||||
|
||||
QMutexLocker locker(&m_mutex);
|
||||
if(m_bStop)
|
||||
break;
|
||||
msleep(10);
|
||||
}
|
||||
if(szFailed.length())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(szFailed + QString(" has failed to update."));
|
||||
msgBox.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void cUpdateThread::setData(cMessageDialog* lpMessageDialog, const cSerieList &serieList, const QSqlDatabase& db)
|
||||
{
|
||||
connect(lpMessageDialog->cancelButton(), SIGNAL(clicked()), this, SLOT(stop()));
|
||||
m_serieList = serieList;
|
||||
m_db = db;
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
#ifndef CUPDATETHREAD_H
|
||||
#define CUPDATETHREAD_H
|
||||
|
||||
|
||||
#include "cmessagedialog.h"
|
||||
|
||||
#include "cserie.h"
|
||||
|
||||
#include <QThread>
|
||||
#include <QMutexLocker>
|
||||
#include <QList>
|
||||
#include <QStandardItem>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
|
||||
class cUpdateThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cUpdateThread();
|
||||
|
||||
void setData(cMessageDialog *lpMessageDialog, const cSerieList& serieList, const QSqlDatabase& db);
|
||||
public slots:
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
void updateMessage(const QString& szMessage, const qint32 &iProgress);
|
||||
void updateAppendMessage(const QString& szMessage);
|
||||
|
||||
private:
|
||||
QMutex m_mutex;
|
||||
bool m_bStop;
|
||||
cSerieList m_serieList;
|
||||
QSqlDatabase m_db;
|
||||
QWidget* m_lpParent;
|
||||
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif // CUPDATETHREAD_H
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 800 KiB |
@ -0,0 +1,750 @@
|
||||
#include "qxtspanslider.h"
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2006 - 2011, the LibQxt project.
|
||||
** See the Qxt AUTHORS file for a list of authors and copyright holders.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** * Neither the name of the LibQxt project nor the
|
||||
** names of its contributors may be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
*****************************************************************************/
|
||||
|
||||
#include "qxtspanslider_p.h"
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
#include <QStylePainter>
|
||||
#include <QStyleOptionSlider>
|
||||
|
||||
QxtSpanSliderPrivate::QxtSpanSliderPrivate() :
|
||||
lower(0),
|
||||
upper(0),
|
||||
lowerPos(0),
|
||||
upperPos(0),
|
||||
offset(0),
|
||||
position(0),
|
||||
lastPressed(QxtSpanSlider::NoHandle),
|
||||
mainControl(QxtSpanSlider::LowerHandle),
|
||||
lowerPressed(QStyle::SC_None),
|
||||
upperPressed(QStyle::SC_None),
|
||||
movement(QxtSpanSlider::FreeMovement),
|
||||
firstMovement(false),
|
||||
blockTracking(false)
|
||||
{
|
||||
}
|
||||
|
||||
void QxtSpanSliderPrivate::initStyleOption(QStyleOptionSlider* option, QxtSpanSlider::SpanHandle handle) const
|
||||
{
|
||||
const QxtSpanSlider* p = q_ptr;
|
||||
p->initStyleOption(option);
|
||||
option->sliderPosition = (handle == QxtSpanSlider::LowerHandle ? lowerPos : upperPos);
|
||||
option->sliderValue = (handle == QxtSpanSlider::LowerHandle ? lower : upper);
|
||||
}
|
||||
|
||||
int QxtSpanSliderPrivate::pixelPosToRangeValue(int pos) const
|
||||
{
|
||||
QStyleOptionSlider opt;
|
||||
initStyleOption(&opt);
|
||||
|
||||
int sliderMin = 0;
|
||||
int sliderMax = 0;
|
||||
int sliderLength = 0;
|
||||
const QSlider* p = q_ptr;
|
||||
const QRect gr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, p);
|
||||
const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p);
|
||||
if (p->orientation() == Qt::Horizontal)
|
||||
{
|
||||
sliderLength = sr.width();
|
||||
sliderMin = gr.x();
|
||||
sliderMax = gr.right() - sliderLength + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sliderLength = sr.height();
|
||||
sliderMin = gr.y();
|
||||
sliderMax = gr.bottom() - sliderLength + 1;
|
||||
}
|
||||
return QStyle::sliderValueFromPosition(p->minimum(), p->maximum(), pos - sliderMin,
|
||||
sliderMax - sliderMin, opt.upsideDown);
|
||||
}
|
||||
|
||||
void QxtSpanSliderPrivate::handleMousePress(const QPoint& pos, QStyle::SubControl& control, int value, QxtSpanSlider::SpanHandle handle)
|
||||
{
|
||||
QStyleOptionSlider opt;
|
||||
initStyleOption(&opt, handle);
|
||||
QxtSpanSlider* p = q_ptr;
|
||||
const QStyle::SubControl oldControl = control;
|
||||
control = p->style()->hitTestComplexControl(QStyle::CC_Slider, &opt, pos, p);
|
||||
const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p);
|
||||
if (control == QStyle::SC_SliderHandle)
|
||||
{
|
||||
position = value;
|
||||
offset = pick(pos - sr.topLeft());
|
||||
lastPressed = handle;
|
||||
p->setSliderDown(true);
|
||||
emit p->sliderPressed(handle);
|
||||
}
|
||||
if (control != oldControl)
|
||||
p->update(sr);
|
||||
}
|
||||
|
||||
void QxtSpanSliderPrivate::setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const
|
||||
{
|
||||
QColor highlight = q_ptr->palette().color(QPalette::Highlight);
|
||||
QLinearGradient gradient(x1, y1, x2, y2);
|
||||
gradient.setColorAt(0, highlight.dark(120));
|
||||
gradient.setColorAt(1, highlight.light(108));
|
||||
painter->setBrush(gradient);
|
||||
|
||||
if (orientation == Qt::Horizontal)
|
||||
painter->setPen(QPen(highlight.dark(130), 0));
|
||||
else
|
||||
painter->setPen(QPen(highlight.dark(150), 0));
|
||||
}
|
||||
|
||||
void QxtSpanSliderPrivate::drawSpan(QStylePainter* painter, const QRect& rect) const
|
||||
{
|
||||
QStyleOptionSlider opt;
|
||||
initStyleOption(&opt);
|
||||
const QSlider* p = q_ptr;
|
||||
|
||||
// area
|
||||
QRect groove = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, p);
|
||||
if (opt.orientation == Qt::Horizontal)
|
||||
groove.adjust(0, 0, -1, 0);
|
||||
else
|
||||
groove.adjust(0, 0, 0, -1);
|
||||
|
||||
// pen & brush
|
||||
painter->setPen(QPen(p->palette().color(QPalette::Dark).light(110), 0));
|
||||
if (opt.orientation == Qt::Horizontal)
|
||||
setupPainter(painter, opt.orientation, groove.center().x(), groove.top(), groove.center().x(), groove.bottom());
|
||||
else
|
||||
setupPainter(painter, opt.orientation, groove.left(), groove.center().y(), groove.right(), groove.center().y());
|
||||
|
||||
// draw groove
|
||||
painter->drawRect(rect.intersected(groove));
|
||||
}
|
||||
|
||||
void QxtSpanSliderPrivate::drawHandle(QStylePainter* painter, QxtSpanSlider::SpanHandle handle) const
|
||||
{
|
||||
QStyleOptionSlider opt;
|
||||
initStyleOption(&opt, handle);
|
||||
opt.subControls = QStyle::SC_SliderHandle;
|
||||
QStyle::SubControl pressed = (handle == QxtSpanSlider::LowerHandle ? lowerPressed : upperPressed);
|
||||
if (pressed == QStyle::SC_SliderHandle)
|
||||
{
|
||||
opt.activeSubControls = pressed;
|
||||
opt.state |= QStyle::State_Sunken;
|
||||
}
|
||||
painter->drawComplexControl(QStyle::CC_Slider, opt);
|
||||
}
|
||||
|
||||
void QxtSpanSliderPrivate::triggerAction(QAbstractSlider::SliderAction action, bool main)
|
||||
{
|
||||
int value = 0;
|
||||
bool no = false;
|
||||
bool up = false;
|
||||
const int min = q_ptr->minimum();
|
||||
const int max = q_ptr->maximum();
|
||||
const QxtSpanSlider::SpanHandle altControl = (mainControl == QxtSpanSlider::LowerHandle ? QxtSpanSlider::UpperHandle : QxtSpanSlider::LowerHandle);
|
||||
|
||||
blockTracking = true;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case QAbstractSlider::SliderSingleStepAdd:
|
||||
if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle))
|
||||
{
|
||||
value = qBound(min, upper + q_ptr->singleStep(), max);
|
||||
up = true;
|
||||
break;
|
||||
}
|
||||
value = qBound(min, lower + q_ptr->singleStep(), max);
|
||||
break;
|
||||
case QAbstractSlider::SliderSingleStepSub:
|
||||
if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle))
|
||||
{
|
||||
value = qBound(min, upper - q_ptr->singleStep(), max);
|
||||
up = true;
|
||||
break;
|
||||
}
|
||||
value = qBound(min, lower - q_ptr->singleStep(), max);
|
||||
break;
|
||||
case QAbstractSlider::SliderToMinimum:
|
||||
value = min;
|
||||
if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle))
|
||||
up = true;
|
||||
break;
|
||||
case QAbstractSlider::SliderToMaximum:
|
||||
value = max;
|
||||
if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle))
|
||||
up = true;
|
||||
break;
|
||||
case QAbstractSlider::SliderMove:
|
||||
if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle))
|
||||
up = true;
|
||||
case QAbstractSlider::SliderNoAction:
|
||||
no = true;
|
||||
break;
|
||||
default:
|
||||
qWarning("QxtSpanSliderPrivate::triggerAction: Unknown action");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!no && !up)
|
||||
{
|
||||
if (movement == QxtSpanSlider::NoCrossing)
|
||||
value = qMin(value, upper);
|
||||
else if (movement == QxtSpanSlider::NoOverlapping)
|
||||
value = qMin(value, upper - 1);
|
||||
|
||||
if (movement == QxtSpanSlider::FreeMovement && value > upper)
|
||||
{
|
||||
swapControls();
|
||||
q_ptr->setUpperPosition(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
q_ptr->setLowerPosition(value);
|
||||
}
|
||||
}
|
||||
else if (!no)
|
||||
{
|
||||
if (movement == QxtSpanSlider::NoCrossing)
|
||||
value = qMax(value, lower);
|
||||
else if (movement == QxtSpanSlider::NoOverlapping)
|
||||
value = qMax(value, lower + 1);
|
||||
|
||||
if (movement == QxtSpanSlider::FreeMovement && value < lower)
|
||||
{
|
||||
swapControls();
|
||||
q_ptr->setLowerPosition(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
q_ptr->setUpperPosition(value);
|
||||
}
|
||||
}
|
||||
|
||||
blockTracking = false;
|
||||
q_ptr->setLowerValue(lowerPos);
|
||||
q_ptr->setUpperValue(upperPos);
|
||||
}
|
||||
|
||||
void QxtSpanSliderPrivate::swapControls()
|
||||
{
|
||||
qSwap(lower, upper);
|
||||
qSwap(lowerPressed, upperPressed);
|
||||
lastPressed = (lastPressed == QxtSpanSlider::LowerHandle ? QxtSpanSlider::UpperHandle : QxtSpanSlider::LowerHandle);
|
||||
mainControl = (mainControl == QxtSpanSlider::LowerHandle ? QxtSpanSlider::UpperHandle : QxtSpanSlider::LowerHandle);
|
||||
}
|
||||
|
||||
void QxtSpanSliderPrivate::updateRange(int min, int max)
|
||||
{
|
||||
Q_UNUSED(min);
|
||||
Q_UNUSED(max);
|
||||
// setSpan() takes care of keeping span in range
|
||||
q_ptr->setSpan(lower, upper);
|
||||
}
|
||||
|
||||
void QxtSpanSliderPrivate::movePressedHandle()
|
||||
{
|
||||
switch (lastPressed)
|
||||
{
|
||||
case QxtSpanSlider::LowerHandle:
|
||||
if (lowerPos != lower)
|
||||
{
|
||||
bool main = (mainControl == QxtSpanSlider::LowerHandle);
|
||||
triggerAction(QAbstractSlider::SliderMove, main);
|
||||
}
|
||||
break;
|
||||
case QxtSpanSlider::UpperHandle:
|
||||
if (upperPos != upper)
|
||||
{
|
||||
bool main = (mainControl == QxtSpanSlider::UpperHandle);
|
||||
triggerAction(QAbstractSlider::SliderMove, main);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QxtSpanSlider
|
||||
\inmodule QxtWidgets
|
||||
\brief The QxtSpanSlider widget is a QSlider with two handles.
|
||||
|
||||
QxtSpanSlider is a slider with two handles. QxtSpanSlider is
|
||||
handy for letting user to choose an span between min/max.
|
||||
|
||||
The span color is calculated based on QPalette::Highlight.
|
||||
|
||||
The keys are bound according to the following table:
|
||||
\table
|
||||
\header \o Orientation \o Key \o Handle
|
||||
\row \o Qt::Horizontal \o Qt::Key_Left \o lower
|
||||
\row \o Qt::Horizontal \o Qt::Key_Right \o lower
|
||||
\row \o Qt::Horizontal \o Qt::Key_Up \o upper
|
||||
\row \o Qt::Horizontal \o Qt::Key_Down \o upper
|
||||
\row \o Qt::Vertical \o Qt::Key_Up \o lower
|
||||
\row \o Qt::Vertical \o Qt::Key_Down \o lower
|
||||
\row \o Qt::Vertical \o Qt::Key_Left \o upper
|
||||
\row \o Qt::Vertical \o Qt::Key_Right \o upper
|
||||
\endtable
|
||||
|
||||
Keys are bound by the time the slider is created. A key is bound
|
||||
to same handle for the lifetime of the slider. So even if the handle
|
||||
representation might change from lower to upper, the same key binding
|
||||
remains.
|
||||
|
||||
\image qxtspanslider.png "QxtSpanSlider in Plastique style."
|
||||
|
||||
\bold {Note:} QxtSpanSlider inherits QSlider for implementation specific
|
||||
reasons. Adjusting any single handle specific properties like
|
||||
\list
|
||||
\o QAbstractSlider::sliderPosition
|
||||
\o QAbstractSlider::value
|
||||
\endlist
|
||||
has no effect. However, all slider specific properties like
|
||||
\list
|
||||
\o QAbstractSlider::invertedAppearance
|
||||
\o QAbstractSlider::invertedControls
|
||||
\o QAbstractSlider::minimum
|
||||
\o QAbstractSlider::maximum
|
||||
\o QAbstractSlider::orientation
|
||||
\o QAbstractSlider::pageStep
|
||||
\o QAbstractSlider::singleStep
|
||||
\o QSlider::tickInterval
|
||||
\o QSlider::tickPosition
|
||||
\endlist
|
||||
are taken into consideration.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QxtSpanSlider::HandleMovementMode
|
||||
|
||||
This enum describes the available handle movement modes.
|
||||
|
||||
\value FreeMovement The handles can be moved freely.
|
||||
\value NoCrossing The handles cannot cross, but they can still overlap each other. The lower and upper values can be the same.
|
||||
\value NoOverlapping The handles cannot overlap each other. The lower and upper values cannot be the same.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QxtSpanSlider::SpanHandle
|
||||
|
||||
This enum describes the available span handles.
|
||||
|
||||
\omitvalue NoHandle \omit Internal only (for now). \endomit
|
||||
\value LowerHandle The lower boundary handle.
|
||||
\value UpperHandle The upper boundary handle.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QxtSpanSlider::lowerValueChanged(int lower)
|
||||
|
||||
This signal is emitted whenever the \a lower value has changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QxtSpanSlider::upperValueChanged(int upper)
|
||||
|
||||
This signal is emitted whenever the \a upper value has changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QxtSpanSlider::spanChanged(int lower, int upper)
|
||||
|
||||
This signal is emitted whenever both the \a lower and the \a upper
|
||||
values have changed ie. the span has changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QxtSpanSlider::lowerPositionChanged(int lower)
|
||||
|
||||
This signal is emitted whenever the \a lower position has changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QxtSpanSlider::upperPositionChanged(int upper)
|
||||
|
||||
This signal is emitted whenever the \a upper position has changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QxtSpanSlider::sliderPressed(SpanHandle handle)
|
||||
|
||||
This signal is emitted whenever the \a handle has been pressed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a new QxtSpanSlider with \a parent.
|
||||
*/
|
||||
QxtSpanSlider::QxtSpanSlider(QWidget* parent) : QSlider(parent), d_ptr(new QxtSpanSliderPrivate())
|
||||
{
|
||||
d_ptr->q_ptr = this;
|
||||
connect(this, SIGNAL(rangeChanged(int, int)), d_ptr, SLOT(updateRange(int, int)));
|
||||
connect(this, SIGNAL(sliderReleased()), d_ptr, SLOT(movePressedHandle()));
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new QxtSpanSlider with \a orientation and \a parent.
|
||||
*/
|
||||
QxtSpanSlider::QxtSpanSlider(Qt::Orientation orientation, QWidget* parent) : QSlider(orientation, parent), d_ptr(new QxtSpanSliderPrivate())
|
||||
{
|
||||
d_ptr->q_ptr = this;
|
||||
connect(this, SIGNAL(rangeChanged(int, int)), d_ptr, SLOT(updateRange(int, int)));
|
||||
connect(this, SIGNAL(sliderReleased()), d_ptr, SLOT(movePressedHandle()));
|
||||
}
|
||||
|
||||
/*!
|
||||
Destructs the span slider.
|
||||
*/
|
||||
QxtSpanSlider::~QxtSpanSlider()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QxtSpanSlider::handleMovementMode
|
||||
\brief the handle movement mode
|
||||
*/
|
||||
QxtSpanSlider::HandleMovementMode QxtSpanSlider::handleMovementMode() const
|
||||
{
|
||||
return d_ptr->movement;
|
||||
}
|
||||
|
||||
void QxtSpanSlider::setHandleMovementMode(QxtSpanSlider::HandleMovementMode mode)
|
||||
{
|
||||
d_ptr->movement = mode;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QxtSpanSlider::lowerValue
|
||||
\brief the lower value of the span
|
||||
*/
|
||||
int QxtSpanSlider::lowerValue() const
|
||||
{
|
||||
return qMin(d_ptr->lower, d_ptr->upper);
|
||||
}
|
||||
|
||||
void QxtSpanSlider::setLowerValue(int lower)
|
||||
{
|
||||
setSpan(lower, d_ptr->upper);
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QxtSpanSlider::upperValue
|
||||
\brief the upper value of the span
|
||||
*/
|
||||
int QxtSpanSlider::upperValue() const
|
||||
{
|
||||
return qMax(d_ptr->lower, d_ptr->upper);
|
||||
}
|
||||
|
||||
void QxtSpanSlider::setUpperValue(int upper)
|
||||
{
|
||||
setSpan(d_ptr->lower, upper);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the span from \a lower to \a upper.
|
||||
*/
|
||||
void QxtSpanSlider::setSpan(int lower, int upper)
|
||||
{
|
||||
const int low = qBound(minimum(), qMin(lower, upper), maximum());
|
||||
const int upp = qBound(minimum(), qMax(lower, upper), maximum());
|
||||
if (low != d_ptr->lower || upp != d_ptr->upper)
|
||||
{
|
||||
if (low != d_ptr->lower)
|
||||
{
|
||||
d_ptr->lower = low;
|
||||
d_ptr->lowerPos = low;
|
||||
emit lowerValueChanged(low);
|
||||
}
|
||||
if (upp != d_ptr->upper)
|
||||
{
|
||||
d_ptr->upper = upp;
|
||||
d_ptr->upperPos = upp;
|
||||
emit upperValueChanged(upp);
|
||||
}
|
||||
emit spanChanged(d_ptr->lower, d_ptr->upper);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QxtSpanSlider::lowerPosition
|
||||
\brief the lower position of the span
|
||||
*/
|
||||
int QxtSpanSlider::lowerPosition() const
|
||||
{
|
||||
return d_ptr->lowerPos;
|
||||
}
|
||||
|
||||
void QxtSpanSlider::setLowerPosition(int lower)
|
||||
{
|
||||
if (d_ptr->lowerPos != lower)
|
||||
{
|
||||
d_ptr->lowerPos = lower;
|
||||
if (!hasTracking())
|
||||
update();
|
||||
if (isSliderDown())
|
||||
emit lowerPositionChanged(lower);
|
||||
if (hasTracking() && !d_ptr->blockTracking)
|
||||
{
|
||||
bool main = (d_ptr->mainControl == QxtSpanSlider::LowerHandle);
|
||||
d_ptr->triggerAction(SliderMove, main);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QxtSpanSlider::upperPosition
|
||||
\brief the upper position of the span
|
||||
*/
|
||||
int QxtSpanSlider::upperPosition() const
|
||||
{
|
||||
return d_ptr->upperPos;
|
||||
}
|
||||
|
||||
void QxtSpanSlider::setUpperPosition(int upper)
|
||||
{
|
||||
if (d_ptr->upperPos != upper)
|
||||
{
|
||||
d_ptr->upperPos = upper;
|
||||
if (!hasTracking())
|
||||
update();
|
||||
if (isSliderDown())
|
||||
emit upperPositionChanged(upper);
|
||||
if (hasTracking() && !d_ptr->blockTracking)
|
||||
{
|
||||
bool main = (d_ptr->mainControl == QxtSpanSlider::UpperHandle);
|
||||
d_ptr->triggerAction(SliderMove, main);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QxtSpanSlider::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
QSlider::keyPressEvent(event);
|
||||
|
||||
bool main = true;
|
||||
SliderAction action = SliderNoAction;
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Left:
|
||||
main = (orientation() == Qt::Horizontal);
|
||||
action = !invertedAppearance() ? SliderSingleStepSub : SliderSingleStepAdd;
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
main = (orientation() == Qt::Horizontal);
|
||||
action = !invertedAppearance() ? SliderSingleStepAdd : SliderSingleStepSub;
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
main = (orientation() == Qt::Vertical);
|
||||
action = invertedControls() ? SliderSingleStepSub : SliderSingleStepAdd;
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
main = (orientation() == Qt::Vertical);
|
||||
action = invertedControls() ? SliderSingleStepAdd : SliderSingleStepSub;
|
||||
break;
|
||||
case Qt::Key_Home:
|
||||
main = (d_ptr->mainControl == QxtSpanSlider::LowerHandle);
|
||||
action = SliderToMinimum;
|
||||
break;
|
||||
case Qt::Key_End:
|
||||
main = (d_ptr->mainControl == QxtSpanSlider::UpperHandle);
|
||||
action = SliderToMaximum;
|
||||
break;
|
||||
default:
|
||||
event->ignore();
|
||||
break;
|
||||
}
|
||||
|
||||
if (action)
|
||||
d_ptr->triggerAction(action, main);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QxtSpanSlider::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (minimum() == maximum() || (event->buttons() ^ event->button()))
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
d_ptr->handleMousePress(event->pos(), d_ptr->upperPressed, d_ptr->upper, QxtSpanSlider::UpperHandle);
|
||||
if (d_ptr->upperPressed != QStyle::SC_SliderHandle)
|
||||
d_ptr->handleMousePress(event->pos(), d_ptr->lowerPressed, d_ptr->lower, QxtSpanSlider::LowerHandle);
|
||||
|
||||
d_ptr->firstMovement = true;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QxtSpanSlider::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (d_ptr->lowerPressed != QStyle::SC_SliderHandle && d_ptr->upperPressed != QStyle::SC_SliderHandle)
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
QStyleOptionSlider opt;
|
||||
d_ptr->initStyleOption(&opt);
|
||||
const int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this);
|
||||
int newPosition = d_ptr->pixelPosToRangeValue(d_ptr->pick(event->pos()) - d_ptr->offset);
|
||||
if (m >= 0)
|
||||
{
|
||||
const QRect r = rect().adjusted(-m, -m, m, m);
|
||||
if (!r.contains(event->pos()))
|
||||
{
|
||||
newPosition = d_ptr->position;
|
||||
}
|
||||
}
|
||||
|
||||
// pick the preferred handle on the first movement
|
||||
if (d_ptr->firstMovement)
|
||||
{
|
||||
if (d_ptr->lower == d_ptr->upper)
|
||||
{
|
||||
if (newPosition < lowerValue())
|
||||
{
|
||||
d_ptr->swapControls();
|
||||
d_ptr->firstMovement = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_ptr->firstMovement = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (d_ptr->lowerPressed == QStyle::SC_SliderHandle)
|
||||
{
|
||||
if (d_ptr->movement == NoCrossing)
|
||||
newPosition = qMin(newPosition, upperValue());
|
||||
else if (d_ptr->movement == NoOverlapping)
|
||||
newPosition = qMin(newPosition, upperValue() - 1);
|
||||
|
||||
if (d_ptr->movement == FreeMovement && newPosition > d_ptr->upper)
|
||||
{
|
||||
d_ptr->swapControls();
|
||||
setUpperPosition(newPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
setLowerPosition(newPosition);
|
||||
}
|
||||
}
|
||||
else if (d_ptr->upperPressed == QStyle::SC_SliderHandle)
|
||||
{
|
||||
if (d_ptr->movement == NoCrossing)
|
||||
newPosition = qMax(newPosition, lowerValue());
|
||||
else if (d_ptr->movement == NoOverlapping)
|
||||
newPosition = qMax(newPosition, lowerValue() + 1);
|
||||
|
||||
if (d_ptr->movement == FreeMovement && newPosition < d_ptr->lower)
|
||||
{
|
||||
d_ptr->swapControls();
|
||||
setLowerPosition(newPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
setUpperPosition(newPosition);
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QxtSpanSlider::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
QSlider::mouseReleaseEvent(event);
|
||||
setSliderDown(false);
|
||||
d_ptr->lowerPressed = QStyle::SC_None;
|
||||
d_ptr->upperPressed = QStyle::SC_None;
|
||||
update();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QxtSpanSlider::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
QStylePainter painter(this);
|
||||
|
||||
// groove & ticks
|
||||
QStyleOptionSlider opt;
|
||||
d_ptr->initStyleOption(&opt);
|
||||
opt.sliderValue = 0;
|
||||
opt.sliderPosition = 0;
|
||||
opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderTickmarks;
|
||||
painter.drawComplexControl(QStyle::CC_Slider, opt);
|
||||
|
||||
// handle rects
|
||||
opt.sliderPosition = d_ptr->lowerPos;
|
||||
const QRect lr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
|
||||
const int lrv = d_ptr->pick(lr.center());
|
||||
opt.sliderPosition = d_ptr->upperPos;
|
||||
const QRect ur = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
|
||||
const int urv = d_ptr->pick(ur.center());
|
||||
|
||||
// span
|
||||
const int minv = qMin(lrv, urv);
|
||||
const int maxv = qMax(lrv, urv);
|
||||
const QPoint c = QRect(lr.center(), ur.center()).center();
|
||||
QRect spanRect;
|
||||
if (orientation() == Qt::Horizontal)
|
||||
spanRect = QRect(QPoint(minv, c.y() - 2), QPoint(maxv, c.y() + 1));
|
||||
else
|
||||
spanRect = QRect(QPoint(c.x() - 2, minv), QPoint(c.x() + 1, maxv));
|
||||
d_ptr->drawSpan(&painter, spanRect);
|
||||
|
||||
// handles
|
||||
switch (d_ptr->lastPressed)
|
||||
{
|
||||
case QxtSpanSlider::LowerHandle:
|
||||
d_ptr->drawHandle(&painter, QxtSpanSlider::UpperHandle);
|
||||
d_ptr->drawHandle(&painter, QxtSpanSlider::LowerHandle);
|
||||
break;
|
||||
case QxtSpanSlider::UpperHandle:
|
||||
default:
|
||||
d_ptr->drawHandle(&painter, QxtSpanSlider::LowerHandle);
|
||||
d_ptr->drawHandle(&painter, QxtSpanSlider::UpperHandle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,276 @@
|
||||
#ifndef QXTSPANSLIDER_H
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2006 - 2011, the LibQxt project.
|
||||
** See the Qxt AUTHORS file for a list of authors and copyright holders.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** * Neither the name of the LibQxt project nor the
|
||||
** names of its contributors may be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
*****************************************************************************/
|
||||
|
||||
#define QXTSPANSLIDER_H
|
||||
|
||||
#include <QSlider>
|
||||
//#include "qxtnamespace.h"
|
||||
//#include "qxtglobal.h"
|
||||
|
||||
class QxtSpanSliderPrivate;
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class QxtSpanSlider qxtspanslider.h "qxtspanslider.h"
|
||||
*/
|
||||
class QxtSpanSlider : public QSlider {
|
||||
Q_OBJECT
|
||||
|
||||
//QXT_DECLARE_PRIVATE(QxtSpanSlider)
|
||||
Q_PROPERTY(int lowerValue READ lowerValue WRITE setLowerValue)
|
||||
Q_PROPERTY(int upperValue READ upperValue WRITE setUpperValue)
|
||||
Q_PROPERTY(int lowerPosition READ lowerPosition WRITE setLowerPosition)
|
||||
Q_PROPERTY(int upperPosition READ upperPosition WRITE setUpperPosition)
|
||||
Q_PROPERTY(HandleMovementMode handleMovementMode READ handleMovementMode WRITE setHandleMovementMode)
|
||||
Q_ENUMS(HandleMovementMode)
|
||||
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn QxtSpanSlider
|
||||
\param parent
|
||||
*/
|
||||
explicit QxtSpanSlider(QWidget* parent = 0);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn QxtSpanSlider
|
||||
\param orientation
|
||||
\param parent
|
||||
*/
|
||||
explicit QxtSpanSlider(Qt::Orientation orientation, QWidget* parent = 0);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn ~QxtSpanSlider
|
||||
*/
|
||||
virtual ~QxtSpanSlider();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\enum HandleMovementMode
|
||||
*/
|
||||
enum HandleMovementMode
|
||||
{
|
||||
FreeMovement,
|
||||
NoCrossing,
|
||||
NoOverlapping
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\enum SpanHandle
|
||||
*/
|
||||
enum SpanHandle
|
||||
{
|
||||
NoHandle,
|
||||
LowerHandle,
|
||||
UpperHandle
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn handleMovementMode
|
||||
\return HandleMovementMode
|
||||
*/
|
||||
HandleMovementMode handleMovementMode() const;
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setHandleMovementMode
|
||||
\param mode
|
||||
*/
|
||||
void setHandleMovementMode(HandleMovementMode mode);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn lowerValue
|
||||
\return int
|
||||
*/
|
||||
int lowerValue() const;
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn upperValue
|
||||
\return int
|
||||
*/
|
||||
int upperValue() const;
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn lowerPosition
|
||||
\return int
|
||||
*/
|
||||
int lowerPosition() const;
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn upperPosition
|
||||
\return int
|
||||
*/
|
||||
int upperPosition() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setLowerValue
|
||||
\param lower
|
||||
*/
|
||||
void setLowerValue(int lower);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setUpperValue
|
||||
\param upper
|
||||
*/
|
||||
void setUpperValue(int upper);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setSpan
|
||||
\param lower
|
||||
\param upper
|
||||
*/
|
||||
void setSpan(int lower, int upper);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setLowerPosition
|
||||
\param lower
|
||||
*/
|
||||
void setLowerPosition(int lower);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setUpperPosition
|
||||
\param upper
|
||||
*/
|
||||
void setUpperPosition(int upper);
|
||||
|
||||
Q_SIGNALS:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn spanChanged
|
||||
\param lower
|
||||
\param upper
|
||||
*/
|
||||
void spanChanged(int lower, int upper);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn lowerValueChanged
|
||||
\param lower
|
||||
*/
|
||||
void lowerValueChanged(int lower);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn upperValueChanged
|
||||
\param upper
|
||||
*/
|
||||
void upperValueChanged(int upper);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn lowerPositionChanged
|
||||
\param lower
|
||||
*/
|
||||
void lowerPositionChanged(int lower);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn upperPositionChanged
|
||||
\param upper
|
||||
*/
|
||||
void upperPositionChanged(int upper);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn sliderPressed
|
||||
\param handle
|
||||
*/
|
||||
void sliderPressed(SpanHandle handle);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn keyPressEvent
|
||||
\param event
|
||||
*/
|
||||
virtual void keyPressEvent(QKeyEvent* event);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn mousePressEvent
|
||||
\param event
|
||||
*/
|
||||
virtual void mousePressEvent(QMouseEvent* event);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn mouseMoveEvent
|
||||
\param event
|
||||
*/
|
||||
virtual void mouseMoveEvent(QMouseEvent* event);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn mouseReleaseEvent
|
||||
\param event
|
||||
*/
|
||||
virtual void mouseReleaseEvent(QMouseEvent* event);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn paintEvent
|
||||
\param event
|
||||
*/
|
||||
virtual void paintEvent(QPaintEvent* event);
|
||||
|
||||
private:
|
||||
QxtSpanSliderPrivate* d_ptr; /*!< TODO: describe */
|
||||
friend class QxtSpanSliderPrivate;
|
||||
};
|
||||
|
||||
#endif // QXTSPANSLIDER_H
|
||||
@ -0,0 +1,173 @@
|
||||
#ifndef QXTSPANSLIDER_P_H
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2006 - 2011, the LibQxt project.
|
||||
** See the Qxt AUTHORS file for a list of authors and copyright holders.
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** * Neither the name of the LibQxt project nor the
|
||||
** names of its contributors may be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** <http://libqxt.org> <foundation@libqxt.org>
|
||||
*****************************************************************************/
|
||||
|
||||
#define QXTSPANSLIDER_P_H
|
||||
|
||||
#include <QStyle>
|
||||
#include <QObject>
|
||||
#include "qxtspanslider.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QStylePainter)
|
||||
QT_FORWARD_DECLARE_CLASS(QStyleOptionSlider)
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\class QxtSpanSliderPrivate qxtspanslider_p.h "qxtspanslider_p.h"
|
||||
*/
|
||||
class QxtSpanSliderPrivate : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn QxtSpanSliderPrivate
|
||||
*/
|
||||
QxtSpanSliderPrivate();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn initStyleOption
|
||||
\param option
|
||||
\param handle
|
||||
*/
|
||||
void initStyleOption(QStyleOptionSlider* option, QxtSpanSlider::SpanHandle handle = QxtSpanSlider::UpperHandle) const;
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn pick
|
||||
\param pt
|
||||
\return int
|
||||
*/
|
||||
int pick(const QPoint& pt) const
|
||||
{
|
||||
return q_ptr->orientation() == Qt::Horizontal ? pt.x() : pt.y();
|
||||
}
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn pixelPosToRangeValue
|
||||
\param pos
|
||||
\return int
|
||||
*/
|
||||
int pixelPosToRangeValue(int pos) const;
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn handleMousePress
|
||||
\param pos
|
||||
\param control
|
||||
\param value
|
||||
\param handle
|
||||
*/
|
||||
void handleMousePress(const QPoint& pos, QStyle::SubControl& control, int value, QxtSpanSlider::SpanHandle handle);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn drawHandle
|
||||
\param painter
|
||||
\param handle
|
||||
*/
|
||||
void drawHandle(QStylePainter* painter, QxtSpanSlider::SpanHandle handle) const;
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setupPainter
|
||||
\param painter
|
||||
\param orientation
|
||||
\param x1
|
||||
\param y1
|
||||
\param x2
|
||||
\param y2
|
||||
*/
|
||||
void setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const;
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn drawSpan
|
||||
\param painter
|
||||
\param rect
|
||||
*/
|
||||
void drawSpan(QStylePainter* painter, const QRect& rect) const;
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn triggerAction
|
||||
\param action
|
||||
\param main
|
||||
*/
|
||||
void triggerAction(QAbstractSlider::SliderAction action, bool main);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn swapControls
|
||||
*/
|
||||
void swapControls();
|
||||
|
||||
int lower; /*!< TODO: describe */
|
||||
int upper; /*!< TODO: describe */
|
||||
int lowerPos; /*!< TODO: describe */
|
||||
int upperPos; /*!< TODO: describe */
|
||||
int offset; /*!< TODO: describe */
|
||||
int position; /*!< TODO: describe */
|
||||
QxtSpanSlider::SpanHandle lastPressed; /*!< TODO: describe */
|
||||
QxtSpanSlider::SpanHandle mainControl; /*!< TODO: describe */
|
||||
QStyle::SubControl lowerPressed; /*!< TODO: describe */
|
||||
QStyle::SubControl upperPressed; /*!< TODO: describe */
|
||||
QxtSpanSlider::HandleMovementMode movement; /*!< TODO: describe */
|
||||
bool firstMovement; /*!< TODO: describe */
|
||||
bool blockTracking; /*!< TODO: describe */
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn updateRange
|
||||
\param min
|
||||
\param max
|
||||
*/
|
||||
void updateRange(int min, int max);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn movePressedHandle
|
||||
*/
|
||||
void movePressedHandle();
|
||||
|
||||
private:
|
||||
QxtSpanSlider* q_ptr; /*!< TODO: describe */
|
||||
friend class QxtSpanSlider;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // QXTSPANSLIDER_P_H
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Loading…
Reference in New Issue