2025-02-15 08:35:11 +01:00
# include "mainwindow.h"
# include "ui_mainwindow.h"
MainWindow : : MainWindow ( QWidget * parent )
: QMainWindow ( parent )
, ui ( new Ui : : MainWindow )
{
2025-02-15 08:38:24 +01:00
Debug = 0 ;
2025-02-15 08:35:11 +01:00
if ( Debug ) qDebug ( ) < < " MainWindow " ;
2025-02-15 08:35:47 +01:00
# ifdef __WIN32__
if ( Debug ) qDebug ( ) < < " Windows Programm " ;
2025-02-15 08:38:24 +01:00
QDir dir ( " pdf " ) ; if ( ! dir . exists ( ) ) dir . mkdir ( dir . absolutePath ( ) ) ;
dir . setPath ( " png " ) ; if ( ! dir . exists ( ) ) dir . mkdir ( dir . absolutePath ( ) ) ;
2025-02-15 08:35:47 +01:00
# elif __linux__
if ( Debug ) qDebug ( ) < < " Linux Programm " ;
2025-02-15 08:38:24 +01:00
QDir dir ( " .Video-Datenbank " ) ; if ( ! dir . exists ( ) ) dir . mkdir ( dir . absolutePath ( ) ) ;
dir . setPath ( " .Video-Datenbank/pdf " ) ; if ( ! dir . exists ( ) ) dir . mkdir ( dir . absolutePath ( ) ) ;
dir . setPath ( " .Video-Datenbank/png " ) ; if ( ! dir . exists ( ) ) dir . mkdir ( dir . absolutePath ( ) ) ;
2025-02-15 08:35:47 +01:00
# endif
2025-02-15 08:35:11 +01:00
ui - > setupUi ( this ) ;
oeffneDatenbank ( ) ;
/*qApp->setStyleSheet("QWidget { color: #0c4909; \
background - color : # aaffaa ; \
selection - color : # ffffff ; \
selection - background - color : # 002500 ; } " );*/
ui - > pushButton_pfad - > setStyleSheet ( " text-align:left; " ) ;
ui - > comboBox_bildformat - > addItems ( { " " , " 16:9 " , " 4:3 " } ) ;
ui - > comboBox_filmtyp - > addItems ( { " " , " Film " , " Serie " } ) ;
ui - > comboBox_genre - > addItems ( { " " , " Abenteuer " , " Action " , " Alien " , " Animation " , " Boxerfilm " , " Computer " , " Drama " , " Dystopie " , " Endzeit " , " Erotik " , " Fantasy " , " Horror " , " Karate " , " Katastrophen " , " Komödie " , " Krieg " , " Krimi " , " Märchen " , " Mittelalter " , " Monster " , " Musik " , " Parodie " , " Piraten " , " Psycho " , " Religion " , " Science-Fiction " , " SuperHelden " , " Szene " , " Tanzfilm " , " Thriller " , " Vampir " , " Weltraum " , " Werwolf " , " Western " , " Zombie " } ) ;
ui - > comboBox_fsk - > addItems ( { " " , " 0 " , " 6 " , " 12 " , " 16 " , " 18 " } ) ;
ui - > lineEdit_suchen - > setText ( " " ) ;
on_lineEdit_suchen_textChanged ( ) ;
if ( Debug ) qDebug ( ) < < " MainWindow-Ende " ;
}
void MainWindow : : oeffneDatenbank ( ) {
if ( Debug ) qDebug ( ) < < " oeffneDatenbank " ;
ui - > tableWidget_Datenbank_ausgabe - > clear ( ) ;
QDateTime now = QDateTime : : currentDateTime ( ) ;
2025-02-15 08:37:35 +01:00
# ifdef __WIN32__
2025-02-15 08:35:11 +01:00
QString newName = " Video-Datenbank-Backup- " + now . toString ( " yyyy.MM.dd-hh.mm.ss " ) + " .db " ;
2025-02-15 08:38:24 +01:00
QFile file ( " Video-Datenbank.db " ) ;
2025-02-15 08:37:35 +01:00
# elif __linux__
2025-02-15 08:38:24 +01:00
QString newName = " .Video-Datenbank/Video-Datenbank-Backup.db " ;
QFile file ( " .Video-Datenbank/Video-Datenbank.db " ) ;
2025-02-15 08:37:35 +01:00
# endif
2025-02-15 08:35:11 +01:00
file . copy ( newName ) ;
db = QSqlDatabase : : addDatabase ( " QSQLITE " ) ;
//db.setConnectOptions("QSQLITE_ENABLE_REGEXP");
2025-02-15 08:37:35 +01:00
# ifdef __WIN32__
2025-02-15 08:35:11 +01:00
db . setDatabaseName ( " Video-Datenbank.db " ) ;
2025-02-15 08:37:35 +01:00
# elif __linux__
2025-02-15 08:38:24 +01:00
db . setDatabaseName ( " .Video-Datenbank/Video-Datenbank.db " ) ;
2025-02-15 08:37:35 +01:00
# endif
2025-02-15 08:35:11 +01:00
if ( db . open ( ) ) {
ui - > statusbar - > showMessage ( " Datenbank Video-Datenbank.db geöffnet! " ) ;
} else {
ui - > statusbar - > showMessage ( " Datenbank Video-Datenbank.db nicht geöffnet! " ) ;
return ;
}
query = QSqlQuery ( db ) ;
2025-02-15 08:42:59 +01:00
query2 = QSqlQuery ( db ) ;
2025-02-15 08:35:11 +01:00
query . exec ( " CREATE TABLE IF NOT EXISTS einstellungen( "
" pfad TEXT) " ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
query . exec ( " SELECT pfad FROM einstellungen " ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
while ( query . next ( ) ) {
datenPfad = query . value ( 0 ) . toString ( ) ;
}
if ( datenPfad = = " " | | datenPfad = = " / " ) {
2025-02-15 08:35:47 +01:00
# ifdef __WIN32__
2025-02-15 08:35:11 +01:00
datenPfad = " c:/ " ;
2025-02-15 08:35:47 +01:00
# elif __linux__
datenPfad = " ~ " ;
# endif
2025-02-15 08:35:11 +01:00
}
setWindowTitle ( " Video-Datenbank - Datenquelle: " + datenPfad ) ;
query . exec ( " CREATE TABLE IF NOT EXISTS video( "
" id INTEGER PRIMARY KEY, "
" pfad TEXT, "
" Titel TEXT, "
" Bildformat TEXT, "
" Filmtyp TEXT, "
" Teil TEXT, "
" Genre TEST, "
" Länge TEXT, "
" Jahr TEXT, "
" FSK TEXT, "
" Handlung TEXT, "
" Bild BLOB) " ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
if ( Debug ) qDebug ( ) < < " oeffneDatenbank-Ende " ;
}
void MainWindow : : schiesseDatenbank ( ) {
if ( Debug ) qDebug ( ) < < " schiesseDatenbank " ;
db . close ( ) ;
if ( Debug ) qDebug ( ) < < " schiesseDatenbank-Ende " ;
}
void MainWindow : : leseVerzeichnis ( ) {
if ( Debug ) qDebug ( ) < < " leseVerzeichnis " ;
ui - > tableWidget_Datenbank_ausgabe - > clear ( ) ;
QDirIterator it ( datenPfad , QStringList ( ) < < " *.3gp " < < " *.avi " < < " *.divx " < < " *.flv " < < " *.m2ts " < < " *.mpeg " < < " *.mts " < < " *.mkv " < < " *.mov " < < " *.mp4 " < < " *.mpg " < < " *.ogv " < < " *.qt " < < " *.webm " < < " *.wmv " , QDir : : Files , QDirIterator : : Subdirectories ) ;
while ( it . hasNext ( ) ) {
QString pfad = it . next ( ) ;
pfad . replace ( QString ( " ' " ) , QString ( " '' " ) ) ;
ui - > statusbar - > showMessage ( pfad ) ;
ui - > statusbar - > repaint ( ) ;
query . exec ( QString ( " SELECT * FROM video WHERE pfad == '%1' " ) . arg ( pfad ) ) ;
if ( ! query . next ( ) ) {
query . exec ( QString ( " INSERT INTO video (pfad) VALUES('%1') " ) . arg ( pfad ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
}
}
ui - > statusbar - > showMessage ( " Daten eingelesen! " ) ;
ui - > lineEdit_suchen - > setText ( " " ) ;
on_lineEdit_suchen_textChanged ( ) ;
if ( Debug ) qDebug ( ) < < " leseVerzeichnis-Ende " ;
}
MainWindow : : ~ MainWindow ( ) {
if ( Debug ) qDebug ( ) < < " ~MainWindow " ;
schiesseDatenbank ( ) ;
delete ui ;
if ( Debug ) qDebug ( ) < < " ~MainWindow-Ende " ;
}
2025-02-15 08:42:59 +01:00
void MainWindow : : on_actionVideopfad_einlesen_triggered ( ) {
2025-02-15 08:35:11 +01:00
if ( Debug ) qDebug ( ) < < " on_actionDaten_aktualisieren_triggered " ;
leseVerzeichnis ( ) ;
if ( Debug ) qDebug ( ) < < " on_actionDaten_aktualisieren_triggered-Ende " ;
}
2025-02-15 08:42:59 +01:00
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 " ;
}
2025-02-15 08:35:11 +01:00
void MainWindow : : on_actionDaten_ausgeben_triggered ( ) {
if ( Debug ) qDebug ( ) < < " on_actionDaten_ausgeben_triggered " ;
ui - > lineEdit_suchen - > setText ( " " ) ;
on_lineEdit_suchen_textChanged ( ) ;
ui - > statusbar - > showMessage ( " Daten ausgegeben " ) ;
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 ) ;
ui - > statusbar - > showMessage ( datenPfad ) ;
if ( datenPfad ! = " " ) {
ui - > tableWidget_Datenbank_ausgabe - > clear ( ) ;
query . exec ( QString ( " INSERT OR REPLACE INTO einstellungen VALUES ('%1') " ) . arg ( datenPfad ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
} else {
query . exec ( " SELECT * FROM einstellungen " ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
while ( query . next ( ) ) {
datenPfad = query . value ( 0 ) . toString ( ) ;
}
if ( datenPfad = = " " | | datenPfad = = " / " ) {
2025-02-15 08:35:47 +01:00
# ifdef __WIN32__
2025-02-15 08:35:11 +01:00
datenPfad = " c:/ " ;
2025-02-15 08:35:47 +01:00
# elif __linux__
datenPfad = " ~ " ;
# endif
2025-02-15 08:35:11 +01:00
}
}
setWindowTitle ( " Video-Datenbank - Datenquelle: " + datenPfad ) ;
if ( Debug ) qDebug ( ) < < " on_actionPfad_zu_den_Videos_triggered-Ende " ;
}
void MainWindow : : on_pushButton_minus_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_minus_clicked " ;
if ( ui - > tableWidget_Datenbank_ausgabe - > rowCount ( ) < = 0 ) return ;
QString Zeile = ui - > pushButton_id - > text ( ) ;
int row = Zeile . toInt ( ) ;
row - - ;
if ( row < 1 ) return ;
ui - > statusbar - > showMessage ( " Datensatz zurück " ) ;
on_tableWidget_Datenbank_ausgabe_cellClicked ( row - 1 , 0 ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_minus_clicked-Ende " ;
}
void MainWindow : : on_pushButton_plus_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_plus_clicked " ;
if ( ui - > tableWidget_Datenbank_ausgabe - > rowCount ( ) < = 0 ) return ;
QString Zeile = ui - > pushButton_id - > text ( ) ;
QString Zeile_max = ui - > pushButton_max - > text ( ) ;
int row = Zeile . toInt ( ) ;
int row_max = Zeile_max . toInt ( ) ;
row + + ;
if ( row > row_max ) return ;
ui - > statusbar - > showMessage ( " Datensatz vor " ) ;
on_tableWidget_Datenbank_ausgabe_cellClicked ( row - 1 , 0 ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_plus_clicked-Ende " ;
}
void MainWindow : : on_lineEdit_suchen_textChanged ( ) {
if ( Debug ) qDebug ( ) < < " on_lineEdit_suchen_textChanged " ;
ui - > tableWidget_Datenbank_ausgabe - > clear ( ) ;
int Zeile_max = 0 ;
QStringList sucheTabelleZeile ;
QVector < QStringList > sucheTabelleIndex ;
QStringList suchenTextList = ui - > lineEdit_suchen - > text ( ) . replace ( ( " $ " ) , ( " " ) ) . replace ( " ' " , " '' " ) . split ( " " ) ;
QString befehl_SQL ;
QString befehl_SELECT_SQL = " SELECT * FROM video WHERE " ;
QString befehl_LIKE_SQL = " (pfad LIKE '%$%' OR Titel LIKE '%$%' OR Bildformat LIKE '%$%' OR Filmtyp LIKE '%$%' OR Teil LIKE '%$%' OR Genre LIKE '%$%' OR Länge LIKE '%$%' OR Jahr LIKE '%$%' OR FSK LIKE '%$%' OR Handlung LIKE '%$%') " ;
for ( int i = 0 ; i < suchenTextList . length ( ) ; i + + ) {
if ( i < 1 ) {
befehl_SQL = befehl_SELECT_SQL + befehl_LIKE_SQL ;
befehl_SQL . replace ( QString ( " $ " ) , QString ( suchenTextList . at ( i ) ) ) ;
} else {
befehl_SQL = befehl_SQL + " AND " + befehl_LIKE_SQL ;
befehl_SQL . replace ( QString ( " $ " ) , QString ( suchenTextList . at ( i ) ) ) ;
}
}
query . exec ( befehl_SQL ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Beim suchen ist ein Fehler aufgetreten: " + query . lastError ( ) . databaseText ( ) ) ;
}
while ( query . next ( ) ) {
sucheTabelleZeile < < query . value ( 1 ) . toString ( ) < < query . value ( 2 ) . toString ( ) < < query . value ( 3 ) . toString ( ) < < query . value ( 4 ) . toString ( ) < < query . value ( 5 ) . toString ( ) < < query . value ( 6 ) . toString ( ) < < query . value ( 7 ) . toString ( ) < < query . value ( 8 ) . toString ( ) < < query . value ( 9 ) . toString ( ) ;
sucheTabelleIndex . append ( sucheTabelleZeile ) ;
sucheTabelleZeile . clear ( ) ;
}
if ( sucheTabelleIndex . length ( ) < = 0 ) {
ui - > tableWidget_Datenbank_ausgabe - > setColumnCount ( 0 ) ;
ui - > tableWidget_Datenbank_ausgabe - > setRowCount ( 0 ) ;
return ;
}
for ( int i = 0 ; i < sucheTabelleIndex . length ( ) ; + + i ) {
Zeile_max + + ;
ui - > tableWidget_Datenbank_ausgabe - > setColumnCount ( 10 ) ; // Table costructor
ui - > tableWidget_Datenbank_ausgabe - > setHorizontalHeaderLabels ( { tr ( " Pfad " ) , tr ( " Titel " ) , tr ( " Format " ) , tr ( " Typ " ) , tr ( " Teil " ) , tr ( " Genre " ) , tr ( " Länge " ) , tr ( " Jahr " ) , tr ( " FSK " ) , tr ( " Status " ) } ) ;
ui - > tableWidget_Datenbank_ausgabe - > setRowCount ( i + 1 ) ; // neue Zeile
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 0 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( sucheTabelleIndex [ i ] [ 0 ] ) ) ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 0 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 1 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( sucheTabelleIndex [ i ] [ 1 ] ) ) ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 1 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 2 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( sucheTabelleIndex [ i ] [ 2 ] ) ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 2 ) - > setTextAlignment ( Qt : : AlignCenter ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 2 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 3 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( sucheTabelleIndex [ i ] [ 3 ] ) ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 3 ) - > setTextAlignment ( Qt : : AlignCenter ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 3 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 4 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( sucheTabelleIndex [ i ] [ 4 ] ) ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 4 ) - > setTextAlignment ( Qt : : AlignCenter ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 4 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 5 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( sucheTabelleIndex [ i ] [ 5 ] ) ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 5 ) - > setTextAlignment ( Qt : : AlignCenter ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 5 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 6 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( sucheTabelleIndex [ i ] [ 6 ] ) ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 6 ) - > setTextAlignment ( Qt : : AlignCenter ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 6 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 7 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( sucheTabelleIndex [ i ] [ 7 ] ) ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 7 ) - > setTextAlignment ( Qt : : AlignCenter ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 7 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 8 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( sucheTabelleIndex [ i ] [ 8 ] ) ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 8 ) - > setTextAlignment ( Qt : : AlignCenter ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 8 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
if ( QFileInfo : : exists ( sucheTabelleIndex [ i ] [ 0 ] ) ) {
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 9 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( " Ok " ) ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 9 ) - > setTextAlignment ( Qt : : AlignCenter ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 9 ) - > setBackground ( QBrush ( QColor ( " #88ff88 " ) ) ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 9 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
} else {
ui - > tableWidget_Datenbank_ausgabe - > setItem ( i , 9 , new QTableWidgetItem ( QStringLiteral ( " %1 " ) . arg ( " kein Video " ) ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 9 ) - > setTextAlignment ( Qt : : AlignCenter ) ;
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 9 ) - > setBackground ( QBrush ( QColor ( " #ff8888 " ) ) ) ;
2025-02-15 08:35:47 +01:00
ui - > tableWidget_Datenbank_ausgabe - > item ( i , 9 ) - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
2025-02-15 08:35:11 +01:00
}
}
ui - > pushButton_max - > setText ( QString : : number ( Zeile_max ) ) ;
ui - > tableWidget_Datenbank_ausgabe - > resizeColumnsToContents ( ) ;
if ( ui - > tableWidget_Datenbank_ausgabe - > rowCount ( ) > 0 ) on_tableWidget_Datenbank_ausgabe_cellClicked ( 0 , 0 ) ;
ui - > tableWidget_Datenbank_ausgabe - > setSortingEnabled ( true ) ;
ui - > tableWidget_Datenbank_ausgabe - > sortByColumn ( 0 , Qt : : AscendingOrder ) ;
if ( Debug ) qDebug ( ) < < " on_lineEdit_suchen_textChanged-Ende " ;
}
void MainWindow : : on_pushButton_abspielen_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_abspielen_clicked " ;
if ( ui - > tableWidget_Datenbank_ausgabe - > rowCount ( ) < = 0 ) return ;
if ( QFileInfo : : exists ( ui - > pushButton_pfad - > text ( ) ) ) {
QProcess * explorer = new QProcess ;
2025-02-15 08:35:47 +01:00
# ifdef __WIN32__
2025-02-15 08:35:11 +01:00
explorer - > start ( " explorer " , { ui - > pushButton_pfad - > text ( ) . replace ( QString ( " / " ) , QString ( " \\ " ) ) } ) ;
2025-02-15 08:35:47 +01:00
# elif __linux__
2025-02-15 08:42:11 +01:00
explorer - > start ( " xdg-open " , { ui - > pushButton_pfad - > text ( ) } ) ;
2025-02-15 08:35:47 +01:00
# endif
2025-02-15 08:35:11 +01:00
}
ui - > statusbar - > showMessage ( " Video abspielen " ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_abspielen_clicked-Ende " ;
}
void MainWindow : : on_pushButton_daten_loeschen_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_daten_loeschen_clicked " ;
if ( ui - > tableWidget_Datenbank_ausgabe - > rowCount ( ) < = 0 ) return ;
// id ermitteln
if ( ui - > pushButton_id - > text ( ) = = " " ) return ;
QString Zeile = ui - > tableWidget_Datenbank_ausgabe - > item ( ui - > pushButton_id - > text ( ) . toInt ( ) - 1 , 0 ) - > text ( ) ;
int id = 0 ;
query . exec ( QString ( " SELECT * FROM video WHERE pfad LIKE '%1' " ) . arg ( Zeile . replace ( QString ( " ' " ) , QString ( " '' " ) ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
while ( query . next ( ) ) {
id = query . value ( 0 ) . toInt ( ) ;
}
// id ermitteln ende
if ( QMessageBox : : Yes = = QMessageBox ( QMessageBox : : Warning , " Datensatz löschen! " , " Willst du wirklich löschen? " , QMessageBox : : No | QMessageBox : : Yes ) . exec ( ) ) {
query . exec ( QString ( " DELETE FROM video WHERE _rowid_ IN ('%1') " ) . arg ( QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
on_lineEdit_suchen_textChanged ( ) ;
}
ui - > statusbar - > showMessage ( " Datensatz gelöscht! " ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_daten_loeschen_clicked-Ende " ;
}
void MainWindow : : on_tableWidget_Datenbank_ausgabe_cellClicked ( int row , int column ) {
if ( Debug ) qDebug ( ) < < " on_tableWidget_Datenbank_ausgabe_cellClicked " ;
ui - > tableWidget_Datenbank_ausgabe - > selectRow ( row ) ;
QString Zeile = ui - > tableWidget_Datenbank_ausgabe - > item ( row , 0 ) - > text ( ) ;
ui - > pushButton_id - > setText ( QString : : number ( row + 1 ) ) ;
query . exec ( QString ( " SELECT * FROM video WHERE pfad LIKE '%1' " ) . arg ( Zeile . replace ( QString ( " ' " ) , QString ( " '' " ) ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
while ( query . next ( ) ) {
ui - > pushButton_pfad - > setText ( query . value ( 1 ) . toString ( ) ) ;
ui - > lineEdit_titel - > setText ( query . value ( 2 ) . toString ( ) ) ;
ui - > comboBox_bildformat - > setCurrentText ( query . value ( 3 ) . toString ( ) ) ;
ui - > comboBox_filmtyp - > setCurrentText ( query . value ( 4 ) . toString ( ) ) ;
ui - > lineEdit_teil - > setText ( query . value ( 5 ) . toString ( ) ) ;
ui - > comboBox_genre - > setCurrentText ( query . value ( 6 ) . toString ( ) ) ;
ui - > lineEdit_laenge - > setText ( query . value ( 7 ) . toString ( ) ) ;
ui - > lineEdit_jahr - > setText ( query . value ( 8 ) . toString ( ) ) ;
ui - > comboBox_fsk - > setCurrentText ( query . value ( 9 ) . toString ( ) ) ;
ui - > plainTextEdit_handlung - > document ( ) - > setPlainText ( query . value ( 10 ) . toString ( ) ) ;
QByteArray outByteArray = query . value ( 11 ) . toByteArray ( ) ;
QPixmap pixmap = QPixmap ( ) ;
pixmap . loadFromData ( outByteArray ) ;
ui - > label_bild - > setPixmap ( pixmap . scaledToHeight ( 297 ) ) ;
if ( QFileInfo : : exists ( query . value ( 1 ) . toString ( ) ) ) {
ui - > pushButton_status - > setStyleSheet ( " background-color: #88ff88; border-radius: 3px; " ) ;
} else {
ui - > pushButton_status - > setStyleSheet ( " background-color: #ff8888; border-radius: 3px; " ) ;
}
2025-02-15 08:37:35 +01:00
QStringList Datei_tmp = ui - > pushButton_pfad - > text ( ) . split ( " / " ) ;
QString Datei = Datei_tmp . at ( Datei_tmp . length ( ) - 1 ) ;
QStringList Dateiname_tmp = Datei . split ( " . " ) ;
QString Dateiname ;
for ( int i = 0 ; i < Dateiname_tmp . length ( ) - 1 ; i + + ) {
if ( i < 1 )
Dateiname = Dateiname + Dateiname_tmp [ i ] ;
else
Dateiname = Dateiname + " . " + Dateiname_tmp [ i ] ;
}
// -> Dateiname
# ifdef __WIN32__
2025-02-15 08:38:24 +01:00
if ( QFileInfo : : exists ( QString ( " pdf/ " + Dateiname + " .pdf " ) ) ) {
2025-02-15 08:37:35 +01:00
# elif __linux__
2025-02-15 08:38:24 +01:00
if ( QFileInfo : : exists ( QString ( " .Video-Datenbank/pdf/ " + Dateiname + " .pdf " ) ) ) {
2025-02-15 08:37:35 +01:00
# endif
ui - > pushButton_PDF_Status - > setStyleSheet ( " background-color: #88ff88; border-radius: 3px; " ) ;
} else {
ui - > pushButton_PDF_Status - > setStyleSheet ( " background-color: #ff8888; border-radius: 3px; " ) ;
}
2025-02-15 08:35:11 +01:00
}
if ( Debug ) qDebug ( ) < < " on_tableWidget_Datenbank_ausgabe_cellClicked-Ende " ;
}
void MainWindow : : on_pushButton_speichern_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_speichern_clicked " ;
if ( ui - > tableWidget_Datenbank_ausgabe - > rowCount ( ) < = 0 ) return ;
// id ermitteln
if ( ui - > pushButton_id - > text ( ) = = " " ) return ;
QString Zeile = ui - > tableWidget_Datenbank_ausgabe - > item ( ui - > pushButton_id - > text ( ) . toInt ( ) - 1 , 0 ) - > text ( ) ;
int id = 0 ;
query . exec ( QString ( " SELECT * FROM video WHERE pfad LIKE '%1' " ) . arg ( Zeile . replace ( QString ( " ' " ) , QString ( " '' " ) ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
while ( query . next ( ) ) {
id = query . value ( 0 ) . toInt ( ) ;
}
// id ermitteln ende
// Titel speichern
QString Titel = ui - > lineEdit_titel - > text ( ) ;
query . exec ( QString ( " UPDATE video SET Titel=('%1') WHERE id=('%2') " ) . arg ( Titel . replace ( QString ( " ' " ) , QString ( " '' " ) ) , QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
// Bildformat speichern
QString Bildformat = ui - > comboBox_bildformat - > currentText ( ) ;
query . exec ( QString ( " UPDATE video SET Bildformat=('%1') WHERE id=('%2') " ) . arg ( Bildformat . replace ( QString ( " ' " ) , QString ( " '' " ) ) , QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
// Filmtyp speichern
QString Filmtyp = ui - > comboBox_filmtyp - > currentText ( ) ;
query . exec ( QString ( " UPDATE video SET Filmtyp=('%1') WHERE id=('%2') " ) . arg ( Filmtyp . replace ( QString ( " ' " ) , QString ( " '' " ) ) , QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
// Teil speichern
QString Teil = ui - > lineEdit_teil - > text ( ) ;
query . exec ( QString ( " UPDATE video SET Teil=('%1') WHERE id=('%2') " ) . arg ( Teil . replace ( QString ( " ' " ) , QString ( " '' " ) ) , QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
// Genre speichern
QString Genre = ui - > comboBox_genre - > currentText ( ) ;
query . exec ( QString ( " UPDATE video SET Genre=('%1') WHERE id=('%2') " ) . arg ( Genre . replace ( QString ( " ' " ) , QString ( " '' " ) ) , QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
// Länge speichern
QString Laenge = ui - > lineEdit_laenge - > text ( ) ;
query . exec ( QString ( " UPDATE video SET Länge=('%1') WHERE id=('%2') " ) . arg ( Laenge . replace ( QString ( " ' " ) , QString ( " '' " ) ) , QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
// Jahr speichern
QString Jahr = ui - > lineEdit_jahr - > text ( ) ;
query . exec ( QString ( " UPDATE video SET Jahr=('%1') WHERE id=('%2') " ) . arg ( Jahr . replace ( QString ( " ' " ) , QString ( " '' " ) ) , QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
// FSK speichern
QString FSK = ui - > comboBox_fsk - > currentText ( ) ;
query . exec ( QString ( " UPDATE video SET FSK=('%1') WHERE id=('%2') " ) . arg ( FSK . replace ( QString ( " ' " ) , QString ( " '' " ) ) , QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
// Handlung speichern
QString Handlung = ui - > plainTextEdit_handlung - > toPlainText ( ) ;
query . exec ( QString ( " UPDATE video SET Handlung=('%1') WHERE id=('%2') " ) . arg ( Handlung . replace ( QString ( " ' " ) , QString ( " '' " ) ) , QString : : number ( id ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
ui - > statusbar - > showMessage ( " Daten gespeichert " ) ;
int row = ui - > tableWidget_Datenbank_ausgabe - > currentRow ( ) ;
on_lineEdit_suchen_textChanged ( ) ;
on_tableWidget_Datenbank_ausgabe_cellClicked ( row , 0 ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_speichern_clicked-Ende " ;
}
void MainWindow : : on_pushButton_bild_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_bild_clicked " ;
if ( ui - > tableWidget_Datenbank_ausgabe - > rowCount ( ) < = 0 ) return ;
// id ermitteln
if ( ui - > pushButton_id - > text ( ) = = " " ) return ;
QString Zeile = ui - > tableWidget_Datenbank_ausgabe - > item ( ui - > pushButton_id - > text ( ) . toInt ( ) - 1 , 0 ) - > text ( ) ;
int id = 0 ;
query . exec ( QString ( " SELECT * FROM video WHERE pfad LIKE '%1' " ) . arg ( Zeile . replace ( QString ( " ' " ) , QString ( " '' " ) ) ) ) ;
if ( query . lastError ( ) . isValid ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
while ( query . next ( ) ) {
id = query . value ( 0 ) . toInt ( ) ;
}
// id ermitteln ende
2025-02-15 08:35:47 +01:00
# ifdef __WIN32__
2025-02-15 08:38:24 +01:00
QString fileName = QFileDialog : : getOpenFileName ( this , tr ( " Öffne Bild " ) , " c: " , tr ( " Bild Datei (*.png *.jpg *.gif *.bmp) " ) ) ;
2025-02-15 08:35:47 +01:00
# elif __linux__
2025-02-15 08:38:24 +01:00
QString fileName = QFileDialog : : getOpenFileName ( this , tr ( " Öffne Bild " ) , " ~ " , tr ( " Bild Datei (*.png *.jpg *.gif *.bmp) " ) ) ;
2025-02-15 08:35:47 +01:00
# endif
2025-02-15 08:35:11 +01:00
if ( ! ( fileName = = " " ) ) {
QFile file ( fileName ) ;
if ( ! file . open ( QIODevice : : ReadOnly ) ) return ;
QByteArray inByteArray = file . readAll ( ) ;
query . prepare ( QString ( " UPDATE video SET Bild=(:imageData) WHERE id=('%1') " ) . arg ( QString : : number ( id ) ) ) ;
query . bindValue ( " :imageData " , inByteArray ) ;
if ( ! query . exec ( ) ) {
ui - > statusbar - > showMessage ( " Fehler: " + query . lastError ( ) . databaseText ( ) ) ;
}
on_tableWidget_Datenbank_ausgabe_cellClicked ( ui - > pushButton_id - > text ( ) . toInt ( ) - 1 , 0 ) ;
}
on_pushButton_speichern_clicked ( ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_bild_clicked-Ende " ;
}
void MainWindow : : on_pushButton_pfad_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_pfad_clicked " ;
QStringList Datei_tmp = ui - > pushButton_pfad - > text ( ) . split ( " / " ) ;
QString Datei = Datei_tmp . at ( Datei_tmp . length ( ) - 1 ) ;
QStringList Dateiname_tmp = Datei . split ( " . " ) ;
QString Dateiname ;
for ( int i = 0 ; i < Dateiname_tmp . length ( ) - 1 ; i + + ) {
if ( i < 1 )
Dateiname = Dateiname + Dateiname_tmp [ i ] ;
else
Dateiname = Dateiname + " . " + Dateiname_tmp [ i ] ;
}
ui - > lineEdit_titel - > setText ( Dateiname ) ;
2025-02-15 08:36:58 +01:00
if ( Debug ) qDebug ( ) < < " on_pushButton_pfad_clicked-Ende " ;
}
void MainWindow : : on_pushButton_PDF_speichern_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_PDF_speichern_clicked " ;
if ( ui - > pushButton_id - > text ( ) . toInt ( ) < = 0 | | ui - > pushButton_id - > text ( ) . toInt ( ) > ui - > pushButton_max - > text ( ) . toInt ( ) ) return ;
QStringList Datei_tmp = ui - > pushButton_pfad - > text ( ) . split ( " / " ) ;
QString Datei = Datei_tmp . at ( Datei_tmp . length ( ) - 1 ) ;
QStringList Dateiname_tmp = Datei . split ( " . " ) ;
QString Dateiname ;
for ( int i = 0 ; i < Dateiname_tmp . length ( ) - 1 ; i + + ) {
if ( i < 1 )
Dateiname = Dateiname + Dateiname_tmp [ i ] ;
else
Dateiname = Dateiname + " . " + Dateiname_tmp [ i ] ;
}
// -> Dateiname
2025-02-15 08:38:24 +01:00
# ifdef __WIN32__
ui - > label_bild - > grab ( ) . save ( " png/ " + Dateiname + " .png " ) ;
# elif __linux__
ui - > label_bild - > grab ( ) . save ( " .Video-Datenbank/png/ " + Dateiname + " .png " ) ;
# endif
2025-02-15 08:36:58 +01:00
QString html ;
2025-02-15 08:38:24 +01:00
# ifdef __WIN32__
2025-02-15 08:40:29 +01:00
html = " \
< html > \
< head > \
< title > Video - Datenbak < / title > \
< / head > \
< body > \
< table border = ' 0 ' > \
< tr > < td width = 10 % > & nbsp ; < / td > < td width = 55 % > & nbsp ; < / td > < td width = 35 % align = ' right ' rowspan = 19 > < img src = ' png / " + Dateiname + " . png ' > < / td > < / tr > \
2025-02-15 08:36:58 +01:00
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td align = right > Pfad : < / td > < td > " + ui->pushButton_pfad->text() + " < / td > < / tr > \
< tr > < td align = right > Titel : < / td > < td > " + ui->lineEdit_titel->text() + " < / td > < / tr > \
< tr > < td align = right > Format : < / td > < td > " + ui->comboBox_bildformat->currentText() + " < / td > < / tr > \
< tr > < td align = right > Typ : < / td > < td > " + ui->comboBox_filmtyp->currentText() + " < / td > < / tr > \
< tr > < td align = right > Teil : < / td > < td > " + ui->lineEdit_teil->text() + " < / td > < / tr > \
< tr > < td align = right > Genre : < / td > < td > " + ui->comboBox_genre->currentText() + " < / td > < / tr > \
< tr > < td align = right > Länge : < / td > < td > " + ui->lineEdit_laenge->text() + " < / td > < / tr > \
< tr > < td align = right > Jahr : < / td > < td > " + ui->lineEdit_jahr->text() + " < / td > < / tr > \
< tr > < td align = right > FSK : < / td > < td > " + ui->comboBox_fsk->currentText() + " < / td > < / tr > \
< / table > \
2025-02-15 08:38:24 +01:00
< br > < br > < code > " + ui->plainTextEdit_handlung->document()->toRawText() + " < / code > \
2025-02-15 08:36:58 +01:00
< / body > \
< / htnl > \
2025-02-15 08:38:24 +01:00
" ;
# elif __linux__
html = " \
< html > \
< head > \
< title > Video - Datenbak < / title > \
< / head > \
< body > \
2025-02-15 08:40:29 +01:00
< table border = ' 0 ' > \
2025-02-15 08:42:11 +01:00
< tr > < td width = 7 % > & nbsp ; < / td > < td width = 58 % > & nbsp ; < / td > < td width = 35 % align = ' right ' rowspan = 16 > < img src = ' . Video - Datenbank / png / " + Dateiname + " . png ' > < / td > < / tr > \
2025-02-15 08:38:24 +01:00
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
2025-02-15 08:42:11 +01:00
< tr > < td align = left > & nbsp ; < / td > < td > & nbsp ; < / td > < / tr > \
< tr > < td align = left > Titel < / td > < td > : " + ui->lineEdit_titel->text() + " < / td > < / tr > \
< tr > < td align = leftt > Format < / td > < td > : " + ui->comboBox_bildformat->currentText() + " < / td > < / tr > \
< tr > < td align = left > Typ < / td > < td > : " + ui->comboBox_filmtyp->currentText() + " < / td > < / tr > \
< tr > < td align = left > Teil < / td > < td > : " + ui->lineEdit_teil->text() + " < / td > < / tr > \
< tr > < td align = left > Genre < / td > < td > : " + ui->comboBox_genre->currentText() + " < / td > < / tr > \
< tr > < td align = left > Länge < / td > < td > : " + ui->lineEdit_laenge->text() + " < / td > < / tr > \
< tr > < td align = left > Jahr < / td > < td > : " + ui->lineEdit_jahr->text() + " < / td > < / tr > \
< tr > < td align = left > FSK < / td > < td > : " + ui->comboBox_fsk->currentText() + " < / td > < / tr > \
2025-02-15 08:38:24 +01:00
< / table > \
< br > < br > < code > " + ui->plainTextEdit_handlung->document()->toRawText() + " < / code > \
< / body > \
< / htnl > \
" ;
# endif
2025-02-15 08:36:58 +01:00
QTextDocument doc ;
doc . setHtml ( html ) ;
QPrinter printer ;
2025-02-15 08:37:35 +01:00
# ifdef __WIN32__
2025-02-15 08:38:24 +01:00
printer . setOutputFileName ( " pdf/ " + Dateiname + " .pdf " ) ;
2025-02-15 08:37:35 +01:00
# elif __linux__
2025-02-15 08:38:24 +01:00
printer . setOutputFileName ( " .Video-Datenbank/pdf/ " + Dateiname + " .pdf " ) ;
2025-02-15 08:37:35 +01:00
# endif
2025-02-15 08:36:58 +01:00
printer . setOutputFormat ( QPrinter : : PdfFormat ) ;
2025-02-15 08:42:11 +01:00
doc . setPageSize ( printer . pageLayout ( ) . paintRect ( ) . size ( ) ) ;
2025-02-15 08:36:58 +01:00
doc . print ( & printer ) ;
printer . newPage ( ) ;
2025-02-15 08:37:35 +01:00
ui - > statusbar - > showMessage ( " Daten gespeichert " ) ;
int row = ui - > tableWidget_Datenbank_ausgabe - > currentRow ( ) ;
on_lineEdit_suchen_textChanged ( ) ;
on_tableWidget_Datenbank_ausgabe_cellClicked ( row , 0 ) ;
2025-02-15 08:36:58 +01:00
if ( Debug ) qDebug ( ) < < " on_pushButton_PDF_speichern_clicked-Ende " ;
2025-02-15 08:35:11 +01:00
}
2025-02-15 08:41:33 +01:00
void MainWindow : : on_pushButton_Wikipedia_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_Wikipedia_clicked-Ende " ;
if ( ui - > lineEdit_titel - > text ( ) = = " " ) {
QMessageBox msgBox ;
msgBox . setText ( " Kein Titel zum Suchen! " ) ;
msgBox . exec ( ) ;
return ;
}
QNetworkAccessManager manager ;
QNetworkReply * reply = manager . get ( QNetworkRequest ( QUrl ( " https://de.wikipedia.org/w/api.php?action=query&list=search&srsearch= " + ui - > lineEdit_titel - > text ( ) + " &srlimit=1&prop=info&inprop=url&utf8=&origin=*&format=json " ) ) ) ;
QEventLoop eventLoop ;
QObject : : connect ( & manager , SIGNAL ( finished ( QNetworkReply * ) ) , & eventLoop , SLOT ( quit ( ) ) ) ;
eventLoop . exec ( ) ;
QJsonDocument getJD = QJsonDocument : : fromJson ( reply - > readAll ( ) ) ;
QJsonObject getJO = getJD . object ( ) ;
QJsonValue queryJV = getJO . value ( QString ( " query " ) ) ;
QJsonArray searchJA = queryJV [ " search " ] . toArray ( ) ;
QJsonObject searchJO = searchJA [ 0 ] . toObject ( ) ;
QJsonValue titelJV = searchJO . value ( QString ( " title " ) ) ;
if ( titelJV . toString ( ) = = " " ) return ;
reply = manager . get ( QNetworkRequest ( QUrl ( " https://de.wikipedia.org/w/api.php?action=parse&page= " + titelJV . toString ( ) + " &prop=text&formatversion=2&format=json " ) ) ) ;
QObject : : connect ( & manager , SIGNAL ( finished ( QNetworkReply * ) ) , & eventLoop , SLOT ( quit ( ) ) ) ;
eventLoop . exec ( ) ;
getJD = QJsonDocument : : fromJson ( reply - > readAll ( ) ) ;
getJO = getJD . object ( ) ;
QJsonValue parseJV = getJO . value ( QString ( " parse " ) ) ;
QJsonObject parseJO = parseJV . toObject ( ) ;
QJsonValue textJV = parseJO . value ( QString ( " text " ) ) ;
if ( textJV . toString ( ) = = " " ) return ;
QTextDocument htmlDoc ;
htmlDoc . setHtml ( textJV . toString ( ) ) ;
QMessageBox messageBox ;
messageBox . setStyleSheet ( " QTextEdit{min-width:800 px;height: 500px; min-height: 500px; max-height: 500px;} " ) ;
messageBox . deleteLater ( ) ;
messageBox . setText ( titelJV . toString ( ) ) ;
//messageBox.setDetailedText(html.remove(QRegExp("<[^>]*>")));
messageBox . setDetailedText ( htmlDoc . toRawText ( ) ) ;
QAbstractButton * detailsButton = NULL ;
foreach ( QAbstractButton * button , messageBox . buttons ( ) ) {
if ( messageBox . buttonRole ( button ) = = QMessageBox : : ActionRole ) {
detailsButton = button ;
break ;
}
}
if ( detailsButton ) {
detailsButton - > click ( ) ;
}
messageBox . exec ( ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_Wikipedia_clicked-Ende " ;
}
2025-02-15 08:42:11 +01:00
void MainWindow : : on_pushButton_google_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_google_clicked " ;
if ( ui - > lineEdit_titel - > text ( ) = = " " ) {
QMessageBox msgBox ;
msgBox . setText ( " Kein Titel zum Suchen! " ) ;
msgBox . exec ( ) ;
return ;
}
QProcess * explorer = new QProcess ;
QString suchen = ui - > lineEdit_titel - > text ( ) . replace ( " " , " + " ) ;
QString url = " https://www.google.de/search?q= " + suchen + " &tbm=isch " ;
# ifdef __WIN32__
QDesktopServices : : openUrl ( QUrl ( url ) ) ;
# elif __linux__
explorer - > start ( " xdg-open " , { url } ) ;
# endif
ui - > statusbar - > showMessage ( " Bilder suchen " ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_google_clicked-Ende " ;
}
void MainWindow : : on_pushButton_imdb_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_imdb_clicked " ;
if ( ui - > lineEdit_titel - > text ( ) = = " " ) {
QMessageBox msgBox ;
msgBox . setText ( " Kein Titel zum Suchen! " ) ;
msgBox . exec ( ) ;
return ;
}
QProcess * explorer = new QProcess ;
QString suchen = ui - > lineEdit_titel - > text ( ) . replace ( " " , " + " ) ;
QString url = " https://www.imdb.com/find?q= " + suchen ;
# ifdef __WIN32__
QDesktopServices : : openUrl ( QUrl ( url ) ) ;
# elif __linux__
explorer - > start ( " xdg-open " , { url } ) ;
# endif
ui - > statusbar - > showMessage ( " IMDb suchen " ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_imdb_clicked-Ende " ;
}
void MainWindow : : on_pushButton_ordner_clicked ( ) {
if ( Debug ) qDebug ( ) < < " on_pushButton_on_pushButton_ordner_clicked " ;
QProcess * explorer = new QProcess ;
# ifdef __WIN32__
explorer - > start ( " explorer " , { " . " } ) ;
# elif __linux__
explorer - > start ( " xdg-open " , { " .Video-Datenbank " } ) ;
# endif
ui - > statusbar - > showMessage ( " Ordner öffnen " ) ;
if ( Debug ) qDebug ( ) < < " on_pushButton_on_pushButton_ordner_clicked-Ende " ;
}