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
06be88a0
Commit
06be88a0
authored
Nov 22, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
still compiling (not tested)
parent
1098166a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
2 deletions
+40
-2
myitemmodel.cpp
helloqube/myitemmodel.cpp
+27
-1
myitemmodel.h
helloqube/myitemmodel.h
+12
-1
treeitem.cpp
helloqube/treeitem.cpp
+1
-0
No files found.
helloqube/myitemmodel.cpp
View file @
06be88a0
#include "myitemmodel.h"
MyItemModel
::
MyItemModel
()
MyItemModel
::
MyItemModel
(
QObject
*
parent
)
:
QAbstractItemModel
(
parent
)
{
root
=
new
TreeItem
();
}
MyItemModel
::~
MyItemModel
(){
delete
root
;
}
int
MyItemModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
TreeItem
*
parentItem
=
getItem
(
parent
);
return
parentItem
->
getChildrenCount
();
}
int
MyItemModel
::
columnCount
(
const
QModelIndex
&
parent
)
const
{
return
root
->
columnCount
();
}
//Helferfunktion
TreeItem
*
MyItemModel
::
getItem
(
const
QModelIndex
&
index
)
const
{
if
(
index
.
isValid
()){
TreeItem
*
item
=
static_cast
<
TreeItem
*>
(
index
.
internalPointer
());
if
(
item
)
{
return
item
;
}
}
return
root
;
}
helloqube/myitemmodel.h
View file @
06be88a0
...
...
@@ -2,11 +2,22 @@
#define MYITEMMODEL_H
#include <QAbstractItemModel>
#include <treeitem.h>
class
MyItemModel
:
public
QAbstractItemModel
{
Q_OBJECT
;
public
:
MyItemModel
();
MyItemModel
(
QObject
*
parent
=
0
);
~
MyItemModel
();
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
Q_DECL_OVERRIDE
;
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
Q_DECL_OVERRIDE
;
private
:
TreeItem
*
root
;
TreeItem
*
getItem
(
const
QModelIndex
&
index
)
const
;
};
#endif // MYITEMMODEL_H
helloqube/treeitem.cpp
View file @
06be88a0
...
...
@@ -3,6 +3,7 @@
TreeItem
::
TreeItem
()
{
children
=
QList
<
TreeItem
*>
();
name
=
"root"
;
}
TreeItem
::~
TreeItem
(){
...
...
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