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-26 23:04:53 +0000
committerStijn Buys <ingar@osirion.org>2012-02-26 23:04:53 +0000
commit802fe3321306a81e227584e34087b477110ffdb5 (patch)
tree3f1c93bd6cd1a0293500f24f4aee42ba74c9c9da
parent06324807359ab34bf1742049ea8b7794d3be126e (diff)
Select newly created entities,
remember entity type updates, rearranged sidebar widget construction code.
-rw-r--r--src/editorwindow.cc9
-rw-r--r--src/mainwindow.cc5
-rw-r--r--src/mapwidget.h3
-rw-r--r--src/sidebar.cc95
-rw-r--r--src/sidebar.h2
5 files changed, 76 insertions, 38 deletions
diff --git a/src/editorwindow.cc b/src/editorwindow.cc
index f54bd6e..88a309b 100644
--- a/src/editorwindow.cc
+++ b/src/editorwindow.cc
@@ -41,13 +41,6 @@ QSize EditorWindow::sizeHint () const
void EditorWindow::resizeEvent (QResizeEvent *event)
{
- /*
- editorwindow_sidebar->resize(256, height());
- editorwindow_mapwidget->setGeometry(
- editorwindow_sidebar->width(), 0,
- width() - editorwindow_sidebar->width(), height()
- );
- */
editorwindow_splitter->resize(width(), height());
}
@@ -245,7 +238,7 @@ bool EditorWindow::saveFile(const QString &filename)
void EditorWindow::addEntity()
{
EntityWidget *entitywidget = editorwindow_mapwidget->addEntity();
- entitywidget->properties()->set_type("entity");
+ editorwindow_mapwidget->select(entitywidget);
}
void EditorWindow::duplicateSelected()
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 414c07b..0a39b0a 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -33,6 +33,7 @@ MainWindow::MainWindow()
// initialize menu bar
initMenus();
+ updateMenus();
}
@@ -137,8 +138,6 @@ EditorWindow *MainWindow::add_child()
//subwindow->resize(768, 512);
child_widget->show();
- // FIXME check if maximized
-
return child_widget;
}
@@ -156,8 +155,6 @@ void MainWindow::slot_open()
QMdiSubWindow *subwindow = find_child(filename);
if (subwindow) {
- subwindow->raise();
- subwindow->activateWindow();
mainwindow_mdiarea->setActiveSubWindow(subwindow);
} else {
EditorWindow *editorwindow = add_child();
diff --git a/src/mapwidget.h b/src/mapwidget.h
index 087fd3d..8d09209 100644
--- a/src/mapwidget.h
+++ b/src/mapwidget.h
@@ -96,13 +96,12 @@ public slots:
* */
void duplicateSelected();
-
-private slots:
/**
* @brief called when an entity on the map has been clicked
* */
void select(EntityWidget *entity);
+private slots:
/**
* @brief clear current selection
* */
diff --git a/src/sidebar.cc b/src/sidebar.cc
index 44fd56e..9299f40 100644
--- a/src/sidebar.cc
+++ b/src/sidebar.cc
@@ -10,6 +10,7 @@
#include <QLineEdit>
#include <QTextEdit>
#include <QVBoxLayout>
+#include <QSplitter>
#include "sidebar.h"
#include "entitywidget.h"
@@ -19,10 +20,16 @@ namespace editor
SideBar::SideBar(QWidget *parent) : QWidget(parent)
{
+ // global vertical layout
+ QVBoxLayout *box_global = new QVBoxLayout();
+
// zone name
label_zone = new QLabel(tr("Zone Name"));
label_zone->setAlignment(Qt::AlignHCenter);
+ box_global->addWidget(label_zone);
+ box_global->addSpacing(16);
+
// entity type
QHBoxLayout *box_entitytype = new QHBoxLayout();
QLabel *label_entitytype = new QLabel(tr("type"));
@@ -37,9 +44,13 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent)
combo_entitytype->addItem(tr("jumppoint"));
combo_entitytype->addItem(tr("navpoint"));
combo_entitytype->setEditable(true);
+
box_entitytype->addWidget(label_entitytype);
box_entitytype->addWidget(combo_entitytype);
+ box_global->addLayout(box_entitytype);
+
+ connect(combo_entitytype, SIGNAL(editTextChanged(const QString &)), this, SLOT(updateEntityType(const QString &)));
// entity label
QHBoxLayout *box_entitylabel = new QHBoxLayout();
@@ -47,26 +58,37 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent)
edit_entitylabel = new QLineEdit(tr("entity_label"));
box_entitylabel->addWidget(label_entitylabel);
box_entitylabel->addWidget(edit_entitylabel);
+
+ box_global->addLayout(box_entitylabel);
+
connect(edit_entitylabel, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityLabel(const QString &)));
// entity name
QHBoxLayout *box_entityname = new QHBoxLayout();
QLabel *label_entityname = new QLabel(tr("name"));
edit_entityname = new QLineEdit(tr("Entity Name"));
+
box_entityname->addWidget(label_entityname);
box_entityname->addWidget(edit_entityname);
- connect(edit_entityname, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityName(const QString &)));
+ box_global->addLayout(box_entityname);
+
+ connect(edit_entityname, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityName(const QString &)));
+
// entity location
QHBoxLayout *box_entitylocation = new QHBoxLayout();
QLabel *label_entitylocation = new QLabel(tr("location"));
edit_entitylocation_x = new QLineEdit(tr("x"));
edit_entitylocation_y = new QLineEdit(tr("y"));
edit_entitylocation_z = new QLineEdit(tr("z"));
+
box_entitylocation->addWidget(label_entitylocation);
box_entitylocation->addWidget(edit_entitylocation_x);
box_entitylocation->addWidget(edit_entitylocation_y);
box_entitylocation->addWidget(edit_entitylocation_z);
+
+ box_global->addLayout(box_entitylocation);
+
connect(edit_entitylocation_x, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityLocationX(const QString &)));
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 &)));
@@ -77,10 +99,14 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent)
edit_entityangles_yaw = new QLineEdit(tr("yaw"));
edit_entityangles_pitch = new QLineEdit(tr("pitch"));
edit_entityangles_roll = new QLineEdit(tr("roll"));
+
box_entityangles->addWidget(label_entityangles);
box_entityangles->addWidget(edit_entityangles_yaw);
box_entityangles->addWidget(edit_entityangles_pitch);
box_entityangles->addWidget(edit_entityangles_roll);
+
+ box_global->addLayout(box_entityangles);
+
connect(edit_entityangles_yaw, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityAnglesYaw(const QString &)));
connect(edit_entityangles_pitch, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityAnglesPitch(const QString &)));
connect(edit_entityangles_roll, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityAnglesRoll(const QString &)));
@@ -89,8 +115,12 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent)
QHBoxLayout *box_entityradius = new QHBoxLayout();
QLabel *label_entityradius = new QLabel(tr("radius"));
edit_entityradius = new QLineEdit(tr("radius"));
+
box_entityradius->addWidget(label_entityradius);
box_entityradius->addWidget(edit_entityradius);
+
+ box_global->addLayout(box_entityradius);
+
connect(edit_entityradius, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityRadius(const QString &)));
// template
@@ -101,60 +131,77 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent)
combo_entitytemplate_type->addItem(tr("ship"));
combo_entitytemplate_type->setEditable(false);
edit_entitytemplate = new QLineEdit();
+
box_entitytemplate->addWidget(label_entitytemplate);
box_entitytemplate->addWidget(combo_entitytemplate_type);
box_entitytemplate->addWidget(edit_entitytemplate);
+
+ box_global->addLayout(box_entitytemplate);
+
connect(combo_entitytemplate_type, SIGNAL(activated(int)), this, SLOT(updateEntityTemplateType(int)));
connect(edit_entitytemplate, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityTemplateLabel(const QString &)));
+ QSplitter *splitter_global = new QSplitter(Qt::Vertical);
+
// entity values
+ QVBoxLayout *box_values = new QVBoxLayout();
+ QWidget *container_values = new QWidget();
QLabel *label_entityproperties = new QLabel(tr("properties"));
text_entityvalues = new QTextEdit();
text_entityvalues ->setTabChangesFocus(true);
+
+ box_values->addWidget(label_entityproperties);
+ box_values->addWidget(text_entityvalues,1);
+
+ container_values->setLayout(box_values);
+ splitter_global->addWidget(container_values);
+
connect(text_entityvalues, SIGNAL(textChanged()), this, SLOT(updateEntityValues()));
// entity info
+ QVBoxLayout *box_info = new QVBoxLayout();
+ QWidget *container_info = new QWidget();
QLabel *label_info = new QLabel(tr("info"));
text_info = new QTextEdit();
text_info ->setTabChangesFocus(true);
+
+ box_info->addWidget(label_info);
+ box_info->addWidget(text_info,1);
+
+ container_info->setLayout(box_info);
+ splitter_global->addWidget(container_info);
+
connect(text_info, SIGNAL(textChanged()), this, SLOT(updateEntityInfo()));
// entity subsections
+ QVBoxLayout *box_subsections = new QVBoxLayout();
+ QWidget *container_subsections = new QWidget();
QLabel *label_entitysubsections = new QLabel(tr("subsections"));
text_subsections = new QTextEdit();
text_subsections ->setTabChangesFocus(true);
- connect(text_subsections, SIGNAL(textChanged()), this, SLOT(updateEntitySubSections()));
-
- // global vertical layout
- QVBoxLayout *box_global = new QVBoxLayout();
-
- box_global->addWidget(label_zone);
- box_global->addSpacing(16);
-
- box_global->addLayout(box_entitytype);
-
- box_global->addLayout(box_entitylabel);
- box_global->addLayout(box_entityname);
- box_global->addLayout(box_entitylocation);
- box_global->addLayout(box_entityangles);
- box_global->addLayout(box_entityradius);
-
- box_global->addLayout(box_entitytemplate);
- box_global->addWidget(label_entityproperties);
- box_global->addWidget(text_entityvalues,1);
+ box_subsections->addWidget(label_entitysubsections);
+ box_subsections->addWidget(text_subsections,1);
- box_global->addWidget(label_info);
- box_global->addWidget(text_info,1);
+ container_subsections->setLayout(box_subsections);
+ splitter_global->addWidget(container_subsections);
- box_global->addWidget(label_entitysubsections);
- box_global->addWidget(text_subsections,1);
+ box_global->addWidget(splitter_global);
+ connect(text_subsections, SIGNAL(textChanged()), this, SLOT(updateEntitySubSections()));
+
setLayout(box_global);
setProperties(0);
}
+void SideBar::updateEntityType(const QString &value)
+{
+ if (last_selected) {
+ last_selected->set_type(value);
+ }
+}
+
void SideBar::updateEntityLabel(const QString &value)
{
if (last_selected) {
diff --git a/src/sidebar.h b/src/sidebar.h
index 0b03f78..5448482 100644
--- a/src/sidebar.h
+++ b/src/sidebar.h
@@ -48,6 +48,8 @@ public slots:
private slots:
+ void updateEntityType(const QString &value);
+
void updateEntityLabel(const QString &value);
void updateEntityName(const QString &value);