Commit 1a845a0e authored by Gus Grubba's avatar Gus Grubba

Adding ability to export a selected set of tile sets.

parent a25626fd
...@@ -119,7 +119,8 @@ public: ...@@ -119,7 +119,8 @@ public:
taskUpdateTileDownloadState, taskUpdateTileDownloadState,
taskDeleteTileSet, taskDeleteTileSet,
taskPruneCache, taskPruneCache,
taskReset taskReset,
taskExport
}; };
QGCMapTask(TaskType type) QGCMapTask(TaskType type)
...@@ -365,5 +366,36 @@ signals: ...@@ -365,5 +366,36 @@ signals:
void resetCompleted(); void resetCompleted();
}; };
//-----------------------------------------------------------------------------
class QGCExportTileTask : public QGCMapTask
{
Q_OBJECT
public:
QGCExportTileTask(QVector<QGCCachedTileSet*> sets, QString path)
: QGCMapTask(QGCMapTask::taskExport)
, _sets(sets)
, _path(path)
{}
~QGCExportTileTask()
{
}
QVector<QGCCachedTileSet*> sets() { return _sets; }
QString path() { return _path; }
void setExportCompleted()
{
emit exportCompleted();
}
private:
QVector<QGCCachedTileSet*> _sets;
QString _path;
signals:
void exportCompleted();
};
#endif // QGC_MAP_ENGINE_DATA_H #endif // QGC_MAP_ENGINE_DATA_H
...@@ -52,6 +52,7 @@ QGCCachedTileSet::QGCCachedTileSet(const QString& name) ...@@ -52,6 +52,7 @@ QGCCachedTileSet::QGCCachedTileSet(const QString& name)
, _noMoreTiles(false) , _noMoreTiles(false)
, _batchRequested(false) , _batchRequested(false)
, _manager(NULL) , _manager(NULL)
, _selected(false)
{ {
} }
...@@ -349,3 +350,14 @@ QGCCachedTileSet::setManager(QGCMapEngineManager* mgr) ...@@ -349,3 +350,14 @@ QGCCachedTileSet::setManager(QGCMapEngineManager* mgr)
{ {
_manager = mgr; _manager = mgr;
} }
//-----------------------------------------------------------------------------
void
QGCCachedTileSet::setSelected(bool sel)
{
_selected = sel;
emit selectedChanged();
if(_manager) {
emit _manager->selectedCountChanged();
}
}
...@@ -72,6 +72,8 @@ public: ...@@ -72,6 +72,8 @@ public:
Q_PROPERTY(quint32 errorCount READ errorCount NOTIFY errorCountChanged) Q_PROPERTY(quint32 errorCount READ errorCount NOTIFY errorCountChanged)
Q_PROPERTY(QString errorCountStr READ errorCountStr NOTIFY errorCountChanged) Q_PROPERTY(QString errorCountStr READ errorCountStr NOTIFY errorCountChanged)
Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
Q_INVOKABLE void createDownloadTask (); Q_INVOKABLE void createDownloadTask ();
Q_INVOKABLE void resumeDownloadTask (); Q_INVOKABLE void resumeDownloadTask ();
Q_INVOKABLE void cancelDownloadTask (); Q_INVOKABLE void cancelDownloadTask ();
...@@ -109,7 +111,9 @@ public: ...@@ -109,7 +111,9 @@ public:
bool downloading () { return _downloading; } bool downloading () { return _downloading; }
quint32 errorCount () { return _errorCount; } quint32 errorCount () { return _errorCount; }
QString errorCountStr (); QString errorCountStr ();
bool selected () { return _selected; }
void setSelected (bool sel);
void setName (QString name) { _name = name; } void setName (QString name) { _name = name; }
void setMapTypeStr (QString typeStr) { _mapTypeStr = typeStr; } void setMapTypeStr (QString typeStr) { _mapTypeStr = typeStr; }
void setTopleftLat (double lat) { _topleftLat = lat; } void setTopleftLat (double lat) { _topleftLat = lat; }
...@@ -142,6 +146,7 @@ signals: ...@@ -142,6 +146,7 @@ signals:
void savedTileSizeChanged (); void savedTileSizeChanged ();
void completeChanged (); void completeChanged ();
void errorCountChanged (); void errorCountChanged ();
void selectedChanged ();
private slots: private slots:
void _tileListFetched (QList<QGCTile*> tiles); void _tileListFetched (QList<QGCTile*> tiles);
...@@ -181,6 +186,7 @@ private: ...@@ -181,6 +186,7 @@ private:
bool _noMoreTiles; bool _noMoreTiles;
bool _batchRequested; bool _batchRequested;
QGCMapEngineManager* _manager; QGCMapEngineManager* _manager;
bool _selected;
}; };
#endif // QGC_MAP_TILE_SET_H #endif // QGC_MAP_TILE_SET_H
......
This diff is collapsed.
...@@ -59,13 +59,15 @@ private: ...@@ -59,13 +59,15 @@ private:
void _deleteTileSet (QGCMapTask* mtask); void _deleteTileSet (QGCMapTask* mtask);
void _resetCacheDatabase (QGCMapTask* mtask); void _resetCacheDatabase (QGCMapTask* mtask);
void _pruneCache (QGCMapTask* mtask); void _pruneCache (QGCMapTask* mtask);
void _exportSets (QGCMapTask* mtask);
bool _testTask (QGCMapTask* mtask);
void _testInternet (); void _testInternet ();
quint64 _findTile (const QString hash); quint64 _findTile (const QString hash);
bool _findTileSetID (const QString name, quint64& setID); bool _findTileSetID (const QString name, quint64& setID);
void _updateSetTotals (QGCCachedTileSet* set); void _updateSetTotals (QGCCachedTileSet* set);
bool _init (); bool _init ();
void _createDB (); bool _createDB (QSqlDatabase *db, bool createDefault = true);
quint64 _getDefaultTileSet (); quint64 _getDefaultTileSet ();
void _updateTotals (); void _updateTotals ();
......
...@@ -37,7 +37,8 @@ QGCView { ...@@ -37,7 +37,8 @@ QGCView {
property string savedMapType: "" property string savedMapType: ""
property bool _showPreview: true property bool _showPreview: true
property bool _defaultSet: offlineMapView && offlineMapView._currentSelection && offlineMapView._currentSelection.defaultSet property bool _defaultSet: offlineMapView && offlineMapView._currentSelection && offlineMapView._currentSelection.defaultSet
property real _margins: ScreenTools.defaultFontPixelWidth / 2 property real _margins: ScreenTools.defaultFontPixelWidth * 0.5
property real _buttonSize: ScreenTools.defaultFontPixelWidth * 12
property bool _saveRealEstate: ScreenTools.isTinyScreen || ScreenTools.isShortScreen property bool _saveRealEstate: ScreenTools.isTinyScreen || ScreenTools.isShortScreen
property real _adjustableFontPointSize: _saveRealEstate ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize property real _adjustableFontPointSize: _saveRealEstate ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
...@@ -100,10 +101,12 @@ QGCView { ...@@ -100,10 +101,12 @@ QGCView {
_map.visible = true _map.visible = true
_tileSetList.visible = false _tileSetList.visible = false
infoView.visible = false infoView.visible = false
_exporTiles.visible = false
addNewSetView.visible = true addNewSetView.visible = true
} }
function showList() { function showList() {
_exporTiles.visible = false
isMapInteractive = false isMapInteractive = false
_map.visible = false _map.visible = false
_tileSetList.visible = true _tileSetList.visible = true
...@@ -111,6 +114,15 @@ QGCView { ...@@ -111,6 +114,15 @@ QGCView {
addNewSetView.visible = false addNewSetView.visible = false
} }
function showExport() {
isMapInteractive = false
_map.visible = false
_tileSetList.visible = false
infoView.visible = false
addNewSetView.visible = false
_exporTiles.visible = true
}
function showInfo() { function showInfo() {
isMapInteractive = false isMapInteractive = false
if(_currentSelection && !offlineMapView._currentSelection.deleting) { if(_currentSelection && !offlineMapView._currentSelection.deleting) {
...@@ -796,7 +808,7 @@ QGCView { ...@@ -796,7 +808,7 @@ QGCView {
clip: true clip: true
anchors.margins: ScreenTools.defaultFontPixelWidth anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: _optionsButton.top anchors.bottom: _listButtonRow.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
contentHeight: _cacheList.height contentHeight: _cacheList.height
...@@ -806,7 +818,6 @@ QGCView { ...@@ -806,7 +818,6 @@ QGCView {
width: Math.min(_tileSetList.width, (ScreenTools.defaultFontPixelWidth * 50).toFixed(0)) width: Math.min(_tileSetList.width, (ScreenTools.defaultFontPixelWidth * 50).toFixed(0))
spacing: ScreenTools.defaultFontPixelHeight * 0.5 spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
OfflineMapButton { OfflineMapButton {
id: firstButton id: firstButton
text: qsTr("Add new set") text: qsTr("Add new set")
...@@ -834,15 +845,94 @@ QGCView { ...@@ -834,15 +845,94 @@ QGCView {
} }
} }
} }
Row {
QGCButton { id: _listButtonRow
id: _optionsButton
text: qsTr("Options")
visible: _tileSetList.visible visible: _tileSetList.visible
spacing: _margins
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelWidth anchors.margins: ScreenTools.defaultFontPixelWidth
QGCButton {
text: qsTr("Import")
width: _buttonSize
}
QGCButton {
text: qsTr("Export")
width: _buttonSize
enabled: QGroundControl.mapEngineManager.tileSets.count > 1
onClicked: showExport()
}
QGCButton {
text: qsTr("Options")
width: _buttonSize
onClicked: showDialog(optionsDialogComponent, qsTr("Offline Maps Options"), qgcView.showDialogDefaultWidth, StandardButton.Save | StandardButton.Cancel) onClicked: showDialog(optionsDialogComponent, qsTr("Offline Maps Options"), qgcView.showDialogDefaultWidth, StandardButton.Save | StandardButton.Cancel)
} }
}
//-- Export Tile Sets
QGCFlickable {
id: _exporTiles
clip: true
visible: false
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.top: parent.top
anchors.bottom: _exportButtonRow.top
anchors.left: parent.left
anchors.right: parent.right
contentHeight: _exportList.height
Column {
id: _exportList
width: Math.min(_exporTiles.width, (ScreenTools.defaultFontPixelWidth * 50).toFixed(0))
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: qsTr("Select Tile Sets to Export")
font.pointSize: ScreenTools.mediumFontPointSize
}
Item { width: 1; height: ScreenTools.defaultFontPixelHeight; }
Repeater {
model: QGroundControl.mapEngineManager.tileSets
delegate: QGCCheckBox {
text: object.name
checked: object.selected
onClicked: {
object.selected = checked
}
}
}
}
}
Row {
id: _exportButtonRow
visible: _exporTiles.visible
spacing: _margins
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelWidth
QGCButton {
text: qsTr("All")
width: _buttonSize
onClicked: QGroundControl.mapEngineManager.selectAll()
}
QGCButton {
text: qsTr("None")
width: _buttonSize
onClicked: QGroundControl.mapEngineManager.selectNone()
}
QGCButton {
text: qsTr("Export")
width: _buttonSize
enabled: QGroundControl.mapEngineManager.selectedCount > 0
onClicked: {
QGroundControl.mapEngineManager.exportSets()
showList()
}
}
QGCButton {
text: qsTr("Cancel")
width: _buttonSize
onClicked: showList()
}
}
} // QGCViewPanel } // QGCViewPanel
} // QGCView } // QGCView
...@@ -308,6 +308,9 @@ QGCMapEngineManager::taskError(QGCMapTask::TaskType type, QString error) ...@@ -308,6 +308,9 @@ QGCMapEngineManager::taskError(QGCMapTask::TaskType type, QString error)
case QGCMapTask::taskReset: case QGCMapTask::taskReset:
task = "Reset Tile Sets"; task = "Reset Tile Sets";
break; break;
case QGCMapTask::taskExport:
task = "Export Tile Sets";
break;
default: default:
task = "Database Error"; task = "Database Error";
break; break;
...@@ -351,6 +354,70 @@ QGCMapEngineManager::findName(const QString& name) ...@@ -351,6 +354,70 @@ QGCMapEngineManager::findName(const QString& name)
return false; return false;
} }
//-----------------------------------------------------------------------------
void
QGCMapEngineManager::selectAll() {
for(int i = 0; i < _tileSets.count(); i++ ) {
QGCCachedTileSet* set = qobject_cast<QGCCachedTileSet*>(_tileSets.get(i));
Q_ASSERT(set);
set->setSelected(true);
}
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager::selectNone() {
for(int i = 0; i < _tileSets.count(); i++ ) {
QGCCachedTileSet* set = qobject_cast<QGCCachedTileSet*>(_tileSets.get(i));
Q_ASSERT(set);
set->setSelected(false);
}
}
//-----------------------------------------------------------------------------
int
QGCMapEngineManager::selectedCount() {
int count = 0;
for(int i = 0; i < _tileSets.count(); i++ ) {
QGCCachedTileSet* set = qobject_cast<QGCCachedTileSet*>(_tileSets.get(i));
Q_ASSERT(set);
if(set->selected()) {
count++;
}
}
return count;
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager::exportSets(QString path) {
QString dir = path;
if(dir.isEmpty()) {
dir = QDir(QDir::homePath()).filePath(QString("export_%1.db").arg(QDateTime::currentDateTime().toTime_t()));
}
QVector<QGCCachedTileSet*> sets;
for(int i = 0; i < _tileSets.count(); i++ ) {
QGCCachedTileSet* set = qobject_cast<QGCCachedTileSet*>(_tileSets.get(i));
Q_ASSERT(set);
if(set->selected()) {
sets.append(set);
}
}
if(sets.count()) {
QGCExportTileTask* task = new QGCExportTileTask(sets, dir);
connect(task, &QGCExportTileTask::exportCompleted, this, &QGCMapEngineManager::_exportCompleted);
connect(task, &QGCMapTask::error, this, &QGCMapEngineManager::taskError);
getQGCMapEngine()->addTask(task);
}
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager::_exportCompleted()
{
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
QString QString
QGCMapEngineManager::getUniqueName() QGCMapEngineManager::getUniqueName()
......
...@@ -46,6 +46,7 @@ public: ...@@ -46,6 +46,7 @@ public:
//-- Disk Space in MB //-- Disk Space in MB
Q_PROPERTY(quint32 freeDiskSpace READ freeDiskSpace NOTIFY freeDiskSpaceChanged) Q_PROPERTY(quint32 freeDiskSpace READ freeDiskSpace NOTIFY freeDiskSpaceChanged)
Q_PROPERTY(quint32 diskSpace READ diskSpace CONSTANT) Q_PROPERTY(quint32 diskSpace READ diskSpace CONSTANT)
Q_PROPERTY(int selectedCount READ selectedCount NOTIFY selectedCountChanged)
Q_INVOKABLE void loadTileSets (); Q_INVOKABLE void loadTileSets ();
Q_INVOKABLE void updateForCurrentView (double lon0, double lat0, double lon1, double lat1, int minZoom, int maxZoom, const QString& mapName); Q_INVOKABLE void updateForCurrentView (double lon0, double lat0, double lon1, double lat1, int minZoom, int maxZoom, const QString& mapName);
...@@ -55,6 +56,9 @@ public: ...@@ -55,6 +56,9 @@ public:
Q_INVOKABLE void deleteTileSet (QGCCachedTileSet* tileSet); Q_INVOKABLE void deleteTileSet (QGCCachedTileSet* tileSet);
Q_INVOKABLE QString getUniqueName (); Q_INVOKABLE QString getUniqueName ();
Q_INVOKABLE bool findName (const QString& name); Q_INVOKABLE bool findName (const QString& name);
Q_INVOKABLE void selectAll ();
Q_INVOKABLE void selectNone ();
Q_INVOKABLE void exportSets (QString path = QString());
int tileX0 () { return _totalSet.tileX0; } int tileX0 () { return _totalSet.tileX0; }
int tileX1 () { return _totalSet.tileX1; } int tileX1 () { return _totalSet.tileX1; }
...@@ -72,6 +76,7 @@ public: ...@@ -72,6 +76,7 @@ public:
QString errorMessage () { return _errorMessage; } QString errorMessage () { return _errorMessage; }
quint64 freeDiskSpace () { return _freeDiskSpace; } quint64 freeDiskSpace () { return _freeDiskSpace; }
quint64 diskSpace () { return _diskSpace; } quint64 diskSpace () { return _diskSpace; }
int selectedCount ();
void setMapboxToken (QString token); void setMapboxToken (QString token);
void setMaxMemCache (quint32 size); void setMaxMemCache (quint32 size);
...@@ -95,6 +100,7 @@ signals: ...@@ -95,6 +100,7 @@ signals:
void maxDiskCacheChanged (); void maxDiskCacheChanged ();
void errorMessageChanged (); void errorMessageChanged ();
void freeDiskSpaceChanged (); void freeDiskSpaceChanged ();
void selectedCountChanged ();
public slots: public slots:
void taskError (QGCMapTask::TaskType type, QString error); void taskError (QGCMapTask::TaskType type, QString error);
...@@ -105,6 +111,7 @@ private slots: ...@@ -105,6 +111,7 @@ private slots:
void _tileSetDeleted (quint64 setID); void _tileSetDeleted (quint64 setID);
void _updateTotals (quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize); void _updateTotals (quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize);
void _resetCompleted (); void _resetCompleted ();
void _exportCompleted ();
private: private:
void _updateDiskFreeSpace (); void _updateDiskFreeSpace ();
......
...@@ -232,14 +232,14 @@ Rectangle { ...@@ -232,14 +232,14 @@ Rectangle {
} }
Repeater { Repeater {
model: _corePlugin.settingsPages model: _corePlugin ? _corePlugin.settingsPages : []
visible: _corePlugin.options.combineSettingsAndSetup visible: _corePlugin && _corePlugin.options.combineSettingsAndSetup
SubMenuButton { SubMenuButton {
imageResource: modelData.icon imageResource: modelData.icon
setupIndicator: false setupIndicator: false
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
text: modelData.title text: modelData.title
visible: _corePlugin.options.combineSettingsAndSetup visible: _corePlugin && _corePlugin.options.combineSettingsAndSetup
onClicked: panelLoader.setSource(modelData.url) onClicked: panelLoader.setSource(modelData.url)
Layout.fillWidth: true Layout.fillWidth: true
} }
...@@ -312,7 +312,7 @@ Rectangle { ...@@ -312,7 +312,7 @@ Rectangle {
SubMenuButton { SubMenuButton {
setupIndicator: false setupIndicator: false
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
visible: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable && _corePlugin.showAdvancedUI visible: QGroundControl.multiVehicleManager && QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable && _corePlugin.showAdvancedUI
text: "Parameters" text: "Parameters"
Layout.fillWidth: true Layout.fillWidth: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment