Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
grapa_alisa
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Alisa Jung
grapa_alisa
Commits
158eb788
Commit
158eb788
authored
Nov 22, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete nodes from model
parent
ab86fe42
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
26 deletions
+22
-26
myitemmodel.cpp
helloqube/myitemmodel.cpp
+18
-22
myitemmodel.h
helloqube/myitemmodel.h
+2
-3
scenegraph.cpp
helloqube/scenegraph.cpp
+2
-1
No files found.
helloqube/myitemmodel.cpp
View file @
158eb788
...
...
@@ -92,31 +92,10 @@ TreeItem* MyItemModel::getItem(const QModelIndex& index) const{
}
bool
MyItemModel
::
insertRows
(
int
position
,
int
rows
,
const
QModelIndex
&
parent
)
{
beginInsertRows
(
QModelIndex
(),
position
,
position
+
rows
-
1
);
TreeItem
*
p
=
getItem
(
parent
);
for
(
int
row
=
0
;
row
<
rows
;
++
row
)
{
qDebug
(
"Add Child to item"
);
p
->
addChild
(
new
TreeItem
());
}
endInsertRows
();
return
true
;
}
void
MyItemModel
::
addChildToRoot
(
TreeItem
*
rbt
,
TreeItem
*
prim
){
void
MyItemModel
::
addNewTransformToRoot
(
TreeItem
*
rbt
,
TreeItem
*
prim
){
beginInsertRows
(
QModelIndex
(),
0
,
0
);
qDebug
()
<<
"Add child "
<<
rbt
->
data
(
0
);
root
->
addChild
(
rbt
);
endInsertRows
();
QModelIndex
i
=
index
(
0
,
0
,
QModelIndex
());
beginInsertRows
(
i
,
0
,
0
);
...
...
@@ -126,3 +105,20 @@ void MyItemModel::addChildToRoot(TreeItem *rbt, TreeItem* prim){
endInsertRows
();
// return true;
}
void
MyItemModel
::
removeTransformFromRoot
(
TreeItem
*
rbt
){
int
row
=
-
1
;
for
(
int
i
=
0
;
i
<
root
->
getChildren
().
length
();
i
++
){
if
(
root
->
getChild
(
i
)
==
rbt
){
row
=
i
;
break
;
}
}
if
(
row
<
0
)
qDebug
(
"item not found"
);
else
{
// QModelIndex i = index(row,0,QModelIndex());
beginRemoveRows
(
QModelIndex
(),
row
,
row
);
root
->
removeChild
(
rbt
);
endRemoveRows
();
}
}
helloqube/myitemmodel.h
View file @
158eb788
...
...
@@ -22,9 +22,8 @@ public:
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
)
const
Q_DECL_OVERRIDE
;
QModelIndex
parent
(
const
QModelIndex
&
index
)
const
Q_DECL_OVERRIDE
;
void
addChildToRoot
(
TreeItem
*
rbt
,
TreeItem
*
prim
);
bool
insertRows
(
int
row
,
int
count
,
const
QModelIndex
&
parent
);
void
addNewTransformToRoot
(
TreeItem
*
rbt
,
TreeItem
*
prim
);
void
removeTransformFromRoot
(
TreeItem
*
rbt
);
private
:
TreeItem
*
root
;
...
...
helloqube/scenegraph.cpp
View file @
158eb788
...
...
@@ -93,7 +93,7 @@ RigidBodyTransformation* SceneGraph::addTorus(int tesselation){
RigidBodyTransformation
*
SceneGraph
::
addPrimitive
(
Primitive
*
p
){
RigidBodyTransformation
*
r
=
new
RigidBodyTransformation
();
nodes
.
append
(
r
);
model
->
add
Child
ToRoot
(
r
,
p
);
model
->
add
NewTransform
ToRoot
(
r
,
p
);
// model->insertRows(1,1,QModelIndex());
notifyViews
();
return
r
;
...
...
@@ -106,6 +106,7 @@ RigidBodyTransformation* SceneGraph::deleteNode(RigidBodyTransformation *r){
}
bool
s
=
nodes
.
removeOne
(
r
);
if
(
!
s
)
qDebug
(
"could not remove this. Delete r anyways."
);
model
->
removeTransformFromRoot
(
r
);
r
->~
RigidBodyTransformation
();
notifyViews
();
if
(
nodes
.
length
()
>
0
)
return
nodes
.
back
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment