Commit bdc74ec5 by Alisa Jung

edit names of rbt/children

parent c7707b1a
...@@ -295,6 +295,10 @@ void Controller::itemDoubleClicked(QModelIndex q){ ...@@ -295,6 +295,10 @@ void Controller::itemDoubleClicked(QModelIndex q){
selectedItem = scene->getItem(q); selectedItem = scene->getItem(q);
} }
QString Controller::getCurrentName(){
return selectedItem->getName();
}
void Controller::changeItemName(QString q){ void Controller::changeItemName(QString q){
//TODO this is not working. //TODO this is not working.
qDebug() << "Name entered: " << q; qDebug() << "Name entered: " << q;
......
...@@ -49,6 +49,8 @@ public: ...@@ -49,6 +49,8 @@ public:
SceneGraph* getSceneGraph(); SceneGraph* getSceneGraph();
QString getCurrentName();//of double clicked thingy
private: private:
QAction *modeCameraAction; QAction *modeCameraAction;
QAction *modeManipulateAction; QAction *modeManipulateAction;
......
...@@ -258,9 +258,14 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -258,9 +258,14 @@ MainWindow::MainWindow(QWidget *parent)
connect(treeView,SIGNAL(clicked(QModelIndex)),controller, SLOT(itemSelected(QModelIndex))); connect(treeView,SIGNAL(clicked(QModelIndex)),controller, SLOT(itemSelected(QModelIndex)));
connect(treeView,SIGNAL(doubleClicked(QModelIndex)),controller,SLOT(itemDoubleClicked(QModelIndex))); connect(treeView,SIGNAL(doubleClicked(QModelIndex)),controller,SLOT(itemDoubleClicked(QModelIndex)));
connect(treeView, SIGNAL(objectNameChanged(QString)),controller,SLOT(changeItemName(QString))); connect(treeView, SIGNAL(objectNameChanged(QString)),controller,SLOT(changeItemName(QString)));
connect(treeView, SIGNAL(doubleClicked(QModelIndex)),this,SLOT(showTextEditBox()));
controller->initTreeView(treeView); controller->initTreeView(treeView);
textInput = new QLineEdit(toolBar);
textInput->setText("Test");
toolBar->addWidget(textInput);
} }
...@@ -282,3 +287,14 @@ void MainWindow::showAboutBox(){ ...@@ -282,3 +287,14 @@ void MainWindow::showAboutBox(){
msgBox.setText("Written by Alisa"); msgBox.setText("Written by Alisa");
msgBox.exec(); msgBox.exec();
} }
void MainWindow::showTextEditBox(){
bool ok;
QString text = QInputDialog::getText(this, "Edit Name",
tr("New Name:"), QLineEdit::Normal,
controller->getCurrentName(), &ok);
if (ok && !text.isEmpty()){
qDebug("Text received");
controller->changeItemName(text);
}
}
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <scenegraph.h> #include <scenegraph.h>
#include <myitemmodel.h> #include <myitemmodel.h>
#include <QDockWidget> #include <QDockWidget>
#include <QLineEdit>
#include <QInputDialog>
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
...@@ -93,8 +95,11 @@ private: ...@@ -93,8 +95,11 @@ private:
QDockWidget* dockWidget; QDockWidget* dockWidget;
QTreeView* treeView; QTreeView* treeView;
QLineEdit* textInput;
public slots : public slots :
void showAboutBox ( ) ; void showAboutBox ( ) ;
void showTextEditBox();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment