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
18280c79
Commit
18280c79
authored
Nov 22, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
still compiling
parent
06be88a0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
myitemmodel.cpp
helloqube/myitemmodel.cpp
+58
-0
myitemmodel.h
helloqube/myitemmodel.h
+8
-0
No files found.
helloqube/myitemmodel.cpp
View file @
18280c79
...
@@ -20,6 +20,64 @@ int MyItemModel::columnCount(const QModelIndex &parent) const{
...
@@ -20,6 +20,64 @@ int MyItemModel::columnCount(const QModelIndex &parent) const{
return
root
->
columnCount
();
return
root
->
columnCount
();
}
}
QVariant
MyItemModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
if
(
!
index
.
isValid
()){
return
QVariant
();
}
if
(
role
!=
Qt
::
DisplayRole
){
return
QVariant
();
}
TreeItem
*
item
=
static_cast
<
TreeItem
*>
(
index
.
internalPointer
());
return
item
->
data
(
index
.
column
());
}
QVariant
MyItemModel
::
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
{
//Im tutorial stand mehr. erstmal ignorieren.
return
root
->
data
(
section
);
}
QModelIndex
MyItemModel
::
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
)
const
{
if
(
!
hasIndex
(
row
,
column
,
parent
)){
return
QModelIndex
();
}
TreeItem
*
parentItem
;
if
(
!
parent
.
isValid
()){
parentItem
=
root
;
}
else
{
parentItem
=
static_cast
<
TreeItem
*>
(
parent
.
internalPointer
());
}
TreeItem
*
childItem
=
parentItem
->
getChild
(
row
);
if
(
childItem
){
return
createIndex
(
row
,
column
,
childItem
);
}
else
{
return
QModelIndex
();
}
}
QModelIndex
MyItemModel
::
parent
(
const
QModelIndex
&
index
)
const
{
if
(
!
index
.
isValid
()){
return
QModelIndex
();
}
TreeItem
*
childItem
=
static_cast
<
TreeItem
*>
(
index
.
internalPointer
());
TreeItem
*
parentItem
=
childItem
->
getParent
();
if
(
parentItem
==
root
){
return
QModelIndex
();
}
else
{
return
createIndex
(
parentItem
->
childNumber
(),
0
,
parentItem
);
}
}
//enable editing and selection.
Qt
::
ItemFlags
MyItemModel
::
flags
(
const
QModelIndex
&
index
)
const
{
if
(
!
index
.
isValid
()){
return
0
;
}
else
{
return
Qt
::
ItemIsEditable
|
QAbstractItemModel
::
flags
(
index
);
}
}
//Helferfunktion
//Helferfunktion
TreeItem
*
MyItemModel
::
getItem
(
const
QModelIndex
&
index
)
const
{
TreeItem
*
MyItemModel
::
getItem
(
const
QModelIndex
&
index
)
const
{
...
...
helloqube/myitemmodel.h
View file @
18280c79
...
@@ -14,6 +14,14 @@ public:
...
@@ -14,6 +14,14 @@ public:
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
Q_DECL_OVERRIDE
;
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
Q_DECL_OVERRIDE
;
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
Q_DECL_OVERRIDE
;
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
Q_DECL_OVERRIDE
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
Q_DECL_OVERRIDE
;
Qt
::
ItemFlags
flags
(
const
QModelIndex
&
index
)
const
Q_DECL_OVERRIDE
;
QVariant
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
Q_DECL_OVERRIDE
;
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
)
const
Q_DECL_OVERRIDE
;
QModelIndex
parent
(
const
QModelIndex
&
index
)
const
Q_DECL_OVERRIDE
;
private
:
private
:
TreeItem
*
root
;
TreeItem
*
root
;
...
...
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