From 43c292e1dda7c789a31cdb679065c75d8f8cebba Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 19 Feb 2012 22:11:38 +0000 Subject: Added entity type label. --- src/editorwindow.cc | 1 + src/entityproperties.h | 17 ++++++++++++++++- src/sidebar.cc | 19 +++++++++++++++++-- src/sidebar.h | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/editorwindow.cc b/src/editorwindow.cc index 5ae0be8..759263f 100644 --- a/src/editorwindow.cc +++ b/src/editorwindow.cc @@ -115,6 +115,7 @@ bool EditorWindow::loadFile(const QString &filename) if (in_entity) { entity = editorwindow_mapwidget->addEntity(); + entity->properties()->set_type(ini.section()); } if (entity && in_subsection) { entity->properties()->add_subsection(ini.section()); diff --git a/src/entityproperties.h b/src/entityproperties.h index 9ea38b5..6189309 100644 --- a/src/entityproperties.h +++ b/src/entityproperties.h @@ -24,6 +24,13 @@ public: /* ---- inspectors ---- */ + /** + * @brief returns the type string of this object + * */ + inline const QString & type() const { + return properties_type; + } + /** * @brief returns the object radius * */ @@ -49,7 +56,14 @@ public: * @brief add a value key pair to the subsection string of this object * */ void add_subsection_value(const QString &key, const QString &value); - + + /** + * @brief set the type string of this object + * */ + inline void set_type(const QString &type) { + properties_type = type; + } + /** * @brief set the object radius * */ @@ -61,6 +75,7 @@ private: float properties_radius; QString properties_subsections; + QString properties_type; }; } // namespace editor diff --git a/src/sidebar.cc b/src/sidebar.cc index f3ac033..0a75b1b 100644 --- a/src/sidebar.cc +++ b/src/sidebar.cc @@ -22,11 +22,16 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent) label_zone = new QLabel(tr("Zone Name")); label_zone->setAlignment(Qt::AlignHCenter); + // entity type + label_entitytype = new QLabel(tr("[type]")); + label_entitytype->setAlignment(Qt::AlignHCenter); + // entity label QHBoxLayout *box_entitylabel = new QHBoxLayout(); QLabel *label_entitylabel = new QLabel(tr("label")); - edit_entitylabel = new QLineEdit(tr("entity_label")); + edit_entitylabel = new QLineEdit(tr("entity_label")); + box_entitylabel->addWidget(label_entitylabel); box_entitylabel->addWidget(edit_entitylabel); @@ -70,6 +75,9 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent) box_global->addWidget(label_zone); box_global->addSpacing(8); + + box_global->addWidget(label_entitytype); + box_global->addLayout(box_entitylabel); box_global->addLayout(box_entityname); box_global->addLayout(box_entitylocation); @@ -129,6 +137,8 @@ void SideBar::setProperties(EntityProperties *properties) last_selected = properties; if (!properties) { + label_entitytype->clear(); + edit_entitylabel->setEnabled(false); edit_entitylabel->clear(); @@ -155,7 +165,12 @@ void SideBar::setProperties(EntityProperties *properties) } else { QString value; - + + value = '['; + value += properties->type(); + value += ']'; + label_entitytype->setText(value); + edit_entitylabel->setEnabled(true); edit_entitylabel->setText(properties->label()); diff --git a/src/sidebar.h b/src/sidebar.h index 0f6b35c..cfa87c7 100644 --- a/src/sidebar.h +++ b/src/sidebar.h @@ -58,6 +58,7 @@ signals: private: QLabel *label_zone; + QLabel *label_entitytype; QLineEdit *edit_entitylabel; QLineEdit *edit_entityname; -- cgit v1.2.3