From f46f715e46f6257fbcaeb899362ea7ffdc804739 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 20 Jan 2009 17:48:03 -0500 Subject: CoinListItem widget cleaned up more --- sigmodr/CoinListItemUI.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'sigmodr/CoinListItemUI.cpp') diff --git a/sigmodr/CoinListItemUI.cpp b/sigmodr/CoinListItemUI.cpp index 02cefddb..7910ed59 100644 --- a/sigmodr/CoinListItemUI.cpp +++ b/sigmodr/CoinListItemUI.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel + * Copyright 2008-2009 Ben Boeckel * * 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 @@ -24,8 +24,12 @@ #include "../sigmod/Sigmod.h" #include "../sigmod/Species.h" +// Qt includes +#include + Sigmodr::CoinListItemUI::CoinListItemUI(Sigmod::CoinListItem* item, QWidget* parent) : ObjectUI(parent), + m_buttonGroup(new QButtonGroup(this)), m_lastType(-1) { setupUi(this); @@ -38,15 +42,18 @@ Sigmodr::CoinListItemUI::~CoinListItemUI() void Sigmodr::CoinListItemUI::initGui() { - connect(varType, SIGNAL(activated(const int)), this, SLOT(setGui())); - varType->addItem(Sigmod::CoinListItem::TypeStr[Sigmod::CoinListItem::Item], QVariant::fromValue(Sigmod::CoinListItem::Item)); - varType->addItem(Sigmod::CoinListItem::TypeStr[Sigmod::CoinListItem::Species], QVariant::fromValue(Sigmod::CoinListItem::Species)); + setTabOrder(varItem, varSpecies); + setTabOrder(varSpecies, varObject); + setTabOrder(varObject, varCost); + m_buttonGroup->addButton(varItem, Sigmod::CoinListItem::Item); + m_buttonGroup->addButton(varSpecies, Sigmod::CoinListItem::Species); + connect(m_buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(typeChanged(int))); } void Sigmodr::CoinListItemUI::setGui() { bool resetObjects = (qobject_cast(modified())->type() != m_lastType); - varType->setCurrentIndex(qobject_cast(modified())->type()); + m_buttonGroup->button(qobject_cast(modified())->type())->setChecked(true); m_lastType = qobject_cast(modified())->type(); if (resetObjects) { @@ -87,9 +94,9 @@ void Sigmodr::CoinListItemUI::discard() emit(changed(false)); } -void Sigmodr::CoinListItemUI::on_varType_activated(const int type) +void Sigmodr::CoinListItemUI::typeChanged(const int type) { - qobject_cast(modified())->setType(varType->itemData(type).value()); + qobject_cast(modified())->setType(Sigmod::CoinListItem::Type(type)); } void Sigmodr::CoinListItemUI::on_varObject_activated(const int obey) -- cgit