1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-18 17:40:48 +02:00

More delegates

This commit is contained in:
nordsoft 2022-09-08 03:06:46 +04:00
parent 07ba024201
commit 3f4fa8ec10
2 changed files with 16 additions and 3 deletions

View File

@ -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);

View File

@ -129,6 +129,8 @@ class InspectorDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
static InspectorDelegate * boolDelegate();
InspectorDelegate(const QStringList &);
using QStyledItemDelegate::QStyledItemDelegate;