From f8d9605077a6ed100a915c064adab76da5d240a6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 24 Feb 2009 22:46:09 -0500 Subject: Fixed up more widgets to load at runtime --- sigmodr/widgets/MapUI.cpp | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'sigmodr/widgets/MapUI.cpp') diff --git a/sigmodr/widgets/MapUI.cpp b/sigmodr/widgets/MapUI.cpp index 799c4da8..d78bce10 100644 --- a/sigmodr/widgets/MapUI.cpp +++ b/sigmodr/widgets/MapUI.cpp @@ -25,6 +25,14 @@ #include #include +// KDE includes +#include +#include + +// Qt includes +#include +#include + // FIXME: Update map editing to new collage map using namespace Sigmod; @@ -33,28 +41,29 @@ using namespace Sigmodr::Widgets; MapUI::MapUI(Map* map, QWidget* parent) : ObjectUI(parent) { - setupUi(this); setObjects(map, new Map(*map)); - varMap->setMap(map); - connect(varMap, SIGNAL(changed()), this, SIGNAL(changed())); -} - -MapUI::~MapUI() -{ +// varMap->setMap(map); +// connect(varMap, SIGNAL(changed()), this, SIGNAL(changed())); } void MapUI::initGui() { - varType->addItem(Map::TypeStr[Map::Outdoor], QVariant::fromValue(Map::Outdoor)); - varType->addItem(Map::TypeStr[Map::Dungeon], QVariant::fromValue(Map::Dungeon)); - varType->addItem(Map::TypeStr[Map::Building], QVariant::fromValue(Map::Building)); + QFile file(":/gui/map.ui"); + file.open(QFile::ReadOnly); + QWidget *formWidget = QUiLoader().load(&file, this); + file.close(); + ui_name = formWidget->findChild("varName"); + ui_type = formWidget->findChild("varType"); + connect(ui_name, SIGNAL(textChanged(QString)), this, SLOT(nameChanged(QString))); + connect(ui_type, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged(int))); + ui_type->addItems(Map::TypeStr); } void MapUI::setGui() { - varName->setText(qobject_cast(modified())->name()); - varType->setCurrentIndex(qobject_cast(modified())->type()); - varMap->reset(); + ui_name->setText(qobject_cast(modified())->name()); + ui_type->setCurrentIndex(qobject_cast(modified())->type()); +// varMap->reset(); } void MapUI::apply() @@ -70,14 +79,14 @@ void MapUI::discard() emit(changed(false)); } -void MapUI::on_varName_textChanged(const QString& name) +void MapUI::nameChanged(const QString& name) { - const int cursor = varName->cursorPosition(); + const int cursor = ui_name->cursorPosition(); qobject_cast(modified())->setName(name); - varName->setCursorPosition(cursor); + ui_name->setCursorPosition(cursor); } -void MapUI::on_varType_activated(const int type) +void MapUI::typeChanged(const int type) { - qobject_cast(modified())->setType(varType->itemData(type).value()); + qobject_cast(modified())->setType(static_cast(type)); } -- cgit