Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
3ffb3646
Commit
3ffb3646
authored
Sep 06, 2019
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
c850bd92
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
10 deletions
+40
-10
QmlObjectListModel.cc
src/QmlControls/QmlObjectListModel.cc
+36
-8
QmlObjectListModel.h
src/QmlControls/QmlObjectListModel.h
+4
-2
No files found.
src/QmlControls/QmlObjectListModel.cc
View file @
3ffb3646
...
...
@@ -20,9 +20,10 @@ const int QmlObjectListModel::ObjectRole = Qt::UserRole;
const
int
QmlObjectListModel
::
TextRole
=
Qt
::
UserRole
+
1
;
QmlObjectListModel
::
QmlObjectListModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
,
_dirty
(
false
)
,
_skipDirtyFirstItem
(
false
)
:
QAbstractListModel
(
parent
)
,
_dirty
(
false
)
,
_skipDirtyFirstItem
(
false
)
,
_externalBeginResetModel
(
false
)
{
}
...
...
@@ -142,8 +143,13 @@ const QObject* QmlObjectListModel::operator[](int index) const
void
QmlObjectListModel
::
clear
()
{
while
(
rowCount
())
{
removeAt
(
0
);
if
(
!
_externalBeginResetModel
)
{
beginResetModel
();
}
_objectList
.
clear
();
if
(
!
_externalBeginResetModel
)
{
endResetModel
();
emit
countChanged
(
count
());
}
}
...
...
@@ -221,10 +227,14 @@ void QmlObjectListModel::append(QList<QObject*> objects)
QObjectList
QmlObjectListModel
::
swapObjectList
(
const
QObjectList
&
newlist
)
{
QObjectList
oldlist
(
_objectList
);
beginResetModel
();
if
(
!
_externalBeginResetModel
)
{
beginResetModel
();
}
_objectList
=
newlist
;
endResetModel
();
emit
countChanged
(
count
());
if
(
!
_externalBeginResetModel
)
{
endResetModel
();
emit
countChanged
(
count
());
}
return
oldlist
;
}
...
...
@@ -274,3 +284,21 @@ void QmlObjectListModel::clearAndDeleteContents()
clear
();
endResetModel
();
}
void
QmlObjectListModel
::
beginReset
(
void
)
{
if
(
_externalBeginResetModel
)
{
qWarning
()
<<
"QmlObjectListModel::beginReset already set"
;
}
_externalBeginResetModel
=
true
;
beginResetModel
();
}
void
QmlObjectListModel
::
endReset
(
void
)
{
if
(
!
_externalBeginResetModel
)
{
qWarning
()
<<
"QmlObjectListModel::endReset begin not set"
;
}
_externalBeginResetModel
=
false
;
endResetModel
();
}
src/QmlControls/QmlObjectListModel.h
View file @
3ffb3646
...
...
@@ -33,6 +33,7 @@ public:
int
count
()
const
;
bool
dirty
()
const
{
return
_dirty
;
}
void
setDirty
(
bool
dirty
);
void
append
(
QObject
*
object
);
void
append
(
QList
<
QObject
*>
objects
);
...
...
@@ -56,8 +57,8 @@ public:
/// Clears the list and calls deleteLater on each entry
void
clearAndDeleteContents
();
void
beginReset
()
{
beginResetModel
();
}
void
endReset
()
{
endResetModel
();
}
void
beginReset
()
;
void
endReset
()
;
signals:
void
countChanged
(
int
count
);
...
...
@@ -80,6 +81,7 @@ private:
bool
_dirty
;
bool
_skipDirtyFirstItem
;
bool
_externalBeginResetModel
;
static
const
int
ObjectRole
;
static
const
int
TextRole
;
...
...
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