diff options
Diffstat (limited to 'moviemappingpage.cpp')
-rw-r--r-- | moviemappingpage.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/moviemappingpage.cpp b/moviemappingpage.cpp new file mode 100644 index 0000000..8b7c328 --- /dev/null +++ b/moviemappingpage.cpp @@ -0,0 +1,52 @@ +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version + 2 of the License, or (at your option) any later version. +*/ + +#include <QHBoxLayout> +#include <QSqlQuery> +#include <QSettings> + +#include "moviemappingpage.h" +#include "smglobals.h" + +MovieMappingPage::MovieMappingPage(const QString &table, QWidget *parent) : QWizardPage(parent), mTable(table){ + QString title = QString(tr("Edit %1")).arg(table); + QString subTitle = QString(tr("Edit %1 by adding them from the text field below")).arg(table); + setTitle(title); + setSubTitle(subTitle); + + mWidget = new MappingEditorWidget(table, true); + QHBoxLayout *mainLayout = new QHBoxLayout; + mainLayout->addWidget(mWidget); + + setLayout(mainLayout); +} + +void MovieMappingPage::initializePage(){ + QSqlDatabase db = QSqlDatabase::database("treedb"); + if(mTable.toLower() == "actors"){ + QStringList actors; + QSqlQuery actorsQ("SELECT tactorname FROM actors", db); + while(actorsQ.next()){ + actors << actorsQ.value(0).toString(); + } + mWidget->fillCompleter(actors); + mWidget->setDecorationItem(SmGlobals::instance()->iconFor("actor")); + }else if(mTable.toLower() == "genres"){ + QStringList genres; + QSqlQuery genresQ("SELECT tgenrename FROM genres", db); + while(genresQ.next()){ + genres << genresQ.value(0).toString(); + } + mWidget->fillCompleter(genres); + mWidget->setDecorationItem(SmGlobals::instance()->iconFor("genre")); + } + QSettings s; + bool clearPage = s.value("ui/clearnewmoviewizard").toBool(); + if(clearPage){ + mWidget->clear(); + } +} |