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 ++++++---- sigmodr/CoinListItemUI.h | 6 ++- sigmodr/gui/coinlistitem.ui | 99 ++++++++++++++++++++++++--------------------- 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 + * 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) 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 + * 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 @@ -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 @@ - - - Type: - - - Qt::AlignRight|Qt::AlignVCenter - - - varType - - - - - - - The type of item - - - The type of item - - - The type ofitem - - - - Object: @@ -37,24 +11,62 @@ Qt::AlignRight|Qt::AlignVCenter - varObject + groupObject - - - - The object to be sold - - - The object to be sold - - - The object to be sold - + + + + + + + The object is an item + + + The object is an item + + + The object is an item + + + Item + + + + + + + The object is a creature + + + The object is a creature + + + The object is a creature + + + Creature + + + + + + + The object to be sold + + + The object to be sold + + + The object to be sold + + + + - + Cost: @@ -67,7 +79,7 @@ - + How much the object[s] cost @@ -83,7 +95,7 @@ - + Qt::Vertical @@ -110,11 +122,6 @@
KIntNumInput
- - varType - varObject - varCost - -- cgit