Commit 10d649c3 by Alisa Jung

not sure what is happening. selecting items in tree view works a little.

parent 158eb788
......@@ -261,3 +261,11 @@ void Controller::selectTransform(RigidBodyTransformation *rbt){
statusBar->showMessage("None selected");
}
}
void Controller::itemSelected(QModelIndex q){
qDebug() << "item selected. Row: " << q.row() << ", column: " << q.column();
qDebug("try to retrieve rbt");
TreeItem* t = scene->getItem(q);
if (t->childNumber() == 0) t = t->getParent();
selectTransform(static_cast<RigidBodyTransformation*>(t));
}
......@@ -17,6 +17,7 @@
#include <QGridLayout>
#include <rigidbodytransformation.h>
#include <QStatusBar>
#include <QModelIndex>
#include <math.h>
......@@ -95,6 +96,8 @@ public slots:
void addTorus();
void deletePrimitive();
void itemSelected(QModelIndex q);
};
#endif // CONTROLLER_H
......@@ -254,6 +254,9 @@ MainWindow::MainWindow(QWidget *parent)
dockWidget->setWidget(treeView);
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
connect(treeView,SIGNAL(clicked(QModelIndex)),controller, SLOT(itemSelected(QModelIndex)));
}
......
......@@ -76,7 +76,7 @@ Qt::ItemFlags MyItemModel::flags(const QModelIndex &index) const{
if (!index.isValid()){
return 0;
}else{
return Qt::ItemIsEditable | QAbstractItemModel::flags(index);
return Qt::ItemIsEditable | Qt::ItemIsSelectable | QAbstractItemModel::flags(index);
}
}
......
......@@ -24,11 +24,11 @@ public:
void addNewTransformToRoot(TreeItem* rbt, TreeItem* prim);
void removeTransformFromRoot(TreeItem* rbt);
TreeItem* getItem(const QModelIndex &index) const;
private:
TreeItem* root;
TreeItem* getItem(const QModelIndex &index) const;
};
#endif // MYITEMMODEL_H
......@@ -5,7 +5,7 @@ RigidBodyTransformation::RigidBodyTransformation()
{
translation = QVector3D(0,0,0);
rotation = QQuaternion();
name = "";
name = "<rbt>";
// qDebug() << "new rbt " << tx << "," << ty << "," << tz << ", rot " << rotation;
}
......
......@@ -136,3 +136,7 @@ void SceneGraph::notifyViews(){
(*i)->modelChanged();
}
}
TreeItem* SceneGraph::getItem(QModelIndex q){
return model->getItem(q);
}
......@@ -34,6 +34,8 @@ public:
MyItemModel* getModel();
TreeItem* getItem(QModelIndex q);
//Hallo. Todos:
//Log selected name in status bar
//add remaining primitive types
......
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