From 1430a9e2b52109f3f57cfa7a9bb2f68e0dda1365 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 1 Mar 2009 20:44:32 -0500 Subject: Made the rest of the widgets use pimpl --- sigmodr/widgets/MapWildListUI.cpp | 59 ++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'sigmodr/widgets/MapWildListUI.cpp') diff --git a/sigmodr/widgets/MapWildListUI.cpp b/sigmodr/widgets/MapWildListUI.cpp index cd211819..1cfef19f 100644 --- a/sigmodr/widgets/MapWildListUI.cpp +++ b/sigmodr/widgets/MapWildListUI.cpp @@ -17,6 +17,7 @@ // Header include #include "MapWildListUI.h" +#include "MapWildListUI_p.h" // Sigmod includes #include @@ -24,54 +25,56 @@ // KDE includes #include -// Qt includes -#include -#include -#include - using namespace Sigmod; using namespace Sigmodr::Widgets; MapWildListUI::MapWildListUI(MapWildList* wildList, QWidget* parent) : - ObjectUI(parent) + ObjectUI(wildList, parent), + d(new Private(new MapWildList(*wildList))) { - setObjects(wildList, new MapWildList(*wildList)); + setWidget(d->makeWidgets(this)); } -void MapWildListUI::initGui() +void MapWildListUI::apply() { - QFile file(":/gui/mapwildlist.ui"); - file.open(QFile::ReadOnly); - QWidget *formWidget = QUiLoader().load(&file, this); - file.close(); - ui_name = formWidget->findChild("varName"); - connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString))); - QVBoxLayout* layout = new QVBoxLayout; - layout->addWidget(formWidget); - setLayout(layout); + *qobject_cast(m_object) = *d->m_wildList; + ObjectUI::apply(); } -void MapWildListUI::setGui() +void MapWildListUI::discard() { - ui_name->setText(qobject_cast(modified())->name()); + *d->m_wildList = *qobject_cast(m_object); + d->resetGui(); + ObjectUI::discard(); } -void MapWildListUI::apply() +MapWildListUI::Private::Private(MapWildList* wildList) : + ObjectUIPrivate(wildList), + m_wildList(wildList) { - *qobject_cast(original()) = *qobject_cast(modified()); - emit(changed(false)); } -void MapWildListUI::discard() +MapWildListUI::Private::~Private() +{ + delete m_wildList; +} + +QWidget* MapWildListUI::Private::makeWidgets(ObjectUI* widget) +{ + QWidget *form = openUiFile(":/gui/mapwildlist.ui", widget); + ui_name = form->findChild("varName"); + connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString))); + return form; +} + +void MapWildListUI::Private::resetGui() { - *qobject_cast(modified()) = *qobject_cast(original()); - setGui(); - emit(changed(false)); + ui_name->setText(m_wildList->name()); } -void MapWildListUI::nameChanged(const QString& name) +void MapWildListUI::Private::nameChanged(const QString& name) { const int cursor = ui_name->cursorPosition(); - qobject_cast(modified())->setName(name); + m_wildList->setName(name); ui_name->setCursorPosition(cursor); } -- cgit