Skip to content

Commit

Permalink
Merge pull request #186 from opengisch/project_properties_jp2k
Browse files Browse the repository at this point in the history
Further project properties improvements
  • Loading branch information
m-kuhn authored Sep 20, 2020
2 parents 27dc051 + fc11b21 commit 8ec7b83
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 38 deletions.
13 changes: 2 additions & 11 deletions qfieldsync/core/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,8 @@ def available_actions(self):

@property
def is_supported(self):
# jpeg 2000
if self.layer.source().endswith(('jp2', 'jpx')):
return False
# ecw raster
elif self.layer.source().endswith('ecw'):
if self.layer.source().endswith('ecw'):
return False
else:
return True
Expand All @@ -189,15 +186,9 @@ def is_geometry_locked(self, is_geometry_locked):

@property
def warning(self):
if self.layer.source().endswith(('jp2', 'jpx')):
return QCoreApplication.translate('DataSourceWarning',
'JPEG2000 layers are not supported by QField.<br>You can rasterize '
'them as basemap.'
)
if self.layer.source().endswith('ecw'):
return QCoreApplication.translate('DataSourceWarning',
'ECW layers are not supported by QField.<br>You can rasterize them '
'as basemap.')
'ECW layers are not supported by QField.')
return None

@property
Expand Down
7 changes: 5 additions & 2 deletions qfieldsync/core/offline_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ def convert(self):
self.total_progress_updated.emit(current_layer_index - len(self.__offline_layers), len(self.__layers),
self.trUtf8('Copying layers…'))

layer_source = LayerSource(layer)
if not layer_source.is_supported:
project.removeMapLayer(layer)
continue

if layer.dataProvider() is not None:
md = QgsProviderRegistry.instance().providerMetadata(layer.dataProvider().name())
if md is not None:
Expand All @@ -141,8 +146,6 @@ def convert(self):
# Layer stored in localized data path, skip
continue

layer_source = LayerSource(layer)

if layer_source.action == SyncAction.OFFLINE:
if self.project_configuration.offline_copy_only_aoi:
layer.selectByRect(self.extent)
Expand Down
24 changes: 12 additions & 12 deletions qfieldsync/gui/project_configuration_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ def reloadProject(self):
self.layersTable.setSortingEnabled(False)
for layer in self.project.mapLayers().values():
layer_source = LayerSource(layer)
if not layer_source.is_supported:
self.unsupportedLayersList.append(layer_source)
count = self.layersTable.rowCount()
self.layersTable.insertRow(count)
item = QTableWidgetItem(layer.name())
Expand All @@ -122,6 +120,13 @@ def reloadProject(self):
self.layersTable.setCellWidget(count, 1, cbx_widget)
self.layersTable.setCellWidget(count, 2, cmb)

if not layer_source.is_supported:
self.unsupportedLayersList.append(layer_source)
self.layersTable.item(count,0).setFlags(Qt.NoItemFlags)
self.layersTable.cellWidget(count,1).setEnabled(False)
self.layersTable.cellWidget(count,2).setEnabled(False)
cmb.setCurrentIndex(cmb.findData(SyncAction.REMOVE))

# make sure layer_source is the same instance everywhere
self.photoNamingTable.addLayerFields(layer_source)

Expand Down Expand Up @@ -156,17 +161,12 @@ def reloadProject(self):
self.onlyOfflineCopyFeaturesInAoi.setChecked(self.__project_configuration.offline_copy_only_aoi)

if self.unsupportedLayersList:
self.unsupportedLayers.setVisible(True)

unsupported_layers_text = '<b>{}</b><br>'.format(self.tr('Warning'))
unsupported_layers_text += self.tr("There are unsupported layers in your project. They will not be available on QField.")

unsupported_layers_text += '<ul>'
for layer in self.unsupportedLayersList:
unsupported_layers_text += '<li>' + '<b>' + layer.name + ':</b> ' + layer.warning
unsupported_layers_text += '<ul>'
self.unsupportedLayersLabel.setVisible(True)

self.unsupportedLayers.setText(unsupported_layers_text)
unsupported_layers_text = '<b>{}: </b>'.format(self.tr('Warning'))
unsupported_layers_text += self.tr("There are unsupported layers in your project which will not be available in QField.")
unsupported_layers_text += self.tr(" If needed, you can create a Base Map to include those layers in your packaged project.")
self.unsupportedLayersLabel.setText(unsupported_layers_text)

def apply(self):
"""
Expand Down
29 changes: 16 additions & 13 deletions qfieldsync/ui/project_configuration_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,25 @@
</column>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="unsupportedLayersLabel">
<property name="text">
<string></string>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="unsupportedLayers">
<property name="text">
<string>Unsupported layers</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand Down

0 comments on commit 8ec7b83

Please sign in to comment.