first commit

This commit is contained in:
2016-10-18 17:27:42 +02:00
commit b63f168fb6
49 changed files with 10135 additions and 0 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
View File
Binary file not shown.
+281
View File
@@ -0,0 +1,281 @@
#include "cedit.h"
#include "ui_cedit.h"
#include "cimage.h"
#include "cseasondetails.h"
#include "cmessageanimatedialog.h"
#include <QRadioButton>
#include <QGroupBox>
#include <QGridLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSpacerItem>
#include <QLineEdit>
#include <QScrollArea>
#include <QDialogButtonBox>
#include <QLabel>
#include <QButtonGroup>
#include <QDebug>
#include <QTime>
cEdit::cEdit(QWidget *parent) :
QDialog(parent),
ui(new Ui::cEdit),
m_bLoaded(false),
m_lpButton1(0),
m_lpButton2(0),
m_lpButton3(0),
m_lpInit(0),
m_lpProgress(0),
m_lpDone(0),
m_lpGroupBox(0),
m_lpGridLayout(0),
m_lpGrid(0),
m_lpLabel(0),
m_lpLabel1(0),
m_lpSpacer(0),
m_lpGroup(0),
m_lpAllInit(0),
m_lpAllProgress(0),
m_lpAllDone(0),
m_lpVerticalSpacer(0),
// m_lpButtonBox(0),
m_lpSerie(0)
{
ui->setupUi(this);
connect(ui->m_lpAllInit, SIGNAL(clicked()), this, SLOT(lpAllInit_clicked()));
connect(ui->m_lpAllProgress, SIGNAL(clicked()), this, SLOT(lpAllProgress_clicked()));
connect(ui->m_lpAllDone, SIGNAL(clicked()), this, SLOT(lpAllDone_clicked()));
ui->m_lpTabWidget->setCurrentIndex(0);
}
cEdit::~cEdit()
{
if(m_lpSerie)
{
int x;
QList<cSeason*> seasonList = m_lpSerie->seasonList();
for(x = 0;x < seasonList.count();x++)
{
cSeason* lpSeason = seasonList.at(x);
QList<cEpisode*> episodeList = lpSeason->episodeList();
for(int y = 0;y < episodeList.count();y++)
{
cEpisode* lpEpisode = episodeList.at(y);
if(lpEpisode)
{
lpEpisode->setButton1(0);
lpEpisode->setButton2(0);
lpEpisode->setButton3(0);
}
}
}
}
delete ui;
}
void cEdit::setSerie(cSerie* lpSerie)
{
m_lpSerie = lpSerie;
if(!lpSerie)
return;
ui->m_lpName->setText(lpSerie->seriesName());
ui->m_lpCliffhanger->setChecked(lpSerie->cliffhanger());
ui->m_lpDownloadLink->setText(lpSerie->download());
int x;
QList<cSeason*> seasonList = lpSerie->seasonList();
for(x = 0;x < seasonList.count();x++)
{
cSeason* lpSeason = seasonList.at(x);
m_lpGroupBox = new QGroupBox(QString("Season %1").arg(lpSeason->number()), ui->m_lpScrollAreaWidget);
lpSeason->setGroupBox(m_lpGroupBox);
m_lpGridLayout = new QGridLayout(m_lpGroupBox);
lpSeason->setGridLayout(m_lpGridLayout);
m_lpGrid = new QGridLayout();
lpSeason->setGrid(m_lpGrid);
m_lpLabel1 = new QLabel("Episode");
lpSeason->setLabel1(m_lpLabel1);
m_lpAllInit = new QPushButton("all Init");
lpSeason->setAllInit(m_lpAllInit);
m_lpAllProgress = new QPushButton("all Prog");
lpSeason->setAllProgress(m_lpAllProgress);
m_lpAllDone = new QPushButton("all Done");
lpSeason->setAllDone(m_lpAllDone);
connect(m_lpAllInit, SIGNAL(clicked()), this, SLOT(allInit_clicked()));
connect(m_lpAllProgress, SIGNAL(clicked()), this, SLOT(allProgress_clicked()));
connect(m_lpAllDone, SIGNAL(clicked()), this, SLOT(allDone_clicked()));
m_lpGrid->addWidget(m_lpLabel1, 0, 0, 1, 1);
m_lpGrid->addWidget(m_lpAllInit, 1, 0, 1, 1);
m_lpGrid->addWidget(m_lpAllProgress, 2, 0, 1, 1);
m_lpGrid->addWidget(m_lpAllDone, 3, 0, 1, 1);
bool bFirst = true;
QList<cEpisode*> episodeList = lpSeason->episodeList();
for(int y = 0;y < episodeList.count();y++)
{
cEpisode* lpEpisode = episodeList.at(y);
m_lpGroup = new QButtonGroup(this);
lpEpisode->setGroup(m_lpGroup);
m_lpLabel = new QLabel(QString("%1").arg(lpEpisode->episodeNumber()), m_lpGroupBox);
lpEpisode->setLabel(m_lpLabel);
if(bFirst)
{
m_lpButton1 = new QRadioButton("init", m_lpGroupBox);
m_lpButton2 = new QRadioButton("prog", m_lpGroupBox);
m_lpButton3 = new QRadioButton("done", m_lpGroupBox);
bFirst = false;
}
else
{
m_lpButton1 = new QRadioButton(m_lpGroupBox);
m_lpButton2 = new QRadioButton(m_lpGroupBox);
m_lpButton3 = new QRadioButton(m_lpGroupBox);
}
lpEpisode->setButton1(m_lpButton1);
lpEpisode->setButton2(m_lpButton2);
lpEpisode->setButton3(m_lpButton3);
m_lpLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
m_lpButton1->setLayoutDirection(Qt::RightToLeft);
m_lpButton2->setLayoutDirection(Qt::RightToLeft);
m_lpButton3->setLayoutDirection(Qt::RightToLeft);
switch(lpEpisode->state())
{
case cEpisode::StateInit:
m_lpButton1->setChecked(true);
break;
case cEpisode::StateProgress:
m_lpButton2->setChecked(true);
break;
case cEpisode::StateDone:
m_lpButton3->setChecked(true);
break;
default:
break;
}
m_lpGroup->addButton(m_lpButton1);
m_lpGroup->addButton(m_lpButton2);
m_lpGroup->addButton(m_lpButton3);
m_lpGrid->addWidget(m_lpLabel, 0, y+1, 1, 1);
m_lpGrid->addWidget(m_lpButton1, 1, y+1, 1, 1);
m_lpGrid->addWidget(m_lpButton2, 2, y+1, 1, 1);
m_lpGrid->addWidget(m_lpButton3, 3, y+1, 1, 1);
}
m_lpGridLayout->addLayout(m_lpGrid, 0, 0, 1, 1);
m_lpSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
lpSeason->setSpacer(m_lpSpacer);
m_lpGridLayout->addItem(m_lpSpacer, 0, 1, 1, 1);
ui->m_lpGridLayoutScroll->addWidget(m_lpGroupBox, x, 0, 1, 1);
}
m_lpVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
ui->m_lpGridLayoutScroll->addItem(m_lpVerticalSpacer, x+1, 0, 1, 1);
}
void cEdit::lpAllInit_clicked()
{
m_lpSerie->allInit();
}
void cEdit::lpAllProgress_clicked()
{
m_lpSerie->allProgress();
}
void cEdit::lpAllDone_clicked()
{
m_lpSerie->allDone();
}
void cEdit::allInit_clicked()
{
QPushButton* lpButton = (QPushButton*)sender();
m_lpSerie->seasonInit(lpButton);
}
void cEdit::allProgress_clicked()
{
QPushButton* lpButton = (QPushButton*)sender();
m_lpSerie->seasonProgress(lpButton);
}
void cEdit::allDone_clicked()
{
QPushButton* lpButton = (QPushButton*)sender();
m_lpSerie->seasonDone(lpButton);
}
QString cEdit::download()
{
return(ui->m_lpDownloadLink->text());
}
void cEdit::on_m_lpTabWidget_tabBarClicked(int index)
{
if(index == 1)
{
if(!m_bLoaded)
{
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Edit");
lpDialog->setMessage("Loading");
lpDialog->show();
cImage image;
QPixmap banner = image.getImage(m_lpSerie->banner());
ui->m_lpDetailsBanner->setPixmap(banner);
ui->m_lpDetailsOverview->setText(m_lpSerie->overview());
ui->m_lpDetailsSeasonTab->clear();
QTreeWidgetItem* lpItem;
for(int x = 0;x < m_lpSerie->actors().count();x++)
{
lpItem = new QTreeWidgetItem(ui->m_lpDetailsActors);
lpItem->setText(0, m_lpSerie->actors().at(x));
ui->m_lpDetailsActors->addTopLevelItem(lpItem);
}
for(int x = 0;x < m_lpSerie->genre().count();x++)
{
lpItem = new QTreeWidgetItem(ui->m_lpDetailsGenre);
lpItem->setText(0, m_lpSerie->genre().at(x));
ui->m_lpDetailsGenre->addTopLevelItem(lpItem);
}
for(int x = 0;x < m_lpSerie->seasonList().count();x++)
{
cSeason* lpSeason = m_lpSerie->seasonList().at(x);
cSeasonDetails* lpSeasonDetails = new cSeasonDetails(ui->m_lpDetailsSeasonTab);
ui->m_lpDetailsSeasonTab->addTab(lpSeasonDetails, QString("Season %1").arg(lpSeason->number()));
lpSeasonDetails->setSeason(lpSeason);
}
delete lpDialog;
m_bLoaded = true;
}
}
}
void cEdit::on_m_lpCliffhanger_clicked()
{
m_lpSerie->setCliffhanger(ui->m_lpCliffhanger->checkState() == Qt::Checked);
}
+65
View File
@@ -0,0 +1,65 @@
#ifndef CEDIT_H
#define CEDIT_H
#include "cserie.h"
#include <QDialog>
//#include <QDialogButtonBox>
namespace Ui {
class cEdit;
}
class cEdit : public QDialog
{
Q_OBJECT
public:
explicit cEdit(QWidget *parent = 0);
~cEdit();
void setSerie(cSerie* lpSerie);
QString download();
private slots:
void lpAllInit_clicked();
void lpAllProgress_clicked();
void lpAllDone_clicked();
void allInit_clicked();
void allProgress_clicked();
void allDone_clicked();
void on_m_lpTabWidget_tabBarClicked(int index);
void on_m_lpCliffhanger_clicked();
private:
Ui::cEdit* ui;
bool m_bLoaded;
QRadioButton* m_lpButton1;
QRadioButton* m_lpButton2;
QRadioButton* m_lpButton3;
QPushButton* m_lpInit;
QPushButton* m_lpProgress;
QPushButton* m_lpDone;
QGroupBox* m_lpGroupBox;
QGridLayout* m_lpGridLayout;
QGridLayout* m_lpGrid;
QLabel* m_lpLabel;
QLabel* m_lpLabel1;
QSpacerItem* m_lpSpacer;
QButtonGroup* m_lpGroup;
QPushButton* m_lpAllInit;
QPushButton* m_lpAllProgress;
QPushButton* m_lpAllDone;
QSpacerItem* m_lpVerticalSpacer;
// QDialogButtonBox* m_lpButtonBox;
cSerie* m_lpSerie;
};
#endif // CEDIT_H
+294
View File
@@ -0,0 +1,294 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cEdit</class>
<widget class="QDialog" name="cEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>732</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="m_lpTabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Progress</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="m_lpVerticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLineEdit" name="m_lpName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_lpCliffhanger">
<property name="text">
<string>Cliffhanger</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Download Link:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_lpDownloadLink"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="m_lpAllInit">
<property name="text">
<string>all Init</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpAllProgress">
<property name="text">
<string>all Progress</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpAllDone">
<property name="text">
<string>all Done</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="m_lpScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="m_lpScrollAreaWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>754</width>
<height>546</height>
</rect>
</property>
<layout class="QGridLayout" name="m_lpGridLayoutScroll"/>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Details</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="0,1,1">
<item>
<widget class="QLabel" name="m_lpDetailsBanner">
<property name="minimumSize">
<size>
<width>758</width>
<height>140</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>
<item>
<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>209</width>
<height>174</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="QTreeWidget" name="m_lpDetailsActors">
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</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="QTreeWidget" name="m_lpDetailsGenre">
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QTabWidget" name="m_lpDetailsSeasonTab">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="m_lpButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>cVerticalLabel</class>
<extends>QLabel</extends>
<header>cverticallabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>m_lpButtonBox</sender>
<signal>accepted()</signal>
<receiver>cEdit</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_lpButtonBox</sender>
<signal>rejected()</signal>
<receiver>cEdit</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>
+350
View File
@@ -0,0 +1,350 @@
#include "cepisode.h"
#define DELETE(x) { if(x) delete x;x = 0;}
cEpisode::cEpisode() :
m_iID(-1),
m_szDirector(""),
m_szEpisodeName(""),
m_iEpisodeNumber(-1),
m_firstAired(QDate(1900, 1, 1)),
m_szGuestStars(""),
m_szIMDBID(""),
m_szLanguage(""),
m_szOverview(""),
m_szProductionCode(""),
m_dRating(-1.0),
m_iRatingCount(-1),
m_iSeasonNumber(-1),
m_szWriter(""),
m_iSeasonID(-1),
m_iSeriesID(-1),
m_state(cEpisode::StateInit),
m_lpGroup(0),
m_lpLabel(0),
m_lpButton1(0),
m_lpButton2(0),
m_lpButton3(0)
{
}
cEpisode::~cEpisode()
{
deleteResources();
}
void cEpisode::setID(const qint32& iID)
{
m_iID = iID;
}
qint32 cEpisode::id()
{
return(m_iID);
}
void cEpisode::setDirector(const QString& szDirector)
{
m_szDirector = szDirector.split("|");
m_szDirector.removeAll("");
}
void cEpisode::setDirector(const QStringList& szDirector)
{
m_szDirector = szDirector;
m_szDirector.removeAll("");
}
QStringList cEpisode::director()
{
return(m_szDirector);
}
void cEpisode::setEpisodeName(const QString& szEpisodeName)
{
m_szEpisodeName = szEpisodeName;
}
QString cEpisode::episodeName()
{
return(m_szEpisodeName);
}
void cEpisode::setEpisodeNumber(const qint16& iEpisodeNumber)
{
m_iEpisodeNumber = iEpisodeNumber;
}
qint16 cEpisode::episodeNumber()
{
return(m_iEpisodeNumber);
}
void cEpisode::setFirstAired(const QString& szFirstAired)
{
m_firstAired = QDate::fromString(szFirstAired, "yyyy-MM-dd");
}
void cEpisode::setFirstAired(const QDate& firstAired)
{
m_firstAired = firstAired;
}
QDate cEpisode::firstAired()
{
return(m_firstAired);
}
void cEpisode::setGuestStars(const QString& szGuestStars)
{
m_szGuestStars = szGuestStars.split("|");
m_szGuestStars.removeAll("");
}
void cEpisode::setGuestStars(const QStringList& szGuestStars)
{
m_szGuestStars = szGuestStars;
m_szGuestStars.removeAll("");
}
QStringList cEpisode::guestStars()
{
return(m_szGuestStars);
}
void cEpisode::setIMDBID(const QString& szIMDBID)
{
m_szIMDBID = szIMDBID;
}
QString cEpisode::imdbID()
{
return(m_szIMDBID);
}
void cEpisode::setLanguage(const QString& szLanguage)
{
m_szLanguage = szLanguage;
}
QString cEpisode::language()
{
return(m_szLanguage);
}
void cEpisode::setOverview(const QString& szOverview)
{
m_szOverview = szOverview;
}
QString cEpisode::overview()
{
return(m_szOverview);
}
void cEpisode::setProductionCode(const QString& szProductionCode)
{
m_szProductionCode = szProductionCode;
}
QString cEpisode::productionCode()
{
return(m_szProductionCode);
}
void cEpisode::setRating(const qreal& dRating)
{
m_dRating = dRating;
}
qreal cEpisode::rating()
{
return(m_dRating);
}
void cEpisode::setRatingCount(const qint32& iRatingCount)
{
m_iRatingCount = iRatingCount;
}
qint32 cEpisode::ratingCount()
{
return(m_iRatingCount);
}
void cEpisode::setSeasonNumber(const qint16& iSeasonNumber)
{
m_iSeasonNumber = iSeasonNumber;
}
qint16 cEpisode::seasonNumber()
{
return(m_iSeasonNumber);
}
void cEpisode::setWriter(const QString& szWriter)
{
m_szWriter = szWriter.split("|");
m_szWriter.removeAll("");
}
void cEpisode::setWriter(const QStringList& szWriter)
{
m_szWriter = szWriter;
m_szWriter.removeAll("");
}
QStringList cEpisode::writer()
{
return(m_szWriter);
}
void cEpisode::setSeasonID(const qint32& iSeasonID)
{
m_iSeasonID = iSeasonID;
}
qint32 cEpisode::seasonID()
{
return(m_iSeasonID);
}
void cEpisode::setSeriesID(const qint32& iSeriesID)
{
m_iSeriesID = iSeriesID;
}
qint32 cEpisode::seriesID()
{
return(m_iSeriesID);
}
void cEpisode::setState(const State& state)
{
m_state = state;
switch(m_state)
{
case StateInit:
if(m_lpButton1)
m_lpButton1->setChecked(true);
if(m_lpButton2)
m_lpButton2->setChecked(false);
if(m_lpButton3)
m_lpButton3->setChecked(false);
break;
case StateProgress:
if(m_lpButton2)
m_lpButton2->setChecked(true);
if(m_lpButton1)
m_lpButton1->setChecked(false);
if(m_lpButton3)
m_lpButton3->setChecked(false);
break;
case StateDone:
if(m_lpButton3)
m_lpButton3->setChecked(true);
if(m_lpButton1)
m_lpButton1->setChecked(false);
if(m_lpButton2)
m_lpButton2->setChecked(false);
break;
default:
break;
}
}
cEpisode::State cEpisode::state()
{
return(m_state);
}
void cEpisode::setFileName(const QString& szFileName)
{
m_szFileName = szFileName;
}
QString cEpisode::fileName()
{
return(m_szFileName);
}
void cEpisode::setThumbHeight(const qint16& iThumbHeight)
{
m_iThumbHeight = iThumbHeight;
}
qint16 cEpisode::thumbHeight()
{
return(m_iThumbHeight);
}
void cEpisode::setThumbWidth(const qint16& iThumbWidth)
{
m_iThumbWidth = iThumbWidth;
}
qint16 cEpisode::thumbWidth()
{
return(m_iThumbWidth);
}
bool cEpisode::isValid()
{
if(m_iSeasonID != -1 && m_iEpisodeNumber != -1 && m_iSeasonNumber != -1)
return(true);
return(false);
}
void cEpisode::setGroup(QButtonGroup* lpGroup)
{
m_lpGroup = lpGroup;
}
void cEpisode::setLabel(QLabel* lpLabel)
{
m_lpLabel = lpLabel;
}
void cEpisode::setButton1(QRadioButton* lpButton1)
{
m_lpButton1 = lpButton1;
}
void cEpisode::setButton2(QRadioButton* lpButton2)
{
m_lpButton2 = lpButton2;
}
void cEpisode::setButton3(QRadioButton* lpButton3)
{
m_lpButton3 = lpButton3;
}
void cEpisode::updateState()
{
if(m_lpButton1)
{
if(m_lpButton1->isChecked())
m_state = StateInit;
}
if(m_lpButton2)
{
if(m_lpButton2->isChecked())
m_state = StateProgress;
}
if(m_lpButton3)
{
if(m_lpButton3->isChecked())
m_state = StateDone;
}
}
void cEpisode::deleteResources()
{
DELETE(m_lpGroup);
DELETE(m_lpLabel);
DELETE(m_lpButton1);
DELETE(m_lpButton2);
DELETE(m_lpButton3);
}
+132
View File
@@ -0,0 +1,132 @@
#ifndef CEPISODE_H
#define CEPISODE_H
#include <QMetaType>
#include <QList>
#include <QDate>
#include <QButtonGroup>
#include <QLabel>
#include <QRadioButton>
class cEpisode
{
public:
enum State
{
StateUnknown = 0,
StateInit = 1,
StateProgress = 2,
StateDone = 3,
};
cEpisode();
~cEpisode();
void setID(const qint32& iID);
qint32 id();
void setDirector(const QString& szDirector);
void setDirector(const QStringList& szDirector);
QStringList director();
void setEpisodeName(const QString& szEpisodeName);
QString episodeName();
void setEpisodeNumber(const qint16& iEpisodeNumber);
qint16 episodeNumber();
void setFirstAired(const QString& szFirstAired);
void setFirstAired(const QDate& firstAired);
QDate firstAired();
void setGuestStars(const QString& szGuestStars);
void setGuestStars(const QStringList& szGuestStars);
QStringList guestStars();
void setIMDBID(const QString& szIMDBID);
QString imdbID();
void setLanguage(const QString& szLanguage);
QString language();
void setOverview(const QString& szOverview);
QString overview();
void setProductionCode(const QString& szProductionCode);
QString productionCode();
void setRating(const qreal& dRating);
qreal rating();
void setRatingCount(const qint32& iRatingCount);
qint32 ratingCount();
void setSeasonNumber(const qint16& iSeasonNumber);
qint16 seasonNumber();
void setWriter(const QString& szWriter);
void setWriter(const QStringList& szWriter);
QStringList writer();
void setSeasonID(const qint32& iSeasonID);
qint32 seasonID();
void setSeriesID(const qint32& iSeriesID);
qint32 seriesID();
void setState(const State& state);
State state();
void setFileName(const QString& szFileName);
QString fileName();
void setThumbHeight(const qint16& iThumbHeight);
qint16 thumbHeight();
void setThumbWidth(const qint16& iThumbWidth);
qint16 thumbWidth();
bool isValid();
void setGroup(QButtonGroup* lpGroup);
void setLabel(QLabel* lpLabel);
void setButton1(QRadioButton* lpButton1);
void setButton2(QRadioButton* lpButton2);
void setButton3(QRadioButton* lpButton3);
void updateState();
void deleteResources();
private:
qint32 m_iID;
QStringList m_szDirector;
QString m_szEpisodeName;
qint16 m_iEpisodeNumber;
QDate m_firstAired;
QStringList m_szGuestStars;
QString m_szIMDBID;
QString m_szLanguage;
QString m_szOverview;
QString m_szProductionCode;
qreal m_dRating;
qint32 m_iRatingCount;
qint16 m_iSeasonNumber;
QStringList m_szWriter;
qint32 m_iSeasonID;
qint32 m_iSeriesID;
State m_state;
QString m_szFileName;
qint16 m_iThumbHeight;
qint16 m_iThumbWidth;
QButtonGroup* m_lpGroup;
QLabel* m_lpLabel;
QRadioButton* m_lpButton1;
QRadioButton* m_lpButton2;
QRadioButton* m_lpButton3;
};
Q_DECLARE_METATYPE(cEpisode*)
#endif // CEPISODE_H
+51
View File
@@ -0,0 +1,51 @@
#include "cepisodedetails.h"
#include "ui_cepisodedetails.h"
#include "cimage.h"
#include "cmessageanimatedialog.h"
#include <QDebug>
cEpisodeDetails::cEpisodeDetails(QWidget *parent) :
QWidget(parent),
ui(new Ui::cEpisodeDetails),
m_lpEpisode(0),
m_bLoaded(false)
{
ui->setupUi(this);
}
cEpisodeDetails::~cEpisodeDetails()
{
delete ui;
}
void cEpisodeDetails::setEpisode(cEpisode* lpEpisode)
{
m_lpEpisode = lpEpisode;
ui->m_lpEpisodeTitle->setText(lpEpisode->episodeName());
ui->m_lpOverview->setText(lpEpisode->overview());
}
void cEpisodeDetails::loadImages()
{
if(!m_lpEpisode)
return;
if(m_bLoaded)
return;
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Details");
lpDialog->setMessage("Loading Images");
lpDialog->show();
cImage image;
QPixmap pixmap = image.getImage(m_lpEpisode->fileName()).scaledToHeight(200);
ui->m_lpEpisodeThumb->setPixmap(pixmap);
delete lpDialog;
m_bLoaded = true;
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef CEPISODEDETAILS_H
#define CEPISODEDETAILS_H
#include <QWidget>
#include "cepisode.h"
namespace Ui {
class cEpisodeDetails;
}
class cEpisodeDetails : public QWidget
{
Q_OBJECT
public:
explicit cEpisodeDetails(QWidget *parent = 0);
~cEpisodeDetails();
void setEpisode(cEpisode* lpEpisode);
void loadImages();
private:
Ui::cEpisodeDetails* ui;
cEpisode* m_lpEpisode;
bool m_bLoaded;
};
#endif // CEPISODEDETAILS_H
+76
View File
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cEpisodeDetails</class>
<widget class="QWidget" name="cEpisodeDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="m_lpEpisodeThumb">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="m_lpEpisodeTitle">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="m_lpScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>365</width>
<height>245</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTextEdit" name="m_lpOverview">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+62
View File
@@ -0,0 +1,62 @@
#include "cimage.h"
#include <QDir>
#include <QFile>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QEventLoop>
#include <QUrl>
cImage::cImage()
{
}
QPixmap cImage::getImage(const QString& szFileName)
{
QPixmap pixmap;
QString szPath = QDir::homePath() + QDir::separator() + "qtseries" + QDir::separator() + szFileName;
if(szFileName.isEmpty())
pixmap.load(QDir::homePath() + QDir::separator() + "qtseries" + QDir::separator() + "empty.jpg");
else
pixmap.load(szPath);
if(!pixmap.width())
return(downloadFile(szFileName));
return(pixmap);
}
QPixmap cImage::downloadFile(const QString& szFileName)
{
QPixmap pixmap;
QString szPath = QDir::homePath() + QDir::separator() + "qtseries" + QDir::separator() + szFileName;
QString szURL = "http://thetvdb.com/banners/" + szFileName;
QNetworkAccessManager networkManager;
QUrl url(szURL);
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/xml");
QNetworkReply* reply = networkManager.get(request);
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QByteArray szData = reply->readAll();
delete reply;
pixmap.loadFromData(szData);
QDir dir(szPath);
QFileInfo fileInfo(szPath);
dir.mkpath(dir.filePath(fileInfo.absolutePath()));
pixmap.save(szPath);
return(pixmap);
}
+17
View File
@@ -0,0 +1,17 @@
#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
+754
View File
@@ -0,0 +1,754 @@
#include "cmainwindow.h"
#include "ui_cmainwindow.h"
#include "cthetvdb.h"
#include "cseasondelegate.h"
#include "csearch.h"
#include "cmessageanimatedialog.h"
#include "cmessagedialog.h"
#include "cedit.h"
#include "cimage.h"
#include <QTreeWidgetItem>
#include <QDir>
#include <QFile>
#include <QSqlQuery>
#include <QSqlError>
#include <QDesktopServices>
#include <QClipboard>
#include <QUrl>
#include <QIcon>
#include <QThread>
#include <QSettings>
#include <QTime>
#include <QMessageBox>
#include <QtDebug>
#include <QElapsedTimer>
cMainWindow::cMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::cMainWindow),
m_szOldSelected(""),
m_lpMessageDialog(0),
m_lpUpdateThread(0),
m_lpPicturesThread(0)
{
m_timer.start();
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Initializing");
lpDialog->setMessage("Initializing");
lpDialog->show();
ui->setupUi(this);
initDB();
ui->m_lpSeriesList->setItemDelegate(new cSeasonDelegate(ui->m_lpSeriesList));
ui->m_lpSeriesList->setHeaderLabels(QStringList() << "Nr" << "Serie" << "Year");
ui->m_lpSeriesList->setColumnCount(3);
loadDB();
displaySeries();
QSettings settings;
qint16 iX = settings.value("main/x", QVariant::fromValue(-1)).toInt();
qint16 iY = settings.value("main/y", QVariant::fromValue(-1)).toInt();
qint16 iWidth = settings.value("main/width", QVariant::fromValue(-1)).toInt();
qint16 iHeight = settings.value("main/height", QVariant::fromValue(-1)).toInt();
if(iWidth != -1 && iHeight != -1)
resize(iWidth, iHeight);
if(iX != -1 && iY != -1)
move(iX, iY);
delete lpDialog;
}
cMainWindow::~cMainWindow()
{
delete ui;
}
void cMainWindow::closeEvent(QCloseEvent *event)
{
QSettings settings;
settings.setValue("main/width", QVariant::fromValue(size().width()));
settings.setValue("main/hight", QVariant::fromValue(size().height()));
settings.setValue("main/x", QVariant::fromValue(x()));
settings.setValue("main/y", QVariant::fromValue(y()));
if(this->isMaximized())
settings.setValue("main/maximized", QVariant::fromValue(true));
else
settings.setValue("main/maximized", QVariant::fromValue(false));
event->accept();
}
void cMainWindow::initDB()
{
QDir dir;
dir.mkpath(QDir::homePath() + QDir::separator() + "qtseries" + QDir::separator());
QString szDBPath = QDir::homePath() + QDir::separator() + "qtseries" + QDir::separator() + "qtseries.db";
m_db = QSqlDatabase::addDatabase("QSQLITE");
m_db.setHostName("localhost");
m_db.setDatabaseName(szDBPath);
if(!m_db.open())
return;
QSqlQuery query;
if(!m_db.tables().count())
{
query.exec("CREATE TABLE serie ("
" seriesID INTEGER,"
" seriesName STRING,"
" language STRING,"
" banner STRING,"
" overview TEXT,"
" firstAired DATE,"
" network STRING,"
" imdbid STRING,"
" id INTEGER,"
" contentRating STRING,"
" rating DOUBLE,"
" ratingCount INTEGER,"
" runtime INTEGER,"
" status STRING,"
" download STRING,"
" cliffhanger BOOL,"
" actor STRING,"
" genre STRING);");
query.exec("CREATE TABLE episode ("
" episodeID INTEGER,"
" episodeName STRING,"
" episodeNumber INTEGER,"
" firstAired DATE,"
" imdbid STRING,"
" language STRING,"
" overview TEXT,"
" productioncode STRING,"
" rating DOUBLE,"
" ratingCount INTEGER,"
" seasonNumber INTEGER,"
" seasonID INTEGER,"
" seriesID INTEGER,"
" state INT,"
" filename STRING,"
" thumb_height INT,"
" thumb_width INT,"
" director STRING,"
" gueststars STRING,"
" episode_writer STRING);");
}
}
void cMainWindow::loadDB()
{
m_serieList.clear();
QSqlQuery query;
qint32 iOldSeriesID = -1;
qint32 iOldSeasonID = -1;
qint32 iSeriesID;
qint32 iSeasonID;
cSerie* lpSerie;
cSeason* lpSeason;
cEpisode* lpEpisode;
if(query.exec("SELECT serie.seriesID, serie.seriesName, serie.language, serie.banner, serie.overview, serie.firstAired, serie.network, serie.imdbid, serie.id, serie.contentRating, serie.rating, serie.ratingCount, serie.runtime, serie.status, serie.download, serie.cliffhanger, serie.actor, serie.genre, episode.episodeID, episode.episodeName, episode.episodeNumber, episode.firstAired, episode.imdbid, episode.language, episode.overview, episode.productioncode, episode.rating, episode.ratingCount, episode.seasonNumber, episode.seasonID, episode.seriesID, episode.state, episode.filename, episode.thumb_height, episode.thumb_width, episode.director, episode.gueststars, episode.episode_writer FROM serie, episode WHERE serie.id = episode.seriesID ORDER BY serie.seriesName, episode.seasonNumber, episode.episodeNumber;"))
{
while(query.next())
{
iSeriesID = query.value( 8).toInt();
iSeasonID = query.value(29).toInt();
if(iSeriesID != iOldSeriesID)
{
lpSerie = m_serieList.add(iSeriesID);
iOldSeriesID = iSeriesID;
}
cSerie* lpSerie = m_serieList.add(iSeriesID);
lpSerie->setSeriesID(query.value(0).toInt());
lpSerie->setSeriesName(query.value(1).toString());
lpSerie->setLanguage(query.value(2).toString());
lpSerie->setBanner(query.value(3).toString());
lpSerie->setOverview(query.value(4).toString());
lpSerie->setFirstAired(query.value(5).toDate());
lpSerie->setNetwork(query.value(6).toString());
lpSerie->setIMDBID(query.value(7).toString());
lpSerie->setContentRating(query.value(9).toString());
lpSerie->setRating(query.value(10).toDouble());
lpSerie->setRatingCount(query.value(11).toInt());
lpSerie->setRuntime(query.value(12).toInt());
lpSerie->setStatus(query.value(13).toString());
lpSerie->setDownload(query.value(14).toString());
lpSerie->setCliffhanger(query.value(15).toBool());
lpSerie->setActors(query.value(16).toString().split(","));
lpSerie->setGenre(query.value(17).toString().split(","));
if(iSeasonID != iOldSeasonID)
{
lpSeason = lpSerie->addSeason(query.value(28).toInt());
iOldSeasonID = iSeasonID;
}
lpEpisode = lpSeason->addEpisode(query.value(20).toInt());
lpEpisode->setID(query.value(18).toInt());
lpEpisode->setEpisodeName(query.value(19).toString());
lpEpisode->setFirstAired(query.value(21).toDate());
lpEpisode->setIMDBID(query.value(22).toString());
lpEpisode->setLanguage(query.value(23).toString());
lpEpisode->setOverview(query.value(24).toString());
lpEpisode->setProductionCode(query.value(25).toString());
lpEpisode->setRating(query.value(26).toDouble());
lpEpisode->setRatingCount(query.value(27).toInt());
lpEpisode->setSeasonNumber(query.value(28).toInt());
lpEpisode->setSeasonID(query.value(29).toInt());
lpEpisode->setSeriesID(query.value(30).toInt());
lpEpisode->setState((cEpisode::State)query.value(31).toInt());
lpEpisode->setFileName(query.value(32).toString());
lpEpisode->setThumbHeight(query.value(33).toInt());
lpEpisode->setThumbWidth(query.value(34).toInt());
lpEpisode->setDirector(query.value(35).toString().split(","));
lpEpisode->setGuestStars(query.value(36).toString().split(","));
lpEpisode->setWriter(query.value(37).toString().split(","));
}
}
}
void cMainWindow::displaySeries()
{
ui->m_lpSeriesList->clear();
qint16 iMin = m_serieList.minSeason();
qint16 iMax = m_serieList.maxSeason();
ui->m_lpSeriesList->setColumnCount(iMax-iMin+2);
QTreeWidgetItem* lpHeader = ui->m_lpSeriesList->headerItem();
for(int z = iMin, x = 1;z < iMax;z++, x++)
lpHeader->setText(x+2, QString("Season %1").arg(z));
lpHeader->setData(0, Qt::UserRole, QVariant(iMin));
QFont font = ui->m_lpSeriesList->font();
QFont fontI = ui->m_lpSeriesList->font();
font.setBold(true);
fontI.setItalic(true);
QIcon icon(":/128279.png");
QTreeWidgetItem* lpSelected = 0;
for(int z = 0;z < m_serieList.count();z++)
{
cSerie* lpSerie = m_serieList.at(z);
QTreeWidgetItem* lp0 = new QTreeWidgetItem(ui->m_lpSeriesList);
lp0->setText(0, QString("%1").arg(z+1));
lp0->setTextAlignment(0, Qt::AlignRight);
lp0->setData(0, Qt::UserRole, QVariant::fromValue(lpSerie));
lp0->setText(1, lpSerie->seriesName());
lp0->setText(2, lpSerie->firstAired().toString("yyyy"));
lp0->setTextAlignment(2, Qt::AlignRight);
QList<cSeason*> seasonList = lpSerie->seasonList();
for(int z = 0;z < seasonList.count();z++)
{
QString szInit = "";
QString szProg = "";
QString szDone = "";
cSeason* lpSeason = seasonList.at(z);
lp0->setData(lpSeason->number()+3-iMin, Qt::UserRole, QVariant::fromValue(lpSeason));
for(int y = 0;y < lpSeason->episodeList().count();y++)
{
if(lpSeason->episodeList().at(y)->state() == cEpisode::StateInit)
{
if(szInit.isEmpty())
szInit.append(QString("%1").arg(lpSeason->episodeList().at(y)->episodeNumber()));
else
szInit.append(QString(", %1").arg(lpSeason->episodeList().at(y)->episodeNumber()));
}
else if(lpSeason->episodeList().at(y)->state() == cEpisode::StateProgress)
{
if(szProg.isEmpty())
szProg.append(QString("%1").arg(lpSeason->episodeList().at(y)->episodeNumber()));
else
szProg.append(QString(", %1").arg(lpSeason->episodeList().at(y)->episodeNumber()));
}
else if(lpSeason->episodeList().at(y)->state() == cEpisode::StateDone)
{
if(szDone.isEmpty())
szDone.append(QString("%1").arg(lpSeason->episodeList().at(y)->episodeNumber()));
else
szDone.append(QString(", %1").arg(lpSeason->episodeList().at(y)->episodeNumber()));
}
}
QString szTooltip;
if(szInit.isEmpty())
szTooltip.append("open: none\n");
else
szTooltip.append("open: " + szInit + "\n");
if(szProg.isEmpty())
szTooltip.append("in progress: none\n");
else
szTooltip.append("in progress: " + szProg + "\n");
if(szDone.isEmpty())
szTooltip.append("done: none");
else
szTooltip.append("done: " + szDone);
if(szTooltip.isEmpty())
lp0->setToolTip(lpSeason->number()+3-iMin, szTooltip);
else
lp0->setToolTip(lpSeason->number()+3-iMin, szTooltip);
}
if(lpSerie->status().compare("Ended", Qt::CaseInsensitive))
{
lp0->setFont(0, font);
lp0->setFont(1, font);
lp0->setFont(2, font);
}
if(lpSerie->cliffhanger())
{
lp0->setFont(0, fontI);
lp0->setFont(1, fontI);
lp0->setFont(2, fontI);
lp0->setForeground(0, QBrush(Qt::red));
lp0->setForeground(1, QBrush(Qt::red));
lp0->setForeground(2, QBrush(Qt::red));
}
if(lpSerie->download().length())
lp0->setIcon(0, icon);
ui->m_lpSeriesList->insertTopLevelItem(0, lp0);
if(!m_szOldSelected.isEmpty())
{
if(!m_szOldSelected.compare(lpSerie->seriesName()))
{
lp0->setSelected(true);
lpSelected = lp0;
}
}
}
for(int z = 0;z < ui->m_lpSeriesList->columnCount();z++)
ui->m_lpSeriesList->resizeColumnToContents(z);
if(lpSelected)
ui->m_lpSeriesList->scrollToItem(lpSelected);
m_szOldSelected = "";
}
void cMainWindow::on_m_lpSeriesList_customContextMenuRequested(const QPoint &pos)
{
QMenu* lpMenu = new QMenu(this);
lpMenu->addAction("add", this, SLOT(onActionAdd()));
if(ui->m_lpSeriesList->selectedItems().count() == 1)
{
cSerie* lpSerie = ui->m_lpSeriesList->selectedItems().at(0)->data(0, Qt::UserRole).value<cSerie*>();
if(lpSerie)
{
lpMenu->addAction("update", this, SLOT(onActionUpdate()));
lpMenu->addAction("delete", this, SLOT(onActionDelete()));
lpMenu->addAction("edit", this, SLOT(onActionEdit()));
lpMenu->addSeparator();
if(!lpSerie->imdbID().isEmpty())
lpMenu->addAction("open IMDB", this, SLOT(onActionGotoIMDB()));
if(!lpSerie->download().isEmpty())
{
lpMenu->addAction("open download link", this, SLOT(onActionGotoDownload()));
lpMenu->addAction("copy download link", this, SLOT(onActionCopyDownload()));
}
lpMenu->addSeparator();
lpMenu->addAction("load images", this, SLOT(onActionLoadPictures()));
}
}
else if(ui->m_lpSeriesList->selectedItems().count())
{
lpMenu->addAction("update", this, SLOT(onActionUpdate()));
lpMenu->addAction("delete", this, SLOT(onActionDelete()));
lpMenu->addSeparator();
lpMenu->addAction("load images", this, SLOT(onActionLoadPictures()));
}
lpMenu->popup(ui->m_lpSeriesList->viewport()->mapToGlobal(pos));
}
static bool serieSort(cSerie* s1, cSerie* s2)
{
QString str1 = s1->seriesName();
QString str2 = s2->seriesName();
return(str1 < str2);
}
bool cMainWindow::runEdit(cSerie* lpSerie, QString& szDownload)
{
cEdit* lpEdit = new cEdit;
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Edit");
lpDialog->setMessage("Loading");
lpDialog->show();
lpEdit->setSerie(lpSerie);
QSettings settings;
qint16 iX = settings.value("edit/x", QVariant::fromValue(-1)).toInt();
qint16 iY = settings.value("edit/y", QVariant::fromValue(-1)).toInt();
qint16 iWidth = settings.value("edit/width", QVariant::fromValue(-1)).toInt();
qint16 iHeight = settings.value("edit/height", QVariant::fromValue(-1)).toInt();
if(iX != -1 && iY != -1)
lpEdit->move(iX, iY);
if(iWidth != -1 && iHeight != -1)
lpEdit->resize(iWidth, iHeight);
delete lpDialog;
qint16 ret = lpEdit->exec();
settings.setValue("edit/width", QVariant::fromValue(lpEdit->size().width()));
settings.setValue("edit/height", QVariant::fromValue(lpEdit->size().height()));
settings.setValue("edit/x", QVariant::fromValue(lpEdit->x()));
settings.setValue("edit/y", QVariant::fromValue(lpEdit->y()));
if(this->isMaximized())
settings.setValue("edit/maximized", QVariant::fromValue(true));
else
settings.setValue("edit/maximized", QVariant::fromValue(false));
if(ret == QDialog::Rejected)
{
delete lpEdit;
int x;
QList<cSeason*> seasonList = lpSerie->seasonList();
for(x = 0;x < seasonList.count();x++)
{
cSeason* lpSeason = seasonList.at(x);
QList<cEpisode*> episodeList = lpSeason->episodeList();
for(int y = 0;y < episodeList.count();y++)
{
cEpisode* lpEpisode = episodeList.at(y);
if(lpEpisode)
{
lpEpisode->setButton1(0);
lpEpisode->setButton2(0);
lpEpisode->setButton3(0);
}
}
}
return(false);
}
szDownload = lpEdit->download();
lpSerie->setDownload(szDownload);
lpSerie->updateState();
delete lpEdit;
return(true);
}
void cMainWindow::onActionAdd()
{
cSearch* lpSearch = new cSearch(this);
if(lpSearch->exec() == QDialog::Rejected)
{
delete lpSearch;
return;
}
qint32 id = lpSearch->id();
QString szPlaceholder = lpSearch->placeholderName();
bool bPlaceholder = lpSearch->placeholder();
qint16 iYear = lpSearch->year();
delete lpSearch;
cSerie* lpSerie = 0;
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Refresh");
lpDialog->setMessage("Loading");
lpDialog->show();
if(!bPlaceholder)
{
if(id == -1)
return;
cTheTVDB tvDB;
lpSerie = tvDB.load(id, "de");
delete lpDialog;
QString szDownload;
if(!runEdit(lpSerie, szDownload))
return;
lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Update");
lpDialog->setMessage("Updating");
lpDialog->show();
// lpSerie->setDownload(szDownload);
// lpSerie->updateState();
lpSerie->save(m_db);
}
else
{
lpSerie = new cSerie;
lpSerie->setSeriesName(szPlaceholder);
qint32 iMax = 0;
QSqlQuery query;
if(query.exec("SELECT MAX(id) FROM serie;"))
{
query.next();
if(query.isValid())
iMax = query.value(0).toInt();
}
if(iMax < 1000000)
iMax = 1000000;
else
iMax++;
lpSerie->setID(iMax);
lpSerie->setFirstAired(QDate(iYear, 1, 1));
lpSerie->save(m_db);
}
m_serieList.add(lpSerie);
std::sort(m_serieList.begin(), m_serieList.end(), serieSort);
m_szOldSelected = lpSerie->seriesName();
displaySeries();
delete lpDialog;
}
void cMainWindow::onActionUpdate()
{
if(ui->m_lpSeriesList->selectedItems().count())
{
m_lpMessageDialog = new cMessageDialog(this);
m_lpMessageDialog->setWindowTitle("Update");
m_lpMessageDialog->setMessage("Updating");
m_lpMessageDialog->setProgress(0, ui->m_lpSeriesList->selectedItems().count());
m_lpMessageDialog->show();
m_lpUpdateThread = new cUpdateThread;
m_lpUpdateThread->setData(m_lpMessageDialog, ui->m_lpSeriesList->selectedItems(), m_db);
connect(m_lpUpdateThread, SIGNAL(finished()), this, SLOT(updateDone()));
connect(m_lpUpdateThread, SIGNAL(updateMessage(QString,qint32)), this, SLOT(updateMessage(QString,qint32)));
connect(m_lpUpdateThread, SIGNAL(updateAppendMessage(QString)), this, SLOT(updateAppendMessage(QString)));
m_lpUpdateThread->start();
}
}
void cMainWindow::updateMessage(const QString& szMessage, const qint32& iProgress)
{
m_lpMessageDialog->setMessage(szMessage);
m_lpMessageDialog->setProgress(iProgress);
}
void cMainWindow::updateAppendMessage(const QString& szMessage)
{
m_lpMessageDialog->addMessage(szMessage);
}
void cMainWindow::updateDone()
{
if(m_lpUpdateThread)
delete m_lpUpdateThread;
m_lpUpdateThread = 0;
loadDB();
displaySeries();
if(m_lpMessageDialog)
delete m_lpMessageDialog;
m_lpMessageDialog = 0;
}
void cMainWindow::onActionDelete()
{
if(QMessageBox::question(this, "Delete Serie", "Are you sure?") == QMessageBox::No)
return;
cSerie* lpSerie = ui->m_lpSeriesList->selectedItems().at(0)->data(0, Qt::UserRole).value<cSerie*>();
if(!lpSerie)
return;
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Delete");
lpDialog->setMessage("Deleting");
lpDialog->show();
lpSerie->del(m_db);
loadDB();
displaySeries();
delete lpDialog;
}
void cMainWindow::onActionEdit()
{
cSerie* lpSerie = ui->m_lpSeriesList->selectedItems().at(0)->data(0, Qt::UserRole).value<cSerie*>();
if(!lpSerie)
return;
QString szDownload;
if(!runEdit(lpSerie, szDownload))
return;
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Update");
lpDialog->setMessage("Updating");
lpDialog->show();
//lpSerie->setDownload(szDownload);
//lpSerie->updateState();
lpSerie->del(m_db);
lpSerie->save(m_db);
m_szOldSelected = lpSerie->seriesName();
loadDB();
displaySeries();
delete lpDialog;
}
void cMainWindow::on_m_lpSeriesList_doubleClicked(const QModelIndex &/*index*/)
{
onActionEdit();
}
void cMainWindow::onActionGotoIMDB()
{
if(ui->m_lpSeriesList->selectedItems().count())
{
cSerie* lpSerie = ui->m_lpSeriesList->selectedItems().at(0)->data(0, Qt::UserRole).value<cSerie*>();
if(lpSerie)
{
QString link = QString("http://www.imdb.com/title/%1").arg(lpSerie->imdbID());
QDesktopServices::openUrl(QUrl(link));
}
}
}
void cMainWindow::onActionGotoDownload()
{
if(ui->m_lpSeriesList->selectedItems().count())
{
cSerie* lpSerie = ui->m_lpSeriesList->selectedItems().at(0)->data(0, Qt::UserRole).value<cSerie*>();
if(lpSerie)
{
QString link = lpSerie->download();
QDesktopServices::openUrl(QUrl(link));
}
}
}
void cMainWindow::onActionCopyDownload()
{
if(ui->m_lpSeriesList->selectedItems().count())
{
cSerie* lpSerie = ui->m_lpSeriesList->selectedItems().at(0)->data(0, Qt::UserRole).value<cSerie*>();
if(lpSerie)
{
QString link = lpSerie->download();
QClipboard* lpClipboard = QApplication::clipboard();
lpClipboard->setText(link);
}
}
}
void cMainWindow::onActionLoadPictures()
{
QList<cSerie*> serieList;
if(ui->m_lpSeriesList->selectedItems().count())
{
for(int z = 0;z < ui->m_lpSeriesList->selectedItems().count();z++)
serieList.append(ui->m_lpSeriesList->selectedItems().at(z)->data(0, Qt::UserRole).value<cSerie*>());
}
if(!serieList.count())
return;
qint16 iTotal = 0;
for(int z = 0;z < serieList.count();z++)
{
cSerie* lpSerie = serieList.at(z);
for(int y = 0;y < lpSerie->seasonList().count();y++)
iTotal += lpSerie->seasonList().at(y)->episodeCount();
}
m_lpMessageDialog = new cMessageDialog(this);
m_lpMessageDialog->setWindowTitle("Images");
m_lpMessageDialog->setMessage("loading Images");
m_lpMessageDialog->setProgress(0, iTotal-1);
m_lpMessageDialog->show();
m_lpPicturesThread = new cPicturesThread;
m_lpPicturesThread->setData(m_lpMessageDialog, serieList);
connect(m_lpPicturesThread, SIGNAL(finished()), this, SLOT(picturesDone()));
connect(m_lpPicturesThread, SIGNAL(picturesMessage(QString,qint32)), this, SLOT(picturesMessage(QString,qint32)));
connect(m_lpPicturesThread, SIGNAL(picturesAppendMessage(QString)), this, SLOT(picturesAppendMessage(QString)));
m_lpPicturesThread->start();
}
void cMainWindow::picturesMessage(const QString& szMessage, const qint32& iProgress)
{
m_lpMessageDialog->setMessage(szMessage);
m_lpMessageDialog->setProgress(iProgress);
}
void cMainWindow::picturesAppendMessage(const QString& szMessage)
{
m_lpMessageDialog->addMessage(szMessage);
}
void cMainWindow::picturesDone()
{
if(m_lpPicturesThread)
delete m_lpPicturesThread;
m_lpPicturesThread = 0;
if(m_lpMessageDialog)
delete m_lpMessageDialog;
m_lpMessageDialog = 0;
}
+71
View File
@@ -0,0 +1,71 @@
#ifndef CMAINWINDOW_H
#define CMAINWINDOW_H
#include "cserie.h"
#include "cupdatethread.h"
#include "cpicturesthread.h"
#include <QMainWindow>
#include <QList>
#include <QSqlDatabase>
#include <QCloseEvent>
#include <QTime>
namespace Ui {
class cMainWindow;
}
class cMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit cMainWindow(QWidget *parent = 0);
~cMainWindow();
private slots:
void on_m_lpSeriesList_customContextMenuRequested(const QPoint &pos);
void onActionAdd();
void onActionUpdate();
void onActionDelete();
void onActionEdit();
void onActionGotoIMDB();
void onActionGotoDownload();
void onActionCopyDownload();
void onActionLoadPictures();
void on_m_lpSeriesList_doubleClicked(const QModelIndex &index);
void updateMessage(const QString& szMessage, const qint32 &iProgress);
void updateAppendMessage(const QString& szMessage);
void updateDone();
void picturesMessage(const QString& szMessage, const qint32 &iProgress);
void picturesAppendMessage(const QString& szMessage);
void picturesDone();
private:
Ui::cMainWindow* ui;
cSerieList m_serieList;
QSqlDatabase m_db;
QString m_szOldSelected;
cMessageDialog* m_lpMessageDialog;
cUpdateThread* m_lpUpdateThread;
cPicturesThread* m_lpPicturesThread;
QTime m_timer;
void initDB();
void loadDB();
void displaySeries();
bool runEdit(cSerie *lpSerie, QString& szDownload);
protected:
void closeEvent(QCloseEvent * event);
};
#endif // CMAINWINDOW_H
+64
View File
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cMainWindow</class>
<widget class="QMainWindow" name="cMainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1002</width>
<height>632</height>
</rect>
</property>
<property name="windowTitle">
<string>qtSerien</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTreeWidget" name="m_lpSeriesList">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1002</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
+58
View File
@@ -0,0 +1,58 @@
#include "cmessageanimatedialog.h"
#include "ui_cmessageanimatedialog.h"
cMessageAnimateDialog::cMessageAnimateDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::cMessageAnimateDialog),
m_szMessage(""),
m_lpTimer(0),
m_iCount(0),
m_iDirection(1)
{
ui->setupUi(this);
}
cMessageAnimateDialog::~cMessageAnimateDialog()
{
if(m_lpTimer)
delete m_lpTimer;
delete ui;
}
void cMessageAnimateDialog::setTitle(const QString& szTitle)
{
setWindowTitle(szTitle);
}
void cMessageAnimateDialog::setMessage(const QString& szMessage)
{
m_szMessage = szMessage;
ui->m_lpText->setText(m_szMessage);
if(m_lpTimer)
delete m_lpTimer;
m_lpTimer = new QTimer(this);
connect(m_lpTimer, SIGNAL(timeout()), this, SLOT(update()));
m_lpTimer->start(500);
}
void cMessageAnimateDialog::update()
{
m_iCount += m_iDirection;
if(m_iCount == 4)
{
m_iCount = 2;
m_iDirection = -1;
}
else if(m_iCount == -1)
{
m_iCount = 1;
m_iDirection = 1;
}
QString sz = m_szMessage;
for(int z = 0;z < m_iCount;z++)
sz.append(".");
ui->m_lpText->setText(sz);
}
+77
View File
@@ -0,0 +1,77 @@
/**
* \class cMessageAnimateDialog
*
* \brief Class to display a modal message dialog.
*
* Class to display a modal message dialog. Title and message can be configured.
* The dialog displays the message and adds up to 3 points zwice a second to the message.
*
* \ingroup KOOKY
*
* \author Herwig Birke
*
* \version 1.0
*
* \date $Date: 2016/02/09
*/
#ifndef CMESSAGEANIMATEDIALOG_H
#define CMESSAGEANIMATEDIALOG_H
#include <QDialog>
#include <QTimer>
namespace Ui {
class cMessageAnimateDialog;
}
class cMessageAnimateDialog : public QDialog
{
Q_OBJECT
public:
/**
* \brief constructor.
*
* \param parent
*/
explicit cMessageAnimateDialog(QWidget *parent = 0);
/**
* \brief destructor.
*
*/
~cMessageAnimateDialog();
/**
* \brief Sets the title of the dialog.
*
* \param szTitle Title text
*/
void setTitle(const QString& szTitle);
/**
* \brief Sets the message of the dialog.
*
* \param szMessage Message text
*/
void setMessage(const QString& szMessage);
private slots:
/**
* \brief This function is called twice a second to update the displayed message.
*
*/
void update();
private:
Ui::cMessageAnimateDialog *ui; /*!< User interface of the dialog. */
protected:
QString m_szMessage; /*!< Message to be displayed */
QTimer* m_lpTimer; /*!< Timer object */
int m_iCount; /*!< Number of points currently being displayed */
int m_iDirection; /*!< Increase / decrease number of points */
};
#endif // CMESSAGEANIMATEDIALOG_H
+31
View File
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cMessageAnimateDialog</class>
<widget class="QDialog" name="cMessageAnimateDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>330</width>
<height>31</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="m_lpText">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+47
View File
@@ -0,0 +1,47 @@
#include "cmessagedialog.h"
#include "ui_cmessagedialog.h"
#include <QThread>
cMessageDialog::cMessageDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::cMessageDialog)
{
ui->setupUi(this);
}
cMessageDialog::~cMessageDialog()
{
delete ui;
}
void cMessageDialog::setMessage(const QString& szMessage)
{
ui->m_lpMessage->setText(szMessage);
QThread::msleep(100);
}
void cMessageDialog::addMessage(const QString& szMessage)
{
ui->m_lpMessage->setText(ui->m_lpMessage->text() + szMessage);
}
void cMessageDialog::setProgress(qint32 iMin, qint32 iMax)
{
ui->m_lpProgressBar->setMinimum(iMin);
ui->m_lpProgressBar->setMaximum(iMax);
ui->m_lpProgressBar->setValue(0);
QThread::msleep(100);
}
void cMessageDialog::setProgress(qint32 iValue)
{
ui->m_lpProgressBar->setValue(iValue);
QThread::msleep(100);
}
QPushButton* cMessageDialog::cancelButton()
{
return(ui->m_lpCancel);
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef CMESSAGEDIALOG_H
#define CMESSAGEDIALOG_H
#include <QDialog>
namespace Ui {
class cMessageDialog;
}
class cMessageDialog : public QDialog
{
Q_OBJECT
public:
explicit cMessageDialog(QWidget *parent = 0);
~cMessageDialog();
void setMessage(const QString& szMessage);
void addMessage(const QString& szMessage);
void setProgress(qint32 iMin, qint32 iMax);
void setProgress(qint32 iValue);
QPushButton* cancelButton();
private:
Ui::cMessageDialog *ui;
};
#endif // CMESSAGEDIALOG_H
+76
View File
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cMessageDialog</class>
<widget class="QDialog" name="cMessageDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>91</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="m_lpMessage">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="m_lpProgressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<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>
<item>
<widget class="QPushButton" name="m_lpCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<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>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+64
View File
@@ -0,0 +1,64 @@
#include "cpicturesthread.h"
#include "cserie.h"
#include "cseason.h"
#include "cepisode.h"
#include "cmessagedialog.h"
#include "cimage.h"
#include <QDebug>
cPicturesThread::cPicturesThread() :
m_bStop(false)
{
}
void cPicturesThread::stop()
{
QMutexLocker locker(&m_mutex);
m_bStop = true;
emit picturesAppendMessage(" - cancel pending ...");
}
void cPicturesThread::run()
{
qint16 iCurrent = 0;
for(int z = 0;z < m_items.count();z++)
{
cSerie* lpSerie = m_items.at(z);
if(lpSerie)
{
emit picturesMessage(lpSerie->seriesName(), iCurrent);
cImage image;
image.getImage(lpSerie->banner());
for(int y = 0;y < lpSerie->seasonList().count();y++)
{
cSeason* lpSeason;
lpSeason = lpSerie->seasonList().at(y);
emit picturesMessage(QString("%1 - Season %2").arg(lpSerie->seriesName()).arg(lpSeason->number()), iCurrent);
for(int x = 0;x < lpSeason->episodeList().count();x++)
{
cEpisode* lpEpisode = lpSeason->episodeList().at(x);
image.getImage(lpEpisode->fileName());
iCurrent++;
QMutexLocker locker(&m_mutex);
if(m_bStop)
break;
msleep(10);
}
}
}
}
}
void cPicturesThread::setData(cMessageDialog* lpMessageDialog, const QList<cSerie *> &list)
{
connect(lpMessageDialog->cancelButton(), SIGNAL(clicked()), this, SLOT(stop()));
m_items = list;
}
+37
View File
@@ -0,0 +1,37 @@
#ifndef CPICTURESTHREAD_H
#define CPICTURESTHREAD_H
#include "cmessagedialog.h"
#include "cserie.h"
#include <QThread>
#include <QMutexLocker>
#include <QList>
class cPicturesThread : public QThread
{
Q_OBJECT
public:
explicit cPicturesThread();
void setData(cMessageDialog *lpMessageDialog, const QList<cSerie*>& list);
public slots:
void stop();
signals:
void picturesMessage(const QString& szMessage, const qint32 &iProgress);
void picturesAppendMessage(const QString& szMessage);
private:
QMutex m_mutex;
bool m_bStop;
QList<cSerie*> m_items;
QWidget* m_lpParent;
void run();
};
#endif // CPICTURESTHREAD_H
+87
View File
@@ -0,0 +1,87 @@
#include "csearch.h"
#include "ui_csearch.h"
#include "cthetvdb.h"
#include "cserie.h"
#include "cmessageanimatedialog.h"
#include <QList>
cSearch::cSearch(QWidget *parent) :
QDialog(parent),
ui(new Ui::cSearch)
{
ui->setupUi(this);
ui->m_lpSearchButton->setEnabled(false);
ui->m_lpTabWidget->setCurrentIndex(0);
}
cSearch::~cSearch()
{
delete ui;
}
void cSearch::on_m_lpSearch_textChanged(const QString& /*arg1*/)
{
if(ui->m_lpSearch->text().isEmpty())
ui->m_lpSearchButton->setEnabled(false);
else
ui->m_lpSearchButton->setEnabled(true);
}
void cSearch::on_m_lpSearchButton_clicked()
{
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Search");
lpDialog->setMessage("Searching");
lpDialog->show();
cTheTVDB theTVDB;
QList<cSerie*> serieList = theTVDB.search(ui->m_lpSearch->text());
ui->m_lpResults->clear();
for(int z = 0;z < serieList.count();z++)
{
cSerie* lpSerie = serieList.at(z);
QTreeWidgetItem* lpNew = new QTreeWidgetItem(ui->m_lpResults);
lpNew->setText(0, lpSerie->seriesName());
lpNew->setText(1, lpSerie->language());
lpNew->setText(2, QString("%1").arg(lpSerie->firstAired().year()));
lpNew->setData(0, Qt::UserRole, QVariant::fromValue(lpSerie->id()));
ui->m_lpResults->addTopLevelItem(lpNew);
}
ui->m_lpResults->resizeColumnToContents(0);
ui->m_lpResults->resizeColumnToContents(1);
ui->m_lpResults->resizeColumnToContents(2);
delete lpDialog;
}
qint32 cSearch::id()
{
if(!ui->m_lpResults->selectedItems().count())
{
qint32 iID = ui->m_lpSearch->text().toInt();
if(iID)
return(iID);
return(-1);
}
return(ui->m_lpResults->selectedItems().at(0)->data(0, Qt::UserRole).toInt());
}
QString cSearch::placeholderName()
{
return(ui->m_lpPlaceholderName->text());
}
bool cSearch::placeholder()
{
return(ui->m_lpTabWidget->currentIndex() == 1);
}
qint16 cSearch::year()
{
return(ui->m_lpYear->value());
}
+31
View File
@@ -0,0 +1,31 @@
#ifndef CSEARCH_H
#define CSEARCH_H
#include <QDialog>
namespace Ui {
class cSearch;
}
class cSearch : public QDialog
{
Q_OBJECT
public:
explicit cSearch(QWidget *parent = 0);
~cSearch();
qint32 id();
QString placeholderName();
bool placeholder();
qint16 year();
private slots:
void on_m_lpSearchButton_clicked();
void on_m_lpSearch_textChanged(const QString &arg1);
private:
Ui::cSearch *ui;
};
#endif // CSEARCH_H
+180
View File
@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cSearch</class>
<widget class="QDialog" name="cSearch">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>334</width>
<height>460</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QDialogButtonBox" name="m_lpButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="m_lpTabWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="Search">
<attribute name="title">
<string>Search</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="m_lpSearch"/>
</item>
<item>
<widget class="QPushButton" name="m_lpSearchButton">
<property name="text">
<string>Search</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="m_lpResults">
<property name="columnCount">
<number>3</number>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
<column>
<property name="text">
<string notr="true">2</string>
</property>
</column>
<column>
<property name="text">
<string notr="true">3</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="Add">
<attribute name="title">
<string>Add Placeholder</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="m_lpPlaceholderName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Year:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="m_lpYear">
<property name="minimum">
<number>1800</number>
</property>
<property name="maximum">
<number>2100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>m_lpButtonBox</sender>
<signal>accepted()</signal>
<receiver>cSearch</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_lpButtonBox</sender>
<signal>rejected()</signal>
<receiver>cSearch</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>
+174
View File
@@ -0,0 +1,174 @@
#include "cseason.h"
#define DELETE(x) { if(x) delete x; x=0; }
cSeason::cSeason() :
m_iNumber(-1),
m_lpGroupBox(0),
m_lpGridLayout(0),
m_lpGrid(0),
m_lpLabel1(0),
m_lpAllInit(0),
m_lpAllProgress(0),
m_lpAllDone(0),
m_lpSpacer(0),
m_lpSerie(0)
{
}
cSeason::~cSeason()
{
deleteResources();
}
void cSeason::setNumber(const qint16& iNumber)
{
m_iNumber = iNumber;
}
qint16 cSeason::number()
{
return(m_iNumber);
}
void cSeason::setSerie(cSerie* lpSerie)
{
m_lpSerie = lpSerie;
}
cSerie* cSeason::serie()
{
return(m_lpSerie);
}
cEpisode* cSeason::addEpisode(qint16 iNumber)
{
cEpisode* lpNew = new cEpisode;
lpNew->setEpisodeNumber(iNumber);
lpNew->setState(cEpisode::StateInit);
m_episodeList.append(lpNew);
return(lpNew);
}
cEpisode* cSeason::addEpisode(cEpisode* lpEpisode)
{
if(episodeList().contains(lpEpisode))
return(0);
m_episodeList.append(lpEpisode);
return(lpEpisode);
}
QList<cEpisode*> cSeason::episodeList()
{
return(m_episodeList);
}
qint16 cSeason::episodeCount()
{
qint16 iTotal = -1;
for(int z = 0;z < m_episodeList.count();z++)
{
cEpisode* lpEpisode = m_episodeList.at(z);
if(lpEpisode)
{
if(lpEpisode->episodeNumber() > iTotal)
iTotal = lpEpisode->episodeNumber();
}
}
return(iTotal);
}
void cSeason::setGroupBox(QGroupBox* lpGroupBox)
{
m_lpGroupBox = lpGroupBox;
}
void cSeason::setGridLayout(QGridLayout* lpGridLayout)
{
m_lpGridLayout = lpGridLayout;
}
void cSeason::setGrid(QGridLayout* lpGrid)
{
m_lpGrid = lpGrid;
}
void cSeason::setLabel1(QLabel* lpLabel1)
{
m_lpLabel1 = lpLabel1;
}
void cSeason::setAllInit(QPushButton* lpAllInit)
{
m_lpAllInit = lpAllInit;
}
void cSeason::setAllProgress(QPushButton* lpAllProgress)
{
m_lpAllProgress = lpAllProgress;
}
void cSeason::setAllDone(QPushButton* lpAllDone)
{
m_lpAllDone = lpAllDone;
}
void cSeason::setSpacer(QSpacerItem* lpSpacer)
{
m_lpSpacer = lpSpacer;
}
void cSeason::deleteResources()
{
DELETE(m_lpGroupBox);
DELETE(m_lpGridLayout);
DELETE(m_lpGrid);
DELETE(m_lpLabel1);
DELETE(m_lpAllInit);
DELETE(m_lpAllProgress);
DELETE(m_lpAllDone);
DELETE(m_lpSpacer);
for(int z = 0;z < m_episodeList.count();z++)
m_episodeList.at(z)->deleteResources();
}
void cSeason::updateState()
{
for(int z = 0;z < m_episodeList.count();z++)
m_episodeList.at(z)->updateState();
}
void cSeason::allInit()
{
for(int z = 0;z < m_episodeList.count();z++)
m_episodeList.at(z)->setState(cEpisode::StateInit);
}
void cSeason::allProgress()
{
for(int z = 0;z < m_episodeList.count();z++)
m_episodeList.at(z)->setState(cEpisode::StateProgress);
}
void cSeason::allDone()
{
for(int z = 0;z < m_episodeList.count();z++)
m_episodeList.at(z)->setState(cEpisode::StateDone);
}
QPushButton* cSeason::allInitButton()
{
return(m_lpAllInit);
}
QPushButton* cSeason::allProgressButton()
{
return(m_lpAllProgress);
}
QPushButton* cSeason::allDoneButton()
{
return(m_lpAllDone);
}
+73
View File
@@ -0,0 +1,73 @@
#ifndef CSEASON_H
#define CSEASON_H
#include "cepisode.h"
#include <QMetaType>
#include <QList>
#include <QGroupBox>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QSpacerItem>
class cSerie;
class cSeason
{
public:
cSeason();
~cSeason();
void setNumber(const qint16& iNumber);
qint16 number();
void setSerie(cSerie* lpSerie);
cSerie* serie();
cEpisode* addEpisode(qint16 iNumber);
cEpisode* addEpisode(cEpisode* lpEpisode);
QList<cEpisode*> episodeList();
qint16 episodeCount();
void setGroupBox(QGroupBox* lpGroupBox);
void setGridLayout(QGridLayout* lpGridLayout);
void setGrid(QGridLayout* lpGrid);
void setLabel1(QLabel* lpLabel1);
void setAllInit(QPushButton* lpAllInit);
void setAllProgress(QPushButton* lpAllProgress);
void setAllDone(QPushButton* lpAllDone);
void setSpacer(QSpacerItem* lpSpacer);
void updateState();
void deleteResources();
void allInit();
void allProgress();
void allDone();
QPushButton* allInitButton();
QPushButton* allProgressButton();
QPushButton* allDoneButton();
private:
qint16 m_iNumber;
QList<cEpisode*> m_episodeList;
QGroupBox* m_lpGroupBox;
QGridLayout* m_lpGridLayout;
QGridLayout* m_lpGrid;
QLabel* m_lpLabel1;
QPushButton* m_lpAllInit;
QPushButton* m_lpAllProgress;
QPushButton* m_lpAllDone;
QSpacerItem* m_lpSpacer;
cSerie* m_lpSerie;
};
Q_DECLARE_METATYPE(cSeason*)
#endif // CSEASON_H
+161
View File
@@ -0,0 +1,161 @@
#include "cseasondelegate.h"
#include "cserie.h"
#include "cseason.h"
#include "cepisode.h"
#include <QPainter>
#include <QTreeWidget>
#include <QDebug>
#define FIELD_WIDTH 3
#define FIELD_STEP 4
#define FIELD_HEIGHT 15
#define STATE_INIT Qt::lightGray
#define STATE_PROGRESS Qt::blue
#define STATE_DONE Qt::green
#define STATE_UNKNOWN Qt::black
void cSeasonDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if(index.column() > 2)
{
cSeason* lpSeason = 0;
if(index.data(Qt::UserRole).canConvert<cSeason*>())
lpSeason = qvariant_cast<cSeason*>(index.data(Qt::UserRole));
if(option.state & QStyle::State_Selected)
painter->fillRect(option.rect, option.palette.highlight());
if(lpSeason)
{
QList<cEpisode*> episodeList = lpSeason->episodeList();
painter->save();
painter->setRenderHint(QPainter::Antialiasing, false);
painter->setBrush(option.palette.foreground());
painter->translate(option.rect.x(), option.rect.y());
for(int z = 0;z < episodeList.count();z++)
{
painter->setPen(Qt::NoPen);
cEpisode* lpEpisode = episodeList.at(z);
if(lpEpisode)
{
switch(lpEpisode->state())
{
case cEpisode::StateInit:
painter->setBrush(STATE_INIT);
break;
case cEpisode::StateProgress:
painter->setBrush(STATE_PROGRESS);
break;
case cEpisode::StateDone:
painter->setBrush(STATE_DONE);
break;
default:
break;
}
painter->drawRect(z*FIELD_STEP, 0, FIELD_STEP, FIELD_HEIGHT);
painter->setPen(Qt::black);
painter->drawLine(z*FIELD_STEP+FIELD_WIDTH, 0, z*FIELD_STEP+FIELD_WIDTH, FIELD_HEIGHT);
}
}
painter->setBrush(Qt::black);
painter->translate(1.0, 0.0);
painter->restore();
}
}
else
{
QStyledItemDelegate::paint(painter, option, index);
}
}
QSize cSeasonDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if(index.column() > 2)
{
qint16 iTotal = -1;
qint16 z;
cSeason* lpSeason = 0;
if(index.data(Qt::UserRole).canConvert<cSeason*>())
lpSeason = qvariant_cast<cSeason*>(index.data(Qt::UserRole));
if(lpSeason)
{
QList<cEpisode*> episodeList = lpSeason->episodeList();
for(z = 0;z < episodeList.count();z++)
{
cEpisode* lpEpisode = episodeList.at(z);
if(lpEpisode)
{
if(lpEpisode->episodeNumber() > iTotal)
iTotal = lpEpisode->episodeNumber();
}
}
if(iTotal > 0 && lpSeason->number() != 0)
return(QSize((iTotal+1)*FIELD_STEP, FIELD_HEIGHT));
else
return(QSize(FIELD_STEP*40, FIELD_HEIGHT));
}
return(QSize(FIELD_STEP, FIELD_HEIGHT));
}
return QStyledItemDelegate::sizeHint(option, index);
}
/*
QWidget *cSeasonDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.data().canConvert<StarRating>()) {
StarEditor *editor = new StarEditor(parent);
connect(editor, SIGNAL(editingFinished()),
this, SLOT(commitAndCloseEditor()));
return editor;
} else {
return QStyledItemDelegate::createEditor(parent, option, index);
}
}
*/
/*
void cSeasonDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
if (index.data().canConvert<StarRating>()) {
StarRating starRating = qvariant_cast<StarRating>(index.data());
StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
starEditor->setStarRating(starRating);
} else {
QStyledItemDelegate::setEditorData(editor, index);
}
}
*/
/*
void cSeasonDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
if (index.data().canConvert<StarRating>())
{
StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
model->setData(index, QVariant::fromValue(starEditor->starRating()));
}
else
{
QStyledItemDelegate::setModelData(editor, model, index);
}
}
*/
/*
void cSeasonDelegate::commitAndCloseEditor()
{
StarEditor *editor = qobject_cast<StarEditor *>(sender());
emit commitData(editor);
emit closeEditor(editor);
}
*/
+22
View File
@@ -0,0 +1,22 @@
#ifndef CSEASONDELEGATE_H
#define CSEASONDELEGATE_H
#include <QStyledItemDelegate>
class cSeasonDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
cSeasonDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
//QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
//void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
//void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE;
};
#endif // CSEASONDELEGATE_H
+44
View File
@@ -0,0 +1,44 @@
#include "cseasondetails.h"
#include "ui_cseasondetails.h"
#include "cepisode.h"
#include "cepisodedetails.h"
#include "cmessageanimatedialog.h"
#include <QDebug>
cSeasonDetails::cSeasonDetails(QWidget *parent) :
QWidget(parent),
ui(new Ui::cSeasonDetails)
{
ui->setupUi(this);
}
cSeasonDetails::~cSeasonDetails()
{
delete ui;
}
void cSeasonDetails::setSeason(cSeason* lpSeason)
{
for(int x = 0;x < lpSeason->episodeList().count();x++)
{
cEpisode* lpEpisode = lpSeason->episodeList().at(x);
cEpisodeDetails* lpEpisodeDetails = new cEpisodeDetails(ui->m_lpDetailsEpisodeTab);
ui->m_lpDetailsEpisodeTab->addTab(lpEpisodeDetails, QString("Episode %1").arg(lpEpisode->episodeNumber()));
lpEpisodeDetails->setEpisode(lpEpisode);
if(!x)
lpEpisodeDetails->loadImages();
}
}
void cSeasonDetails::on_m_lpDetailsEpisodeTab_tabBarClicked(int index)
{
cEpisodeDetails* lpEpisodeDetails = (cEpisodeDetails*)ui->m_lpDetailsEpisodeTab->widget(index);
if(!lpEpisodeDetails)
return;
lpEpisodeDetails->loadImages();
}
+31
View File
@@ -0,0 +1,31 @@
#ifndef CSEASONDETAILS_H
#define CSEASONDETAILS_H
#include "cseason.h"
#include <QWidget>
namespace Ui {
class cSeasonDetails;
}
class cSeasonDetails : public QWidget
{
Q_OBJECT
public:
explicit cSeasonDetails(QWidget *parent = 0);
~cSeasonDetails();
void setSeason(cSeason* lpSeason);
private slots:
void on_m_lpDetailsEpisodeTab_tabBarClicked(int index);
private:
Ui::cSeasonDetails* ui;
};
#endif // CSEASONDETAILS_H
+28
View File
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cSeasonDetails</class>
<widget class="QWidget" name="cSeasonDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>415</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="m_lpDetailsEpisodeTab">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+572
View File
@@ -0,0 +1,572 @@
#include "cserie.h"
#include <QStringList>
#include <QSqlQuery>
#include <QVariant>
void addPerson(const QString& szTable, const QString& szField1, const qint32 &iValue1, const QString &szField2, const QString& szName)
{
qint32 personID;
QSqlQuery query;
query.exec(QString("SELECT personID FROM person WHERE name='%1';").arg(szName));
if(query.next())
personID = query.value(0).toInt();
else
{
query.prepare("INSERT INTO person (name) VALUES (:name);");
query.bindValue(":name", szName);
query.exec();
query.clear();
query.prepare("SELECT personID FROM person WHERE name=:name;");
query.bindValue(":name", szName);
query.exec();
query.next();
personID = query.value(0).toInt();
}
query.exec(QString("SELECT * FROM %1 WHERE %2=%3 AND %4=%5;").arg(szTable).arg(szField1).arg(iValue1).arg(szField2).arg(personID));
if(!query.next())
{
query.prepare(QString("INSERT INTO %1 (%2, %3) VALUES (:%4, :%5);").arg(szTable).arg(szField1).arg(szField2).arg(szField1).arg(szField2));
query.bindValue(QString(":%1").arg(szField1), iValue1);
query.bindValue(QString(":%1").arg(szField2), personID);
query.exec();
}
}
cSerie::cSerie() :
m_szSeriesName(""),
m_iSeriesID(-1),
m_szLanguage(""),
m_szBanner(""),
m_szOverview(""),
m_firstAired(QDate(1900, 1, 1)),
m_szNetwork(""),
m_szIMDBID(""),
m_iID(-1),
m_szActors(),
m_szContentRating(""),
m_szGenre(),
m_dRating(-1.0),
m_iRatingCount(-1),
m_iRuntime(-1),
m_szStatus(""),
m_szDownload(""),
m_bCliffhanger(false)
{
}
void cSerie::setSeriesName(const QString& szSeriesName)
{
m_szSeriesName = szSeriesName;
}
QString cSerie::seriesName()
{
return(m_szSeriesName);
}
void cSerie::setSeriesID(const qint32& iSeriesID)
{
m_iSeriesID = iSeriesID;
}
qint32 cSerie::seriesID()
{
return(m_iSeriesID);
}
void cSerie::setLanguage(const QString& szLanguage)
{
m_szLanguage = szLanguage;
}
QString cSerie::language()
{
return(m_szLanguage);
}
void cSerie::setBanner(const QString& szBanner)
{
m_szBanner = szBanner;
}
QString cSerie::banner()
{
return(m_szBanner);
}
void cSerie::setOverview(const QString& szOverview)
{
m_szOverview = szOverview;
}
QString cSerie::overview()
{
return(m_szOverview);
}
void cSerie::setFirstAired(const QString& szFirstAired)
{
m_firstAired = QDate::fromString(szFirstAired, "yyyy-MM-dd");
}
void cSerie::setFirstAired(const QDate& firstAired)
{
m_firstAired = firstAired;
}
QDate cSerie::firstAired()
{
return(m_firstAired);
}
void cSerie::setNetwork(const QString& szNetwork)
{
m_szNetwork = szNetwork;
}
QString cSerie::network()
{
return(m_szNetwork);
}
void cSerie::setIMDBID(const QString& szIMDBID)
{
m_szIMDBID = szIMDBID;
}
QString cSerie::imdbID()
{
return(m_szIMDBID);
}
void cSerie::setID(const qint32& iID)
{
m_iID = iID;
}
qint32 cSerie::id()
{
return(m_iID);
}
void cSerie::setActors(const QString& szActors)
{
m_szActors = szActors.split("|");
m_szActors.removeAll("");
}
void cSerie::setActors(const QStringList& szActors)
{
m_szActors = szActors;
m_szActors.removeAll("");
}
QStringList cSerie::actors()
{
return(m_szActors);
}
void cSerie::setContentRating(const QString& szContentRating)
{
m_szContentRating = szContentRating;
}
QString cSerie::contentRating()
{
return(m_szContentRating);
}
void cSerie::setGenre(const QString& szGenre)
{
m_szGenre = szGenre.split("|");
m_szGenre.removeAll("");
}
void cSerie::setGenre(const QStringList& szGenre)
{
m_szGenre = szGenre;
m_szGenre.removeAll("");
}
QStringList cSerie::genre()
{
return(m_szGenre);
}
void cSerie::setRating(const qreal& dRating)
{
m_dRating = dRating;
}
qreal cSerie::rating()
{
return(m_dRating);
}
void cSerie::setRatingCount(const qint16& iRatingCount)
{
m_iRatingCount = iRatingCount;
}
qint16 cSerie::ratingCount()
{
return(m_iRatingCount);
}
void cSerie::setRuntime(const qint16& iRuntime)
{
m_iRuntime = iRuntime;
}
qint16 cSerie::runime()
{
return(m_iRuntime);
}
void cSerie::setStatus(const QString& szStatus)
{
m_szStatus = szStatus;
}
QString cSerie::status()
{
return(m_szStatus);
}
void cSerie::setDownload(const QString& szDownload)
{
m_szDownload = szDownload;
}
QString cSerie::download()
{
return(m_szDownload);
}
void cSerie::setCliffhanger(const bool& bCliffhanger)
{
m_bCliffhanger = bCliffhanger;
}
bool cSerie::cliffhanger()
{
return(m_bCliffhanger);
}
cSeason* cSerie::addSeason(const qint16& iSeason)
{
cSeason* lpNew = new cSeason;
lpNew->setNumber(iSeason);
lpNew->setSerie(this);
m_seasonList.append(lpNew);
return(lpNew);
}
cSeason* cSerie::findSeason(const qint16& iSeason)
{
for(int z = 0;z < m_seasonList.count();z++)
{
if(m_seasonList.at(z)->number() == iSeason)
return(m_seasonList.at(z));
}
return(0);
}
QList<cSeason*> cSerie::seasonList()
{
return(m_seasonList);
}
qint16 cSerie::minSeason()
{
qint16 iMin = 9999;
for(int z = 0;z < m_seasonList.count();z++)
{
if(m_seasonList.at(z)->number() < iMin)
iMin = m_seasonList.at(z)->number();
}
if(iMin == 9999)
return(-1);
return(iMin);
}
qint16 cSerie::maxSeason()
{
qint16 iMax = -1;
for(int z = 0;z < m_seasonList.count();z++)
{
if(m_seasonList.at(z)->number() > iMax)
iMax = m_seasonList.at(z)->number();
}
return(iMax);
}
cEpisode* cSerie::findEpisode(const qint32& id)
{
for(int x = 0;x < m_seasonList.count();x++)
{
cSeason* lpSeason = m_seasonList.at(x);
for(int y = 0;y < lpSeason->episodeList().count();y++)
{
cEpisode* lpEpisode = lpSeason->episodeList().at(y);
if(lpEpisode->id() == id)
return(lpEpisode);
}
}
return(0);
}
bool cSerie::isValid()
{
if(m_iSeriesID != -1 &&
m_szSeriesName.length())
return(true);
return(false);
}
qint16 cSerie::maxEpisode()
{
qint16 iMax = -1;
for(int z = 0;z < m_seasonList.count();z++)
{
if(m_seasonList.at(z)->episodeCount() > iMax)
iMax = m_seasonList.at(z)->episodeCount();
}
return(iMax);
}
bool cSerie::save(QSqlDatabase &db)
{
QSqlQuery query;
QSqlQuery querySerie;
QSqlQuery queryEpisode;
querySerie.prepare("INSERT INTO serie (seriesID,seriesName,language,banner,overview,firstAired,network,imdbid,id,contentRating,rating,ratingCount,runtime,status,download,cliffhanger,actor,genre)"
" VALUES (:seriesID,:seriesName,:language,:banner,:overview,:firstAired,:network,:imdbid,:id,:contentRating,:rating,:ratingCount,:runtime,:status,:download,:cliffhanger,:actor,:genre);");
queryEpisode.prepare("INSERT INTO episode (episodeID,episodeName,episodeNumber,firstAired,imdbid,language,overview,productioncode,rating,ratingCount,seasonNumber,seasonID,seriesID,state,filename,thumb_height,thumb_width,director,gueststars,episode_writer) VALUES (:episodeID,:episodeName,:episodeNumber,:firstAired,:imdbid,:language,:overview,:productioncode,:rating,:ratingCount,:seasonNumber,:seasonID,:seriesID,:state,:filename,:thumb_height,:thumb_width,:director,:gueststars,:episode_writer);");
db.transaction();
query.exec(QString("SELECT id FROM serie WHERE id=%1;").arg(id()));
if(!query.next())
{
query.prepare(QString("SELECT episodeID FROM episode WHERE episodeID=:episodeID"));
querySerie.bindValue(":seriesID", seriesID());
querySerie.bindValue(":seriesName", seriesName());
querySerie.bindValue(":language", language());
querySerie.bindValue(":banner", banner());
querySerie.bindValue(":overview", overview());
querySerie.bindValue(":firstAired", firstAired());
querySerie.bindValue(":network", network());
querySerie.bindValue(":imdbid", imdbID());
querySerie.bindValue(":id", id());
querySerie.bindValue(":contentRating", contentRating());
querySerie.bindValue(":rating", rating());
querySerie.bindValue(":ratingCount", ratingCount());
querySerie.bindValue(":runtime", runime());
querySerie.bindValue(":status", status());
querySerie.bindValue(":download", download());
querySerie.bindValue(":cliffhanger", cliffhanger());
querySerie.bindValue(":actor", actors().join(","));
querySerie.bindValue(":genre", genre().join(","));
if(querySerie.exec())
{
QList<cSeason*> seasonList = this->seasonList();
for(int season = 0;season < seasonList.count();season++)
{
QList<cEpisode*> episodeList = seasonList.at(season)->episodeList();
for(int episode = 0;episode < episodeList.count();episode++)
{
cEpisode* lpEpisode = episodeList.at(episode);
//query.bindValue(":episodeID", lpEpisode->id());
//query.exec();
//if(!query.next())
{
queryEpisode.bindValue(":episodeID", lpEpisode->id());
queryEpisode.bindValue(":episodeName", lpEpisode->episodeName());
queryEpisode.bindValue(":episodeNumber", lpEpisode->episodeNumber());
queryEpisode.bindValue(":firstAired", lpEpisode->firstAired());
queryEpisode.bindValue(":imdbid", lpEpisode->imdbID());
queryEpisode.bindValue(":language", lpEpisode->language());
queryEpisode.bindValue(":overview", lpEpisode->overview());
queryEpisode.bindValue(":productioncode", lpEpisode->productionCode());
queryEpisode.bindValue(":rating", lpEpisode->rating());
queryEpisode.bindValue(":ratingCount", lpEpisode->ratingCount());
queryEpisode.bindValue(":seasonNumber", lpEpisode->seasonNumber());
queryEpisode.bindValue(":seasonID", lpEpisode->seasonID());
queryEpisode.bindValue(":seriesID", lpEpisode->seriesID());
queryEpisode.bindValue(":state", lpEpisode->state());
queryEpisode.bindValue(":filename", lpEpisode->fileName());
queryEpisode.bindValue(":thumb_height", lpEpisode->thumbHeight());
queryEpisode.bindValue(":thumb_width", lpEpisode->thumbWidth());
queryEpisode.bindValue(":director", lpEpisode->director().join(","));
queryEpisode.bindValue(":gueststars", lpEpisode->guestStars().join(","));
queryEpisode.bindValue(":episode_writer", lpEpisode->writer().join(","));
if(queryEpisode.exec())
{
}
}
}
}
}
}
db.commit();
return(true);
}
bool cSerie::del(QSqlDatabase& db)
{
QSqlQuery query;
db.transaction();
query.prepare("DELETE FROM episode WHERE seriesID=:seriesID;");
query.bindValue(":seriesID", id());
query.exec();
query.prepare("DELETE FROM serie WHERE id=:seriesID;");
query.bindValue(":seriesID", id());
query.exec();
db.commit();
return(true);
}
void cSerie::allInit()
{
for(int z = 0;z < m_seasonList.count();z++)
m_seasonList.at(z)->allInit();
}
void cSerie::allProgress()
{
for(int z = 0;z < m_seasonList.count();z++)
m_seasonList.at(z)->allProgress();
}
void cSerie::allDone()
{
for(int z = 0;z < m_seasonList.count();z++)
m_seasonList.at(z)->allDone();
}
void cSerie::seasonInit(QPushButton* lpButton)
{
for(int z = 0;z < m_seasonList.count();z++)
{
if(m_seasonList.at(z)->allInitButton() == lpButton)
{
m_seasonList.at(z)->allInit();
return;
}
}
}
void cSerie::seasonProgress(QPushButton* lpButton)
{
for(int z = 0;z < m_seasonList.count();z++)
{
if(m_seasonList.at(z)->allProgressButton() == lpButton)
{
m_seasonList.at(z)->allProgress();
return;
}
}
}
void cSerie::seasonDone(QPushButton* lpButton)
{
for(int z = 0;z < m_seasonList.count();z++)
{
if(m_seasonList.at(z)->allDoneButton() == lpButton)
{
m_seasonList.at(z)->allDone();
return;
}
}
}
void cSerie::updateState()
{
for(int z = 0;z < m_seasonList.count();z++)
m_seasonList.at(z)->updateState();
}
void cSerie::deleteResources()
{
for(int z = 0;z < m_seasonList.count();z++)
m_seasonList.at(z)->deleteResources();
}
cSerie* cSerieList::add(const qint32& iID)
{
for(int z = 0;z < count();z++)
{
if(at(z)->id() == iID)
return(at(z));
}
cSerie* lpNew = new cSerie;
lpNew->setID(iID);
append(lpNew);
return(lpNew);
}
cSerie* cSerieList::add(cSerie* lpSerie)
{
for(int z = 0;z < count();z++)
{
if(at(z) == lpSerie)
return(0);
}
append(lpSerie);
return(lpSerie);
}
qint16 cSerieList::minSeason()
{
qint16 iMin = 9999;
for(int z = 0;z < count();z++)
{
if(at(z)->minSeason() < iMin)
iMin = at(z)->minSeason();
}
if(iMin == 9999 || iMin < 0)
return(0);
return(iMin);
}
qint16 cSerieList::maxSeason()
{
qint16 iMax = -1;
for(int z = 0;z < count();z++)
{
if(at(z)->maxSeason() > iMax)
iMax = at(z)->maxSeason();
}
if(iMax < 0)
return(0);
return(iMax);
}
qint16 cSerieList::maxEpisode()
{
qint16 iMax = -1;
for(int z = 0;z < count();z++)
{
if(at(z)->maxEpisode() > iMax)
iMax = at(z)->maxEpisode();
}
if(iMax < 0)
return(0);
return(iMax);
}
+137
View File
@@ -0,0 +1,137 @@
#ifndef CSERIE_H
#define CSERIE_H
#include "cseason.h"
#include <QMetaType>
#include <QDate>
#include <QSqlDatabase>
class cSerie
{
public:
cSerie();
void setSeriesName(const QString& szSeriesName);
QString seriesName();
void setSeriesID(const qint32& iSeriesID);
qint32 seriesID();
void setLanguage(const QString& szLanguage);
QString language();
void setBanner(const QString& szBanner);
QString banner();
void setOverview(const QString& szOverview);
QString overview();
void setFirstAired(const QString& szFirstAired);
void setFirstAired(const QDate& firstAired);
QDate firstAired();
void setNetwork(const QString& szNetwork);
QString network();
void setIMDBID(const QString& szIMDBID);
QString imdbID();
void setID(const qint32& iID);
qint32 id();
void setActors(const QString& szActors);
void setActors(const QStringList& szActors);
QStringList actors();
void setContentRating(const QString& szContentRating);
QString contentRating();
void setGenre(const QString& szGenre);
void setGenre(const QStringList& szGenre);
QStringList genre();
void setRating(const qreal& dRating);
qreal rating();
void setRatingCount(const qint16& iRatingCount);
qint16 ratingCount();
void setRuntime(const qint16& iRuntime);
qint16 runime();
void setStatus(const QString& szStatus);
QString status();
void setDownload(const QString& szDownload);
QString download();
void setCliffhanger(const bool& bCliffhanger);
bool cliffhanger();
cSeason* addSeason(const qint16& iSeason);
QList<cSeason*> seasonList();
cSeason* findSeason(const qint16& iSeason);
qint16 minSeason();
qint16 maxSeason();
qint16 maxEpisode();
cEpisode* findEpisode(const qint32& id);
bool isValid();
bool save(QSqlDatabase& db);
bool del(QSqlDatabase& db);
void allInit();
void allProgress();
void allDone();
void seasonInit(QPushButton* lpButton);
void seasonProgress(QPushButton* lpButton);
void seasonDone(QPushButton* lpButton);
void updateState();
void deleteResources();
private:
QString m_szSeriesName;
qint32 m_iSeriesID;
QString m_szLanguage;
QString m_szBanner;
QString m_szOverview;
QDate m_firstAired;
QString m_szNetwork;
QString m_szIMDBID;
qint32 m_iID;
QStringList m_szActors;
QString m_szContentRating;
QStringList m_szGenre;
qreal m_dRating;
qint16 m_iRatingCount;
qint16 m_iRuntime;
QString m_szStatus;
QString m_szDownload;
bool m_bCliffhanger;
QList<cSeason*> m_seasonList;
};
Q_DECLARE_METATYPE(cSerie*)
class cSerieList : public QList<cSerie*>
{
public:
cSerie* add(const qint32& iID);
cSerie* add(cSerie* lpSerie);
qint16 minSeason();
qint16 maxSeason();
qint16 maxEpisode();
};
#endif // CSERIE_H
+230
View File
@@ -0,0 +1,230 @@
#include "cthetvdb.h"
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QEventLoop>
#include <QUrlQuery>
#include <QBuffer>
cTheTVDB::cTheTVDB()
{
}
// BC0893B659680049
// Mirrors: http://thetvdb.com/api/BC0893B659680049/mirrors.xml
// Server time: http://thetvdb.com/api/Updates.php?type=none
// Search: http://thetvdb.com/api/GetSeries.php?seriesname=outer limits&language=all
// Episodes: http://thetvdb.com/api/BC0893B659680049/series/72224/all/de.xml
// Banner: http://thetvdb.com/banners/graphical/77092-g3.jpg // 758 x 140
// Banner: http://thetvdb.com/banners/graphical/77544-g2.jpg
// Banner: http://thetvdb.com/banners/graphical/210841-g10.jpg
QList<cSerie*> cTheTVDB::search(const QString& szSerie, const QString& szLanguage)
{
QList<cSerie*> serieList;
QNetworkAccessManager networkManager;
cSerie* lpNew;
QNetworkRequest request(QUrl(QString("http://thetvdb.com/api/GetSeries.php?seriesname=%1&language=%2").arg(szSerie).arg(szLanguage)));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/xml");
QNetworkReply* reply = networkManager.get(request);
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QByteArray szData = reply->readAll();
delete reply;
QDomDocument doc;
QString errorStr;
int errorLine;
int errorColumn;
if(!doc.setContent(szData, false, &errorStr, &errorLine, &errorColumn))
return(serieList);
QDomElement root = doc.documentElement();
if(root.tagName().compare("Data", Qt::CaseInsensitive))
return(serieList);
QDomNode child = root.firstChild();
while(!child.isNull())
{
if(!child.toElement().tagName().compare("Series", Qt::CaseInsensitive))
{
lpNew = parseSeries(child.toElement());
if(lpNew)
serieList.append(lpNew);
}
child = child.nextSibling();
}
return(serieList);
}
cSerie* cTheTVDB::parseSeries(const QDomElement& element)
{
cSerie* lpNew = new cSerie;
QDomNode child = element.firstChild();
while(!child.isNull())
{
if(!child.toElement().tagName().compare("SeriesName", Qt::CaseInsensitive))
lpNew->setSeriesName(child.toElement().text());
else if(!child.toElement().tagName().compare("seriesid", Qt::CaseInsensitive))
lpNew->setSeriesID(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("language", Qt::CaseInsensitive))
lpNew->setLanguage(child.toElement().text());
else if(!child.toElement().tagName().compare("banner", Qt::CaseInsensitive))
lpNew->setBanner(child.toElement().text());
else if(!child.toElement().tagName().compare("Overview", Qt::CaseInsensitive))
lpNew->setOverview(child.toElement().text());
else if(!child.toElement().tagName().compare("FirstAired", Qt::CaseInsensitive))
lpNew->setFirstAired(child.toElement().text());
else if(!child.toElement().tagName().compare("Network", Qt::CaseInsensitive))
lpNew->setNetwork(child.toElement().text());
else if(!child.toElement().tagName().compare("IMDB_ID", Qt::CaseInsensitive))
lpNew->setIMDBID(child.toElement().text());
else if(!child.toElement().tagName().compare("id", Qt::CaseInsensitive))
lpNew->setID(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("Actors", Qt::CaseInsensitive))
lpNew->setActors(child.toElement().text());
else if(!child.toElement().tagName().compare("ContentRating", Qt::CaseInsensitive))
lpNew->setContentRating(child.toElement().text());
else if(!child.toElement().tagName().compare("Genre", Qt::CaseInsensitive))
lpNew->setGenre(child.toElement().text());
else if(!child.toElement().tagName().compare("Rating", Qt::CaseInsensitive))
lpNew->setRating(child.toElement().text().toDouble());
else if(!child.toElement().tagName().compare("RatingCount", Qt::CaseInsensitive))
lpNew->setRatingCount(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("Runtime", Qt::CaseInsensitive))
lpNew->setRuntime(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("Status", Qt::CaseInsensitive))
lpNew->setStatus(child.toElement().text());
child = child.nextSibling();
}
if(lpNew->isValid())
return(lpNew);
delete lpNew;
return(0);
}
cSerie* cTheTVDB::load(const qint32 &iID, const QString &szLanguage)
{
cSerie* lpSerie = 0;
QNetworkAccessManager networkManager;
QNetworkRequest request(QUrl(QString("http://thetvdb.com/api/BC0893B659680049/series/%1/all/%2.xml").arg(iID).arg(szLanguage)));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/xml");
QNetworkReply* reply = networkManager.get(request);
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QByteArray szData = reply->readAll();
delete reply;
QDomDocument doc;
QString errorStr;
int errorLine;
int errorColumn;
if(!doc.setContent(szData, false, &errorStr, &errorLine, &errorColumn))
return(lpSerie);
QDomElement root = doc.documentElement();
if(root.tagName().compare("Data", Qt::CaseInsensitive))
return(lpSerie);
QDomNode child = root.firstChild();
while(!child.isNull())
{
if(!child.toElement().tagName().compare("Series", Qt::CaseInsensitive))
{
lpSerie = parseSeries(child.toElement());
if(!lpSerie)
return(lpSerie);
}
else if(!child.toElement().tagName().compare("Episode", Qt::CaseInsensitive))
parseEpisode(lpSerie, child.toElement());
child = child.nextSibling();
}
return(lpSerie);
}
void cTheTVDB::parseEpisode(cSerie* lpSerie, const QDomElement& element)
{
cSeason* lpSeason = 0;
cEpisode* lpEpisode = new cEpisode;
QDomNode child = element.firstChild();
while(!child.isNull())
{
if(!child.toElement().tagName().compare("id", Qt::CaseInsensitive))
lpEpisode->setID(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("Director", Qt::CaseInsensitive))
lpEpisode->setDirector(child.toElement().text());
else if(!child.toElement().tagName().compare("EpisodeName", Qt::CaseInsensitive))
lpEpisode->setEpisodeName(child.toElement().text());
else if(!child.toElement().tagName().compare("EpisodeNumber", Qt::CaseInsensitive))
lpEpisode->setEpisodeNumber(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("FirstAired", Qt::CaseInsensitive))
lpEpisode->setFirstAired(child.toElement().text());
else if(!child.toElement().tagName().compare("GuestStars", Qt::CaseInsensitive))
lpEpisode->setGuestStars(child.toElement().text());
else if(!child.toElement().tagName().compare("IMDB_ID", Qt::CaseInsensitive))
lpEpisode->setIMDBID(child.toElement().text());
else if(!child.toElement().tagName().compare("Language", Qt::CaseInsensitive))
lpEpisode->setLanguage(child.toElement().text());
else if(!child.toElement().tagName().compare("Overview", Qt::CaseInsensitive))
lpEpisode->setOverview(child.toElement().text());
else if(!child.toElement().tagName().compare("ProductionCode", Qt::CaseInsensitive))
lpEpisode->setProductionCode(child.toElement().text());
else if(!child.toElement().tagName().compare("Rating", Qt::CaseInsensitive))
lpEpisode->setRating(child.toElement().text().toDouble());
else if(!child.toElement().tagName().compare("RatingCount", Qt::CaseInsensitive))
lpEpisode->setRatingCount(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("SeasonNumber", Qt::CaseInsensitive))
lpEpisode->setSeasonNumber(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("Writer", Qt::CaseInsensitive))
lpEpisode->setWriter(child.toElement().text());
else if(!child.toElement().tagName().compare("seasonid", Qt::CaseInsensitive))
lpEpisode->setSeasonID(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("seriesid", Qt::CaseInsensitive))
lpEpisode->setSeriesID(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("filename", Qt::CaseInsensitive))
lpEpisode->setFileName(child.toElement().text());
else if(!child.toElement().tagName().compare("thumb_height", Qt::CaseInsensitive))
lpEpisode->setThumbHeight(child.toElement().text().toInt());
else if(!child.toElement().tagName().compare("thumb_width", Qt::CaseInsensitive))
lpEpisode->setThumbWidth(child.toElement().text().toInt());
child = child.nextSibling();
}
if(!lpEpisode->isValid())
{
delete lpEpisode;
return;
}
lpSeason = lpSerie->findSeason(lpEpisode->seasonNumber());
if(!lpSeason)
lpSeason = lpSerie->addSeason(lpEpisode->seasonNumber());
if(!lpSeason)
{
delete lpEpisode;
return;
}
lpSeason->addEpisode(lpEpisode);
}
+24
View File
@@ -0,0 +1,24 @@
#ifndef CTHETVDB_H
#define CTHETVDB_H
#include "cserie.h"
#include <QList>
#include <QStringList>
#include <QDomDocument>
class cTheTVDB
{
public:
cTheTVDB();
QList<cSerie*> search(const QString& szSerie, const QString& szLanguage = "all");
cSerie* load(const qint32 &iID, const QString& szLanguage);
private:
cSerie* parseSeries(const QDomElement& element);
void parseEpisode(cSerie* lpSerie, const QDomElement& element);
};
#endif // CTHETVDB_H
+71
View File
@@ -0,0 +1,71 @@
#include "cupdatethread.h"
#include "cserie.h"
#include "cseason.h"
#include "cepisode.h"
#include "cthetvdb.h"
#include "cmessagedialog.h"
#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();
for(int x = 0;x < m_items.count();x++)
{
cSerie* lpSerie = m_items.at(x)->data(0, Qt::UserRole).value<cSerie*>();
if(lpSerie)
{
emit updateMessage(lpSerie->seriesName(), x);
cTheTVDB tvDB;
cSerie* lpSerieNew;
if(lpSerie->seriesID() != -1)
{
lpSerieNew = tvDB.load(lpSerie->id(), "de");
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());
}
}
lpSerie->del(m_db);
lpSerieNew->save(m_db);
}
}
QMutexLocker locker(&m_mutex);
if(m_bStop)
break;
msleep(10);
}
}
void cUpdateThread::setData(cMessageDialog* lpMessageDialog, const QList<QTreeWidgetItem*>& items, const QSqlDatabase& db)
{
connect(lpMessageDialog->cancelButton(), SIGNAL(clicked()), this, SLOT(stop()));
m_items = items;
m_db = db;
}
+39
View File
@@ -0,0 +1,39 @@
#ifndef CUPDATETHREAD_H
#define CUPDATETHREAD_H
#include "cmessagedialog.h"
#include <QThread>
#include <QMutexLocker>
#include <QList>
#include <QTreeWidgetItem>
#include <QSqlDatabase>
class cUpdateThread : public QThread
{
Q_OBJECT
public:
explicit cUpdateThread();
void setData(cMessageDialog *lpMessageDialog, const QList<QTreeWidgetItem*>& items, 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;
QList<QTreeWidgetItem*> m_items;
QSqlDatabase m_db;
QWidget* m_lpParent;
void run();
};
#endif // CUPDATETHREAD_H
+38
View File
@@ -0,0 +1,38 @@
#include "cverticallabel.h"
#include <QPainter>
cVerticalLabel::cVerticalLabel(QWidget *parent)
: QLabel(parent)
{
}
cVerticalLabel::cVerticalLabel(const QString &text, QWidget *parent)
: QLabel(text, parent)
{
}
void cVerticalLabel::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(Qt::black);
painter.setBrush(Qt::Dense1Pattern);
painter.translate(sizeHint().width(), sizeHint().height());
painter.rotate(270);
painter.drawText(0,0, text());
}
QSize cVerticalLabel::minimumSizeHint() const
{
QSize s = QLabel::minimumSizeHint();
return QSize(s.height(), s.width());
}
QSize cVerticalLabel::sizeHint() const
{
QSize s = QLabel::sizeHint();
return QSize(s.height(), s.width());
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef CVERTICALLABEL_H
#define CVERTICALLABEL_H
#include <QLabel>
class cVerticalLabel : public QLabel
{
Q_OBJECT
public:
explicit cVerticalLabel(QWidget *parent = 0);
explicit cVerticalLabel(const QString &text, QWidget *parent=0);
signals:
protected:
void paintEvent(QPaintEvent*);
QSize sizeHint() const ;
QSize minimumSizeHint() const;
public slots:
private:
};
#endif // CVERTICALLABEL_H
BIN
View File
Binary file not shown.
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Actors>
<Actor>
<id>316405</id>
<Image></Image>
<Name>Kevin Conway</Name>
<Role>Control Voice</Role>
<SortOrder>3</SortOrder>
</Actor>
</Actors>
+428
View File
@@ -0,0 +1,428 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Banners>
<Banner>
<id>1065691</id>
<BannerPath>fanart/original/72224-1.jpg</BannerPath>
<BannerType>fanart</BannerType>
<BannerType2>1280x720</BannerType2>
<Colors></Colors>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>2</RatingCount>
<SeriesName>false</SeriesName>
<ThumbnailPath>_cache/fanart/original/72224-1.jpg</ThumbnailPath>
<VignettePath>fanart/vignette/72224-1.jpg</VignettePath>
</Banner>
<Banner>
<id>887842</id>
<BannerPath>fanart/original/72224-6.jpg</BannerPath>
<BannerType>fanart</BannerType>
<BannerType2>1280x720</BannerType2>
<Colors></Colors>
<Language>en</Language>
<Rating>9.6667</Rating>
<RatingCount>3</RatingCount>
<SeriesName>true</SeriesName>
<ThumbnailPath>_cache/fanart/original/72224-6.jpg</ThumbnailPath>
<VignettePath>fanart/vignette/72224-6.jpg</VignettePath>
</Banner>
<Banner>
<id>28625</id>
<BannerPath>fanart/original/72224-2.jpg</BannerPath>
<BannerType>fanart</BannerType>
<BannerType2>1280x720</BannerType2>
<Colors></Colors>
<Language>en</Language>
<Rating>5.5714</Rating>
<RatingCount>7</RatingCount>
<SeriesName>false</SeriesName>
<ThumbnailPath>_cache/fanart/original/72224-2.jpg</ThumbnailPath>
<VignettePath>fanart/vignette/72224-2.jpg</VignettePath>
</Banner>
<Banner>
<id>39152</id>
<BannerPath>fanart/original/72224-5.jpg</BannerPath>
<BannerType>fanart</BannerType>
<BannerType2>1280x720</BannerType2>
<Colors>|233,229,226|186,183,178|139,135,134|</Colors>
<Language>en</Language>
<Rating>4.0000</Rating>
<RatingCount>5</RatingCount>
<SeriesName>false</SeriesName>
<ThumbnailPath>_cache/fanart/original/72224-5.jpg</ThumbnailPath>
<VignettePath>fanart/vignette/72224-5.jpg</VignettePath>
</Banner>
<Banner>
<id>28627</id>
<BannerPath>fanart/original/72224-3.jpg</BannerPath>
<BannerType>fanart</BannerType>
<BannerType2>1280x720</BannerType2>
<Colors></Colors>
<Language>en</Language>
<Rating>3.2500</Rating>
<RatingCount>4</RatingCount>
<SeriesName>false</SeriesName>
<ThumbnailPath>_cache/fanart/original/72224-3.jpg</ThumbnailPath>
<VignettePath>fanart/vignette/72224-3.jpg</VignettePath>
</Banner>
<Banner>
<id>29656</id>
<BannerPath>fanart/original/72224-4.jpg</BannerPath>
<BannerType>fanart</BannerType>
<BannerType2>1280x720</BannerType2>
<Colors></Colors>
<Language>en</Language>
<Rating>3.0000</Rating>
<RatingCount>3</RatingCount>
<SeriesName>false</SeriesName>
<ThumbnailPath>_cache/fanart/original/72224-4.jpg</ThumbnailPath>
<VignettePath>fanart/vignette/72224-4.jpg</VignettePath>
</Banner>
<Banner>
<id>1066059</id>
<BannerPath>posters/72224-5.jpg</BannerPath>
<BannerType>poster</BannerType>
<BannerType2>680x1000</BannerType2>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>1</RatingCount>
</Banner>
<Banner>
<id>1065692</id>
<BannerPath>posters/72224-3.jpg</BannerPath>
<BannerType>poster</BannerType>
<BannerType2>680x1000</BannerType2>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>1</RatingCount>
</Banner>
<Banner>
<id>29000</id>
<BannerPath>posters/72224-1.jpg</BannerPath>
<BannerType>poster</BannerType>
<BannerType2>680x1000</BannerType2>
<Language>en</Language>
<Rating>9.0000</Rating>
<RatingCount>8</RatingCount>
</Banner>
<Banner>
<id>876245</id>
<BannerPath>posters/72224-2.jpg</BannerPath>
<BannerType>poster</BannerType>
<BannerType2>680x1000</BannerType2>
<Language>en</Language>
<Rating>6.0000</Rating>
<RatingCount>4</RatingCount>
</Banner>
<Banner>
<id>1065971</id>
<BannerPath>seasons/72224-7-3.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>1</RatingCount>
<Season>7</Season>
</Banner>
<Banner>
<id>1012015</id>
<BannerPath>seasons/72224-5-2.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>2</RatingCount>
<Season>5</Season>
</Banner>
<Banner>
<id>1012008</id>
<BannerPath>seasons/72224-4-2.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>2</RatingCount>
<Season>4</Season>
</Banner>
<Banner>
<id>1012014</id>
<BannerPath>seasons/72224-3-2.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>2</RatingCount>
<Season>3</Season>
</Banner>
<Banner>
<id>1012009</id>
<BannerPath>seasons/72224-2-2.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>2</RatingCount>
<Season>2</Season>
</Banner>
<Banner>
<id>1065972</id>
<BannerPath>seasons/72224-6-3.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>1</RatingCount>
<Season>6</Season>
</Banner>
<Banner>
<id>1012013</id>
<BannerPath>seasons/72224-1-4.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>10.0000</Rating>
<RatingCount>2</RatingCount>
<Season>1</Season>
</Banner>
<Banner>
<id>7592</id>
<BannerPath>seasons/172-1.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>9.0000</Rating>
<RatingCount>1</RatingCount>
<Season>1</Season>
</Banner>
<Banner>
<id>7598</id>
<BannerPath>seasons/172-7.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>9.0000</Rating>
<RatingCount>1</RatingCount>
<Season>7</Season>
</Banner>
<Banner>
<id>7596</id>
<BannerPath>seasons/172-5.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>9.0000</Rating>
<RatingCount>2</RatingCount>
<Season>5</Season>
</Banner>
<Banner>
<id>7594</id>
<BannerPath>seasons/172-3.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>9.0000</Rating>
<RatingCount>1</RatingCount>
<Season>3</Season>
</Banner>
<Banner>
<id>7593</id>
<BannerPath>seasons/172-2.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>9.0000</Rating>
<RatingCount>1</RatingCount>
<Season>2</Season>
</Banner>
<Banner>
<id>7597</id>
<BannerPath>seasons/172-6.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>8.5000</Rating>
<RatingCount>2</RatingCount>
<Season>6</Season>
</Banner>
<Banner>
<id>7595</id>
<BannerPath>seasons/172-4.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>en</Language>
<Rating>8.5000</Rating>
<RatingCount>2</RatingCount>
<Season>4</Season>
</Banner>
<Banner>
<id>27333</id>
<BannerPath>seasons/72224-1.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>es</Language>
<Rating>8.0000</Rating>
<RatingCount>1</RatingCount>
<Season>1</Season>
</Banner>
<Banner>
<id>887839</id>
<BannerPath>seasons/72224-1-3.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>de</Language>
<Rating>6.0000</Rating>
<RatingCount>1</RatingCount>
<Season>1</Season>
</Banner>
<Banner>
<id>27412</id>
<BannerPath>seasons/72224-6.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>es</Language>
<Rating>1.0000</Rating>
<RatingCount>1</RatingCount>
<Season>6</Season>
</Banner>
<Banner>
<id>27407</id>
<BannerPath>seasons/72224-1-2.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>es</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
<Season>1</Season>
</Banner>
<Banner>
<id>27410</id>
<BannerPath>seasons/72224-4.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>es</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
<Season>4</Season>
</Banner>
<Banner>
<id>27411</id>
<BannerPath>seasons/72224-5.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>es</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
<Season>5</Season>
</Banner>
<Banner>
<id>27413</id>
<BannerPath>seasons/72224-7.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>es</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
<Season>7</Season>
</Banner>
<Banner>
<id>27409</id>
<BannerPath>seasons/72224-3.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>es</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
<Season>3</Season>
</Banner>
<Banner>
<id>27408</id>
<BannerPath>seasons/72224-2.jpg</BannerPath>
<BannerType>season</BannerType>
<BannerType2>season</BannerType2>
<Language>es</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
<Season>2</Season>
</Banner>
<Banner>
<id>9536</id>
<BannerPath>graphical/72224-g.jpg</BannerPath>
<BannerType>series</BannerType>
<BannerType2>graphical</BannerType2>
<Language>en</Language>
<Rating>7.7500</Rating>
<RatingCount>4</RatingCount>
</Banner>
<Banner>
<id>21494</id>
<BannerPath>graphical/72224-g2.jpg</BannerPath>
<BannerType>series</BannerType>
<BannerType2>graphical</BannerType2>
<Language>en</Language>
<Rating>5.5000</Rating>
<RatingCount>2</RatingCount>
</Banner>
<Banner>
<id>6449</id>
<BannerPath>graphical/172-g.jpg</BannerPath>
<BannerType>series</BannerType>
<BannerType2>graphical</BannerType2>
<Language>en</Language>
<Rating>4.0000</Rating>
<RatingCount>2</RatingCount>
</Banner>
<Banner>
<id>5337</id>
<BannerPath>text/172.jpg</BannerPath>
<BannerType>series</BannerType>
<BannerType2>text</BannerType2>
<Language>en</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
</Banner>
<Banner>
<id>1078125</id>
<BannerPath>graphical/72224-g6.jpg</BannerPath>
<BannerType>series</BannerType>
<BannerType2>graphical</BannerType2>
<Language>en</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
</Banner>
<Banner>
<id>1078123</id>
<BannerPath>graphical/72224-g4.jpg</BannerPath>
<BannerType>series</BannerType>
<BannerType2>graphical</BannerType2>
<Language>en</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
</Banner>
<Banner>
<id>1078122</id>
<BannerPath>graphical/72224-g3.jpg</BannerPath>
<BannerType>series</BannerType>
<BannerType2>graphical</BannerType2>
<Language>en</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
</Banner>
<Banner>
<id>1078124</id>
<BannerPath>graphical/72224-g5.jpg</BannerPath>
<BannerType>series</BannerType>
<BannerType2>graphical</BannerType2>
<Language>en</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
</Banner>
<Banner>
<id>1078126</id>
<BannerPath>graphical/72224-g7.jpg</BannerPath>
<BannerType>series</BannerType>
<BannerType2>graphical</BannerType2>
<Language>en</Language>
<Rating></Rating>
<RatingCount>0</RatingCount>
</Banner>
</Banners>
+4975
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
#include "cmainwindow.h"
#include <QApplication>
#include <QSettings>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication::setOrganizationName("WIN-DESIGN");
QCoreApplication::setOrganizationDomain("windesign.at");
QCoreApplication::setApplicationName("qtSerien");
QSettings settings;
cMainWindow w;
if(settings.value("main/maximized").toBool())
w.showMaximized();
else
w.show();
return a.exec();
}
+61
View File
@@ -0,0 +1,61 @@
#-------------------------------------------------
#
# Project created by QtCreator 2016-02-16T11:33:54
#
#-------------------------------------------------
QT += core gui network xml sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qtSerien
TEMPLATE = app
SOURCES += main.cpp\
cmainwindow.cpp \
cthetvdb.cpp \
cserie.cpp \
cseasondelegate.cpp \
cseason.cpp \
cepisode.cpp \
csearch.cpp \
cmessageanimatedialog.cpp \
cedit.cpp \
cimage.cpp \
cseasondetails.cpp \
cverticallabel.cpp \
cepisodedetails.cpp \
cmessagedialog.cpp \
cupdatethread.cpp \
cpicturesthread.cpp
HEADERS += cmainwindow.h \
cthetvdb.h \
cserie.h \
cseasondelegate.h \
cseason.h \
cepisode.h \
csearch.h \
cmessageanimatedialog.h \
cedit.h \
cimage.h \
cseasondetails.h \
cverticallabel.h \
cepisodedetails.h \
cmessagedialog.h \
cupdatethread.h \
cpicturesthread.h
FORMS += cmainwindow.ui \
csearch.ui \
cmessageanimatedialog.ui \
cedit.ui \
cseasondetails.ui \
cepisodedetails.ui \
cmessagedialog.ui
DISTFILES +=
RESOURCES += \
resource.qrc
+6
View File
@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>empty.db</file>
<file>128279.png</file>
</qresource>
</RCC>