[prev in list] [next in list] [prev in thread] [next in thread]
List: atlantik-devel
Subject: [atlantik-devel] CVS: kdeaddons/atlantikdesigner/designer designer.cpp,1.35,1.36 designer.h,1.13,1.1
From: kde () office ! kde ! org
Date: 2002-06-09 7:18:48
[Download RAW message or body]
Update of /home/kde/kdeaddons/atlantikdesigner/designer
In directory office:/tmp/cvs-serv23234/designer
Modified Files:
designer.cpp designer.h editor.cpp editor.h group.cpp group.h
Log Message:
make it work perfectly, except no complex math stuff and no load/save.
Index: designer.cpp
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/designer.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- designer.cpp 2002/06/08 06:07:13 1.35
+++ designer.cpp 2002/06/09 07:18:46 1.36
@@ -35,10 +35,6 @@
AtlanticDesigner::AtlanticDesigner(QWidget *parent, const char *name) : \
KMainWindow(parent, name) {
- groups.setAutoDelete(true);
- chanceStack.setAutoDelete(true);
- ccStack.setAutoDelete(true);
-
firstBoard = true;
m_player = 0;
@@ -75,16 +71,12 @@
// these MUST match up to the ones in editor.cpp!
types.append("street");
- types.append("rr");
types.append("utility");
- types.append("cc");
- types.append("chance");
+ types.append("cards");
types.append("freeparking");
types.append("tojail");
types.append("tax");
- types.append("airport");
types.append("jail");
- types.append("go");
types.append("TODO");
isMod = false;
@@ -104,12 +96,7 @@
void AtlanticDesigner::initMembers()
{
estates.clear();
- chanceStack.setAutoDelete(true);
- chanceStack.clear();
- chanceStack.setAutoDelete(false);
- ccStack.setAutoDelete(true);
- ccStack.clear();
- ccStack.setAutoDelete(false);
+ cards.clear();
boardInfo = BoardInfo();
}
@@ -129,7 +116,7 @@
board = new AtlantikBoard(0, max, AtlantikBoard::Edit, this, "Board");
setCentralWidget(board);
layout = new QVBoxLayout(board->centerWidget());
- editor = new EstateEdit(&estates, &chanceStack, &ccStack, board->centerWidget(), \
"Estate Editor"); + editor = new EstateEdit(&groups, &estates, &cards, \
board->centerWidget(), "Estate Editor"); layout->addWidget(editor);
editor->setReady(false);
@@ -173,7 +160,6 @@
estate->setColor(fg);
estate->setBgColor(bg);
estate->setPrice(100);
- estate->setHousePrice(50);
for (int j = 0; j < 6; ++j)
estate->setRent(j, 10 * (j + 1));
estate->setChanged(false);
@@ -236,13 +222,13 @@
void AtlanticDesigner::openFile(const QString &filename)
{
- enum ParseMode { Estates=0, Chance_Cards=1, CC_Cards=2, Other=3, Meta=4 };
+ enum ParseMode { General, Board, Estates, Cards, Other, Meta };
QFile f(filename);
if (!f.open(IO_ReadOnly))
return;
initMembers();
-
+
QTextStream t(&f);
QString s = t.readLine();
ParseMode parseMode = Other;
@@ -251,7 +237,7 @@
for (i = 0; !t.atEnd();)
{
//if (i < 500)
- //kdDebug() << "s is [" << s << "]" << endl;
+ //kdDebug() << "s is [" << s << "]" << endl;
s = s.stripWhiteSpace();
if (s.isEmpty())
@@ -268,10 +254,8 @@
//kdDebug() << "setting parsemode for s [" << s << "]" << endl;
if (s == "<Estates>")
parseMode = Estates;
- else if (s == "<Chance_Cards>")
- parseMode = Chance_Cards;
- else if (s == "<CC_Cards>")
- parseMode = CC_Cards;
+ else if (s == "<Cards>")
+ parseMode = Cards;
else if (s == "<Meta>")
parseMode = Meta;
else
@@ -283,7 +267,7 @@
name = s.left(s.find("]"));
name = name.right(name.length() - name.find("[") - 1);
-
+
if (name.isEmpty())
name = i18n("No Name");
//kdDebug() << "name is " << name << endl;
@@ -293,7 +277,6 @@
int type = 0;
int group = -1;
int price = -1;
- int housePrice = -1;
int rent[6] = {-1, -1, -1, -1, -1, -1};
int tax = -1;
int taxPercentage = -1;
@@ -301,6 +284,8 @@
QStringList keys;
QValueList<int> values;
+ CardStack *curCardStack = 0;
+
while (true)
{
if (t.atEnd())
@@ -327,67 +312,72 @@
//////////////////////////////// ESTATES
if (parseMode == Estates)
{
- if (key == "type")
- {
- //kdDebug() << "its a type!\n";
- int j = 0;
- for (QStringList::Iterator it = types.begin(); it != types.end(); ++it)
+ if (key == "type")
{
- //kdDebug() << (*it) << ", " << value << endl;
- if ((*it) == value)
+ //kdDebug() << "its a type!\n";
+ int j = 0;
+ for (QStringList::Iterator it = types.begin(); it != types.end(); ++it)
{
- type = j;
- break;
+ //kdDebug() << (*it) << ", " << value << endl;
+ if ((*it) == value)
+ {
+ type = j;
+ break;
+ }
+ j++;
}
- j++;
+ //kdDebug() << "type is " << type << endl;
}
- //kdDebug() << "type is " << type << endl;
- }
- else if (key == "price")
- {
- price = value.toInt();
- }
- else if (key == "houseprice")
- {
- housePrice = value.toInt();
- }
- else if (key.left(4) == "rent")
- {
- int houses = key.right(1).toInt();
- if (houses < 0 || houses > 5)
+ else if (key == "price")
{
- continue;
+ price = value.toInt();
}
- rent[houses] = value.toInt();
- }
- else if (key == "tax")
- {
- tax = value.toInt();
- }
- else if (key == "taxpercentage")
- {
- taxPercentage = value.toInt();
- }
- else if (key == "group")
- {
- group = value.toInt();
- }
- else if (key == "color")
- {
- color.setNamedColor(value);
- //kdDebug() << "color is " << color.name() << endl;
- }
- else if (key == "bgcolor")
- {
- bgColor.setNamedColor(value);
- //kdDebug() << "bgcolor is " << bgColor.name() << endl;
- }
+ else if (key.left(4) == "rent")
+ {
+ int houses = key.right(1).toInt();
+ if (houses < 0 || houses > 5)
+ {
+ continue;
+ }
+ rent[houses] = value.toInt();
+ }
+ else if (key == "tax")
+ {
+ tax = value.toInt();
+ }
+ else if (key == "taxpercentage")
+ {
+ taxPercentage = value.toInt();
+ }
+ else if (key == "group")
+ {
+ group = value.toInt();
+ }
+ else if (key == "color")
+ {
+ color.setNamedColor(value);
+ //kdDebug() << "color is " << color.name() << endl;
+ }
+ else if (key == "bgcolor")
+ {
+ bgColor.setNamedColor(value);
+ //kdDebug() << "bgcolor is " << bgColor.name() << endl;
+ }
} ///////////////////////////// END ESTATES
- ///////////////////////////// CARDS
- else if (parseMode == Chance_Cards || parseMode == CC_Cards)
+ ///////////////////////////// CARDS
+ else if (parseMode == Cards)
{
//kdDebug() << "in card area\n";
+
+ if (key == "groupname")
+ for (QValueList<CardStack>::Iterator it = cards.begin(); it != cards.end(); \
++it) + if ((*it).name() == value)
+ {
+ curCardStack = &(*it);
+ continue;
+ }
+
bool ok;
int v = value.toInt(&ok);
if (!ok)
@@ -432,7 +422,7 @@
}
}
//else
- //kdDebug() << "ignoring line, unknown parseMode" << endl;
+ //kdDebug() << "ignoring line, unknown parseMode" << endl;
}
if (parseMode == Estates)
@@ -443,39 +433,37 @@
estate->setColor(color);
estate->setBgColor(bgColor);
estate->setType(type);
- estate->setGroup(group);
estate->setPrice(price);
- estate->setHousePrice(housePrice);
for (int j = 0; j < 6; j++)
estate->setRent(j, rent[j]);
estate->setTax(tax);
estate->setTaxPercentage(taxPercentage);
estate->setChanged(false);
estates.append(estate);
-
+
connect(estate, SIGNAL(LMBClicked(Estate *)), this, SLOT(changeEstate(Estate \
*))); connect(estate, SIGNAL(changed()), this, SLOT(modified()));
-
+
//kdDebug() << "incrementing i\n";
i++;
}
- else if (parseMode == Chance_Cards || parseMode == CC_Cards)
+ else if (parseMode == Cards)
{
//kdDebug() << "making new card" << endl;
- Card *card = new Card();
- card->name = name;
- card->keys = keys;
- card->values = values;
- (parseMode == Chance_Cards ? chanceStack : ccStack).append(card);
+ Card card;
+ card.name = name;
+ card.keys = keys;
+ card.values = values;
+ curCardStack->append(card);
}
}
if (i < 4)
{
- KMessageBox::detailedSorry(this, i18n("This board file is invalid; cannot \
open."), i18n("There are only %1 estates specified in this \
file.").arg(i));
- if (this->filename.isNull())
- close();
- return;
+ KMessageBox::detailedSorry(this, i18n("This board file is invalid; cannot open."), \
i18n("There are only %1 estates specified in this file.").arg(i)); + if \
(this->filename.isNull()) + close();
+ return;
}
max = i;
@@ -560,13 +548,8 @@
EstateType type = (EstateType)estate->type();
- t << QString("[%1]\ntype=%2\nbgcolor=%4\n").arg(estate->name()).arg(*types.at(estate->type())).arg(estate->bgColor().name());
- if (estate->color().isValid())
- t << "color=" << estate->color().name() << endl;
- if (estate->group() >= 0 && type == Street)
- t << "group=" << estate->group() << endl;
- if (estate->housePrice() >= 0 && type == Street)
- t << "houseprice=" << estate->housePrice() << endl;
+ t << QString("[%1]").arg(estate->name()) << endl;
+
if (estate->price() >= 0 && type == Street)
t << "price=" << estate->price() << endl;
if (estate->tax() >= 0 && type == Tax)
@@ -586,26 +569,23 @@
// now do the cards
+ t << "<Cards>" << endl << endl;
+
CardStack *stack = 0;
- for (int i = 0; i < 2; i++)
+ for (QValueList<CardStack>::Iterator it = cards.begin(); it != cards.end(); ++it)
{
- if (i == 0)
- {
- t << endl << QString("<Chance_Cards>") << endl;
- stack = &chanceStack;
- }
- else if (i == 1)
- {
- t << endl << QString("<CC_Cards>") << endl;
- stack = &ccStack;
- }
+ stack = &(*it);
+
+ t << "groupname=" << stack->name() << endl << endl;
Card *card = 0;
- for (card = stack->first(); card; card = stack->next())
+ for (CardStack::Iterator cit = stack->begin(); cit != stack->end(); ++cit)
{
+ card = &(*cit);
+
t << endl << "[" << card->name << "]" << endl;
QValueList<int>::Iterator vit = card->values.begin();
- for (QStringList::Iterator it = card->keys.begin(); it != card->keys.end(); ++it)
+ for (QStringList::Iterator it = card->keys.begin(); it != card->keys.end(); ++it, \
++vit) {
QString key = (*it);
int value = (*vit);
@@ -615,12 +595,12 @@
value *= -1;
key = "pay";
}
- if (key == "collecteach")
+ else if (key == "collecteach")
{
value *= -1;
key = "payeach";
}
- if (key == "goback")
+ else if (key == "goback")
{
value *= -1;
key = "advance";
@@ -630,8 +610,6 @@
value = 1;
t << key << "=" << value << endl;
-
- ++vit;
}
}
}
@@ -656,11 +634,9 @@
estate->setColor(copiedEstate->color());
estate->setBgColor(copiedEstate->bgColor());
estate->setType(copiedEstate->type());
- estate->setGroup(copiedEstate->group());
for (int i = 0; i < 6; i++)
estate->setRent(i, copiedEstate->rent(i));
estate->setPrice(copiedEstate->price());
- estate->setHousePrice(copiedEstate->housePrice());
estate->setTax(copiedEstate->tax());
estate->setTaxPercentage(copiedEstate->taxPercentage());
@@ -695,7 +671,6 @@
if (!estate)
return;
- kdDebug() << "saving first time:\n";
(void) editor->saveEstate();
editor->setEstate(static_cast<ConfigEstate *>(estate));
@@ -800,6 +775,30 @@
groupEditor->raise();
connect(groupEditor, SIGNAL(changed()), this, SLOT(modified()));
+ connect(groupEditor, SIGNAL(update()), this, SLOT(groupsChanged()));
+ connect(groupEditor, SIGNAL(update()), editor, SLOT(groupsChanged()));
+}
+
+void AtlanticDesigner::groupsChanged()
+{
+ ConfigEstate *curEstate = 0;
+ for (curEstate = estates.first(); curEstate; curEstate = estates.next())
+ {
+ // skip estate currently being edited
+ if (curEstate == editor->theEstate())
+ continue;
+
+ for (ConfigEstateGroupList::Iterator it = groups.begin(); it != groups.end(); \
++it) + {
+ if ((*it).name() == curEstate->group())
+ {
+ curEstate->setBgColor((*it).bgColor());
+ curEstate->setColor((*it).fgColor());
+ curEstate->update();
+ break;
+ }
+ }
+ }
}
void AtlanticDesigner::info()
Index: designer.h
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/designer.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- designer.h 2002/06/08 06:07:13 1.13
+++ designer.h 2002/06/09 07:18:46 1.14
@@ -48,6 +48,7 @@
void setPlayerAtBeginning();
void info();
void editGroups();
+ void groupsChanged();
void up();
void down();
@@ -75,8 +76,7 @@
KListAction *estateAct;
KRecentFilesAction *recentAct;
- CardStack chanceStack;
- CardStack ccStack;
+ QValueList<CardStack> cards;
BoardInfo boardInfo;
ConfigEstateGroupList groups;
Index: editor.cpp
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/editor.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- editor.cpp 2002/06/08 06:07:13 1.22
+++ editor.cpp 2002/06/09 07:18:46 1.23
@@ -1,21 +1,25 @@
-#include <qvbox.h>
-#include <qlabel.h>
+#include <qcheckbox.h>
#include <qframe.h>
+#include <qhgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qspinbox.h>
#include <qstringlist.h>
#include <qvaluelist.h>
-#include <qspinbox.h>
-#include <qlineedit.h>
+#include <qvbox.h>
#include <qvgroupbox.h>
-#include <qhgroupbox.h>
-#include <qlayout.h>
#include <kcombobox.h>
#include <kdebug.h>
#include <kdialog.h>
-#include <klineeditdlg.h>
#include <kdialogbase.h>
+#include <klineeditdlg.h>
+#include <klistbox.h>
#include <klocale.h>
+#include <kmessagebox.h>
#include <kpushbutton.h>
+#include <kseparator.h>
#include <atlantic/estate.h>
@@ -25,7 +29,6 @@
{
m_rent[0] = m_rent[1] = m_rent[2] = m_rent[3] = m_rent[4] = m_rent[5] = 0;
m_type = 0;
- m_group = -1;
}
void ConfigEstate::setChanged(bool b)
@@ -51,7 +54,7 @@
}
}
-void ConfigEstate::setGroup(const int group)
+void ConfigEstate::setGroup(const QString &group)
{
if (m_group != group)
{
@@ -69,15 +72,6 @@
}
}
-void ConfigEstate::setHousePrice(const int housePrice)
-{
- if (m_housePrice != housePrice)
- {
- m_housePrice = housePrice;
- m_changed = true;
- }
-}
-
void ConfigEstate::setRent(const int houses, const int rent)
{
if (m_rent[houses] != rent)
@@ -105,12 +99,51 @@
}
}
+void ConfigEstate::setTakeCard(const QString &takeCard)
+{
+ if (m_takeCard != takeCard)
+ {
+ m_takeCard = takeCard;
+ m_changed = true;
+ }
+}
+
+void ConfigEstate::setRentMath(const QString &rentMath)
+{
+ if (m_rentMath != rentMath)
+ {
+ m_rentMath = rentMath;
+ m_changed = true;
+ }
+}
+
+void ConfigEstate::setRentVar(const QString &rentVar)
+{
+ if (m_rentVar != rentVar)
+ {
+ m_rentVar = rentVar;
+ m_changed = true;
+ }
+}
+
+void ConfigEstate::setGo(const bool go)
+{
+ if (m_go != go)
+ {
+ m_go = go;
+ m_changed = true;
+ }
+}
+
///////////////////////////
QStringList types;
-EstateEdit::EstateEdit(EstateList *estates, CardStack *chanceStack, CardStack \
*ccStack, QWidget *parent, const char *name) : QWidget(parent, name) \
+EstateEdit::EstateEdit(ConfigEstateGroupList *newGroups, EstateList *estates, \
QValueList<CardStack> *cards, QWidget *parent, const char *name) + : QWidget(parent, \
name) {
+ groups = newGroups;
+
types.append("pay");
types.append("payeach");
types.append("collect");
@@ -125,55 +158,50 @@
types.append("payhouse");
types.append("payhotel");
- this->chanceStack = chanceStack;
- this->ccStack = ccStack;
+ oldType = -1;
+ estate = 0;
+ this->cards = cards;
this->estates = estates;
ready = false;
locked = false;
connect(this, SIGNAL(somethingChanged()), this, SLOT(saveEstate()));
- layout = new QGridLayout(this, 6, 1, 6, 3);
+ layout = new QGridLayout(this, 5, 1, KDialog::marginHint(), \
KDialog::spacingHint()); nameEdit = new QLineEdit(this, "Name Edit");
layout->addWidget(nameEdit, 0, 0);
connect(nameEdit, SIGNAL(returnPressed()), this, SIGNAL(somethingChanged()));
confDlg = 0;
- oldConfDlg = 0;
- reallyOldConfDlg = 0;
- layout->addWidget(new QWidget(this), 2, 0);
- layout->setRowStretch(2, 1);
+ layout->setRowStretch(2, 2);
- QHBoxLayout *typeLayout = new QHBoxLayout(layout, 6);
+ QHBoxLayout *typeLayout = new QHBoxLayout(KDialog::spacingHint());
+ layout->addLayout(typeLayout, 3, 0);
+
QLabel *typeLabel = new QLabel(i18n("Type"), this);
- typeLayout->addWidget(typeLabel, 4, 0);
+ typeLayout->addWidget(typeLabel);
typeCombo = new KComboBox(false, this, "Type Combo");
- typeLayout->addWidget(typeCombo, 5, 0);
+ typeLayout->addWidget(typeCombo);
connect(typeCombo, SIGNAL(activated(int)), this, SIGNAL(somethingChanged()));
- QStringList types(i18n("Street"));
- types.append(i18n("Railroad"));
- types.append(i18n("Utility"));
- types.append(i18n("Community Chest"));
- types.append(i18n("Chance"));
- types.append(i18n("Free Parking"));
- types.append(i18n("Go to jail"));
- types.append(i18n("Tax"));
- types.append(i18n("Airport"));
- types.append(i18n("Jail"));
- types.append(i18n("Go"));
- types.append("TODO");
- typeCombo->insertStringList(types);
+ goCheck = new QCheckBox(i18n("This estate is a Go"), this);
+ connect(goCheck, SIGNAL(toggled(bool)), this, SIGNAL(somethingChanged()));
+ layout->addWidget(goCheck, 4, 0);
+
+ QStringList estateTypes(i18n("Street"));
+ estateTypes.append(i18n("Utility"));
+ estateTypes.append(i18n("Cards"));
+ estateTypes.append(i18n("Free Parking"));
+ estateTypes.append(i18n("Go to jail"));
+ estateTypes.append(i18n("Tax"));
+ estateTypes.append(i18n("Jail"));
+ estateTypes.append("TODO");
+ typeCombo->insertStringList(estateTypes);
}
void EstateEdit::aboutToDie()
{
- //kdDebug() << "aboutToDie()\n";
- delete reallyOldConfDlg;
- reallyOldConfDlg = 0;
- delete oldConfDlg;
- oldConfDlg = 0;
delete confDlg;
confDlg = 0;
}
@@ -185,16 +213,20 @@
void EstateEdit::setEstate(ConfigEstate *_estate)
{
+ if (!_estate)
+ return;
+
// wait for it to become unlocked
while (1)
if (!locked)
break;
- this->estate = _estate;
+ estate = _estate;
ready = false;
- nameEdit->setText(_estate->name());
- typeCombo->setCurrentItem(_estate->type());
+ nameEdit->setText(estate->name());
+ typeCombo->setCurrentItem(estate->type());
+ goCheck->setChecked(estate->go());
ready = true;
@@ -208,16 +240,15 @@
locked = true;
- //kdDebug() << "saveEstate, saving " << estate->name() << endl;
-
EstateType curType = (EstateType)typeCombo->currentItem();
if (!superficial)
{
- emit saveDialogSettings();
+ confDlg->slotOk();
estate->setType(curType);
estate->setName(nameEdit->text());
+ estate->setGo(goCheck->isChecked());
}
if (curType != Street)
@@ -238,44 +269,42 @@
{
if (oldType == typeCombo->currentItem())
{
- emit updateDialogSettings(estate);
+ confDlg->slotUpdate(estate);
return;
}
-
- if (reallyOldConfDlg)
- {
- delete reallyOldConfDlg;
- }
- reallyOldConfDlg = oldConfDlg;
- oldConfDlg = confDlg;
- confDlg = 0;
+ delete confDlg;
- switch ((EstateType)typeCombo->currentItem())
+ switch (estate->type())
{
case Street:
- confDlg = new StreetDlg(estate, this);
- connect(this, SIGNAL(saveDialogSettings()), static_cast<StreetDlg *>(confDlg), \
SLOT(slotOk()));
- connect(this, SIGNAL(updateDialogSettings(ConfigEstate *)), static_cast<StreetDlg \
*>(confDlg), SLOT(slotUpdate(ConfigEstate *))); + confDlg = new StreetDlg(groups, \
this); break;
+
case Tax:
- confDlg = new TaxDlg(estate, this);
- connect(this, SIGNAL(saveDialogSettings()), static_cast<TaxDlg *>(confDlg), \
SLOT(slotOk()));
- connect(this, SIGNAL(updateDialogSettings(ConfigEstate *)), static_cast<TaxDlg \
*>(confDlg), SLOT(slotUpdate(ConfigEstate *)));
- break;
- case Chance:
- confDlg = new CardView(estates, chanceStack, this);
+ confDlg = new TaxDlg(this);
break;
- case CommunityChest:
- confDlg = new CardView(estates, ccStack, this);
+
+ case Cards:
+ confDlg = new CardsDlg(estates, cards, this);
break;
+
default:
- confDlg = new QWidget(this);
+ confDlg = new EstateDlg(this);
+ break;
}
+
+ confDlg->slotUpdate(estate);
+
layout->addWidget(confDlg, 1, 0);
confDlg->show();
- oldType = (EstateType)typeCombo->currentItem();
+ oldType = typeCombo->currentItem();
+}
+
+void EstateEdit::groupsChanged()
+{
+ confDlg->groupsChanged();
}
bool EstateEdit::upArrow()
@@ -310,36 +339,112 @@
/////////////////////////////////
-TaxDlg::TaxDlg(ConfigEstate *estate, QWidget *parent, char *name)
- : QWidget(parent, name)
+TaxDlg::TaxDlg(QWidget *parent, char *name)
+ : EstateDlg(parent, name)
{
- QGridLayout *taxBox = new QGridLayout(this, 2, 2);
+ QGridLayout *taxBox = new QGridLayout(this, 2, 2, KDialog::marginHint(), \
KDialog::spacingHint()); taxBox->addWidget(new QLabel(i18n("Fixed tax"), this), 0, \
0); taxBox->addWidget(tax = new QSpinBox(0, 3000, 1, this), 0, 1);
tax->setSuffix("$");
taxBox->addWidget(new QLabel(i18n("Percentage tax"), this), 1, 0);
taxBox->addWidget(taxPercentage = new QSpinBox(0, 100, 1, this), 1, 1);
taxPercentage->setSuffix("%");
-
- slotUpdate(estate);
}
-void TaxDlg::slotOk()
+void TaxDlg::save()
{
estate->setTax(tax->value());
estate->setTaxPercentage(taxPercentage->value());
}
-void TaxDlg::slotUpdate(ConfigEstate *estate)
+void TaxDlg::update()
{
- this->estate = estate;
tax->setValue(estate->tax());
-
taxPercentage->setValue(estate->taxPercentage());
}
/////////////////////////////////
+CardsDlg::CardsDlg(EstateList *newEstates, QValueList<CardStack> *newCards, QWidget \
*parent, char *name) + : EstateDlg(parent, name)
+{
+ estates = newEstates;
+ stacks = newCards;
+
+ view = 0;
+
+ vlayout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
+
+ QHBoxLayout *layout = new QHBoxLayout(vlayout, KDialog::spacingHint());
+
+ KPushButton *addB = new KPushButton(i18n("&New Stack"), this);
+ connect(addB, SIGNAL(clicked()), this, SLOT(addStack()));
+ layout->addWidget(addB);
+ layout->addStretch();
+
+ layout->addWidget(new QLabel(i18n("Cards from"), this));
+ QStringList cardNames;
+ for (QValueList<CardStack>::Iterator it = stacks->begin(); it != stacks->end(); \
++it) + cardNames.append((*it).name());
+
+ cards = new QComboBox(this);
+ cards->insertStringList(cardNames);
+ layout->addWidget(cards);
+ connect(cards, SIGNAL(activated(const QString &)), this, SLOT(updateView(const \
QString &))); +
+ vlayout->addWidget(new KSeparator(this));
+}
+
+void CardsDlg::addStack()
+{
+ bool ok;
+ QString name = KLineEditDlg::getText(i18n("Add Stack"), i18n("Enter the name of the \
new stack below."), QString::null, &ok, this); + if (ok)
+ {
+ for (QValueList<CardStack>::Iterator it = stacks->begin(); it != stacks->end(); \
++it) + {
+ if ((*it).name() == name)
+ {
+ KMessageBox::information(this, i18n("That name is already on the list."));
+ return;
+ }
+ }
+
+ stacks->append(CardStack(name));
+ cards->insertItem(name);
+ cards->setCurrentText(name);
+ updateView(name);
+ }
+}
+
+void CardsDlg::updateView(const QString &curName)
+{
+ CardStack *curStack = 0;
+ for (QValueList<CardStack>::Iterator it = stacks->begin(); it != stacks->end(); \
++it) + if ((*it).name() == curName)
+ curStack = &(*it);
+
+ if (!curStack)
+ return;
+
+ delete view;
+ view = new CardView(estates, curStack, this);
+ vlayout->addWidget(view);
+ view->show();
+}
+
+void CardsDlg::save()
+{
+ estate->setTakeCard(cards->currentText());
+}
+
+void CardsDlg::update()
+{
+ cards->setCurrentText(estate->takeCard());
+}
+
+/////////////////////////////////
+
ChooseWidget::ChooseWidget(EstateList *estates, int id, Card *card, QWidget *parent, \
char *name) : QWidget (parent, name)
{
@@ -389,7 +494,7 @@
{
if (!estate)
return;
- //kdDebug() << "estateChanged, and changing\n";
+
(*card->values.at(id)) = i;
estate->setCurrentItem(i);
}
@@ -408,14 +513,11 @@
if (number)
{
- //kdDebug() << "initting number\n";
delete estate;
estate = 0;
- //kdDebug() << "estate deleted\n";
value = new QSpinBox(0, 1000, 1, this);
- //kdDebug() << "adding widget\n";
hlayout->addWidget(value);
connect(value, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
@@ -423,10 +525,8 @@
}
else
{
- //kdDebug() << "deleting value\n";
delete value;
value = 0;
- //kdDebug() << "making combobox\n";
estate = new KComboBox(this);
ConfigEstate *curestate = 0;
QStringList estateStrings;
@@ -435,7 +535,6 @@
estate->insertStringList(estateStrings);
connect(estate, SIGNAL(activated(int)), this, SLOT(estateChanged(int)));
- //kdDebug() << "adding estate\n";
hlayout->addWidget(estate);
estate->show();
}
@@ -481,7 +580,7 @@
layout = new QVBoxLayout(this, KDialog::spacingHint());
QHBoxLayout *hlayout = new QHBoxLayout(layout);
- addButton = new KPushButton(i18n("&Add..."), this);
+ addButton = new KPushButton(i18n("&Add Card..."), this);
connect(addButton, SIGNAL(clicked()), this, SLOT(add()));
hlayout->addWidget(addButton);
hlayout->addStretch();
@@ -493,9 +592,7 @@
connect(delButton, SIGNAL(clicked()), this, SLOT(del()));
hlayout->addWidget(delButton);
- List = new QListBox(this);
- List->setMinimumHeight(50); // gets squashed vertically w/o
- List->setMaximumHeight(80); // gets spreeaaaaad vertically w/o
+ List = new KListBox(this);
layout->addWidget(List);
connect(List, SIGNAL(highlighted(int)), this, SLOT(selected(int)));
@@ -507,15 +604,9 @@
lessButton = new KPushButton(i18n("&Fewer Properties"), this);
connect(lessButton, SIGNAL(clicked()), this, SLOT(less()));
hlayout->addWidget(lessButton);
-
- //kdDebug() << "loading cards...\n";
- Card *card = 0;
- for (card = stack->first(); card; card = stack->next())
- {
- //kdDebug() << "adding to list: " << card->name << endl;
- List->insertItem(card->name);
- }
+ for (CardStack::Iterator it = stack->begin(); it != stack->end(); ++it)
+ List->insertItem((*it).name);
updateButtonsEnabled();
}
@@ -554,15 +645,13 @@
void CardView::add()
{
bool ok = false;
- QString name = KLineEditDlg::getText(i18n("New card name:"), QString::null, &ok, \
this); + QString name = KLineEditDlg::getText(i18n("Add Card"), i18n("Enter the name \
of the new card below."), QString::null, &ok, this); if (ok)
List->insertItem(name, 0);
choosies.clear();
- Card *newCard = new Card;
- newCard->name = name;
- stack->prepend(newCard);
+ stack->prepend(Card(name));
List->setCurrentItem(0);
@@ -578,10 +667,10 @@
return;
bool ok = false;;
- QString name = KLineEditDlg::getText(i18n("New card name:"), List->text(curItem), \
&ok, this); + QString name = KLineEditDlg::getText(i18n("Add Card"), i18n("Enter the \
name of the new card below."), QString::null, &ok, this); if (ok)
{
- stack->at(curItem)->name = name;
+ (*stack->at(curItem)).name = name;
List->changeItem(name, curItem);
}
@@ -607,15 +696,12 @@
{
choosies.clear();
- //kdDebug() << "selected (" << i << ")\n";
- card = stack->at(i);
+ card = &(*stack->at(i));
unsigned int num = card->keys.count();
- //kdDebug() << "num is " << num << endl;
QValueList<int>::Iterator vit = card->values.begin();
for (QStringList::Iterator it = card->keys.begin(); it != card->keys.end(); ++it)
{
- //kdDebug() << "creating a choser, id " << choosies.count() << endl;
ChooseWidget *newChooseWidget = new ChooseWidget(estates, choosies.count(), card, \
this);
choosies.append(newChooseWidget);
@@ -627,14 +713,11 @@
newChooseWidget->valueChanged(*vit);
newChooseWidget->estateChanged(*vit);
- //kdDebug() << "chooser made\n";
-
++vit;
}
if (num == 0)
{
- //kdDebug() << "doing more\n";
card->values.clear();
more();
}
@@ -654,34 +737,32 @@
/////////////////////////////////
-StreetDlg::StreetDlg(ConfigEstate *estate, QWidget *parent, char *name)
- : QWidget(parent, name)
+StreetDlg::StreetDlg(ConfigEstateGroupList *newGroups, QWidget *parent, char *name)
+ : EstateDlg(parent, name)
{
- QVBoxLayout *bigbox = new QVBoxLayout(this, KDialog::spacingHint());
+ groups = newGroups;
- QVGroupBox *RentPage = new QVGroupBox(i18n("&Rent by # of houses"), this);
+ QVBoxLayout *bigbox = new QVBoxLayout(this, KDialog::marginHint(), \
KDialog::spacingHint()); +
+ QVGroupBox *RentPage = new QVGroupBox(i18n("&Rent By Number of Houses"), this);
RentPage->setInsideSpacing(KDialog::spacingHint());
+ RentPage->setInsideMargin(KDialog::marginHint());
bigbox->addWidget(RentPage);
QWidget *topRent = new QWidget(RentPage);
- QGridLayout *rentBox = new QGridLayout(topRent, 2, 7, KDialog::spacingHint());
+ QGridLayout *rentBox = new QGridLayout(topRent, 3, 3, KDialog::spacingHint());
rentBox->addWidget(new QLabel(i18n("None"), topRent), 0, 0);
rentBox->addWidget(new QLabel(i18n("One"), topRent), 0, 1);
- rentBox->setColStretch(1, 1);
rentBox->addWidget(new QLabel(i18n("Two"), topRent), 0, 2);
- rentBox->setColStretch(2, 2);
- rentBox->addWidget(new QLabel(i18n("Three"), topRent), 0, 3);
- rentBox->setColStretch(3, 3);
- rentBox->addWidget(new QLabel(i18n("Four"), topRent), 0, 4);
- rentBox->setColStretch(4, 4);
- rentBox->addWidget(new QLabel(i18n("Hotel"), topRent), 0, 5);
- rentBox->setColStretch(5, 5);
+ rentBox->addWidget(new QLabel(i18n("Three"), topRent), 2, 0);
+ rentBox->addWidget(new QLabel(i18n("Four"), topRent), 2, 1);
+ rentBox->addWidget(new QLabel(i18n("Hotel"), topRent), 2, 2);
rentBox->addWidget(houses0 = new QSpinBox(0, 3000, 1, topRent), 1, 0);
rentBox->addWidget(houses1 = new QSpinBox(0, 3000, 1, topRent), 1, 1);
rentBox->addWidget(houses2 = new QSpinBox(0, 3000, 1, topRent), 1, 2);
- rentBox->addWidget(houses3 = new QSpinBox(0, 3000, 1, topRent), 1, 3);
- rentBox->addWidget(houses4 = new QSpinBox(0, 3000, 1, topRent), 1, 4);
- rentBox->addWidget(houses5 = new QSpinBox(0, 3000, 1, topRent), 1, 5);
+ rentBox->addWidget(houses3 = new QSpinBox(0, 3000, 1, topRent), 3, 0);
+ rentBox->addWidget(houses4 = new QSpinBox(0, 3000, 1, topRent), 3, 1);
+ rentBox->addWidget(houses5 = new QSpinBox(0, 3000, 1, topRent), 3, 2);
houses0->setSuffix(i18n("$"));
houses1->setSuffix(i18n("$"));
houses2->setSuffix(i18n("$"));
@@ -693,26 +774,51 @@
pricesBox->addWidget(new QLabel(i18n("Price"), this), 0, 0);
pricesBox->addWidget(price = new QSpinBox(0, 3000, 25, this), 0, 1);
price->setSuffix(i18n("$"));
- pricesBox->addWidget(new QLabel(i18n("House price"), this), 1, 0);
- pricesBox->addWidget(housePrice = new QSpinBox(0, 3000, 25, this), 1, 1);
- housePrice->setSuffix(i18n("$"));
- QHBoxLayout *groupLayout = new QHBoxLayout(bigbox, KDialog::spacingHint());
QLabel *groupLabel = new QLabel(i18n("Group"), this);
- groupLayout->addWidget(groupLabel);
- groupCombo = new KComboBox(false, this, "Group Combo");
- QStringList groups(i18n("None"));
- for (int i = 0; i <= 20; i++)
+ pricesBox->addWidget(groupLabel, 1, 0);
+ groupCombo = new KComboBox(this, "Group Combo");
+ groupUpdate();
+ connect(groupCombo, SIGNAL(activated(const QString &)), this, \
SLOT(groupChanged(const QString &))); +
+ pricesBox->addWidget(groupCombo, 1, 1);
+}
+
+void StreetDlg::groupChanged(const QString &groupName)
+{
+ for (ConfigEstateGroupList::Iterator it = groups->begin(); it != groups->end(); \
++it) {
- groups.append(QString::number(i));
+ if ((*it).name() == groupName)
+ {
+ estate->setColor((*it).fgColor());
+ estate->setBgColor((*it).bgColor());
+
+ estate->update();
+
+ break;
+ }
}
- groupCombo->insertStringList(groups);
- groupLayout->addWidget(groupCombo);
+}
- slotUpdate(estate);
+void StreetDlg::groupUpdate()
+{
+ QString curGroupName = groupCombo->currentText();
+
+ QStringList newGroups;
+ for (ConfigEstateGroupList::Iterator it = groups->begin(); it != groups->end(); \
++it) + newGroups.append((*it).name());
+
+ groupCombo->clear();
+ groupCombo->insertStringList(newGroups);
+
+ if (!curGroupName.isNull())
+ {
+ groupCombo->setCurrentText(curGroupName);
+ groupChanged(curGroupName);
+ }
}
-void StreetDlg::slotOk()
+void StreetDlg::save()
{
estate->setRent(0, houses0->value());
estate->setRent(1, houses1->value());
@@ -721,14 +827,11 @@
estate->setRent(4, houses4->value());
estate->setRent(5, houses5->value());
estate->setPrice(price->value());
- estate->setHousePrice(housePrice->value());
- estate->setGroup(groupCombo->currentItem() - 1);
+ estate->setGroup(groupCombo->currentText());
}
-void StreetDlg::slotUpdate(ConfigEstate *estate)
+void StreetDlg::update()
{
- this->estate = estate;
-
houses0->setValue(estate->rent(0));
houses1->setValue(estate->rent(1));
houses2->setValue(estate->rent(2));
@@ -737,9 +840,11 @@
houses5->setValue(estate->rent(5));
price->setValue(estate->price());
- housePrice->setValue(estate->housePrice());
- groupCombo->setCurrentItem(estate->group() + 1);
+ if (estate->group().isNull())
+ groupCombo->setCurrentItem(-1);
+ else
+ groupCombo->setCurrentText(estate->group());
}
#include "editor.moc"
Index: editor.h
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/editor.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- editor.h 2002/06/08 06:07:13 1.17
+++ editor.h 2002/06/09 07:18:46 1.18
@@ -8,65 +8,106 @@
#include <atlantic/estate.h>
+#include "group.h"
+
class QCheckBox;
class QGridLayout;
class QLineEdit;
class QSpinBox;
class KComboBox;
+class KListBox;
class KPushButton;
-// following enum taken from monopd/estate.h, and numbers all decreased by one
-enum EstateType { Street=0, RR=1, Utility=2, CommunityChest=3, Chance=4, \
FreeParking=5, ToJail=6, Tax=7, Airport=8, Jail=9, Go=10, Other=11 }; +enum \
EstateType { Street = 0, Utility, Cards, FreeParking, ToJail, Tax, Jail, Other };
class ConfigEstate : public Estate
{
public:
ConfigEstate(int estateId);
void setEstateId(const int estateId);
- int type() {return m_type; };
+ int type() { return m_type; };
void setType(const int type);
- int group() {return m_group; };
- void setGroup(const int group);
+ const QString &group() { return m_group; };
+ void setGroup(const QString &group);
int price() { return m_price; }
void setPrice(int);
- int housePrice() { return m_housePrice; }
- void setHousePrice(const int);
int rent(int _h) { return m_rent[_h]; }
void setRent(const int, const int);
int tax() { return m_tax; }
void setTax(const int);
- int taxPercentage() {return m_taxPercentage; }
+ int taxPercentage() { return m_taxPercentage; }
void setTaxPercentage(const int);
+ const QString &takeCard() { return m_takeCard; }
+ void setTakeCard(const QString &);
+ const QString &rentMath() { return m_rentMath; }
+ void setRentMath(const QString &);
+ const QString &rentVar() { return m_rentVar; }
+ void setRentVar(const QString &);
+ bool go() { return m_go; }
+ void setGo(const bool);
void setChanged(bool);
private:
int m_type;
- int m_group;
+ QString m_group;
int m_rent[6];
int m_price;
- int m_housePrice;
int m_tax;
int m_taxPercentage;
+ QString m_takeCard;
+ QString m_rentMath;
+ QString m_rentVar;
+ bool m_go;
};
typedef QPtrList<ConfigEstate> EstateList;
struct Card
{
- Card() { name = QString::null; }
+ Card() {}
+ Card(const QString &newName) { name = newName; }
QString name;
QStringList keys;
QValueList<int> values;
};
-typedef QPtrList<Card> CardStack;
+class CardStack : public QValueList<Card>
+{
+ public:
+ CardStack() {}
+ CardStack(const QString &newName) { setName(newName); }
+ const QString &name() { return m_name; }
+ void setName(const QString &newName) { m_name = newName; }
+
+ private:
+ QString m_name;
+};
+
+class EstateDlg : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ EstateDlg(QWidget *parent = 0, char *name = 0) : QWidget(parent, name) { estate = \
0; };
+ public slots:
+ virtual void slotOk() { save(); }
+ void slotUpdate(ConfigEstate *newEstate) { estate = newEstate; if (estate) \
update(); } + void groupsChanged() { groupUpdate(); }
+
+ protected:
+ virtual void update() {}
+ virtual void save() {}
+ virtual void groupUpdate() {};
+ ConfigEstate *estate;
+};
+
class EstateEdit : public QWidget
{
Q_OBJECT
public:
- EstateEdit(EstateList *, CardStack *, CardStack *, QWidget *parent = 0, const char \
*name = 0); + EstateEdit(ConfigEstateGroupList *, EstateList *, QValueList<CardStack> \
*, QWidget *parent = 0, const char *name = 0); ConfigEstate *theEstate() { return \
estate; } bool upArrow();
bool downArrow();
@@ -78,12 +119,11 @@
public slots:
void setEstate(ConfigEstate *);
ConfigEstate *saveEstate(bool superficial = false);
+ void groupsChanged();
signals:
void somethingChanged();
void modified();
- void saveDialogSettings();
- void updateDialogSettings(ConfigEstate *);
private slots:
void configure();
@@ -91,20 +131,19 @@
private:
KComboBox *typeCombo;
QLineEdit *nameEdit;
+ QCheckBox *goCheck;
QWidget *centerWidget;
QGridLayout *layout;
EstateList *estates;
+ QValueList<CardStack> *cards;
+ ConfigEstateGroupList *groups;
ConfigEstate *estate;
- CardStack *chanceStack;
- CardStack *ccStack;
- QWidget *confDlg;
- QWidget *oldConfDlg;
- QWidget *reallyOldConfDlg;
+ EstateDlg *confDlg;
- EstateType oldType;
+ int oldType;
bool ready;
bool locked;
@@ -154,7 +193,7 @@
void updateButtonsEnabled();
private:
- QListBox *List;
+ KListBox *List;
KPushButton *addButton;
KPushButton *renameButton;
KPushButton *delButton;
@@ -171,36 +210,62 @@
QPtrList<ChooseWidget> choosies;
};
-class TaxDlg : public QWidget
+class TaxDlg : public EstateDlg
{
Q_OBJECT
public:
- TaxDlg(ConfigEstate *, QWidget *parent = 0, char *name = 0);
+ TaxDlg(QWidget *parent = 0, char *name = 0);
- public slots:
- void slotOk();
- void slotUpdate(ConfigEstate *);
+ protected:
+ virtual void save();
+ virtual void update();
private:
- ConfigEstate *estate;
QSpinBox *tax;
QSpinBox *taxPercentage;
};
-class StreetDlg : public QWidget
+class CardsDlg : public EstateDlg
{
Q_OBJECT
public:
- StreetDlg(ConfigEstate *, QWidget *parent = 0, char *name = 0);
+ CardsDlg(EstateList *, QValueList<CardStack> *, QWidget *parent = 0, char *name = \
0);
- public slots:
- void slotOk();
- void slotUpdate(ConfigEstate *);
+ protected:
+ virtual void save();
+ virtual void update();
+ private slots:
+ void addStack();
+ void updateView(const QString &);
+
private:
- ConfigEstate *estate;
+ QValueList<CardStack> *stacks;
+ EstateList *estates;
+
+ QComboBox *cards;
+ CardView *view;
+ QVBoxLayout *vlayout;
+};
+
+class StreetDlg : public EstateDlg
+{
+ Q_OBJECT
+
+ public:
+ StreetDlg(ConfigEstateGroupList *, QWidget *parent = 0, char *name = 0);
+
+ protected:
+ virtual void save();
+ virtual void update();
+ virtual void groupUpdate();
+
+ private slots:
+ void groupChanged(const QString &);
+
+ private:
QSpinBox *houses0;
QSpinBox *houses1;
QSpinBox *houses2;
@@ -208,8 +273,11 @@
QSpinBox *houses4;
QSpinBox *houses5;
QSpinBox *price;
- QSpinBox *housePrice;
KComboBox *groupCombo;
+
+ ConfigEstateGroupList *groups;
+
+ ConfigEstateGroup *curGroup();
};
#endif
Index: group.cpp
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/group.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- group.cpp 2002/06/08 06:07:13 1.1
+++ group.cpp 2002/06/09 07:18:46 1.2
@@ -2,6 +2,7 @@
#include <qvgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
+#include <qspinbox.h>
#include <qstring.h>
#include <qstringlist.h>
@@ -12,11 +13,12 @@
#include <klocale.h>
#include <kmessagebox.h>
#include <kpushbutton.h>
+#include <kseparator.h>
#include "group.h"
GroupEditor::GroupEditor(ConfigEstateGroupList *newList)
- : KDialogBase(KDialogBase::Plain, i18n("Group Editor"), Ok|Cancel, Ok, 0, "Group \
Editor", false, true), mylist(*newList) + : KDialogBase(KDialogBase::Plain, \
i18n("Group Editor"), Ok|Apply|Cancel, Ok, 0, "Group Editor", false, true), \
mylist(*newList) {
setWFlags(WDestructiveClose);
list = newList;
@@ -28,9 +30,8 @@
hlayout->addWidget(groups);
connect(groups, SIGNAL(executed(QListBoxItem *)), this, \
SLOT(updateSettings(QListBoxItem *))); QStringList newgroups;
- ConfigEstateGroup *group = 0;
- for (group = list->first(); group; group = list->next())
- newgroups.append(group->name());
+ for (ConfigEstateGroupList::Iterator it = list->begin(); it != list->end(); ++it)
+ newgroups.append((*it).name());
groups->insertStringList(newgroups);
connect(groups, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
@@ -48,6 +49,18 @@
connect(bgButton, SIGNAL(changed(const QColor &)), this, SLOT(bgChanged(const \
QColor &))); connect(bgButton, SIGNAL(changed(const QColor &)), this, \
SIGNAL(changed()));
+ pricesGroupBox = new QVGroupBox(i18n("&Prices"), page);
+ vlayout->addWidget(pricesGroupBox);
+
+ QWidget *pricesDummy = new QWidget(pricesGroupBox);
+ QHBoxLayout *housePriceLayout = new QHBoxLayout(pricesDummy, spacingHint());
+ housePriceLayout->addWidget(new QLabel(i18n("House price"), pricesDummy), 1, 0);
+ housePriceLayout->addWidget(housePrice = new QSpinBox(0, 3000, 25, pricesDummy));
+ housePrice->setSuffix(i18n("$"));
+ connect(housePrice, SIGNAL(valueChanged(int)), this, SLOT(housePriceChanged(int)));
+
+ //vlayout->addWidget(new KSeparator(page));
+
QHBoxLayout *buttonlayout = new QHBoxLayout(vlayout, spacingHint());
removeB = new KPushButton(i18n("&Remove"), page);
buttonlayout->addWidget(removeB);
@@ -66,17 +79,16 @@
QString name = KLineEditDlg::getText(i18n("Add Group"), i18n("Enter the name of the \
new group below."), QString::null, &ok, this); if (ok)
{
- ConfigEstateGroup *group = 0;
- for (group = mylist.first(); group; group = mylist.next())
+ for (ConfigEstateGroupList::Iterator it = mylist.begin(); it != mylist.end(); \
++it) {
- if (group->name() == name)
+ if ((*it).name() == name)
{
KMessageBox::information(this, i18n("That group is already on the list."));
return;
}
}
- mylist.append(new ConfigEstateGroup(name));
+ mylist.append(ConfigEstateGroup(name));
groups->insertItem(name);
emit changed();
@@ -89,6 +101,14 @@
if (!curText.isNull())
{
groups->removeItem(groups->currentItem());
+ for (ConfigEstateGroupList::Iterator it = mylist.begin(); it != mylist.end(); \
++it) + {
+ if ((*it).name() == curText)
+ {
+ mylist.remove(it);
+ break;
+ }
+ }
emit changed();
}
@@ -96,13 +116,16 @@
void GroupEditor::updateSettings(QListBoxItem *item)
{
- ConfigEstateGroup *group = 0;
- for (group = mylist.first(); group; group = mylist.next())
- if (group->name() == item->text())
+ for (ConfigEstateGroupList::Iterator it = mylist.begin(); it != mylist.end(); \
++it) + {
+ if ((*it).name() == item->text())
+ {
+ fgButton->setColor((*it).fgColor());
+ bgButton->setColor((*it).bgColor());
+ housePrice->setValue((*it).housePrice());
break;
-
- fgButton->setColor(group->fgColor());
- bgButton->setColor(group->bgColor());
+ }
+ }
}
ConfigEstateGroup *GroupEditor::currentGroup()
@@ -111,10 +134,9 @@
if (!item)
return 0;
- ConfigEstateGroup *group = 0;
- for (group = mylist.first(); group; group = mylist.next())
- if (group->name() == item->text())
- return group;
+ for (ConfigEstateGroupList::Iterator it = mylist.begin(); it != mylist.end(); \
++it) + if ((*it).name() == item->text())
+ return &(*it);
return 0;
}
@@ -133,10 +155,26 @@
group->setBgColor(color);
}
-void GroupEditor::slotOk()
+void GroupEditor::housePriceChanged(int newValue)
+{
+ ConfigEstateGroup *group = currentGroup();
+ if (group)
+ group->setHousePrice(newValue);
+}
+
+void GroupEditor::slotApply()
{
*list = mylist;
+ KDialogBase::slotApply();
+
+ emit update();
+}
+
+void GroupEditor::slotOk()
+{
+ slotApply();
+
KDialogBase::slotOk();
}
@@ -144,6 +182,7 @@
{
bool issel = groups->currentItem() >= 0;
colorGroupBox->setEnabled(issel);
+ pricesGroupBox->setEnabled(issel);
removeB->setEnabled(issel);
}
Index: group.h
===================================================================
RCS file: /home/kde/kdeaddons/atlantikdesigner/designer/group.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- group.h 2002/06/08 06:07:13 1.1
+++ group.h 2002/06/09 07:18:46 1.2
@@ -13,26 +13,33 @@
class KPushButton;
class QListBoxItem;
+class QSpinBox;
class QVGroupBox;
-class ConfigEstateGroup : public EstateGroup
+class ConfigEstateGroup
{
- Q_OBJECT
-
public:
- ConfigEstateGroup() : EstateGroup(QString::null) {}
- ConfigEstateGroup(const QString &name) : EstateGroup(name) {}
- void setFgColor(const QColor &color) { m_fgColor = color; }
- void setBgColor(const QColor &color) { m_bgColor = color; }
+ ConfigEstateGroup() { init(); }
+ ConfigEstateGroup(const QString &name) { setName(name); init(); }
+ void init() { setHousePrice(0); }
+
+ void setHousePrice(int newPrice) { m_housePrice = newPrice; }
+ int housePrice() { return m_housePrice; }
+ void setName(const QString &name) { m_name = name; }
+ const QString &name() { return m_name; }
const QColor &fgColor() { return m_fgColor; }
+ void setFgColor(const QColor &color) { m_fgColor = color; }
const QColor &bgColor() { return m_bgColor; }
+ void setBgColor(const QColor &color) { m_bgColor = color; }
private:
QColor m_fgColor;
QColor m_bgColor;
+ int m_housePrice;
+ QString m_name;
};
-typedef QPtrList<ConfigEstateGroup> ConfigEstateGroupList;
+typedef QValueList<ConfigEstateGroup> ConfigEstateGroupList;
class GroupEditor : public KDialogBase
{
@@ -43,14 +50,17 @@
signals:
void changed();
+ void update();
protected slots:
virtual void slotOk();
+ virtual void slotApply();
private slots:
void updateSettings(QListBoxItem *item);
void fgChanged(const QColor &);
void bgChanged(const QColor &);
+ void housePriceChanged(int);
void add();
void remove();
void selectionChanged();
@@ -59,7 +69,9 @@
KListBox *groups;
KColorButton *fgButton;
KColorButton *bgButton;
+ QSpinBox *housePrice;
QVGroupBox *colorGroupBox;
+ QVGroupBox *pricesGroupBox;
KPushButton *removeB;
ConfigEstateGroupList *list;
_______________________________________________
atlantik-devel mailing list
atlantik-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/atlantik-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic