summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-01-20 17:48:03 -0500
committerBen Boeckel <MathStuf@gmail.com>2009-01-20 17:48:03 -0500
commitf46f715e46f6257fbcaeb899362ea7ffdc804739 (patch)
tree3522cd48d4f949ccf7ca64350493ff1938a3a550
parent817c5fff9a504321fc8f3a9ade72c5655f26ca11 (diff)
CoinListItem widget cleaned up more
-rw-r--r--sigmodr/CoinListItemUI.cpp21
-rw-r--r--sigmodr/CoinListItemUI.h6
-rw-r--r--sigmodr/gui/coinlistitem.ui99
3 files changed, 71 insertions, 55 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)
diff --git a/sigmodr/CoinListItemUI.h b/sigmodr/CoinListItemUI.h
index c8d3202b..a8d2312a 100644
--- a/sigmodr/CoinListItemUI.h
+++ b/sigmodr/CoinListItemUI.h
@@ -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
@@ -29,6 +29,7 @@ namespace Sigmod
{
class CoinListItem;
}
+class QButtonGroup;
namespace Sigmodr
{
@@ -43,13 +44,14 @@ class CoinListItemUI : public ObjectUI, private Ui::formCoinListItem
void apply();
void discard();
protected slots:
- void on_varType_activated(const int type);
+ void typeChanged(const int type);
void on_varObject_activated(const int object);
void on_varCost_valueChanged(const int cost);
private slots:
void initGui();
void setGui();
private:
+ QButtonGroup* m_buttonGroup;
bool m_lastType;
};
}
diff --git a/sigmodr/gui/coinlistitem.ui b/sigmodr/gui/coinlistitem.ui
index 6010df58..b5e1bd44 100644
--- a/sigmodr/gui/coinlistitem.ui
+++ b/sigmodr/gui/coinlistitem.ui
@@ -3,32 +3,6 @@
<widget class="QWidget" name="formCoinListItem" >
<layout class="QGridLayout" >
<item row="0" column="0" >
- <widget class="QLabel" name="labelType" >
- <property name="text" >
- <string>Type:</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignVCenter</set>
- </property>
- <property name="buddy" >
- <cstring>varType</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="KComboBox" name="varType" >
- <property name="toolTip" >
- <string>The type of item</string>
- </property>
- <property name="statusTip" >
- <string>The type of item</string>
- </property>
- <property name="whatsThis" >
- <string>The type ofitem</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
<widget class="QLabel" name="labelObject" >
<property name="text" >
<string>Object:</string>
@@ -37,24 +11,62 @@
<set>Qt::AlignRight|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
- <cstring>varObject</cstring>
+ <cstring>groupObject</cstring>
</property>
</widget>
</item>
- <item row="1" column="1" >
- <widget class="KComboBox" name="varObject" >
- <property name="toolTip" >
- <string>The object to be sold</string>
- </property>
- <property name="statusTip" >
- <string>The object to be sold</string>
- </property>
- <property name="whatsThis" >
- <string>The object to be sold</string>
- </property>
+ <item row="0" column="1" >
+ <widget class="QWidget" name="groupObject" >
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QRadioButton" name="varItem" >
+ <property name="toolTip" >
+ <string>The object is an item</string>
+ </property>
+ <property name="statusTip" >
+ <string>The object is an item</string>
+ </property>
+ <property name="whatsThis" >
+ <string>The object is an item</string>
+ </property>
+ <property name="text" >
+ <string>Item</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QRadioButton" name="varSpecies" >
+ <property name="toolTip" >
+ <string>The object is a creature</string>
+ </property>
+ <property name="statusTip" >
+ <string>The object is a creature</string>
+ </property>
+ <property name="whatsThis" >
+ <string>The object is a creature</string>
+ </property>
+ <property name="text" >
+ <string>Creature</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" rowspan="2" >
+ <widget class="KComboBox" name="varObject" >
+ <property name="toolTip" >
+ <string>The object to be sold</string>
+ </property>
+ <property name="statusTip" >
+ <string>The object to be sold</string>
+ </property>
+ <property name="whatsThis" >
+ <string>The object to be sold</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
- <item row="2" column="0" >
+ <item row="1" column="0" >
<widget class="QLabel" name="labelCost" >
<property name="text" >
<string>Cost:</string>
@@ -67,7 +79,7 @@
</property>
</widget>
</item>
- <item row="2" column="1" >
+ <item row="1" column="1" >
<widget class="KIntNumInput" name="varCost" >
<property name="toolTip" >
<string>How much the object[s] cost</string>
@@ -83,7 +95,7 @@
</property>
</widget>
</item>
- <item row="3" column="0" colspan="2" >
+ <item row="2" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
@@ -110,11 +122,6 @@
<header location="global" >KIntNumInput</header>
</customwidget>
</customwidgets>
- <tabstops>
- <tabstop>varType</tabstop>
- <tabstop>varObject</tabstop>
- <tabstop>varCost</tabstop>
- </tabstops>
<resources/>
<connections/>
</ui>