Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GraPa
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
GraPa
Commits
cb240d35
Commit
cb240d35
authored
Nov 24, 2015
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added name CHange
parent
8ece7716
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
4 deletions
+61
-4
hellocube.pro
A2/hellocube.pro
+4
-2
mainwindow.cpp
A2/mainwindow.cpp
+5
-1
scene.cpp
A2/scene.cpp
+1
-1
treedelegate.cpp
A2/treedelegate.cpp
+34
-0
treedelegate.h
A2/treedelegate.h
+17
-0
No files found.
A2/hellocube.pro
View file @
cb240d35
...
@@ -23,7 +23,8 @@ SOURCES += main.cpp\
...
@@ -23,7 +23,8 @@ SOURCES += main.cpp\
camera
.
cpp
\
camera
.
cpp
\
sceneprimitive
.
cpp
\
sceneprimitive
.
cpp
\
sceneobject
.
cpp
\
sceneobject
.
cpp
\
scenenode
.
cpp
scenenode
.
cpp
\
treedelegate
.
cpp
HEADERS
+=
mainwindow
.
h
\
HEADERS
+=
mainwindow
.
h
\
cubewidget
.
h
\
cubewidget
.
h
\
...
@@ -34,7 +35,8 @@ HEADERS += mainwindow.h \
...
@@ -34,7 +35,8 @@ HEADERS += mainwindow.h \
sceneprimitive
.
h
\
sceneprimitive
.
h
\
sceneobject
.
h
\
sceneobject
.
h
\
scenenode
.
h
\
scenenode
.
h
\
glut
.
h
glut
.
h
\
treedelegate
.
h
RESOURCES
+=
\
RESOURCES
+=
\
hellocube
.
qrc
hellocube
.
qrc
...
...
A2/mainwindow.cpp
View file @
cb240d35
#include "mainwindow.h"
#include "mainwindow.h"
#include <treedelegate.h>
MainWindow
::
MainWindow
(
QWidget
*
parent
)
MainWindow
::
MainWindow
(
QWidget
*
parent
)
...
@@ -264,6 +264,7 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -264,6 +264,7 @@ MainWindow::MainWindow(QWidget *parent)
}
}
void
MainWindow
::
initDoc
()
void
MainWindow
::
initDoc
()
{
{
QDockWidget
*
dock
=
new
QDockWidget
(
"Scene"
,
this
);
QDockWidget
*
dock
=
new
QDockWidget
(
"Scene"
,
this
);
...
@@ -273,7 +274,10 @@ void MainWindow::initDoc()
...
@@ -273,7 +274,10 @@ void MainWindow::initDoc()
sceneView
->
setSelectionBehavior
(
QAbstractItemView
::
SelectRows
);
sceneView
->
setSelectionBehavior
(
QAbstractItemView
::
SelectRows
);
sceneView
->
expandAll
();
sceneView
->
expandAll
();
sceneView
->
setModel
(
scene
);
sceneView
->
setModel
(
scene
);
TreeDelegate
*
delegate
=
new
TreeDelegate
();
sceneView
->
setItemDelegate
(
delegate
);
connect
(
sceneView
,
SIGNAL
(
clicked
(
QModelIndex
)),
scene
,
SLOT
(
objectSelected
(
QModelIndex
)));
connect
(
sceneView
,
SIGNAL
(
clicked
(
QModelIndex
)),
scene
,
SLOT
(
objectSelected
(
QModelIndex
)));
connect
(
delegate
,
SIGNAL
(
nameChanged
()),
this
,
SLOT
(
updateStatusBar
()));
dock
->
setWidget
(
sceneView
);
dock
->
setWidget
(
sceneView
);
...
...
A2/scene.cpp
View file @
cb240d35
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
Scene
::
Scene
(
)
Scene
::
Scene
(
)
{
{
root
=
new
SceneNode
();
root
=
new
SceneNode
();
root
->
setName
(
"
ROOT
"
);
root
->
setName
(
"
<NONE>
"
);
active
=
root
;
active
=
root
;
activeIndex
=
QModelIndex
();
activeIndex
=
QModelIndex
();
}
}
...
...
A2/treedelegate.cpp
0 → 100644
View file @
cb240d35
#include "treedelegate.h"
#include <QDebug>
#include <QLineEdit>
#include <QString>
#include <scene.h>
TreeDelegate
::
TreeDelegate
()
{
}
void
TreeDelegate
::
setModelData
(
QWidget
*
editor
,
QAbstractItemModel
*
model
,
const
QModelIndex
&
index
)
const
{
qDebug
()
<<
"out"
;
QLineEdit
*
lineEdit
=
qobject_cast
<
QLineEdit
*>
(
editor
);
if
(
!
lineEdit
->
isModified
())
{
return
;
}
QString
text
=
lineEdit
->
text
();
text
=
text
.
trimmed
();
if
(
text
.
isEmpty
())
{
// If text is empty, do nothing - preserve the old value.
return
;
}
else
{
if
(
index
.
isValid
())
{
SceneObject
*
item
=
static_cast
<
SceneObject
*>
(
index
.
internalPointer
());
if
(
item
)
item
->
setName
(
text
);
}
emit
nameChanged
();
}
}
A2/treedelegate.h
0 → 100644
View file @
cb240d35
#ifndef TREEDELEGATE_H
#define TREEDELEGATE_H
#include <QItemDelegate>
class
TreeDelegate
:
public
QItemDelegate
{
Q_OBJECT
;
public
:
TreeDelegate
();
void
setModelData
(
QWidget
*
editor
,
QAbstractItemModel
*
model
,
const
QModelIndex
&
index
)
const
;
signals
:
void
nameChanged
()
const
;
};
#endif // TREEDELEGATE_H
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