Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-02-19 16:11:07 +0000
committerStijn Buys <ingar@osirion.org>2012-02-19 16:11:07 +0000
commit85500fcb7a8aae73da87af337e2984cc91425eb8 (patch)
treef8cc7ca6dacd72fa72cf0ba6a6d8cc1054706965
parent7a9c504720e494ee07d16a6234b77c500af4da93 (diff)
Added subsections textbox
-rw-r--r--src/editorwindow.cc16
-rw-r--r--src/entitywidget.cc26
-rw-r--r--src/entitywidget.h19
-rw-r--r--src/sidebar.cc13
-rw-r--r--src/sidebar.h1
5 files changed, 71 insertions, 4 deletions
diff --git a/src/editorwindow.cc b/src/editorwindow.cc
index ec7ebe2..1ced0c0 100644
--- a/src/editorwindow.cc
+++ b/src/editorwindow.cc
@@ -55,6 +55,7 @@ bool EditorWindow::loadFile(const QString &filename)
EntityWidget *entity = 0;
bool in_entity = false;
+ bool in_subsection = false;
float x, y, z;
float f;
QString str;
@@ -64,6 +65,7 @@ bool EditorWindow::loadFile(const QString &filename)
if (ini.got_section()) {
//qDebug() << "got section" << ini.section();
+ in_subsection = false;
if (ini.got_section("zone")) {
in_entity = false;
@@ -89,6 +91,14 @@ bool EditorWindow::loadFile(const QString &filename)
} else if (ini.got_section("planet")) {
in_entity = true;
+ } else if (ini.got_section("cargo")) {
+ in_entity = false;
+ in_subsection = true;
+
+ } else if (ini.got_section("ship")) {
+ in_entity = false;
+ in_subsection = true;
+
} else {
entity = 0;
in_entity = false;
@@ -97,6 +107,9 @@ bool EditorWindow::loadFile(const QString &filename)
if (in_entity) {
entity = editorwindow_mapwidget->addEntity();
}
+ if (entity && in_subsection) {
+ entity->add_subsection(ini.section());
+ }
} else if(ini.got_key()) {
@@ -119,6 +132,9 @@ bool EditorWindow::loadFile(const QString &filename)
} else if (ini.got_key()) {
entity->add_property(ini.key(), ini.value());
}
+
+ } else if (entity && in_subsection) {
+ entity->add_subsection_property(ini.key(), ini.value());
} else if (ini.in_section("zone")) {
diff --git a/src/entitywidget.cc b/src/entitywidget.cc
index f04c177..50056c0 100644
--- a/src/entitywidget.cc
+++ b/src/entitywidget.cc
@@ -55,14 +55,34 @@ void EntityWidget::set_properties(const QString &properties)
{
entity_properties = properties;
}
+
void EntityWidget::add_property(const QString &key, const QString &value)
{
- if (entity_properties.size()) {
- entity_properties += '\n';
- }
entity_properties += key;
entity_properties += '=';
entity_properties += value;
+ entity_properties += '\n';
+}
+
+void EntityWidget::add_subsection(const QString &name)
+{
+ if (entity_subsections.size()) {
+ entity_subsections += '\n';
+ }
+
+ entity_subsections += '[';
+ entity_subsections += name;
+ entity_subsections += ']';
+ entity_subsections += '\n';
+
+}
+
+void EntityWidget::add_subsection_property(const QString &key, const QString &value)
+{
+ entity_subsections += key;
+ entity_subsections += '=';
+ entity_subsections += value;
+ entity_subsections += '\n';
}
void EntityWidget::paintEvent(QPaintEvent *event)
diff --git a/src/entitywidget.h b/src/entitywidget.h
index 04a925b..4eaaf49 100644
--- a/src/entitywidget.h
+++ b/src/entitywidget.h
@@ -59,7 +59,13 @@ public:
inline const QString &properties() const {
return entity_properties;
}
-
+
+ /**
+ * @brief returns the subsections string
+ * */
+ inline const QString &subsections() const {
+ return entity_subsections;
+ }
signals:
/**
* @brief this signal is emitted if the entity is clicked with the left mouse button
@@ -104,6 +110,16 @@ public slots:
void add_property(const QString &key, const QString &value);
/**
+ * @brief add a subsection
+ * */
+ void add_subsection(const QString &name);
+
+ /**
+ * @brief add a subsection property
+ * */
+ void add_subsection_property(const QString &key, const QString &value);
+
+ /**
* @brief set the selected state
* */
void set_selected(const bool selected);
@@ -138,6 +154,7 @@ private:
QString entity_type;
QString entity_properties;
+ QString entity_subsections;
float entity_location[3];
float entity_radius;
diff --git a/src/sidebar.cc b/src/sidebar.cc
index 6298589..498a457 100644
--- a/src/sidebar.cc
+++ b/src/sidebar.cc
@@ -53,9 +53,14 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent)
connect(edit_entitylocation_y, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityLocationY(const QString &)));
connect(edit_entitylocation_z, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityLocationZ(const QString &)));
+ // entity properties
QLabel *label_entityproperties = new QLabel(tr("properties"));
text_entityproperties = new QTextEdit();
+ // entity subsections
+ QLabel *label_entitysubsections = new QLabel(tr("subsections"));
+ text_subsections = new QTextEdit();
+
// global vertical layout
QVBoxLayout *box_global = new QVBoxLayout();
@@ -66,6 +71,8 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent)
box_global->addLayout(box_entitylocation);
box_global->addWidget(label_entityproperties);
box_global->addWidget(text_entityproperties,1);
+ box_global->addWidget(label_entitysubsections);
+ box_global->addWidget(text_subsections,1);
setLayout(box_global);
@@ -132,6 +139,9 @@ void SideBar::setEntity(EntityWidget *entity)
text_entityproperties->setEnabled(false);
text_entityproperties->clear();
+
+ text_subsections->setEnabled(false);
+ text_subsections->clear();
} else {
edit_entitylabel->setEnabled(true);
edit_entitylabel->setText(entity->label());
@@ -153,6 +163,9 @@ void SideBar::setEntity(EntityWidget *entity)
text_entityproperties->setEnabled(true);
text_entityproperties->setText(entity->properties());
+
+ text_subsections->setEnabled(true);
+ text_subsections->setText(entity->subsections());
}
}
diff --git a/src/sidebar.h b/src/sidebar.h
index 48fcafe..5a20c37 100644
--- a/src/sidebar.h
+++ b/src/sidebar.h
@@ -53,6 +53,7 @@ private:
QLineEdit *edit_entitylocation_y;
QLineEdit *edit_entitylocation_z;
QTextEdit *text_entityproperties;
+ QTextEdit *text_subsections;
EntityWidget *last_selected;
};