Skip to content

Commit

Permalink
Symbolxml 3.4 (#128)
Browse files Browse the repository at this point in the history
* QGIS 3.4 does not support labelsettings and textformats in styles

* check if directory exists before removing

* move thread cleanup forward

* remove repo

* Testing

* fix

* Update metadata.txt - prepare for release
  • Loading branch information
havatv authored Apr 25, 2020
1 parent 145fced commit ca93b54
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
6 changes: 4 additions & 2 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ author=Akbar Gumbira, Håvard Tveite
qgisMinimumVersion=3.0
description=Download shared collections
about=Search for published collections and install them for use with QGIS. Symbology (SVG, images, styles), Processing scripts, Processing models and R scripts are supported. There are several options for repositories: Github, Bitbucket, local file system and HTTP(S).
version=0.14.0
version=0.14.1
tracker=https://github.com/QGIS-Contribution/QGIS-ResourceSharing/issues
repository=https://github.com/QGIS-Contribution/QGIS-ResourceSharing.git

Expand All @@ -17,8 +17,10 @@ experimental=False
deprecated=False
icon=resources/icon.png
changelog=
0.14.1 - Also support QGIS 3.4 (avoid install of style labelsettings and textformatting for v. < 3.10 - #127)
- Try another way to avoid [WinError 5] on Microsoft Windows (#103)
0.14.0 - Style import improvements (fix colorramp support, add support for label settings and text formats, clean up Style Manager tags) (#113, #114, #116, #118)
- Change collection directory names from a hash to more user friendly name (composition of the name of the collection and its repository) (#110)
- Change collection directory names from a hash to a more user friendly name (composition of the name of the collection and its repository) (#110)
- Preserve the installed collections when renaming a repository (#121)
- Documentation updates (#105, #109, #113)
0.13.1 - Fix #44 (files removed from repository are still being installed from cache)
Expand Down
18 changes: 10 additions & 8 deletions resource_sharing/gui/resource_sharing_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,16 @@ def install_collection(self):
def install_finished(self):
# Process the result
self.progress_dialog.hide()
if self.installer_worker.install_status:
installStatus = self.installer_worker.install_status
if not installStatus:
message = self.installer_worker.error_message
# Clean up the worker and thread
self.installer_worker.deleteLater()
self.installer_thread.quit()
self.installer_thread.wait()
self.installer_thread.deleteLater()

if installStatus:
self.reload_collections_model()
# Report what has been installed
message = '<b>%s</b> was successfully installed, containing:\n<ul>' % (
Expand Down Expand Up @@ -507,14 +516,7 @@ def install_finished(self):
if number > 1:
message = message + 's'
message = message + '\n</ul>'
else:
message = self.installer_worker.error_message
QMessageBox.information(self, 'Resource Sharing', message)
# Clean up the worker and thread
self.installer_worker.deleteLater()
self.installer_thread.quit()
self.installer_thread.wait()
self.installer_thread.deleteLater()
self.populate_repositories_widget()
# Set the selection
oldRow = self.current_index.row()
Expand Down
16 changes: 13 additions & 3 deletions resource_sharing/repository_handler/remote_git_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ def download_collection(self, id, register_name):
"""
# Hack to avoid irritating Dulwich / Porcelain ResourceWarning
warnings.filterwarnings("ignore", category=ResourceWarning)
# Clone or pull the repositories first
# Clone or pull the repositories first
local_repo_dir = os.path.join(
QgsApplication.qgisSettingsDirPath(),
'resource_sharing',
'repositories',
self.git_host, self.git_owner, self.git_repository
)
# Hack to try to avoid sharing errors
if os.path.exists(local_repo_dir):
try:
shutil.rmtree(local_repo_dir)
except:
pass
if not os.path.exists(os.path.join(local_repo_dir, '.git')):
os.makedirs(local_repo_dir)
try:
Expand Down Expand Up @@ -137,8 +143,12 @@ def download_collection(self, id, register_name):
return False, error_message
else:
# Hack until dulwich/porcelain handles file removal
collDir = os.path.join(local_repo_dir, 'collections')
shutil.rmtree(collDir)
#collDir = os.path.join(local_repo_dir, 'collections')
# ????!!!!
#if os.path.exists(collDir):
# shutil.rmtree(collDir)
if os.path.exists(local_repo_dir):
shutil.rmtree(local_repo_dir)
try:
porcelain.pull(
local_repo_dir,
Expand Down
10 changes: 10 additions & 0 deletions resource_sharing/resource_handler/symbol_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from resource_sharing.symbol_xml_extractor import SymbolXMLExtractor
from resource_sharing.resource_handler.symbol_resolver_mixin import \
SymbolResolverMixin
from resource_sharing.utilities import qgis_version

LOGGER = logging.getLogger('QGIS Resource Sharing')
SYMBOL = 'symbol'
Expand Down Expand Up @@ -174,6 +175,9 @@ def install(self):
colorramp_name, colorramp['colorramp'], True):
self._group_or_tag(QgsStyle.ColorrampEntity,
colorramp_name, groupOrTag_id)
# textformat and labelsettings were introduced in QGIS 3.10
if qgis_version() < 31000:
continue
for textformat in symbol_xml_extractor.textformats:
textformat_name = '%s (%s)' % (
textformat['name'], self.collection['repository_name'])
Expand Down Expand Up @@ -208,6 +212,12 @@ def uninstall(self):
QgsStyle.ColorrampEntity, child_group_id)
for colorramp in colorramps:
self.style.removeColorRamp(colorramp)

# textformat and labelsettings were introduced in QGIS 3.10
if qgis_version() < 31000:
# Remove this tag / child group
self._group_or_tag_remove(child_group_id)
continue
# Get all the textformats for this tag / child group and remove them
textformats = self._get_symbols_for_group_or_tag(
QgsStyle.TextFormatEntity, child_group_id)
Expand Down

0 comments on commit ca93b54

Please sign in to comment.