/* 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 #include #include #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(); } }