Skip to content

Commit

Permalink
Improve publish layer item selection behavior, set last version if om…
Browse files Browse the repository at this point in the history
…itted in build.py
  • Loading branch information
GeoSander committed Sep 26, 2024
1 parent 1177892 commit 63879a6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 3 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
from pathlib import Path
from fnmatch import fnmatch

from geocatbridge.utils.meta import getVersion

OUTPUT_DIRNAME = 'build'


def package():
ap = argparse.ArgumentParser(description='Package GeoCat Bridge plugin')
ap.add_argument('--filename', help='ZIP file name', default='GeoCat_Bridge')
ap.add_argument('--filename', help='ZIP file name', default=f'GeoCat_Bridge_v{getVersion()}')
ns = ap.parse_args()

file_name = f'{ns.filename}.zip'
Expand Down
2 changes: 1 addition & 1 deletion geocatbridge/libs/bridgestyle
Submodule bridgestyle updated 0 files
21 changes: 11 additions & 10 deletions geocatbridge/ui/publishwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
QWidget,
QHBoxLayout,
QCheckBox,
QListWidget,
QListWidgetItem,
QTableWidgetItem,
QFileDialog
Expand Down Expand Up @@ -92,7 +93,6 @@ def _setupUi(self):
self.listLayers.setContextMenuPolicy(Qt.CustomContextMenu)
self.listLayers.customContextMenuRequested.connect(self.showContextMenu)
self.listLayers.currentRowChanged.connect(self.currentRowChanged)
self.listLayers.itemClicked.connect(self.rowClicked)
self.comboGeodataServer.currentIndexChanged.connect(self.geodataServerChanged)
self.comboMetadataServer.currentIndexChanged.connect(self.metadataServerChanged)
self.txtExportFolder.textChanged.connect(self.exportFolderChanged)
Expand Down Expand Up @@ -250,10 +250,6 @@ def toggleLayers(self, state: bool):
item = self.listLayers.item(i)
self.listLayers.itemWidget(item).setCheckbox(state)

def rowClicked(self, item: QListWidgetItem):
""" Called whenever the user clicks on a layer item. """
self.listLayers.itemWidget(item).toggleCheckbox()

def currentRowChanged(self, current_row: int):
""" Called whenever the user selects another layer item. """
if self.currentRow == current_row:
Expand Down Expand Up @@ -361,7 +357,7 @@ def populateLayers(self):
self.updateOnlineLayersPublicationStatus()

def addLayerListItem(self, layer):
widget = LayerItemWidget(layer)
widget = LayerItemWidget(layer, self.listLayers)
item = QListWidgetItem(self.listLayers)
item.setSizeHint(widget.sizeHint())
self.listLayers.addItem(item)
Expand Down Expand Up @@ -854,11 +850,14 @@ def getPublishTask(self, parent: QWidget, to_publish: List[str]):


class LayerItemWidget(QWidget):
def __init__(self, layer: BridgeLayer):
def __init__(self, layer: BridgeLayer, list_widget: QListWidget = None):
super(LayerItemWidget, self).__init__() # noqa
self._list_widget = list_widget
self._position = list_widget.count() if list_widget else 0
self._name = layer.name()
self._id = layer.id()
self._checkbox = QCheckBox(self._name, self)
self._checkbox.clicked.connect(self._checkbox_clicked)
if layer.is_vector:
self._checkbox.setIcon(QgsApplication.getThemeIcon('mIconVector.svg'))
elif layer.is_raster:
Expand Down Expand Up @@ -915,13 +914,15 @@ def setDataPublished(self, server):
self._datalabel.setToolTip('')
self.update()

def _checkbox_clicked(self, _):
""" Make sure that the list widget item is selected when the checkbox is clicked (toggled). """
if isinstance(self._list_widget, QListWidget):
self._list_widget.item(self._position).setSelected(True)

@property
def checked(self) -> bool:
""" Returns True if the list widget item checkbox is in a checked state. """
return self._checkbox.isChecked()

def setCheckbox(self, state: bool):
self._checkbox.setCheckState(Qt.Checked if state else Qt.Unchecked)

def toggleCheckbox(self):
self._checkbox.toggle()

0 comments on commit 63879a6

Please sign in to comment.