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
97c92ae7
Commit
97c92ae7
authored
Oct 10, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dirty bit support
parent
dca59af3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
6 deletions
+120
-6
Sync.png
resources/Sync.png
+0
-0
MissionEditor.cc
src/MissionEditor/MissionEditor.cc
+5
-0
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+25
-5
MissionItem.cc
src/MissionItem.cc
+24
-0
MissionItem.h
src/MissionItem.h
+12
-0
QmlObjectListModel.cc
src/QmlControls/QmlObjectListModel.cc
+38
-1
QmlObjectListModel.h
src/QmlControls/QmlObjectListModel.h
+16
-0
No files found.
resources/Sync.png
View replaced file @
dca59af3
View file @
97c92ae7
3.48 KB
|
W:
|
H:
3.94 KB
|
W:
|
H:
2-up
Swipe
Onion skin
src/MissionEditor/MissionEditor.cc
View file @
97c92ae7
...
...
@@ -73,6 +73,7 @@ void MissionEditor::_newMissionItemsAvailable(void)
_canEdit
=
missionManager
->
canEdit
();
_missionItems
=
missionManager
->
copyMissionItems
();
_reSequence
();
_missionItems
->
setDirty
(
false
);
emit
missionItemsChanged
();
emit
canEditChanged
(
_canEdit
);
...
...
@@ -95,6 +96,7 @@ void MissionEditor::setMissionItems(void)
if
(
activeVehicle
)
{
activeVehicle
->
missionManager
()
->
writeMissionItems
(
*
_missionItems
);
_missionItems
->
setDirty
(
false
);
}
}
...
...
@@ -225,6 +227,7 @@ void MissionEditor::loadMissionFromFile(void)
_missionItems
->
clear
();
}
_missionItems
->
setDirty
(
false
);
emit
canEditChanged
(
_canEdit
);
}
...
...
@@ -250,4 +253,6 @@ void MissionEditor::saveMissionToFile(void)
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
i
))
->
save
(
out
);
}
}
_missionItems
->
setDirty
(
false
);
}
src/MissionEditor/MissionEditor.qml
View file @
97c92ae7
...
...
@@ -88,11 +88,6 @@ QGCView {
longitude
=
_homePositionCoordinate
.
longitude
}
QGCLabel
{
anchors.bottom
:
parent
.
bottom
text
:
"
WIP: Danger, do not fly with this!
"
;
font.pixelSize
:
ScreenTools
.
largeFontPixelSize
}
MouseArea
{
anchors.fill
:
parent
...
...
@@ -110,6 +105,31 @@ QGCView {
}
}
Rectangle
{
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.bottom
:
parent
.
bottom
width
:
parent
.
width
/
3
height
:
syncNeededText
.
height
+
(
ScreenTools
.
defaultFontPixelWidth
*
2
)
border.width
:
1
border.color
:
"
white
"
color
:
"
black
"
opacity
:
0.75
visible
:
controller
.
missionItems
.
dirty
QGCLabel
{
id
:
syncNeededText
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.top
:
parent
.
top
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
wrapMode
:
Text
.
WordWrap
horizontalAlignment
:
Text
.
AlignHCenter
verticalAlignment
:
Text
.
AlignVCenter
font.pixelSize
:
ScreenTools
.
mediumFontPixelSize
text
:
"
You have unsaved changes. Be sure to use the Sync tool to save when ready.
"
}
}
Rectangle
{
id
:
addMissionItemsButton
anchors.rightMargin
:
ScreenTools
.
defaultFontPixelHeight
...
...
src/MissionItem.cc
View file @
97c92ae7
...
...
@@ -83,6 +83,7 @@ MissionItem::MissionItem(QObject* parent,
,
_isCurrentItem
(
isCurrentItem
)
,
_reachedTime
(
0
)
,
_yawRadiansFact
(
NULL
)
,
_dirty
(
false
)
{
_latitudeFact
=
new
Fact
(
0
,
"Latitude:"
,
FactMetaData
::
valueTypeDouble
,
this
);
_longitudeFact
=
new
Fact
(
0
,
"Longitude:"
,
FactMetaData
::
valueTypeDouble
,
this
);
...
...
@@ -147,6 +148,16 @@ MissionItem::MissionItem(QObject* parent,
_altitudeFact
->
setMetaData
(
altitudeMetaData
);
_yawRadiansFact
->
setMetaData
(
yawMetaData
);
_loiterOrbitRadiusFact
->
setMetaData
(
loiterOrbitRadiusMetaData
);
// Connect to valueChanged to track dirty state
connect
(
_latitudeFact
,
&
Fact
::
valueChanged
,
this
,
&
MissionItem
::
_factValueChanged
);
connect
(
_longitudeFact
,
&
Fact
::
valueChanged
,
this
,
&
MissionItem
::
_factValueChanged
);
connect
(
_altitudeFact
,
&
Fact
::
valueChanged
,
this
,
&
MissionItem
::
_factValueChanged
);
connect
(
_yawRadiansFact
,
&
Fact
::
valueChanged
,
this
,
&
MissionItem
::
_factValueChanged
);
connect
(
_loiterOrbitRadiusFact
,
&
Fact
::
valueChanged
,
this
,
&
MissionItem
::
_factValueChanged
);
connect
(
_param1Fact
,
&
Fact
::
valueChanged
,
this
,
&
MissionItem
::
_factValueChanged
);
connect
(
_param2Fact
,
&
Fact
::
valueChanged
,
this
,
&
MissionItem
::
_factValueChanged
);
connect
(
_altitudeRelativeToHomeFact
,
&
Fact
::
valueChanged
,
this
,
&
MissionItem
::
_factValueChanged
);
}
MissionItem
::
MissionItem
(
const
MissionItem
&
other
,
QObject
*
parent
)
...
...
@@ -187,6 +198,7 @@ const MissionItem& MissionItem::operator=(const MissionItem& other)
_autocontinue
=
other
.
_autocontinue
;
_reachedTime
=
other
.
_reachedTime
;
_altitudeRelativeToHomeFact
=
other
.
_altitudeRelativeToHomeFact
;
_dirty
=
other
.
_dirty
;
*
_latitudeFact
=
*
other
.
_latitudeFact
;
*
_longitudeFact
=
*
other
.
_longitudeFact
;
...
...
@@ -797,3 +809,15 @@ bool MissionItem::canEdit(void)
return
false
;
}
}
void
MissionItem
::
setDirty
(
bool
dirty
)
{
_dirty
=
dirty
;
emit
dirtyChanged
(
_dirty
);
}
void
MissionItem
::
_factValueChanged
(
QVariant
value
)
{
Q_UNUSED
(
value
);
setDirty
(
true
);
}
src/MissionItem.h
View file @
97c92ae7
...
...
@@ -61,6 +61,9 @@ public:
const
MissionItem
&
operator
=
(
const
MissionItem
&
other
);
/// Returns true if the item has been modified since the last time dirty was false
Q_PROPERTY
(
bool
dirty
READ
dirty
WRITE
setDirty
NOTIFY
dirtyChanged
)
Q_PROPERTY
(
int
sequenceNumber
READ
sequenceNumber
WRITE
setSequenceNumber
NOTIFY
sequenceNumberChanged
)
Q_PROPERTY
(
bool
isCurrentItem
READ
isCurrentItem
WRITE
setIsCurrentItem
NOTIFY
isCurrentItemChanged
)
Q_PROPERTY
(
bool
specifiesCoordinate
READ
specifiesCoordinate
NOTIFY
commandChanged
)
...
...
@@ -106,6 +109,9 @@ public:
double
yawDegrees
(
void
)
const
;
void
setYawDegrees
(
double
yaw
);
bool
dirty
(
void
)
{
return
_dirty
;
}
void
setDirty
(
bool
dirty
);
// C++ only methods
/// Returns true if this item can be edited in the ui
...
...
@@ -184,6 +190,7 @@ signals:
void
isCurrentItemChanged
(
bool
isCurrentItem
);
void
coordinateChanged
(
const
QGeoCoordinate
&
coordinate
);
void
yawChanged
(
double
yaw
);
void
dirtyChanged
(
bool
dirty
);
/** @brief Announces a change to the waypoint data */
void
changed
(
MissionItem
*
wp
);
...
...
@@ -219,6 +226,9 @@ public:
void
setChanged
()
{
emit
changed
(
this
);
}
private
slots
:
void
_factValueChanged
(
QVariant
value
);
private:
QString
_oneDecimalString
(
double
value
);
...
...
@@ -254,6 +264,8 @@ private:
FactMetaData
*
_jumpSequenceMetaData
;
FactMetaData
*
_jumpRepeatMetaData
;
bool
_dirty
;
static
const
int
_cMavCmd2Name
=
9
;
static
const
MavCmd2Name_t
_rgMavCmd2Name
[
_cMavCmd2Name
];
};
...
...
src/QmlControls/QmlObjectListModel.cc
View file @
97c92ae7
...
...
@@ -34,6 +34,7 @@ const int QmlObjectListModel::TextRole = Qt::UserRole + 1;
QmlObjectListModel
::
QmlObjectListModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
,
_dirty
(
false
)
{
}
...
...
@@ -142,22 +143,36 @@ const QObject* QmlObjectListModel::operator[](int index) const
void
QmlObjectListModel
::
clear
(
void
)
{
while
(
rowCount
())
{
remove
Rows
(
0
,
1
);
remove
At
(
0
);
}
}
void
QmlObjectListModel
::
removeAt
(
int
i
)
{
setDirty
(
true
);
// Look for a dirtyChanged signal on the object
if
(
_objectList
[
i
]
->
metaObject
()
->
indexOfSignal
(
QMetaObject
::
normalizedSignature
(
"dirtyChanged(bool)"
))
!=
-
1
)
{
QObject
::
disconnect
(
_objectList
[
i
],
SIGNAL
(
dirtyChanged
(
bool
)),
this
,
SLOT
(
_childDirtyChanged
(
bool
)));
}
removeRows
(
i
,
1
);
}
void
QmlObjectListModel
::
insert
(
int
i
,
QObject
*
object
)
{
setDirty
(
true
);
if
(
i
<
0
||
i
>
_objectList
.
count
())
{
qWarning
()
<<
"Invalid index index:count"
<<
i
<<
_objectList
.
count
();
}
QQmlEngine
::
setObjectOwnership
(
object
,
QQmlEngine
::
CppOwnership
);
// Look for a dirtyChanged signal on the object
if
(
object
->
metaObject
()
->
indexOfSignal
(
QMetaObject
::
normalizedSignature
(
"dirtyChanged(bool)"
))
!=
-
1
)
{
QObject
::
connect
(
object
,
SIGNAL
(
dirtyChanged
(
bool
)),
this
,
SLOT
(
_childDirtyChanged
(
bool
)));
}
_objectList
.
insert
(
i
,
object
);
insertRows
(
i
,
1
);
...
...
@@ -177,3 +192,25 @@ QObject* QmlObjectListModel::get(int index)
{
return
_objectList
[
index
];
}
void
QmlObjectListModel
::
setDirty
(
bool
dirty
)
{
_dirty
=
dirty
;
if
(
!
dirty
)
{
// Need to clear dirty from all children
foreach
(
QObject
*
object
,
_objectList
)
{
if
(
object
->
property
(
"dirty"
).
isValid
())
{
object
->
setProperty
(
"dirty"
,
false
);
}
}
}
emit
dirtyChanged
(
_dirty
);
}
void
QmlObjectListModel
::
_childDirtyChanged
(
bool
dirty
)
{
_dirty
|=
dirty
;
emit
dirtyChanged
(
_dirty
);
}
src/QmlControls/QmlObjectListModel.h
View file @
97c92ae7
...
...
@@ -37,8 +37,18 @@ public:
Q_INVOKABLE
QObject
*
get
(
int
index
);
Q_PROPERTY
(
int
count
READ
count
NOTIFY
countChanged
)
/// Returns true if any of the items in the list are dirty. Requires each object to have
/// a dirty property and dirtyChanged signal.
Q_PROPERTY
(
bool
dirty
READ
dirty
WRITE
setDirty
NOTIFY
dirtyChanged
)
// Property accessors
int
count
(
void
)
const
;
bool
dirty
(
void
)
{
return
_dirty
;
}
void
setDirty
(
bool
dirty
);
void
append
(
QObject
*
object
);
void
clear
(
void
);
void
removeAt
(
int
i
);
...
...
@@ -51,6 +61,10 @@ public:
signals:
void
countChanged
(
int
count
);
void
dirtyChanged
(
bool
dirtyChanged
);
private
slots
:
void
_childDirtyChanged
(
bool
dirty
);
private:
// Overrides from QAbstractListModel
...
...
@@ -63,6 +77,8 @@ private:
private:
QList
<
QObject
*>
_objectList
;
bool
_dirty
;
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