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
54331a19
Commit
54331a19
authored
Jun 18, 2017
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add delete file support to QGCFileDialog
parent
1d46da77
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
218 additions
and
46 deletions
+218
-46
qgroundcontrol.pro
qgroundcontrol.pro
+2
-2
qgroundcontrol.qrc
qgroundcontrol.qrc
+1
-0
MissionSettingsEditor.qml
src/PlanView/MissionSettingsEditor.qml
+5
-4
QGCApplication.cc
src/QGCApplication.cc
+11
-11
FileButton.qml
src/QmlControls/FileButton.qml
+64
-0
QGCFileDialog.qml
src/QmlControls/QGCFileDialog.qml
+60
-24
QGCFileDialogController.cc
src/QmlControls/QGCFileDialogController.cc
+66
-0
QGCFileDialogController.h
src/QmlControls/QGCFileDialogController.h
+8
-5
QGroundControl.Controls.qmldir
src/QmlControls/QGroundControl.Controls.qmldir
+1
-0
No files found.
qgroundcontrol.pro
View file @
54331a19
...
...
@@ -515,7 +515,7 @@ HEADERS += \
src
/
QmlControls
/
CoordinateVector
.
h
\
src
/
QmlControls
/
MavlinkQmlSingleton
.
h
\
src
/
QmlControls
/
ParameterEditorController
.
h
\
src
/
QmlControls
/
QFileDialogController
.
h
\
src
/
QmlControls
/
Q
GC
FileDialogController
.
h
\
src
/
QmlControls
/
QGCImageProvider
.
h
\
src
/
QmlControls
/
QGroundControlQmlGlobal
.
h
\
src
/
QmlControls
/
QmlObjectListModel
.
h
\
...
...
@@ -691,7 +691,7 @@ SOURCES += \
src
/
QmlControls
/
AppMessages
.
cc
\
src
/
QmlControls
/
CoordinateVector
.
cc
\
src
/
QmlControls
/
ParameterEditorController
.
cc
\
src
/
QmlControls
/
QFileDialogController
.
cc
\
src
/
QmlControls
/
Q
GC
FileDialogController
.
cc
\
src
/
QmlControls
/
QGCImageProvider
.
cc
\
src
/
QmlControls
/
QGroundControlQmlGlobal
.
cc
\
src
/
QmlControls
/
QmlObjectListModel
.
cc
\
...
...
qgroundcontrol.qrc
View file @
54331a19
...
...
@@ -55,6 +55,7 @@
<file alias="QGroundControl/Controls/DropButton.qml">src/QmlControls/DropButton.qml</file>
<file alias="QGroundControl/Controls/ExclusiveGroupItem.qml">src/QmlControls/ExclusiveGroupItem.qml</file>
<file alias="QGroundControl/Controls/FactSliderPanel.qml">src/QmlControls/FactSliderPanel.qml</file>
<file alias="QGroundControl/Controls/FileButton.qml">src/QmlControls/FileButton.qml</file>
<file alias="QGroundControl/Controls/FlightModeDropdown.qml">src/QmlControls/FlightModeDropdown.qml</file>
<file alias="QGroundControl/Controls/FlightModeMenu.qml">src/QmlControls/FlightModeMenu.qml</file>
<file alias="QGroundControl/Controls/FWLandingPatternMapVisual.qml">src/PlanView/FWLandingPatternMapVisual.qml</file>
...
...
src/PlanView/MissionSettingsEditor.qml
View file @
54331a19
...
...
@@ -41,7 +41,7 @@ Rectangle {
readonly
property
string
_vehicleLabel
:
qsTr
(
"
Vehicle
"
)
QGCPalette
{
id
:
qgcPal
}
QFileDialogController
{
id
:
fileController
}
Q
GC
FileDialogController
{
id
:
fileController
}
Loader
{
id
:
deferedload
...
...
@@ -153,9 +153,10 @@ Rectangle {
spacing
:
_margin
visible
:
missionEndHeader
.
checked
FactCheckBox
{
text
:
qsTr
(
"
Return To Launch
"
)
fact
:
missionItem
.
missionEndRTL
QGCCheckBox
{
text
:
qsTr
(
"
Return To Launch
"
)
checked
:
missionItem
.
missionEndRTL
onClicked
:
missionItem
.
missionEndRTL
=
checked
}
}
...
...
src/QGCApplication.cc
View file @
54331a19
...
...
@@ -49,7 +49,7 @@
#include "CustomCommandWidgetController.h"
#include "ESP8266ComponentController.h"
#include "ScreenToolsController.h"
#include "QFileDialogController.h"
#include "Q
GC
FileDialogController.h"
#include "RCChannelMonitorController.h"
#include "SyslinkComponentController.h"
#include "AutoPilotPlugin.h"
...
...
@@ -363,16 +363,16 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType
<
GeoFenceController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"GeoFenceController"
,
"Reference only"
);
qmlRegisterUncreatableType
<
RallyPointController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"RallyPointController"
,
"Reference only"
);
qmlRegisterType
<
ParameterEditorController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ParameterEditorController"
);
qmlRegisterType
<
ESP8266ComponentController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ESP8266ComponentController"
);
qmlRegisterType
<
ScreenToolsController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ScreenToolsController"
);
qmlRegisterType
<
PlanMasterController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"PlanElemementMasterController"
);
qmlRegisterType
<
ValuesWidgetController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ValuesWidgetController"
);
qmlRegisterType
<
Q
FileDialogController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"Q
FileDialogController"
);
qmlRegisterType
<
RCChannelMonitorController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"RCChannelMonitorController"
);
qmlRegisterType
<
JoystickConfigController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"JoystickConfigController"
);
qmlRegisterType
<
LogDownloadController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"LogDownloadController"
);
qmlRegisterType
<
SyslinkComponentController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"SyslinkComponentController"
);
qmlRegisterType
<
ParameterEditorController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ParameterEditorController"
);
qmlRegisterType
<
ESP8266ComponentController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ESP8266ComponentController"
);
qmlRegisterType
<
ScreenToolsController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ScreenToolsController"
);
qmlRegisterType
<
PlanMasterController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"PlanElemementMasterController"
);
qmlRegisterType
<
ValuesWidgetController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ValuesWidgetController"
);
qmlRegisterType
<
Q
GCFileDialogController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"QGC
FileDialogController"
);
qmlRegisterType
<
RCChannelMonitorController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"RCChannelMonitorController"
);
qmlRegisterType
<
JoystickConfigController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"JoystickConfigController"
);
qmlRegisterType
<
LogDownloadController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"LogDownloadController"
);
qmlRegisterType
<
SyslinkComponentController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"SyslinkComponentController"
);
#ifndef __mobile__
qmlRegisterType
<
ViewWidgetController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ViewWidgetController"
);
qmlRegisterType
<
CustomCommandWidgetController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"CustomCommandWidgetController"
);
...
...
src/QmlControls/FileButton.qml
0 → 100644
View file @
54331a19
import
QtQuick
2.3
import
QtQuick
.
Controls
1.2
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
ScreenTools
1.0
/// File Button controls used by QGCFileDialog control
Rectangle
{
implicitWidth
:
ScreenTools
.
implicitButtonWidth
implicitHeight
:
ScreenTools
.
implicitButtonHeight
color
:
highlight
?
qgcPal
.
buttonHighlight
:
qgcPal
.
button
border.color
:
highlight
?
qgcPal
.
buttonHighlightText
:
qgcPal
.
buttonText
property
alias
text
:
label
.
text
property
bool
highlight
:
false
signal
clicked
signal
hamburgerClicked
property
real
_margins
:
ScreenTools
.
defaultFontPixelWidth
/
2
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
enabled
}
QGCLabel
{
id
:
label
anchors.margins
:
_margins
anchors.left
:
parent
.
left
anchors.right
:
hamburger
.
left
anchors.top
:
parent
.
top
anchors.bottom
:
parent
.
bottom
verticalAlignment
:
Text
.
AlignVCenter
horizontalAlignment
:
Text
.
AlignHCenter
color
:
highlight
?
qgcPal
.
buttonHighlightText
:
qgcPal
.
buttonText
elide
:
Text
.
ElideRight
}
QGCColoredImage
{
id
:
hamburger
anchors.rightMargin
:
_margins
anchors.right
:
parent
.
right
anchors.verticalCenter
:
parent
.
verticalCenter
width
:
_hamburgerSize
height
:
_hamburgerSize
sourceSize.height
:
_hamburgerSize
source
:
"
qrc:/qmlimages/Hamburger.svg
"
color
:
highlight
?
qgcPal
.
buttonHighlightText
:
qgcPal
.
buttonText
property
real
_hamburgerSize
:
parent
.
height
*
0.75
}
QGCMouseArea
{
anchors.fill
:
parent
onClicked
:
parent
.
clicked
()
}
QGCMouseArea
{
anchors.leftMargin
:
-
_margins
*
2
anchors.top
:
parent
.
top
anchors.bottom
:
parent
.
bottom
anchors.right
:
parent
.
right
anchors.left
:
hamburger
.
left
onClicked
:
parent
.
hamburgerClicked
()
}
}
src/QmlControls/QGCFileDialog.qml
View file @
54331a19
...
...
@@ -17,16 +17,25 @@ Item {
property
var
qgcView
property
string
folder
property
var
nameFilters
property
string
fileExtension
property
string
fileExtension2
property
string
fileExtension
// Primary file extension to search for
property
string
fileExtension2
// Secondary file extension to search for
property
string
title
property
bool
selectExisting
property
bool
selectFolder
property
bool
_openForLoad
:
true
property
real
_margins
:
ScreenTools
.
defaultFontPixelHeight
/
2
property
bool
_mobile
:
ScreenTools
.
isMobile
property
bool
_openForLoad
:
true
property
real
_margins
:
ScreenTools
.
defaultFontPixelHeight
/
2
property
bool
_mobile
:
ScreenTools
.
isMobile
property
var
_rgExtensions
Component.onCompleted
:
{
if
(
fileExtension2
===
""
)
{
_rgExtensions
=
[
fileExtension
]
}
else
{
_rgExtensions
=
[
fileExtension
,
fileExtension2
]
}
}
function
openForLoad
()
{
_openForLoad
=
true
...
...
@@ -54,7 +63,7 @@ Item {
signal
acceptedForSave
(
string
file
)
signal
rejected
QFileDialogController
{
id
:
controller
}
Q
GC
FileDialogController
{
id
:
controller
}
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
true
}
FileDialog
{
...
...
@@ -92,9 +101,10 @@ Item {
Repeater
{
id
:
fileList
model
:
controller
.
getFiles
(
folder
,
fileExtension
)
model
:
controller
.
getFiles
(
folder
,
_rgExtensions
)
QGCButton
{
FileButton
{
id
:
fileButton
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
text
:
modelData
...
...
@@ -103,21 +113,27 @@ Item {
hideDialog
()
_root
.
acceptedForLoad
(
controller
.
fullyQualifiedFilename
(
folder
,
modelData
,
fileExtension
))
}
}
}
Repeater
{
id
:
fileList2
model
:
fileExtension2
==
""
?
[
]
:
controller
.
getFiles
(
folder
,
fileExtension2
)
onHamburgerClicked
:
{
highlight
=
true
hamburgerMenu
.
fileToDelete
=
controller
.
fullyQualifiedFilename
(
folder
,
modelData
,
fileExtension
)
hamburgerMenu
.
popup
()
}
QGCButton
{
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
text
:
modelData
Menu
{
id
:
hamburgerMenu
onClicked
:
{
hideDialog
()
_root
.
acceptedForLoad
(
controller
.
fullyQualifiedFilename
(
folder
,
modelData
,
fileExtension2
))
property
string
fileToDelete
onAboutToHide
:
{
fileButton
.
highlight
=
false
hideDialog
()
}
MenuItem
{
text
:
qsTr
(
"
Delete
"
)
onTriggered
:
controller
.
deleteFile
(
hamburgerMenu
.
fileToDelete
);
}
}
}
}
...
...
@@ -197,9 +213,9 @@ Item {
}
Repeater
{
model
:
controller
.
getFiles
(
folder
,
fileExtension
)
model
:
controller
.
getFiles
(
folder
,
[
fileExtension
]
)
QGC
Button
{
File
Button
{
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
text
:
modelData
...
...
@@ -208,10 +224,30 @@ Item {
hideDialog
()
_root
.
acceptedForSave
(
controller
.
fullyQualifiedFilename
(
folder
,
modelData
,
fileExtension
))
}
}
}
onHamburgerClicked
:
{
highlight
=
true
hamburgerMenu
.
fileToDelete
=
controller
.
fullyQualifiedFilename
(
folder
,
modelData
,
fileExtension
)
hamburgerMenu
.
popup
()
}
Menu
{
id
:
hamburgerMenu
property
string
fileToDelete
onAboutToHide
:
{
fileButton
.
highlight
=
false
hideDialog
()
}
MenuItem
{
text
:
qsTr
(
"
Delete
"
)
onTriggered
:
controller
.
deleteFile
(
hamburgerMenu
.
fileToDelete
);
}
}
}
}
}
}
}
...
...
src/QmlControls/QFileDialogController.cc
→
src/QmlControls/Q
GC
FileDialogController.cc
View file @
54331a19
...
...
@@ -8,32 +8,37 @@
****************************************************************************/
#include "QFileDialogController.h"
#include "Q
GC
FileDialogController.h"
#include <QStandardPaths>
#include <QDebug>
#include <QDir>
QGC_LOGGING_CATEGORY
(
Q
FileDialogControllerLog
,
"Q
FileDialogControllerLog"
)
QGC_LOGGING_CATEGORY
(
Q
GCFileDialogControllerLog
,
"QGC
FileDialogControllerLog"
)
QStringList
Q
FileDialogController
::
getFiles
(
const
QString
&
directoryPath
,
const
QString
&
fileExtension
)
QStringList
Q
GCFileDialogController
::
getFiles
(
const
QString
&
directoryPath
,
const
QStringList
&
fileExtensions
)
{
qCDebug
(
Q
FileDialogControllerLog
)
<<
"getFiles"
<<
directoryPath
<<
fileExtension
;
qCDebug
(
Q
GCFileDialogControllerLog
)
<<
"getFiles"
<<
directoryPath
<<
fileExtensions
;
QStringList
files
;
QDir
fileDir
(
directoryPath
);
QFileInfoList
fileInfoList
=
fileDir
.
entryInfoList
(
QStringList
(
QString
(
"*.%1"
).
arg
(
fileExtension
)),
QDir
::
Files
,
QDir
::
Name
);
QStringList
infoListExtensions
;
foreach
(
const
QString
&
extension
,
fileExtensions
)
{
infoListExtensions
.
append
(
QStringLiteral
(
"*.%1"
).
arg
(
extension
));
}
QFileInfoList
fileInfoList
=
fileDir
.
entryInfoList
(
infoListExtensions
,
QDir
::
Files
,
QDir
::
Name
);
foreach
(
const
QFileInfo
&
fileInfo
,
fileInfoList
)
{
qCDebug
(
Q
FileDialogControllerLog
)
<<
"getFiles found"
<<
fileInfo
.
bas
eName
();
files
<<
fileInfo
.
bas
eName
();
qCDebug
(
Q
GCFileDialogControllerLog
)
<<
"getFiles found"
<<
fileInfo
.
fil
eName
();
files
<<
fileInfo
.
fil
eName
();
}
return
files
;
}
QString
QFileDialogController
::
filenameWithExtension
(
const
QString
&
filename
,
const
QString
&
fileExtension
)
QString
Q
GC
FileDialogController
::
filenameWithExtension
(
const
QString
&
filename
,
const
QString
&
fileExtension
)
{
QString
filenameWithExtension
(
filename
);
...
...
@@ -45,12 +50,17 @@ QString QFileDialogController::filenameWithExtension(const QString& filename, co
return
filenameWithExtension
;
}
bool
QFileDialogController
::
fileExists
(
const
QString
&
filename
)
bool
Q
GC
FileDialogController
::
fileExists
(
const
QString
&
filename
)
{
return
QFile
(
filename
).
exists
();
}
QString
QFileDialogController
::
fullyQualifiedFilename
(
const
QString
&
directoryPath
,
const
QString
&
filename
,
const
QString
&
fileExtension
)
QString
Q
GC
FileDialogController
::
fullyQualifiedFilename
(
const
QString
&
directoryPath
,
const
QString
&
filename
,
const
QString
&
fileExtension
)
{
return
directoryPath
+
QStringLiteral
(
"/"
)
+
filenameWithExtension
(
filename
,
fileExtension
);
}
void
QGCFileDialogController
::
deleteFile
(
const
QString
&
filename
)
{
QFile
::
remove
(
filename
);
}
src/QmlControls/QFileDialogController.h
→
src/QmlControls/Q
GC
FileDialogController.h
View file @
54331a19
...
...
@@ -8,23 +8,23 @@
****************************************************************************/
#ifndef QFileDialogController_H
#define QFileDialogController_H
#ifndef Q
GC
FileDialogController_H
#define Q
GC
FileDialogController_H
#include <QObject>
#include <QUrl>
#include "QGCLoggingCategory.h"
Q_DECLARE_LOGGING_CATEGORY
(
QFileDialogControllerLog
)
Q_DECLARE_LOGGING_CATEGORY
(
Q
GC
FileDialogControllerLog
)
class
QFileDialogController
:
public
QObject
class
Q
GC
FileDialogController
:
public
QObject
{
Q_OBJECT
public:
/// Return all file in the specified path which match the specified extension
Q_INVOKABLE
QStringList
getFiles
(
const
QString
&
directoryPath
,
const
QString
&
fileExtension
);
Q_INVOKABLE
QStringList
getFiles
(
const
QString
&
directoryPath
,
const
QString
List
&
fileExtensions
);
/// Returns the specified file name with the extension added it needed
Q_INVOKABLE
QString
filenameWithExtension
(
const
QString
&
filename
,
const
QString
&
fileExtension
);
...
...
@@ -35,6 +35,9 @@ public:
/// Check for file existence of specified fully qualified file name
Q_INVOKABLE
bool
fileExists
(
const
QString
&
filename
);
/// Deletes the file specified by the fully qualified file name
Q_INVOKABLE
void
deleteFile
(
const
QString
&
filename
);
Q_INVOKABLE
QString
urlToLocalFile
(
QUrl
url
)
{
return
url
.
toLocalFile
();
}
};
...
...
src/QmlControls/QGroundControl.Controls.qmldir
View file @
54331a19
...
...
@@ -8,6 +8,7 @@ DropButton 1.0 DropButton.qml
DropPanel 1.0 DropPanel.qml
ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml
FactSliderPanel 1.0 FactSliderPanel.qml
FileButton 1.0 FileButton.qml
FlightModeDropdown 1.0 FlightModeDropdown.qml
FlightModeMenu 1.0 FlightModeMenu.qml
GeoFenceEditor 1.0 GeoFenceEditor.qml
...
...
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