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
7766a76e
Commit
7766a76e
authored
Feb 13, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2789 from DonLakeFlyer/TabletMissionLoadSave
Add support for load/save mission on tablet
parents
ff0edd16
b85ca3bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
18 deletions
+139
-18
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+65
-4
MissionController.cc
src/MissionManager/MissionController.cc
+69
-12
MissionController.h
src/MissionManager/MissionController.h
+5
-2
No files found.
src/MissionEditor/MissionEditor.qml
View file @
7766a76e
...
...
@@ -92,8 +92,20 @@ QGCView {
}
function
loadFromFile
()
{
controller
.
loadMissionFromFile
()
fitViewportToMissionItems
()
if
(
ScreenTools
.
isMobile
)
{
_root
.
showDialog
(
mobileFilePicker
,
"
Select Mission File
"
,
_root
.
showDialogDefaultWidth
,
StandardButton
.
Yes
|
StandardButton
.
Cancel
)
}
else
{
controller
.
loadMissionFromFile
()
fitViewportToMissionItems
()
}
}
function
saveToFile
()
{
if
(
ScreenTools
.
isMobile
)
{
_root
.
showDialog
(
mobileFileSaver
,
"
Save Mission File
"
,
_root
.
showDialogDefaultWidth
,
StandardButton
.
Save
|
StandardButton
.
Cancel
)
}
else
{
controller
.
saveToFile
()
}
}
function
normalizeLat
(
lat
)
{
...
...
@@ -175,6 +187,56 @@ QGCView {
property
int
_moveDialogMissionItemIndex
Component
{
id
:
mobileFilePicker
QGCViewDialog
{
ListView
{
anchors.margins
:
_margin
anchors.fill
:
parent
spacing
:
_margin
/
2
orientation
:
ListView
.
Vertical
model
:
controller
.
getMobileMissionFiles
()
delegate
:
QGCButton
{
text
:
modelData
onClicked
:
{
hideDialog
()
controller
.
loadMobileMissionFromFile
(
modelData
)
fitViewportToMissionItems
()
}
}
}
}
}
Component
{
id
:
mobileFileSaver
QGCViewDialog
{
function
accept
()
{
hideDialog
()
console
.
log
(
filenameTextField
.
text
)
controller
.
saveMobileMissionToFile
(
filenameTextField
.
text
)
}
Column
{
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
spacing
:
ScreenTools
.
defaultFontPixelHeight
QGCLabel
{
text
:
"
File name:
"
}
QGCTextField
{
id
:
filenameTextField
}
}
}
}
Component
{
id
:
moveDialog
...
...
@@ -659,14 +721,13 @@ QGCView {
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
visible
:
!
ScreenTools
.
isMobile
QGCButton
{
text
:
"
Save to file...
"
onClicked
:
{
syncButton
.
hideDropDown
()
controller
.
saveMission
ToFile
()
save
ToFile
()
}
}
...
...
src/MissionManager/MissionController.cc
View file @
7766a76e
...
...
@@ -184,7 +184,6 @@ void MissionController::removeAllMissionItems(void)
}
}
#ifndef __mobile__
bool
MissionController
::
_loadJsonMissionFile
(
const
QByteArray
&
bytes
,
QmlObjectListModel
*
missionItems
,
QString
&
errorString
)
{
QJsonParseError
jsonParseError
;
...
...
@@ -242,9 +241,7 @@ bool MissionController::_loadJsonMissionFile(const QByteArray& bytes, QmlObjectL
return
true
;
}
#endif
#ifndef __mobile__
bool
MissionController
::
_loadTextMissionFile
(
QTextStream
&
stream
,
QmlObjectListModel
*
missionItems
,
QString
&
errorString
)
{
bool
addPlannedHomePosition
=
false
;
...
...
@@ -295,13 +292,10 @@ bool MissionController::_loadTextMissionFile(QTextStream& stream, QmlObjectListM
return
true
;
}
#endif
void
MissionController
::
loadMissionFromFile
(
void
)
void
MissionController
::
_loadMissionFromFile
(
const
QString
&
filename
)
{
#ifndef __mobile__
QString
errorString
;
QString
filename
=
QGCFileDialog
::
getOpenFileName
(
NULL
,
"Select Mission File to load"
,
QString
(),
"Mission file (*.mission);;All Files (*.*)"
);
if
(
filename
.
isEmpty
())
{
return
;
...
...
@@ -342,23 +336,34 @@ void MissionController::loadMissionFromFile(void)
}
_initAllMissionItems
();
#endif
}
void
MissionController
::
saveMissionTo
File
(
void
)
void
MissionController
::
loadMissionFrom
File
(
void
)
{
#ifndef __mobile__
QString
filename
=
QGCFileDialog
::
getSaveFileName
(
NULL
,
"Select file to save mission to"
,
QString
(),
"Mission file (*.mission);;All Files (*.*)"
);
QString
filename
=
QGCFileDialog
::
getOpenFileName
(
NULL
,
"Select Mission File to load"
,
QString
(),
"Mission file (*.mission);;All Files (*.*)"
);
if
(
filename
.
isEmpty
())
{
return
;
}
_loadMissionFromFile
(
filename
);
#endif
}
void
MissionController
::
_saveMissionToFile
(
const
QString
&
filename
)
{
qDebug
()
<<
filename
;
if
(
filename
.
isEmpty
())
{
return
;
}
QString
missionFilename
=
filename
;
if
(
!
QFileInfo
(
filename
).
fileName
().
contains
(
"."
))
{
f
ilename
+=
".mission"
;
missionF
ilename
+=
".mission"
;
}
QFile
file
(
f
ilename
);
QFile
file
(
missionF
ilename
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
{
qgcApp
()
->
showMessage
(
file
.
errorString
());
...
...
@@ -397,9 +402,41 @@ void MissionController::saveMissionToFile(void)
}
_missionItems
->
setDirty
(
false
);
}
void
MissionController
::
saveMissionToFile
(
void
)
{
#ifndef __mobile__
QString
filename
=
QGCFileDialog
::
getSaveFileName
(
NULL
,
"Select file to save mission to"
,
QString
(),
"Mission file (*.mission);;All Files (*.*)"
);
if
(
filename
.
isEmpty
())
{
return
;
}
_saveMissionToFile
(
filename
);
#endif
}
void
MissionController
::
saveMobileMissionToFile
(
const
QString
&
filename
)
{
QStringList
docDirs
=
QStandardPaths
::
standardLocations
(
QStandardPaths
::
DocumentsLocation
);
if
(
docDirs
.
count
()
<=
0
)
{
qWarning
()
<<
"No Documents location"
;
return
;
}
_saveMissionToFile
(
docDirs
.
at
(
0
)
+
QDir
::
separator
()
+
filename
);
}
void
MissionController
::
loadMobileMissionFromFile
(
const
QString
&
filename
)
{
QStringList
docDirs
=
QStandardPaths
::
standardLocations
(
QStandardPaths
::
DocumentsLocation
);
if
(
docDirs
.
count
()
<=
0
)
{
qWarning
()
<<
"No Documents location"
;
return
;
}
_loadMissionFromFile
(
docDirs
.
at
(
0
)
+
QDir
::
separator
()
+
filename
);
}
void
MissionController
::
_calcPrevWaypointValues
(
double
homeAlt
,
MissionItem
*
currentItem
,
MissionItem
*
prevItem
,
double
*
azimuth
,
double
*
distance
,
double
*
altDifference
)
{
QGeoCoordinate
currentCoord
=
currentItem
->
coordinate
();
...
...
@@ -834,3 +871,23 @@ void MissionController::_currentMissionItemChanged(int sequenceNumber)
}
}
}
QStringList
MissionController
::
getMobileMissionFiles
(
void
)
{
QStringList
missionFiles
;
QStringList
docDirs
=
QStandardPaths
::
standardLocations
(
QStandardPaths
::
DocumentsLocation
);
if
(
docDirs
.
count
()
<=
0
)
{
qWarning
()
<<
"No Documents location"
;
return
QStringList
();
}
QDir
missionDir
=
docDirs
.
at
(
0
);
QFileInfoList
missionFileInfoList
=
missionDir
.
entryInfoList
(
QStringList
(
QStringLiteral
(
"*.mission"
)),
QDir
::
Files
,
QDir
::
Name
);
foreach
(
const
QFileInfo
&
missionFileInfo
,
missionFileInfoList
)
{
missionFiles
<<
missionFileInfo
.
baseName
()
+
".mission"
;
}
return
missionFiles
;
}
src/MissionManager/MissionController.h
View file @
7766a76e
...
...
@@ -49,8 +49,11 @@ public:
Q_INVOKABLE
void
sendMissionItems
(
void
);
Q_INVOKABLE
void
loadMissionFromFile
(
void
);
Q_INVOKABLE
void
saveMissionToFile
(
void
);
Q_INVOKABLE
void
loadMobileMissionFromFile
(
const
QString
&
file
);
Q_INVOKABLE
void
saveMobileMissionToFile
(
const
QString
&
file
);
Q_INVOKABLE
void
removeMissionItem
(
int
index
);
Q_INVOKABLE
void
removeAllMissionItems
(
void
);
Q_INVOKABLE
QStringList
getMobileMissionFiles
(
void
);
/// @param i: index to insert at
Q_INVOKABLE
int
insertMissionItem
(
QGeoCoordinate
coordinate
,
int
i
);
...
...
@@ -97,10 +100,10 @@ private:
void
_addPlannedHomePosition
(
QmlObjectListModel
*
missionItems
,
bool
addToCenter
);
double
_normalizeLat
(
double
lat
);
double
_normalizeLon
(
double
lon
);
#ifndef __mobile__
bool
_loadJsonMissionFile
(
const
QByteArray
&
bytes
,
QmlObjectListModel
*
missionItems
,
QString
&
errorString
);
bool
_loadTextMissionFile
(
QTextStream
&
stream
,
QmlObjectListModel
*
missionItems
,
QString
&
errorString
);
#endif
void
_loadMissionFromFile
(
const
QString
&
file
);
void
_saveMissionToFile
(
const
QString
&
file
);
private:
bool
_editMode
;
...
...
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