summaryrefslogtreecommitdiffstats
path: root/sigmodr/CoinListItemUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigmodr/CoinListItemUI.cpp')
-rw-r--r--sigmodr/CoinListItemUI.cpp21
1 files changed, 14 insertions, 7 deletions
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 <MathStuf@gmail.com>
+ * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com>
*
* 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 <QtGui/QButtonGroup>
+
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<Sigmod::CoinListItem*>(modified())->type() != m_lastType);
- varType->setCurrentIndex(qobject_cast<Sigmod::CoinListItem*>(modified())->type());
+ m_buttonGroup->button(qobject_cast<Sigmod::CoinListItem*>(modified())->type())->setChecked(true);
m_lastType = qobject_cast<Sigmod::CoinListItem*>(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<Sigmod::CoinListItem*>(modified())->setType(varType->itemData(type).value<Sigmod::CoinListItem::Type>());
+ qobject_cast<Sigmod::CoinListItem*>(modified())->setType(Sigmod::CoinListItem::Type(type));
}
void Sigmodr::CoinListItemUI::on_varObject_activated(const int obey)