Commit bdc74ec5 by Alisa Jung

edit names of rbt/children

parent c7707b1a
......@@ -295,6 +295,10 @@ void Controller::itemDoubleClicked(QModelIndex q){
selectedItem = scene->getItem(q);
}
QString Controller::getCurrentName(){
return selectedItem->getName();
}
void Controller::changeItemName(QString q){
//TODO this is not working.
qDebug() << "Name entered: " << q;
......
......@@ -49,6 +49,8 @@ public:
SceneGraph* getSceneGraph();
QString getCurrentName();//of double clicked thingy
private:
QAction *modeCameraAction;
QAction *modeManipulateAction;
......
......@@ -258,9 +258,14 @@ MainWindow::MainWindow(QWidget *parent)
connect(treeView,SIGNAL(clicked(QModelIndex)),controller, SLOT(itemSelected(QModelIndex)));
connect(treeView,SIGNAL(doubleClicked(QModelIndex)),controller,SLOT(itemDoubleClicked(QModelIndex)));
connect(treeView, SIGNAL(objectNameChanged(QString)),controller,SLOT(changeItemName(QString)));
connect(treeView, SIGNAL(doubleClicked(QModelIndex)),this,SLOT(showTextEditBox()));
controller->initTreeView(treeView);
textInput = new QLineEdit(toolBar);
textInput->setText("Test");
toolBar->addWidget(textInput);
}
......@@ -282,3 +287,14 @@ void MainWindow::showAboutBox(){
msgBox.setText("Written by Alisa");
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 @@
#include <scenegraph.h>
#include <myitemmodel.h>
#include <QDockWidget>
#include <QLineEdit>
#include <QInputDialog>
class MainWindow : public QMainWindow
{
Q_OBJECT
......@@ -93,8 +95,11 @@ private:
QDockWidget* dockWidget;
QTreeView* treeView;
QLineEdit* textInput;
public slots :
void showAboutBox ( ) ;
void showTextEditBox();
};
#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