3.7
This commit is contained in:
parent
d71fc587b0
commit
9fd535f8b7
4 changed files with 142 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
|||
QT += core gui sql printsupport network
|
||||
QT += core gui sql printsupport network xml
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
|
|
122
mainwindow.cpp
122
mainwindow.cpp
|
@ -67,6 +67,7 @@ if(Debug) qDebug() << "oeffneDatenbank";
|
|||
}
|
||||
|
||||
query = QSqlQuery(db);
|
||||
query2 = QSqlQuery(db);
|
||||
|
||||
query.exec("CREATE TABLE IF NOT EXISTS einstellungen("
|
||||
"pfad TEXT)");
|
||||
|
@ -149,12 +150,128 @@ if(Debug) qDebug() << "~MainWindow";
|
|||
if(Debug) qDebug() << "~MainWindow-Ende";
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDaten_aktualisieren_triggered(){
|
||||
void MainWindow::on_actionVideopfad_einlesen_triggered(){
|
||||
if(Debug) qDebug() << "on_actionDaten_aktualisieren_triggered";
|
||||
leseVerzeichnis();
|
||||
if(Debug) qDebug() << "on_actionDaten_aktualisieren_triggered-Ende";
|
||||
}
|
||||
|
||||
void MainWindow::on_actionKodi_Daten_einlesen_triggered(){
|
||||
if(Debug) qDebug() << "on_actionKodi_Daten_einlesen_triggered";
|
||||
QSqlQuery query("SELECT pfad FROM video");
|
||||
while (query.next()) {
|
||||
QString pfad = query.value(0).toString();
|
||||
QStringList list_pfad = pfad.split(u'.');
|
||||
QString pfad_tmp;
|
||||
for(int i=0; i<list_pfad.length()-1; ++i){
|
||||
pfad_tmp.append(list_pfad.at(i)+".");
|
||||
}
|
||||
QString pfad_nfo = pfad_tmp+"nfo";
|
||||
QString pfad_Bild = pfad_tmp+"-poster.jpg";
|
||||
pfad_Bild.replace(".-poster.jpg","-poster.jpg");
|
||||
|
||||
QDomDocument doc("nfo");
|
||||
QString Titel;
|
||||
QString Genre;
|
||||
QString Laenge;
|
||||
QString Jahr;
|
||||
QString Handlung;
|
||||
QFile file(pfad_nfo);
|
||||
if(file.open(QIODevice::ReadOnly)){
|
||||
if(doc.setContent(&file)){
|
||||
QDomElement docElement = doc.documentElement();
|
||||
for(QDomNode n = docElement.firstChild(); !n.isNull(); n = n.nextSibling()){
|
||||
if( !n.isNull() ) {
|
||||
if ( n.isElement() && n.nodeName() == "title" ) {
|
||||
Titel = n.toElement().text();
|
||||
}
|
||||
}
|
||||
}
|
||||
for(QDomNode n = docElement.firstChild(); !n.isNull(); n = n.nextSibling()){
|
||||
if( !n.isNull() ) {
|
||||
if ( n.isElement() && n.nodeName() == "genre" ) {
|
||||
Genre = n.toElement().text();
|
||||
}
|
||||
}
|
||||
}
|
||||
for(QDomNode n = docElement.firstChild(); !n.isNull(); n = n.nextSibling()){
|
||||
if( !n.isNull() ) {
|
||||
if ( n.isElement() && n.nodeName() == "runtime" ) {
|
||||
Laenge = n.toElement().text();
|
||||
}
|
||||
}
|
||||
}
|
||||
for(QDomNode n = docElement.firstChild(); !n.isNull(); n = n.nextSibling()){
|
||||
if( !n.isNull() ) {
|
||||
if ( n.isElement() && n.nodeName() == "year" ) {
|
||||
Jahr = n.toElement().text();
|
||||
}
|
||||
}
|
||||
}
|
||||
for(QDomNode n = docElement.firstChild(); !n.isNull(); n = n.nextSibling()){
|
||||
if( !n.isNull() ) {
|
||||
if ( n.isElement() && n.nodeName() == "plot" ) {
|
||||
Handlung = n.toElement().text();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
|
||||
// id ermitteln
|
||||
int id=0;
|
||||
query2.exec(QString("SELECT * FROM video WHERE pfad LIKE '%1'").arg(pfad.replace(QString("'"), QString("''"))));
|
||||
if(query2.lastError().isValid()){
|
||||
ui->statusbar->showMessage("Fehler:" + query.lastError().databaseText());
|
||||
}
|
||||
while(query2.next()){
|
||||
id=query2.value(0).toInt();
|
||||
}
|
||||
// id ermitteln ende
|
||||
// Titel speichern
|
||||
query2.exec(QString("UPDATE video SET Titel=('%1') WHERE id=('%2')").arg(Titel.replace(QString("'"), QString("''")), QString::number(id)));
|
||||
if(query2.lastError().isValid()){
|
||||
ui->statusbar->showMessage("Fehler:" + query2.lastError().databaseText());
|
||||
}
|
||||
// Genre speichern
|
||||
query2.exec(QString("UPDATE video SET Genre=('%1') WHERE id=('%2')").arg(Genre.replace(QString("'"), QString("''")), QString::number(id)));
|
||||
if(query2.lastError().isValid()){
|
||||
ui->statusbar->showMessage("Fehler:" + query2.lastError().databaseText());
|
||||
}
|
||||
// Länge speichern
|
||||
query2.exec(QString("UPDATE video SET Länge=('%1') WHERE id=('%2')").arg(Laenge.replace(QString("'"), QString("''")), QString::number(id)));
|
||||
if(query2.lastError().isValid()){
|
||||
ui->statusbar->showMessage("Fehler:" + query2.lastError().databaseText());
|
||||
}
|
||||
// Jahr speichern
|
||||
query2.exec(QString("UPDATE video SET Jahr=('%1') WHERE id=('%2')").arg(Jahr.replace(QString("'"), QString("''")), QString::number(id)));
|
||||
if(query2.lastError().isValid()){
|
||||
ui->statusbar->showMessage("Fehler:" + query2.lastError().databaseText());
|
||||
}
|
||||
// Handlung speichern
|
||||
query2.exec(QString("UPDATE video SET Handlung=('%1') WHERE id=('%2')").arg(Handlung.replace(QString("'"), QString("''")), QString::number(id)));
|
||||
if(query2.lastError().isValid()){
|
||||
ui->statusbar->showMessage("Fehler:" + query2.lastError().databaseText());
|
||||
}
|
||||
// Bild speichern
|
||||
if(!(pfad_Bild=="")){
|
||||
QFile file(pfad_Bild);
|
||||
if(file.open(QIODevice::ReadOnly)){
|
||||
QByteArray inByteArray = file.readAll();
|
||||
query2.prepare(QString("UPDATE video SET Bild=(:imageData) WHERE id=('%1')").arg(QString::number(id)));
|
||||
query2.bindValue(":imageData", inByteArray);
|
||||
if(!query2.exec()){
|
||||
ui->statusbar->showMessage("Fehler:" + query2.lastError().databaseText());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ui->statusbar->showMessage(pfad);
|
||||
ui->statusbar->repaint();
|
||||
}
|
||||
ui->statusbar->showMessage("Daten gespeichert");
|
||||
if(Debug) qDebug() << "on_actionKodi_Daten_einlesen_triggered";
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDaten_ausgeben_triggered(){
|
||||
if(Debug) qDebug() << "on_actionDaten_ausgeben_triggered";
|
||||
|
@ -164,14 +281,12 @@ if(Debug) qDebug() << "on_actionDaten_ausgeben_triggered";
|
|||
if(Debug) qDebug() << "on_actionDaten_ausgeben_triggered-Ende";
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionBeenden_triggered(){
|
||||
if(Debug) qDebug() << "on_actionBeenden_triggered";
|
||||
MainWindow::close();
|
||||
if(Debug) qDebug() << "on_actionBeenden_triggered-Ende";
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionPfad_zu_den_Videos_triggered(){
|
||||
if(Debug) qDebug() << "on_actionPfad_zu_den_Videos_triggered";
|
||||
datenPfad = QFileDialog::getExistingDirectory(this, tr("Öffne Verzeichnis"), datenPfad, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
@ -766,4 +881,3 @@ if(Debug) qDebug() << "on_pushButton_on_pushButton_ordner_clicked";
|
|||
ui->statusbar->showMessage("Ordner öffnen");
|
||||
if(Debug) qDebug() << "on_pushButton_on_pushButton_ordner_clicked-Ende";
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <QJsonArray>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QtXml/QDomDocument>
|
||||
#include <QtXml/QDomNode>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
|
@ -35,7 +37,8 @@ public:
|
|||
|
||||
private slots:
|
||||
// Menü
|
||||
void on_actionDaten_aktualisieren_triggered();
|
||||
void on_actionVideopfad_einlesen_triggered();
|
||||
void on_actionKodi_Daten_einlesen_triggered();
|
||||
void on_actionDaten_ausgeben_triggered();
|
||||
void on_actionBeenden_triggered();
|
||||
void on_actionPfad_zu_den_Videos_triggered();
|
||||
|
@ -68,5 +71,6 @@ private:
|
|||
Ui::MainWindow *ui;
|
||||
QSqlDatabase db;
|
||||
QSqlQuery query;
|
||||
QSqlQuery query2;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -439,7 +439,14 @@
|
|||
<property name="title">
|
||||
<string>Datei</string>
|
||||
</property>
|
||||
<addaction name="actionDaten_aktualisieren"/>
|
||||
<widget class="QMenu" name="menuDaten_aktualisieren">
|
||||
<property name="title">
|
||||
<string>Daten aktualisieren</string>
|
||||
</property>
|
||||
<addaction name="actionVideopfad_einlesen"/>
|
||||
<addaction name="actionKodi_Daten_einlesen"/>
|
||||
</widget>
|
||||
<addaction name="menuDaten_aktualisieren"/>
|
||||
<addaction name="actionDaten_ausgeben"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionBeenden"/>
|
||||
|
@ -454,11 +461,6 @@
|
|||
<addaction name="menuEinstellungen"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionDaten_aktualisieren">
|
||||
<property name="text">
|
||||
<string>Daten aktualisieren</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDaten_ausgeben">
|
||||
<property name="text">
|
||||
<string>Daten ausgeben</string>
|
||||
|
@ -474,6 +476,16 @@
|
|||
<string>Beenden</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionVideopfad_einlesen">
|
||||
<property name="text">
|
||||
<string>Videopfad einlesen</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionKodi_Daten_einlesen">
|
||||
<property name="text">
|
||||
<string>Kodi Daten einlesen</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
Loading…
Add table
Reference in a new issue