mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-18 17:40:48 +02:00
More delegates
This commit is contained in:
parent
07ba024201
commit
3f4fa8ec10
@ -193,9 +193,13 @@ void Inspector::updateProperties(CGCreature * o)
|
||||
if(!o) return;
|
||||
|
||||
addProperty("Message", o->message, false);
|
||||
addProperty<CGCreature::Character>("Character", (CGCreature::Character)o->character, false);
|
||||
addProperty("Never flees", o->neverFlees, false);
|
||||
addProperty("Not growing", o->notGrowingTeam, false);
|
||||
{
|
||||
auto * delegate = new InspectorDelegate;
|
||||
delegate->options << "COMPLIANT" << "FRIENDLY" << "AGRESSIVE" << "HOSTILE" << "SAVAGE";
|
||||
addProperty<CGCreature::Character>("Character", (CGCreature::Character)o->character, delegate, false);
|
||||
}
|
||||
addProperty("Never flees", o->neverFlees, InspectorDelegate::boolDelegate(), false);
|
||||
addProperty("Not growing", o->notGrowingTeam, InspectorDelegate::boolDelegate(), false);
|
||||
addProperty("Artifact reward", o->gainedArtifact); //TODO: implement in setProperty
|
||||
//addProperty("Resources reward", o->resources); //TODO: implement in setProperty
|
||||
}
|
||||
@ -454,6 +458,13 @@ Inspector::Inspector(CMap * m, CGObjectInstance * o, QTableWidget * t): obj(o),
|
||||
* Delegates
|
||||
*/
|
||||
|
||||
InspectorDelegate * InspectorDelegate::boolDelegate()
|
||||
{
|
||||
auto * d = new InspectorDelegate;
|
||||
d->options << "TRUE" << "FALSE";
|
||||
return d;
|
||||
}
|
||||
|
||||
QWidget * InspectorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
return new QComboBox(parent);
|
||||
|
@ -129,6 +129,8 @@ class InspectorDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static InspectorDelegate * boolDelegate();
|
||||
|
||||
InspectorDelegate(const QStringList &);
|
||||
|
||||
using QStyledItemDelegate::QStyledItemDelegate;
|
||||
|
Loading…
Reference in New Issue
Block a user