#include "cmainwindow.h" #include "ui_cmainwindow.h" #include "csourcescombodelegate.h" #include "csourcesbuttondelegate.h" #include #include #include #include #include #include #include #include #define FANART_W 1920 #define FANART_H 1080 #define POSTER_W 200 #define POSTER_H 300 cMainWindow::cMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::cMainWindow) { m_bTVShowCheck = false; m_lpXBMC = 0; m_bGenreToSelecting = false; init(); load(); m_htmlList << HTML("&", "&"); m_htmlList << HTML("\"", """); m_htmlList << HTML("<", "<"); m_htmlList << HTML(">", ">"); m_htmlList << HTML("¡", "¡"); m_htmlList << HTML("¢", "¢"); m_htmlList << HTML("£", "£"); m_htmlList << HTML("¤", "¤"); m_htmlList << HTML("¥", "¥"); m_htmlList << HTML("¦", "¦"); m_htmlList << HTML("§", "§"); m_htmlList << HTML("¨", "¨"); m_htmlList << HTML("©", "©"); m_htmlList << HTML("ª", "ª"); m_htmlList << HTML("«", "«"); m_htmlList << HTML("¬", "¬"); m_htmlList << HTML("­", "­"); m_htmlList << HTML("®", "®"); m_htmlList << HTML("¯", "¯"); m_htmlList << HTML("°", "°"); m_htmlList << HTML("±", "±"); m_htmlList << HTML("²", "²"); m_htmlList << HTML("³", "³"); m_htmlList << HTML("´", "´"); m_htmlList << HTML("µ", "µ"); m_htmlList << HTML("¶", "¶"); m_htmlList << HTML("·", "·"); m_htmlList << HTML("¸", "¸"); m_htmlList << HTML("¹", "¹"); m_htmlList << HTML("º", "º"); m_htmlList << HTML("»", "»"); m_htmlList << HTML("¼", "¼"); m_htmlList << HTML("½", "½"); m_htmlList << HTML("¾", "¾"); m_htmlList << HTML("¿", "¿"); m_htmlList << HTML("À", "À"); m_htmlList << HTML("Á", "Á"); m_htmlList << HTML("Â", "Â"); m_htmlList << HTML("Ã", "Ã"); m_htmlList << HTML("Ä", "Ä"); m_htmlList << HTML("Å", "Å"); m_htmlList << HTML("Æ", "Æ"); m_htmlList << HTML("Ç", "Ç"); m_htmlList << HTML("È", "È"); m_htmlList << HTML("É", "É"); m_htmlList << HTML("Ê", "Ê"); m_htmlList << HTML("Ë", "Ë"); m_htmlList << HTML("Ì", "Ì"); m_htmlList << HTML("Í", "Í"); m_htmlList << HTML("Î", "Î"); m_htmlList << HTML("Ï", "Ï"); m_htmlList << HTML("Ð", "Ð"); m_htmlList << HTML("Ñ", "Ñ"); m_htmlList << HTML("Ò", "Ò"); m_htmlList << HTML("Ó", "Ó"); m_htmlList << HTML("Ô", "Ô"); m_htmlList << HTML("Õ", "Õ"); m_htmlList << HTML("Ö", "Ö"); m_htmlList << HTML("×", "×"); m_htmlList << HTML("Ø", "Ø"); m_htmlList << HTML("Ù", "Ù"); m_htmlList << HTML("Ú", "Ú"); m_htmlList << HTML("Û", "Û"); m_htmlList << HTML("Ü", "Ü"); m_htmlList << HTML("Ý", "Ý"); m_htmlList << HTML("Þ", "Þ"); m_htmlList << HTML("ß", "ß"); m_htmlList << HTML("à", "à"); m_htmlList << HTML("á", "á"); m_htmlList << HTML("â", "â"); m_htmlList << HTML("ã", "ã"); m_htmlList << HTML("ä", "ä"); m_htmlList << HTML("å", "å"); m_htmlList << HTML("æ", "æ"); m_htmlList << HTML("ç", "ç"); m_htmlList << HTML("è", "è"); m_htmlList << HTML("é", "é"); m_htmlList << HTML("ê", "ê"); m_htmlList << HTML("ë", "ë"); m_htmlList << HTML("ì", "ì"); m_htmlList << HTML("í", "í"); m_htmlList << HTML("î", "î"); m_htmlList << HTML("ï", "ï"); m_htmlList << HTML("ð", "ð"); m_htmlList << HTML("ñ", "ñ"); m_htmlList << HTML("ò", "ò"); m_htmlList << HTML("ó", "ó"); m_htmlList << HTML("ô", "ô"); m_htmlList << HTML("õ", "õ"); m_htmlList << HTML("ö", "ö"); m_htmlList << HTML("÷", "÷"); m_htmlList << HTML("ø", "ø"); m_htmlList << HTML("ù", "ù"); m_htmlList << HTML("ú", "ú"); m_htmlList << HTML("û", "û"); m_htmlList << HTML("ü", "ü"); m_htmlList << HTML("ý", "ý"); m_htmlList << HTML("þ", "þ"); m_htmlList << HTML("ÿ", "ÿ"); } cMainWindow::~cMainWindow() { saveSettings(); if(m_lpSourcesModel) delete m_lpSourcesModel; if(m_lpExceptionsModel) delete m_lpExceptionsModel; if(m_lpStatusProgress) delete m_lpStatusProgress; if(m_lpXBMC) delete m_lpXBMC; if(m_lpGenreFromModel) delete m_lpGenreFromModel; if(m_lpGenreToModel) delete m_lpGenreToModel; delete ui; } void cMainWindow::init() { ui->setupUi(this); m_lpSourcesModel = new QStandardItemModel(0, 3); QStringList headerLabels1 = QStringList() << tr("Type") << tr("Path") << tr(""); m_lpSourcesModel->setHorizontalHeaderLabels(headerLabels1); ui->m_lpSources->setModel(m_lpSourcesModel); m_lpExceptionsModel = new QStandardItemModel(0, 2); QStringList headerLabels2 = QStringList() << tr("Path") << tr(""); m_lpExceptionsModel->setHorizontalHeaderLabels(headerLabels2); ui->m_lpExceptions->setModel(m_lpExceptionsModel); m_lpMoviesModel = new QStandardItemModel(0, 1); ui->m_lpMovies->setModel(m_lpMoviesModel); m_lpTVShowsModel = new QStandardItemModel(0, 1); ui->m_lpTVShows->setModel(m_lpTVShowsModel); m_lpGenreFromModel = new QStandardItemModel(0, 1); ui->m_lpGenreFrom->setModel(m_lpGenreFromModel); m_lpGenreToModel = new QStandardItemModel(0, 1); ui->m_lpGenreTo->setModel(m_lpGenreToModel); cSourcesComboDelegate* lpSourcesComboDelegate = new cSourcesComboDelegate(this); ui->m_lpSources->setItemDelegateForColumn(0, lpSourcesComboDelegate); ui->m_lpSources->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); ui->m_lpSources->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed); ui->m_lpSources->resizeColumnToContents(0); ui->m_lpSources->setColumnWidth(2, 25); ui->m_lpSources->resizeRowsToContents(); ui->m_lpExceptions->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); ui->m_lpExceptions->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed); // ui->m_lpExceptions->resizeColumnToContents(0); ui->m_lpExceptions->setColumnWidth(1, 25); ui->m_lpExceptions->resizeRowsToContents(); ui->m_lpMainTab->setCurrentIndex(0); m_lpStatusProgress = new QProgressBar(this); m_lpStatusProgress->setMinimum(0); m_lpStatusProgress->setMaximum(100); ui->m_lpStatusBar->addPermanentWidget(m_lpStatusProgress); m_lpStatusProgress->hide(); loadSettings(); connect(m_lpTVShowsModel, SIGNAL(itemChanged(QStandardItem*)), SLOT(onTVShowsItemChanged(QStandardItem*))); connect(ui->m_lpGenreTo->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(on_m_lpGenreToSelectionChanged(QItemSelection,QItemSelection))); connect(ui->m_lpGenreFrom->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(on_m_lpGenreFromSelectionChanged(QItemSelection,QItemSelection))); } void cMainWindow::load() { m_lpXBMC = new cXBMC; #ifdef WITHDB m_MovieList.open(); displayMovieList(); #endif } void cMainWindow::loadSettings() { QSettings settings; for(int z = 0;;z++) { Sources t; QString szPath; t = (Sources)settings.value(QString("sources/type%1").arg(z)).toInt(); szPath = settings.value(QString("sources/path%1").arg(z)).toString(); if(szPath.isEmpty()) break; addSourcesLine(t, szPath); } for(int z = 0;;z++) { QString szPath; szPath = settings.value(QString("exceptions/path%1").arg(z)).toString(); if(szPath.isEmpty()) break; addExceptionsLine(szPath); } QString szOutputPath = settings.value("output/path").toString(); ui->m_lpOutputPath->setText(szOutputPath); qint16 iMaxActor = settings.value("output/maxactor", QVariant((int)15)).toInt(); ui->m_lpMaxActor->setValue(iMaxActor); QString szTitle = settings.value("output/title", "Movie Collection").toString(); ui->m_lpTitle->setText(szTitle); if(settings.value("xbmc/enabled", "false").toBool() == true) ui->m_lpXBMC->setChecked(true); else ui->m_lpXBMC->setChecked(false); ui->m_lpXBMCServer->setText(settings.value("xbmc/server").toString()); ui->m_lpXBMCPort->setText(settings.value("xbmc/port").toString()); ui->m_lpXBMCUser->setText(settings.value("xbmc/user").toString()); ui->m_lpXBMCPass->setText(settings.value("xbmc/pass").toString()); ui->m_lpPosterW->setValue(settings.value("poster/w", QVariant(POSTER_W)).toInt()); ui->m_lpPosterH->setValue(settings.value("poster/h", QVariant(POSTER_H)).toInt()); ui->m_lpFanartW->setValue(settings.value("fanart/w", QVariant(FANART_W)).toInt()); ui->m_lpFanartH->setValue(settings.value("fanart/h", QVariant(FANART_H)).toInt()); QStringList genres; settings.beginGroup("genre"); genres = settings.allKeys(); settings.endGroup(); genres.removeDuplicates(); genres.sort(Qt::CaseInsensitive); for(int z = 0;z < genres.count();z++) { cGenreCombine* lpGenreCombine = m_GenreCombineList.add(genres.at(z)); if(lpGenreCombine) lpGenreCombine->addFrom(settings.value(QString("genre/%1").arg(genres.at(z))).toStringList()); } showGenres(); } bool genreCompare(cGenreCombine* g1, cGenreCombine* g2) { return(g1->genreTo() < g2->genreTo()); } void cMainWindow::showGenres() { m_lpGenreToModel->clear(); m_lpGenreFromModel->clear(); qSort(m_GenreCombineList.begin(), m_GenreCombineList.end(), genreCompare); QStringList szGenresFrom; for(int z = 0;z < m_GenreCombineList.count();z++) { QStandardItem* lpItem = new QStandardItem(m_GenreCombineList.at(z)->genreTo()); m_lpGenreToModel->appendRow(lpItem); QModelIndex iIndex = m_lpGenreToModel->indexFromItem(lpItem); m_lpGenreToModel->setData(iIndex, QVariant::fromValue(m_GenreCombineList.at(z)), Qt::UserRole); szGenresFrom.append(m_GenreCombineList.at(z)->genreFrom()); } szGenresFrom.removeDuplicates(); szGenresFrom.sort(Qt::CaseInsensitive); for(int z = 0;z < szGenresFrom.count();z++) { QStandardItem* lpItem = new QStandardItem(szGenresFrom.at(z)); m_lpGenreFromModel->appendRow(lpItem); } } void cMainWindow::saveSettings() { QSettings settings; settings.remove("sources"); settings.remove("exceptions"); settings.remove("output"); settings.remove("xbmc"); settings.remove("poster"); settings.remove("fanart"); settings.remove("genre"); int i = 0; for(int z = 0;z < m_lpSourcesModel->rowCount();z++) { QStandardItem* type = m_lpSourcesModel->item(z, 0); QStandardItem* path = m_lpSourcesModel->item(z, 1); Sources t = (Sources)type->data(Qt::EditRole).toInt(); QString szPath = path->text(); if(!szPath.isEmpty()) { settings.setValue(QString("sources/type%1").arg(i), QVariant(t)); settings.setValue(QString("sources/path%1").arg(i), QVariant(szPath)); i++; } } i = 0; for(int z = 0;z < m_lpExceptionsModel->rowCount();z++) { QStandardItem* path = m_lpExceptionsModel->item(z, 0); QString szPath = path->text(); if(!szPath.isEmpty()) { settings.setValue(QString("exceptions/path%1").arg(i), QVariant(szPath)); i++; } } settings.setValue("output/path", QVariant(ui->m_lpOutputPath->text())); settings.setValue("output/maxactor", QVariant(ui->m_lpMaxActor->value())); settings.setValue("output/title", QVariant(ui->m_lpTitle->text())); settings.setValue("xbmc/enabled", QVariant(ui->m_lpXBMC->isChecked())); settings.setValue("xbmc/server", QVariant(ui->m_lpXBMCServer->text())); settings.setValue("xbmc/port", QVariant(ui->m_lpXBMCPort->text())); settings.setValue("xbmc/user", QVariant(ui->m_lpXBMCUser->text())); settings.setValue("xbmc/pass", QVariant(ui->m_lpXBMCPass->text())); settings.setValue("poster/w", QVariant(ui->m_lpPosterW->value())); settings.setValue("poster/h", QVariant(ui->m_lpPosterH->value())); settings.setValue("fanart/w", QVariant(ui->m_lpFanartW->value())); settings.setValue("fanart/h", QVariant(ui->m_lpFanartH->value())); for(int z = 0;z < m_GenreCombineList.count();z++) { cGenreCombine* lpGenreCombine = m_GenreCombineList.at(z); settings.setValue(QString("genre/%1").arg(lpGenreCombine->genreTo()), QVariant(lpGenreCombine->genreFrom())); } } void cMainWindow::addSourcesLine(Sources type, const QString& szText) { SOURCES s; s.lpTypeItem = new QStandardItem; m_lpSourcesModel->appendRow(s.lpTypeItem); s.index = m_lpSourcesModel->indexFromItem(s.lpTypeItem); m_lpSourcesModel->setData(s.index, QVariant((int)type)); ui->m_lpSources->openPersistentEditor(s.index); s.lpPathItem = new QStandardItem(szText); m_lpSourcesModel->setItem(s.index.row(), 1, s.lpPathItem); s.lpButton = new cPushButton("..."); ui->m_lpSources->setIndexWidget(m_lpSourcesModel->index(s.index.row(), 2), s.lpButton); m_SourcesList.append(s); connect(s.lpButton, SIGNAL(buttonClicked(cPushButton*)), this, SLOT(sourcesButtonClicked(cPushButton*))); ui->m_lpSources->resizeColumnToContents(0); ui->m_lpSources->setColumnWidth(2, 25); ui->m_lpSources->resizeRowsToContents(); } void cMainWindow::addExceptionsLine(const QString& szText) { EXCEPTIONS e; e.lpPathItem = new QStandardItem(szText); m_lpExceptionsModel->appendRow(e.lpPathItem); e.index = m_lpExceptionsModel->indexFromItem(e.lpPathItem); e.lpButton = new cPushButton("..."); ui->m_lpExceptions->setIndexWidget(m_lpExceptionsModel->index(e.index.row(), 1), e.lpButton); m_ExceptionsList.append(e); connect(e.lpButton, SIGNAL(buttonClicked(cPushButton*)), this, SLOT(exceptionsButtonClicked(cPushButton*))); ui->m_lpExceptions->resizeColumnToContents(0); ui->m_lpExceptions->setColumnWidth(1, 25); ui->m_lpExceptions->resizeRowsToContents(); } void cMainWindow::sourcesButtonClicked(cPushButton* lpButton) { for(int z = 0;z < m_SourcesList.count();z++) { if(lpButton == m_SourcesList.at(z).lpButton) { QString szPath = m_SourcesList.at(z).lpPathItem->text(); if(szPath.isEmpty()) szPath = m_szLastPath; QFileDialog dlg(this, "select Path", szPath); dlg.setFileMode(QFileDialog::Directory); if(dlg.exec()) { QString szNewPath = dlg.selectedFiles().at(0); if(szNewPath.isEmpty()) return; m_SourcesList.at(z).lpPathItem->setText(szNewPath); m_szLastPath = szNewPath; } } } } void cMainWindow::exceptionsButtonClicked(cPushButton* lpButton) { for(int z = 0;z < m_ExceptionsList.count();z++) { if(lpButton == m_ExceptionsList.at(z).lpButton) { QString szPath = m_ExceptionsList.at(z).lpPathItem->text(); if(szPath.isEmpty()) szPath = m_szLastPath; QFileDialog dlg(this, "select Path", szPath); dlg.setFileMode(QFileDialog::Directory); if(dlg.exec()) { QString szNewPath = dlg.selectedFiles().at(0); if(szNewPath.isEmpty()) return; m_ExceptionsList.at(z).lpPathItem->setText(szNewPath); m_szLastPath = szNewPath; } } } } void cMainWindow::on_m_lpAddSources_clicked() { addSourcesLine(SourcesNone, ""); } void cMainWindow::on_m_lpDeleteSources_clicked() { if(ui->m_lpSources->selectionModel()->selectedIndexes().count() == 0) return; for(int z = 0;z < ui->m_lpSources->selectionModel()->selectedIndexes().count();z++) { QModelIndex i = ui->m_lpSources->selectionModel()->selectedIndexes().at(z); m_lpSourcesModel->removeRow(i.row()); } } void cMainWindow::on_m_lpAddExceptions_clicked() { addExceptionsLine(""); } void cMainWindow::on_m_lpDeleteExceptions_clicked() { if(ui->m_lpExceptions->selectionModel()->selectedIndexes().count() == 0) return; for(int z = 0;z < ui->m_lpExceptions->selectionModel()->selectedIndexes().count();z++) { QModelIndex i = ui->m_lpExceptions->selectionModel()->selectedIndexes().at(z); m_lpExceptionsModel->removeRow(i.row()); } } void cMainWindow::on_m_lpMoviesScan_clicked() { if(ui->m_lpXBMC->isChecked()) { ui->m_lpStatusBar->showMessage(QString("Loading XBMC ...")); m_lpXBMC->loadMovies(ui->m_lpXBMCServer->text(), ui->m_lpXBMCPort->text(), ui->m_lpXBMCUser->text(), ui->m_lpXBMCPass->text()); } m_lpMoviesModel->clear(); m_MovieList.clear(); QStringList exceptions; for(int x = 0;x < m_lpExceptionsModel->rowCount();x++) exceptions.append(m_lpExceptionsModel->item(x, 0)->text()); for(int z = 0;z < m_lpSourcesModel->rowCount();z++) { QStandardItem* type = m_lpSourcesModel->item(z, 0); QStandardItem* path = m_lpSourcesModel->item(z, 1); Sources t = (Sources)type->data(Qt::EditRole).toInt(); QString szPath = path->text(); if(!szPath.isEmpty() && t == SourcesMovie) m_MovieList.parse(szPath, exceptions, m_lpXBMC, ui->m_lpStatusBar); } ui->m_lpStatusBar->showMessage(QString("")); displayMovieList(); QStringList szGenreList = m_MovieList.genreList(); addGenreList(szGenreList); showGenres(); } bool tvshowSort(cTVShow* left, cTVShow* right) { return(left->title() < right->title()); } void cMainWindow::on_m_lpTVShowsScan_clicked() { if(ui->m_lpXBMC->isChecked()) { ui->m_lpStatusBar->showMessage(QString("Loading XBMC ...")); m_lpXBMC->loadTVShows(ui->m_lpXBMCServer->text(), ui->m_lpXBMCPort->text(), ui->m_lpXBMCUser->text(), ui->m_lpXBMCPass->text()); } m_bTVShowCheck = true; m_lpTVShowsModel->clear(); m_TVShowList.clear(); QStringList exceptions; for(int x = 0;x < m_lpExceptionsModel->rowCount();x++) exceptions.append(m_lpExceptionsModel->item(x, 0)->text()); for(int z = 0;z < m_lpSourcesModel->rowCount();z++) { QStandardItem* type = m_lpSourcesModel->item(z, 0); QStandardItem* path = m_lpSourcesModel->item(z, 1); Sources t = (Sources)type->data(Qt::EditRole).toInt(); QString szPath = path->text(); if(!szPath.isEmpty() && t == SourcesTVShow) m_TVShowList.parse(szPath, exceptions, m_lpXBMC, ui->m_lpStatusBar); } ui->m_lpStatusBar->showMessage(QString("")); qSort(m_TVShowList.begin(), m_TVShowList.end(), tvshowSort); for(int z = 0;z < m_TVShowList.count();z++) { cTVShow* lpTVShow = m_TVShowList.at(z); QStandardItem* lpTVShowItem = new QStandardItem(lpTVShow->title()); lpTVShowItem->setCheckable(true); lpTVShowItem->setCheckState(Qt::Checked); QVariant v = qVariantFromValue(lpTVShow); lpTVShowItem->setData(v, Qt::UserRole); m_lpTVShowsModel->appendRow(lpTVShowItem); qint16 iSeason = -999; QStandardItem* lpSeasonItem = 0; for(int z = 0;z < lpTVShow->episodeList().count();z++) { cTVShowEpisode* lpEpisode = lpTVShow->episodeList().at(z); if(lpEpisode->season() != iSeason) { lpSeasonItem = new QStandardItem(QString(tr("Season %1").arg(lpEpisode->season()))); lpSeasonItem->setCheckable(true); lpSeasonItem->setCheckState(Qt::Checked); lpTVShowItem->appendRow(lpSeasonItem); iSeason = lpEpisode->season(); } QStandardItem* lpItem = new QStandardItem(QString("%1 - %2").arg(lpEpisode->episode(), 2, 10, QChar('0')).arg(lpEpisode->title())); lpItem->setCheckable(true); lpItem->setCheckState(Qt::Checked); lpSeasonItem->appendRow(lpItem); } } QStringList szGenreList = m_TVShowList.genreList(); addGenreList(szGenreList); showGenres(); m_bTVShowCheck = false; } void cMainWindow::on_m_lpMoviesSelectAll_clicked() { for(int z = 0;z < m_lpMoviesModel->rowCount();z++) { QStandardItem* lpItem = m_lpMoviesModel->item(z, 0); lpItem->setCheckState(Qt::Checked); } } void cMainWindow::on_m_lpTVShowsSelectAll_clicked() { m_bTVShowCheck = true; for(int z = 0;z < m_lpTVShowsModel->rowCount();z++) { QStandardItem* lpItem = m_lpTVShowsModel->item(z, 0); lpItem->setCheckState(Qt::Checked); for(int y = 0;y < lpItem->rowCount();y++) { QStandardItem* lpSeasonItem = lpItem->child(y, 0); lpSeasonItem->setCheckState(Qt::Checked); for(int x = 0;x < lpSeasonItem->rowCount();x++) { QStandardItem* lpEpisodeItem = lpSeasonItem->child(x, 0); lpEpisodeItem->setCheckState(Qt::Checked); } } } m_bTVShowCheck = false; } void cMainWindow::on_m_lpMoviesDeselectAll_clicked() { for(int z = 0;z < m_lpMoviesModel->rowCount();z++) { QStandardItem* lpItem = m_lpMoviesModel->item(z, 0); lpItem->setCheckState(Qt::Unchecked); } } void cMainWindow::on_m_lpTVShowsDeselectAll_clicked() { m_bTVShowCheck = true; for(int z = 0;z < m_lpTVShowsModel->rowCount();z++) { QStandardItem* lpItem = m_lpTVShowsModel->item(z, 0); lpItem->setCheckState(Qt::Unchecked); for(int y = 0;y < lpItem->rowCount();y++) { QStandardItem* lpSeasonItem = lpItem->child(y, 0); lpSeasonItem->setCheckState(Qt::Unchecked); for(int x = 0;x < lpSeasonItem->rowCount();x++) { QStandardItem* lpEpisodeItem = lpSeasonItem->child(x, 0); lpEpisodeItem->setCheckState(Qt::Unchecked); } } } m_bTVShowCheck = false; } void cMainWindow::on_m_lpMoviesInvertSelection_clicked() { for(int z = 0;z < m_lpMoviesModel->rowCount();z++) { QStandardItem* lpItem = m_lpMoviesModel->item(z, 0); if(lpItem->checkState() == Qt::Unchecked) lpItem->setCheckState(Qt::Checked); else lpItem->setCheckState(Qt::Unchecked); } } void cMainWindow::on_m_lpTVShowsInvertSelection_clicked() { m_bTVShowCheck = true; for(int z = 0;z < m_lpTVShowsModel->rowCount();z++) { QStandardItem* lpItem = m_lpTVShowsModel->item(z, 0); bool bSeasonChecked = true; for(int y = 0;y < lpItem->rowCount();y++) { QStandardItem* lpSeasonItem = lpItem->child(y, 0); bool bEpisodeChecked = true; for(int x = 0;x < lpSeasonItem->rowCount();x++) { QStandardItem* lpEpisodeItem = lpSeasonItem->child(x, 0); if(lpEpisodeItem->checkState() == Qt::Checked) { bEpisodeChecked = false; lpEpisodeItem->setCheckState(Qt::Unchecked); } else lpEpisodeItem->setCheckState(Qt::Checked); } if(bEpisodeChecked) lpSeasonItem->setCheckState(Qt::Checked); else { bSeasonChecked = false; lpSeasonItem->setCheckState(Qt::Unchecked); } } if(bSeasonChecked) lpItem->setCheckState(Qt::Checked); else lpItem->setCheckState(Qt::Unchecked); } m_bTVShowCheck = false; } void cMainWindow::on_m_lpMoviesClear_clicked() { m_lpMoviesModel->clear(); } void cMainWindow::on_m_lpTVShowsClearList_clicked() { m_bTVShowCheck = true; m_lpTVShowsModel->clear(); m_bTVShowCheck = false; } QString cMainWindow::string2HTML(const QString& sz) { QString sz1 = sz; for(int z = 0;z < m_htmlList.count();z++) sz1 = sz1.replace(m_htmlList.at(z).m_str, m_htmlList.at(z).m_html); return(sz1); } void cMainWindow::copyResource(const QString& szResource, const QString& szPath) { QFile::copy(QString(":/template/%1").arg(szResource), QString("%1/%2").arg(szPath).arg(szResource)); } QString cMainWindow::preparePath() { if(ui->m_lpOutputPath->text().isEmpty()) return(""); QString szDestDir = ui->m_lpOutputPath->text(); QDir dir(szDestDir); dir.removeRecursively(); dir.mkpath(szDestDir); dir.setCurrent(QString("%1/poster").arg(szDestDir)); dir.removeRecursively(); dir.setCurrent(QString("%1/fanart").arg(szDestDir)); dir.removeRecursively(); dir.mkpath(szDestDir); dir.mkpath(QString("%1/poster").arg(szDestDir)); dir.mkpath(QString("%1/fanart").arg(szDestDir)); dir.mkpath(QString("%1/Flags").arg(szDestDir)); dir.mkpath(QString("%1/images").arg(szDestDir)); copyResource("function.js", szDestDir); copyResource("style.css", szDestDir); copyResource("Flags/a_aac.png", szDestDir); copyResource("Flags/achan_1.png", szDestDir); copyResource("Flags/achan_2.png", szDestDir); copyResource("Flags/achan_6.png", szDestDir); copyResource("Flags/achan_7.png", szDestDir); copyResource("Flags/achan_8.png", szDestDir); copyResource("Flags/achan_defaultsound.png", szDestDir); copyResource("Flags/acodec_a_vorbis.png", szDestDir); copyResource("Flags/acodec_aac.png", szDestDir); copyResource("Flags/acodec_ac3.png", szDestDir); copyResource("Flags/acodec_aif.png", szDestDir); copyResource("Flags/acodec_aifc.png", szDestDir); copyResource("Flags/acodec_aiff.png", szDestDir); copyResource("Flags/acodec_ape.png", szDestDir); copyResource("Flags/acodec_dca.png", szDestDir); copyResource("Flags/acodec_dd.png", szDestDir); copyResource("Flags/acodec_defaultsound.png", szDestDir); copyResource("Flags/acodec_dolbydigital.png", szDestDir); copyResource("Flags/acodec_dts.png", szDestDir); copyResource("Flags/acodec_dtshd_hra.png", szDestDir); copyResource("Flags/acodec_dtshd_ma.png", szDestDir); copyResource("Flags/acodec_dtshr.png", szDestDir); copyResource("Flags/acodec_dtsma.png", szDestDir); copyResource("Flags/acodec_flac.png", szDestDir); copyResource("Flags/acodec_mp1.png", szDestDir); copyResource("Flags/acodec_mp2.png", szDestDir); copyResource("Flags/acodec_mp3.png", szDestDir); copyResource("Flags/acodec_ogg.png", szDestDir); copyResource("Flags/acodec_truehd.png", szDestDir); copyResource("Flags/acodec_vorbis.png", szDestDir); copyResource("Flags/acodec_wma.png", szDestDir); copyResource("Flags/acodec_wmahd.png", szDestDir); copyResource("Flags/acodec_wmapro.png", szDestDir); copyResource("Flags/vcodec_3iv2.png", szDestDir); copyResource("Flags/vcodec_3ivd.png", szDestDir); copyResource("Flags/vcodec_3ivx.png", szDestDir); copyResource("Flags/vcodec_8bps.png", szDestDir); copyResource("Flags/vcodec_advj.png", szDestDir); copyResource("Flags/vcodec_avc.png", szDestDir); copyResource("Flags/vcodec_avc1.png", szDestDir); copyResource("Flags/vcodec_avrn.png", szDestDir); copyResource("Flags/vcodec_dca.png", szDestDir); copyResource("Flags/vcodec_defaultscreen.png", szDestDir); copyResource("Flags/vcodec_div1.png", szDestDir); copyResource("Flags/vcodec_div2.png", szDestDir); copyResource("Flags/vcodec_div3.png", szDestDir); copyResource("Flags/vcodec_div4.png", szDestDir); copyResource("Flags/vcodec_div5.png", szDestDir); copyResource("Flags/vcodec_div6.png", szDestDir); copyResource("Flags/vcodec_divx.png", szDestDir); copyResource("Flags/vcodec_dm4v.png", szDestDir); copyResource("Flags/vcodec_dx50.png", szDestDir); copyResource("Flags/vcodec_em2v.png", szDestDir); copyResource("Flags/vcodec_flv.png", szDestDir); copyResource("Flags/vcodec_geox.png", szDestDir); copyResource("Flags/vcodec_h264.png", szDestDir); copyResource("Flags/vcodec_lmp2.png", szDestDir); copyResource("Flags/vcodec_m4s2.png", szDestDir); copyResource("Flags/vcodec_mmes.png", szDestDir); copyResource("Flags/vcodec_mp4.png", szDestDir); copyResource("Flags/vcodec_mpeg.png", szDestDir); copyResource("Flags/vcodec_mpeg2.png", szDestDir); copyResource("Flags/vcodec_mpeg-2.png", szDestDir); copyResource("Flags/vcodec_mpeg4.png", szDestDir); copyResource("Flags/vcodec_mpeg-4.png", szDestDir); copyResource("Flags/vcodec_nds.png", szDestDir); copyResource("Flags/vcodec_ndx.png", szDestDir); copyResource("Flags/vcodec_pim1.png", szDestDir); copyResource("Flags/vcodec_pvmm.png", szDestDir); copyResource("Flags/vcodec_qt.png", szDestDir); copyResource("Flags/vcodec_rle.png", szDestDir); copyResource("Flags/vcodec_rpza.png", szDestDir); copyResource("Flags/vcodec_smc.png", szDestDir); copyResource("Flags/vcodec_sv10.png", szDestDir); copyResource("Flags/vcodec_svq.png", szDestDir); copyResource("Flags/vcodec_vc1.png", szDestDir); copyResource("Flags/vcodec_wmv.png", szDestDir); copyResource("Flags/vcodec_wmva.png", szDestDir); copyResource("Flags/vcodec_wvc1.png", szDestDir); copyResource("Flags/vcodec_xvid.png", szDestDir); copyResource("Flags/vcodec_xvix.png", szDestDir); copyResource("Flags/vcodec_zygo.png", szDestDir); copyResource("Flags/vres_480.png", szDestDir); copyResource("Flags/vres_480i.png", szDestDir); copyResource("Flags/vres_480p.png", szDestDir); copyResource("Flags/vres_540.png", szDestDir); copyResource("Flags/vres_540i.png", szDestDir); copyResource("Flags/vres_540p.png", szDestDir); copyResource("Flags/vres_576.png", szDestDir); copyResource("Flags/vres_576i.png", szDestDir); copyResource("Flags/vres_576p.png", szDestDir); copyResource("Flags/vres_720.png", szDestDir); copyResource("Flags/vres_720i.png", szDestDir); copyResource("Flags/vres_720p.png", szDestDir); copyResource("Flags/vres_768.png", szDestDir); copyResource("Flags/vres_768i.png", szDestDir); copyResource("Flags/vres_768p.png", szDestDir); copyResource("Flags/vres_1080.png", szDestDir); copyResource("Flags/vres_1080i.png", szDestDir); copyResource("Flags/vres_1080p.png", szDestDir); copyResource("Flags/vres_defaultscreen.png", szDestDir); copyResource("Flags/vres_sd.png", szDestDir); copyResource("Flags/vres_sdi.png", szDestDir); copyResource("Flags/vres_sdp.png", szDestDir); copyResource("Flags/vsource_bluray.png", szDestDir); copyResource("Flags/vsource_defaultscreen.png", szDestDir); copyResource("Flags/vsource_dvd.png", szDestDir); copyResource("Flags/vsource_hddvd.png", szDestDir); copyResource("Flags/vsource_hdtv.png", szDestDir); copyResource("Flags/vsource_sdtv.png", szDestDir); copyResource("images/default.jpg", szDestDir); copyResource("images/dvd.jpg", szDestDir); copyResource("images/haken.png", szDestDir); copyResource("images/hd.jpg", szDestDir); copyResource("images/imdb.jpg", szDestDir); copyResource("images/movie_folder.png", szDestDir); copyResource("images/youtube.jpg", szDestDir); return(szDestDir); } void cMainWindow::writeHeader(QTextStream &out) { QStringList szHeader; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << ":.%PAGETITLE%.:"; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << ""; szHeader << " "; szHeader << ""; for(int z = 0;z < szHeader.count();z++) { QString sz = szHeader.at(z); if(szHeader.at(z).contains("%PAGETITLE%", Qt::CaseInsensitive)) sz = sz.replace("%PAGETITLE%", ui->m_lpTitle->text(), Qt::CaseInsensitive); out << sz << "\n"; } } void cMainWindow::writeFooter(QTextStream &out, const QStringList& szGenreList) { QStringList szFooter1; QStringList szFooter2; QStringList szFooterGenre; szFooter1 << ""; szFooter1 << "
"; szFooter1 << "
"; szFooter1 << ""; szFooter1 << "
"; szFooter1 << ""; szFooter1 << ""; szFooter1 << ""; szFooter1 << "
"; szFooter1 << "
"; szFooter1 << "
"; szFooter1 << "
"; szFooter1 << ""; szFooter1 << ""; szFooter1 << ""; szFooter1 << "
"; szFooter1 << "

