implemented export dialog
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#include "cexportdialog.h"
|
||||
#include "ui_cexportdialog.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
cExportDialog::cExportDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::cExportDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QSettings settings;
|
||||
QString szExportSerie = settings.value("exportSeriePath", QDir::homePath()).toString();
|
||||
QString szExportMovie = settings.value("exportMoviePath", QDir::homePath()).toString();
|
||||
bool bExportSerie = settings.value("exportSerie", QDir::homePath()).toBool();
|
||||
bool bExportMovie = settings.value("exportMovie", QDir::homePath()).toBool();
|
||||
|
||||
ui->m_lpExportSeries->setChecked(bExportSerie);
|
||||
ui->m_lpExportMovies->setChecked(bExportMovie);
|
||||
ui->m_lpSeriesPath->setText(szExportSerie);
|
||||
ui->m_lpMoviesPath->setText(szExportMovie);
|
||||
}
|
||||
|
||||
cExportDialog::~cExportDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cExportDialog::on_m_lpSeriesPathSelect_clicked()
|
||||
{
|
||||
QString szFile = QFileDialog::getSaveFileName(this, tr("export Serie"), ui->m_lpSeriesPath->text(), tr("XML Files (*.xml)"));
|
||||
|
||||
if(szFile.isEmpty())
|
||||
return;
|
||||
|
||||
ui->m_lpSeriesPath->setText(szFile);
|
||||
}
|
||||
|
||||
void cExportDialog::on_m_lpMoviesPathSelect_clicked()
|
||||
{
|
||||
QString szFile = QFileDialog::getSaveFileName(this, tr("export Serie"), ui->m_lpMoviesPath->text(), tr("XML Files (*.xml)"));
|
||||
|
||||
if(szFile.isEmpty())
|
||||
return;
|
||||
|
||||
ui->m_lpMoviesPath->setText(szFile);
|
||||
}
|
||||
|
||||
void cExportDialog::values(bool& bSeries, QString& szSeriesPath, bool& bMovies, QString& szMoviesPath)
|
||||
{
|
||||
bSeries = ui->m_lpExportSeries->checkState() == Qt::Checked;
|
||||
szSeriesPath = ui->m_lpSeriesPath->text();
|
||||
bMovies = ui->m_lpExportMovies->checkState() == Qt::Checked;
|
||||
szMoviesPath = ui->m_lpMoviesPath->text();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef CEXPORTDIALOG_H
|
||||
#define CEXPORTDIALOG_H
|
||||
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cExportDialog;
|
||||
}
|
||||
|
||||
class cExportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cExportDialog(QWidget *parent = 0);
|
||||
~cExportDialog();
|
||||
|
||||
void values(bool& bSeries, QString& szSeriesPath, bool& bMovies, QString& szMoviesPath);
|
||||
private slots:
|
||||
void on_m_lpSeriesPathSelect_clicked();
|
||||
void on_m_lpMoviesPathSelect_clicked();
|
||||
|
||||
private:
|
||||
Ui::cExportDialog *ui;
|
||||
};
|
||||
|
||||
#endif // CEXPORTDIALOG_H
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cExportDialog</class>
|
||||
<widget class="QDialog" name="cExportDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>99</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Export</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_lpExportSeries">
|
||||
<property name="text">
|
||||
<string>Series</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_lpSeriesPath"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="m_lpSeriesPathSelect">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_lpExportMovies">
|
||||
<property name="text">
|
||||
<string>Movies</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_lpMoviesPath"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="m_lpMoviesPathSelect">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>cExportDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>cExportDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
+105
-63
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "cmovieviewitemdelegate.h"
|
||||
|
||||
#include "cexportdialog.h"
|
||||
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@@ -82,9 +84,12 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
||||
m_lpShortcutAdd(0),
|
||||
m_lpShortcutFind(0),
|
||||
m_szFind(""),
|
||||
m_szFindMovie("")
|
||||
m_szFindMovie(""),
|
||||
m_lpFileMenu(0),
|
||||
m_lpFileExportAction(0),
|
||||
m_lpFileExitAction(0)
|
||||
{
|
||||
m_timer.start();
|
||||
// m_timer.start();
|
||||
|
||||
QSettings settings;
|
||||
|
||||
@@ -95,6 +100,14 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
m_lpFileMenu = menuBar()->addMenu(tr("&File"));
|
||||
|
||||
m_lpFileExportAction = m_lpFileMenu->addAction(tr("&Export"), this, &cMainWindow::onActionExport);
|
||||
m_lpFileExportAction->setShortcut(Qt::CTRL + Qt::Key_E);
|
||||
|
||||
m_lpFileExportAction = m_lpFileMenu->addAction(tr("E&xit"), this, &cMainWindow::onActionExit);
|
||||
m_lpFileExportAction->setShortcut(Qt::CTRL + Qt::Key_X);
|
||||
|
||||
ui->m_lpMainTab->setCurrentIndex(0);
|
||||
ui->m_lpSeriesFilter->setChecked(settings.value("seriesFilter/enabled", QVariant::fromValue(false)).toBool());
|
||||
ui->m_lpSeriesFilterInitialized->setCheckState(static_cast<Qt::CheckState>(settings.value("seriesFilter/hasInit", (uint)Qt::PartiallyChecked).toUInt()));
|
||||
@@ -186,6 +199,15 @@ cMainWindow::~cMainWindow()
|
||||
if(m_lpShortcutFindAgain)
|
||||
delete m_lpShortcutFindAgain;
|
||||
|
||||
if(m_lpFileExportAction)
|
||||
delete m_lpFileExportAction;
|
||||
|
||||
if(m_lpFileExitAction)
|
||||
delete m_lpFileExitAction;
|
||||
|
||||
if(m_lpFileMenu)
|
||||
delete m_lpFileMenu;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -1450,81 +1472,96 @@ void cMainWindow::onActionMovieUpdate()
|
||||
|
||||
void cMainWindow::onActionExport()
|
||||
{
|
||||
QSettings settings;
|
||||
QString szExportSerie = settings.value("exportSerie", QDir::homePath()).toString();
|
||||
QString szFileSerie = QFileDialog::getSaveFileName(this, tr("export Serie"), szExportSerie, tr("XML Files (*.xml)"));
|
||||
cExportDialog* lpExportDialog = new cExportDialog(this);
|
||||
|
||||
if(szFileSerie.isEmpty())
|
||||
return;
|
||||
int x;
|
||||
|
||||
settings.setValue("exportSerie", szFileSerie);
|
||||
|
||||
QFile fileSerie(szFileSerie);
|
||||
fileSerie.open(QIODevice::WriteOnly);
|
||||
QXmlStreamWriter xmlWriterSerie(&fileSerie);
|
||||
|
||||
xmlWriterSerie.setAutoFormatting(true);
|
||||
xmlWriterSerie.writeStartDocument();
|
||||
|
||||
xmlWriterSerie.writeStartElement("series");
|
||||
|
||||
for(int x = 0;x < m_serieList.count();x++)
|
||||
if(x = lpExportDialog->exec() == QDialog::Rejected)
|
||||
{
|
||||
cSerie* lpSerie = m_serieList.at(x);
|
||||
delete lpExportDialog;
|
||||
return;
|
||||
}
|
||||
|
||||
xmlWriterSerie.writeStartElement("serie");
|
||||
xmlWriterSerie.writeTextElement("seriesName", lpSerie->seriesName());
|
||||
xmlWriterSerie.writeTextElement("seriesID", QString("%1").arg(lpSerie->seriesID()));
|
||||
xmlWriterSerie.writeTextElement("seriesOverview", lpSerie->overview());
|
||||
xmlWriterSerie.writeTextElement("seriesYear", QString("%1").arg(lpSerie->firstAired().year()));
|
||||
if(lpSerie->hasProgress() || lpSerie->hasDone())
|
||||
xmlWriterSerie.writeTextElement("seriesStarted", "true");
|
||||
else
|
||||
xmlWriterSerie.writeTextElement("seriesStarted", "false");
|
||||
QSettings settings;
|
||||
bool bExportSerie;
|
||||
QString szFileSerie;
|
||||
bool bExportMovie;
|
||||
QString szFileMovie;
|
||||
|
||||
lpExportDialog->values(bExportSerie, szFileSerie, bExportMovie, szFileMovie);
|
||||
delete lpExportDialog;
|
||||
|
||||
settings.setValue("exportSeriePath", szFileSerie);
|
||||
settings.setValue("exportMoviePath", szFileMovie);
|
||||
settings.setValue("exportSerie", bExportSerie);
|
||||
settings.setValue("exportMovie", bExportMovie);
|
||||
|
||||
if(!szFileSerie.isEmpty() && bExportSerie)
|
||||
{
|
||||
QFile fileSerie(szFileSerie);
|
||||
fileSerie.open(QIODevice::WriteOnly);
|
||||
QXmlStreamWriter xmlWriterSerie(&fileSerie);
|
||||
|
||||
xmlWriterSerie.setAutoFormatting(true);
|
||||
xmlWriterSerie.writeStartDocument();
|
||||
|
||||
xmlWriterSerie.writeStartElement("series");
|
||||
|
||||
for(int x = 0;x < m_serieList.count();x++)
|
||||
{
|
||||
cSerie* lpSerie = m_serieList.at(x);
|
||||
|
||||
xmlWriterSerie.writeStartElement("serie");
|
||||
xmlWriterSerie.writeTextElement("seriesName", lpSerie->seriesName());
|
||||
xmlWriterSerie.writeTextElement("seriesID", QString("%1").arg(lpSerie->seriesID()));
|
||||
xmlWriterSerie.writeTextElement("seriesOverview", lpSerie->overview());
|
||||
xmlWriterSerie.writeTextElement("seriesYear", QString("%1").arg(lpSerie->firstAired().year()));
|
||||
if(lpSerie->hasProgress() || lpSerie->hasDone())
|
||||
xmlWriterSerie.writeTextElement("seriesStarted", "true");
|
||||
else
|
||||
xmlWriterSerie.writeTextElement("seriesStarted", "false");
|
||||
|
||||
xmlWriterSerie.writeEndElement();
|
||||
}
|
||||
|
||||
xmlWriterSerie.writeEndElement();
|
||||
fileSerie.close();
|
||||
}
|
||||
|
||||
xmlWriterSerie.writeEndElement();
|
||||
fileSerie.close();
|
||||
|
||||
QString szExportMovie = settings.value("exportMovie", QDir::homePath()).toString();
|
||||
QString szFileMovie = QFileDialog::getSaveFileName(this, tr("export Movie"), szExportMovie, tr("XML Files (*.xml)"));
|
||||
QFile fileMovie(szFileMovie);
|
||||
|
||||
if(szFileMovie.isEmpty())
|
||||
return;
|
||||
|
||||
settings.setValue("exportMovie", szFileMovie);
|
||||
|
||||
fileMovie.open(QIODevice::WriteOnly);
|
||||
QXmlStreamWriter xmlWriterMovie(&fileMovie);
|
||||
|
||||
xmlWriterMovie.setAutoFormatting(true);
|
||||
xmlWriterMovie.writeStartDocument();
|
||||
|
||||
xmlWriterMovie.writeStartElement("movies");
|
||||
|
||||
for(int x = 0;x < m_movieList.count();x++)
|
||||
if(!szFileMovie.isEmpty() && bExportMovie)
|
||||
{
|
||||
cMovie* lpMovie = m_movieList.at(x);
|
||||
QFile fileMovie(szFileMovie);
|
||||
fileMovie.open(QIODevice::WriteOnly);
|
||||
QXmlStreamWriter xmlWriterMovie(&fileMovie);
|
||||
|
||||
xmlWriterMovie.writeStartElement("movie");
|
||||
xmlWriterMovie.writeTextElement("movieTitle", lpMovie->movieTitle());
|
||||
xmlWriterMovie.writeTextElement("movieID", QString("%1").arg(lpMovie->movieID()));
|
||||
xmlWriterMovie.writeTextElement("movieOverview", lpMovie->overview());
|
||||
xmlWriterMovie.writeTextElement("movieYear", QString("%1").arg(lpMovie->releaseDate().year()));
|
||||
if(lpMovie->state() == cMovie::StateDone || lpMovie->state() == cMovie::StateProgress)
|
||||
xmlWriterMovie.writeTextElement("movieStarted", "true");
|
||||
else
|
||||
xmlWriterMovie.writeTextElement("movieStarted", "false");
|
||||
xmlWriterMovie.setAutoFormatting(true);
|
||||
xmlWriterMovie.writeStartDocument();
|
||||
|
||||
xmlWriterMovie.writeStartElement("movies");
|
||||
|
||||
for(int x = 0;x < m_movieList.count();x++)
|
||||
{
|
||||
cMovie* lpMovie = m_movieList.at(x);
|
||||
|
||||
xmlWriterMovie.writeStartElement("movie");
|
||||
xmlWriterMovie.writeTextElement("movieTitle", lpMovie->movieTitle());
|
||||
xmlWriterMovie.writeTextElement("movieID", QString("%1").arg(lpMovie->movieID()));
|
||||
xmlWriterMovie.writeTextElement("movieOverview", lpMovie->overview());
|
||||
xmlWriterMovie.writeTextElement("movieYear", QString("%1").arg(lpMovie->releaseDate().year()));
|
||||
if(lpMovie->state() == cMovie::StateDone || lpMovie->state() == cMovie::StateProgress)
|
||||
xmlWriterMovie.writeTextElement("movieStarted", "true");
|
||||
else
|
||||
xmlWriterMovie.writeTextElement("movieStarted", "false");
|
||||
|
||||
xmlWriterMovie.writeEndElement();
|
||||
}
|
||||
|
||||
xmlWriterMovie.writeEndElement();
|
||||
|
||||
fileMovie.close();
|
||||
}
|
||||
|
||||
xmlWriterMovie.writeEndElement();
|
||||
|
||||
fileMovie.close();
|
||||
QMessageBox::information(this, "Export", "export done");
|
||||
}
|
||||
|
||||
void cMainWindow::doUpdate(cSerieList& serieList)
|
||||
@@ -2412,3 +2449,8 @@ void cMainWindow::findMovie()
|
||||
|
||||
QMessageBox::information(this, "Find", "Nothing found.");
|
||||
}
|
||||
|
||||
void cMainWindow::onActionExit()
|
||||
{
|
||||
qApp->exit();
|
||||
}
|
||||
|
||||
+7
-1
@@ -107,6 +107,8 @@ private slots:
|
||||
void on_m_lpSeriesFilter_clicked();
|
||||
void on_m_lpMoviesFilter_clicked();
|
||||
|
||||
void onActionExit();
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui;
|
||||
cSerieList m_serieList;
|
||||
@@ -119,7 +121,7 @@ private:
|
||||
// cUpdateThread* m_lpUpdateThread;
|
||||
cPicturesThread* m_lpPicturesThread;
|
||||
|
||||
QTime m_timer;
|
||||
// QTime m_timer;
|
||||
|
||||
QStandardItemModel* m_lpSeriesListModel;
|
||||
QStandardItemModel* m_lpMoviesListModel;
|
||||
@@ -133,6 +135,10 @@ private:
|
||||
QString m_szFind;
|
||||
QString m_szFindMovie;
|
||||
|
||||
QMenu* m_lpFileMenu;
|
||||
QAction* m_lpFileExportAction;
|
||||
QAction* m_lpFileExitAction;
|
||||
|
||||
void initDB();
|
||||
void loadDB();
|
||||
|
||||
|
||||
+18
-2
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>qtSeries</string>
|
||||
<string>qtMovies</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
@@ -382,7 +382,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<widget class="QMenuBar" name="m_lpMenuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -409,6 +409,22 @@
|
||||
<string>Ctrl+F</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Export">
|
||||
<property name="text">
|
||||
<string>&Export...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+E</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionE_xit">
|
||||
<property name="text">
|
||||
<string>E&xit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+X</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
||||
+6
-3
@@ -38,7 +38,8 @@ SOURCES += main.cpp\
|
||||
cpixmapwidget.cpp \
|
||||
cfanart.cpp \
|
||||
cfanarttv.cpp \
|
||||
cfanartimage.cpp
|
||||
cfanartimage.cpp \
|
||||
cexportdialog.cpp
|
||||
|
||||
HEADERS += cmainwindow.h \
|
||||
cserie.h \
|
||||
@@ -65,7 +66,8 @@ HEADERS += cmainwindow.h \
|
||||
cpixmapwidget.h \
|
||||
cfanart.h \
|
||||
cfanarttv.h \
|
||||
cfanartimage.h
|
||||
cfanartimage.h \
|
||||
cexportdialog.h
|
||||
|
||||
FORMS += cmainwindow.ui \
|
||||
csearch.ui \
|
||||
@@ -75,7 +77,8 @@ FORMS += cmainwindow.ui \
|
||||
cepisodedetails.ui \
|
||||
cmessagedialog.ui \
|
||||
cmoviesearch.ui \
|
||||
cmovieedit.ui
|
||||
cmovieedit.ui \
|
||||
cexportdialog.ui
|
||||
|
||||
DISTFILES += \
|
||||
qtMovies.ico
|
||||
|
||||
Reference in New Issue
Block a user