m_UnitsLayout = new QGridLayout(m_MainLayout, rows, 6);
buildUnitTable();
//QSpacerItem* space = new QSpacerItem(1, 1);
- fillTable();
+
m_MainLayout->addStretch(10);
{
m_RoidsEditView = new RoidsEditView(this);
m_MainLayout->addWidget(m_RoidsEditView);
+ connect(m_RoidsEditView, SIGNAL(changed(const QString&, int)), SLOT(slotRoidsChanged(const QString&, int)));
}
m_ResourceView = new ResourceView(this);
m_MainLayout->addWidget(m_ResourceView);
-
+ fillTable();
}
FleetView::~FleetView(){
{
m_UnitsEdit[(*i)]->setText(QString("%1").arg(m_Fleet->fleet(i->latin1(), 0)));
}
+ Planet* pl;
+ if ((pl = dynamic_cast<Planet*>(m_Fleet)) && m_bHome)
+ {
+ m_RoidsEditView->setValue(tr("score"),pl->planetScore());
+ m_RoidsEditView->setValue(tr("metal"),pl->roids(tr("metal").latin1()));
+ m_RoidsEditView->setValue(tr("crystal"),pl->roids(tr("crystal").latin1()));
+ m_RoidsEditView->setValue(tr("eonium"),pl->roids(tr("eonium").latin1()));
+ m_RoidsEditView->setValue(tr("uninit"),pl->roids(tr("uninit").latin1()));
+ }
+}
+
+/////////////////////////////////////////////////////////////////////
+//
+void FleetView::slotRoidsChanged(const QString& type, int value)
+{
+ Planet* pl;
+ if ((pl = dynamic_cast<Planet*>(m_Fleet)))
+ {
+ if (type == tr("score"))
+ pl->setPlanetScore(value);
+ else
+ {
+ pl->setRoids(type.latin1(), value);
+ }
+ emit fleetChanged(pl);
+ }
}
-
protected slots:
void unitsChanged(const QString& number);
+ void slotRoidsChanged(const QString& type, int value);
protected:
void findNames();
{
// const... I would like [] as for const types: int ticks = m_Roids[type].size();
- vector<int>const* roids;
+ vector<int>const* roids = 0;
for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i)
{
if (i->first == type)
break;
}
}
+ if (roids == 0)
+ return 0;
int ticks = roids->size();
</signals>
<slots>
<slot>init()</slot>
- <slot>setValue( const QString & s, unsigned value )</slot>
+ <slot>setValue( const QString & type, unsigned value )</slot>
<slot access="protected">slotValueChanged( const QString & s )</slot>
</slots>
<pixmapinproject/>
}
-void RoidsEditView::setValue( const QString & s, unsigned value )
+void RoidsEditView::setValue( const QString & type, unsigned value )
{
if (type == tr("metal"))
- MetalEdit->setText("%1").arg(value);
- else if (type == tr("crystall"))
- CrystalEdit->setText("%1").arg(value);
- else if (type == tr("eoniuml"))
- EoniumEdit->setText("%1").arg(value);
+ MetalEdit->setText(QString("%1").arg(value));
+ else if (type == tr("crystal"))
+ CrystalEdit->setText(QString("%1").arg(value));
+ else if (type == tr("eonium"))
+ EoniumEdit->setText(QString("%1").arg(value));
else if (type == tr("uninit"))
- UninitEdit->setText("%1").arg(value);
+ UninitEdit->setText(QString("%1").arg(value));
else if (type == tr("score"))
- ScoreEdit->setText("%1").arg(value);
+ ScoreEdit->setText(QString("%1").arg(value));
}
void RoidsEditView::slotValueChanged( const QString & s )
{
- QString type = send()->name();
+ QString type = sender()->name();
- if (type == "MetalEdit")
- type = tr("metal");
- else if (type == "CrystalEdit")
- type = tr("crystal");
- else if (type == "EoniumEdit")
- type = tr("eonium");
- else if (type == "UninitEdit")
- type = tr("uninit");
- else if (type == "ScoreEdit")
- type = tr("score");
+ if (type == "MetalEdit")
+ type = tr("metal");
+ else if (type == "CrystalEdit")
+ type = tr("crystal");
+ else if (type == "EoniumEdit")
+ type = tr("eonium");
+ else if (type == "UninitEdit")
+ type = tr("uninit");
+ else if (type == "ScoreEdit")
+ type = tr("score");
emit changed(type, s.toInt());
}
\ No newline at end of file