%PAGETITLE%

"; szFooter1 << "
"; szFooter1 << ""; szFooter1 << "
"; szFooter1 << ""; szFooter1 << "
"; szFooter1 << "
    "; szFooter1 << "
  • #
  • "; szFooter1 << "
  • A
  • "; szFooter1 << "
  • B
  • "; szFooter1 << "
  • C
  • "; szFooter1 << "
  • D
  • "; szFooter1 << "
  • E
  • "; szFooter1 << "
  • F
  • "; szFooter1 << "
  • G
  • "; szFooter1 << "
  • H
  • "; szFooter1 << "
  • I
  • "; szFooter1 << "
  • J
  • "; szFooter1 << "
  • K
  • "; szFooter1 << "
  • L
  • "; szFooter1 << "
  • M
  • "; szFooter1 << "
  • N
  • "; szFooter1 << "
  • O
  • "; szFooter1 << "
  • P
  • "; szFooter1 << "
  • Q
  • "; szFooter1 << "
  • R
  • "; szFooter1 << "
  • S
  • "; szFooter1 << "
  • T
  • "; szFooter1 << "
  • U
  • "; szFooter1 << "
  • V
  • "; szFooter1 << "
  • W
  • "; szFooter1 << "
  • X
  • "; szFooter1 << "
  • Y
  • "; szFooter1 << "
  • Z
  • "; szFooter1 << "

"; szFooter1 << ""; szFooter2 << "
"; szFooter2 << ""; szFooter2 << ""; szFooter2 << " "; szFooter2 << " "; szFooter2 << " "; szFooter2 << " "; /* szFooter2 << " "; */ szFooter2 << " "; szFooter2 << " "; szFooter2 << "
"; szFooter2 << "
"; szFooter2 << " "; szFooter2 << " "; szFooter2 << " "; szFooter2 << " "; szFooter2 << "
"; szFooter2 << "
"; szFooter2 << " "; szFooter2 << "
"; szFooter2 << " "; szFooter2 << " "; szFooter2 << " "; szFooter2 << "
"; szFooter2 << "
"; szFooter2 << ""; szFooter2 << ""; szFooter2 << "
"; szFooter2 << ""; szFooter2 << ""; szFooter2 << ""; szFooter2 << "
"; szFooter2 << "
"; szFooter2 << "

"; szFooter2 << " Hilfe/Support: Ember auf german-yamj-board
"; szFooter2 << " Template v1.80 design by Cocotus

"; szFooter2 << " \"Valid "; szFooter2 << "
"; szFooter2 << "
"; szFooter2 << ""; szFooter2 << ""; szFooter2 << ""; szFooter2 << ""; szFooter2 << ""; for(int z = 0;z < szFooter1.count();z++) { QString sz = szFooter1.at(z); if(sz.contains("%PAGETITLE%", Qt::CaseInsensitive)) sz = sz.replace(QString("%PAGETITLE%"), ui->m_lpTitle->text(), Qt::CaseInsensitive); out << sz << "\n"; } for(int x = 0;x < szGenreList.count();x++) { for(int z = 0;z < szFooterGenre.count();z++) { QString sz = szFooterGenre.at(z); if(sz.contains("%GENRE%", Qt::CaseInsensitive)) sz = sz.replace(QString("%GENRE%"), szGenreList.at(x), Qt::CaseInsensitive); if(sz.contains("%GENRE1%", Qt::CaseInsensitive)) sz = sz.replace(QString("%GENRE1%"), string2HTML(szGenreList.at(x)), Qt::CaseInsensitive); out << sz << "\n"; } } for(int z = 0;z < szFooter2.count();z++) { QString sz = szFooter2.at(z); if(szFooter2.at(z).contains("%PAGETITLE%", Qt::CaseInsensitive)) sz = sz.replace(QString("%PAGETITLE%"), ui->m_lpTitle->text(), Qt::CaseInsensitive); out << sz << "\n"; } } void cMainWindow::writeMovie(QTextStream& out, const qint16& iMovie, const QString& szTitle, const qint16& iYear, const QString& szTagline, const double& dRating, const QStringList& szDirectorList, const QList& ActorList, const QStringList& szGenreList, const qint16& iRuntime, const QString& szMPAA, const QString& szPlot, const QList