Skip to content

Commit

Permalink
Added additional fields. (#5)
Browse files Browse the repository at this point in the history
* Added additional fields.

* Added additional fields.

* metadata.txt update.
  • Loading branch information
ldebek authored Jul 18, 2024
1 parent 6e16a60 commit 1b9c788
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 114 deletions.
70 changes: 47 additions & 23 deletions NnpaReporting/fields_dialog.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from os import path

from qgis.core import QgsFields, QgsSettings
from qgis.PyQt import uic
from qgis.PyQt.QtCore import QVariant
from qgis.PyQt.QtWidgets import QDialog
from qgis.core import QgsSettings, QgsFields

ui_file = path.join(path.dirname(__file__), "fields_dialog.ui")

Expand All @@ -16,34 +16,58 @@ def __init__(self, parent, fields: QgsFields):
for field in fields:
if field.type() != QVariant.String:
continue
self.ui.nameComboBox.addItem(field.name())
self.ui.dateComboBox.addItem(field.name())
self.ui.precisionComboBox.addItem(field.name())

self.ui.nameComboBox.setCurrentIndex(-1)
self.ui.dateComboBox.setCurrentIndex(-1)
self.ui.precisionComboBox.setCurrentIndex(-1)
for field_combo_box in self.field_selection_widgets:
field_combo_box.addItem(field.name())
for field_combo_box in self.field_selection_widgets:
field_combo_box.setCurrentIndex(-1)

s = QgsSettings()
nameFieldName = s.value('plugins/nnpa_reporting_plugin/name_field_name', "Common_Nam")
dateFieldName = s.value('plugins/nnpa_reporting_plugin/date_field_name', "Sample_Dat")
precisionFieldName = s.value('plugins/nnpa_reporting_plugin/precision_field_name', "Precision")
name_field_name = s.value("plugins/nnpa_reporting_plugin/name_field_name", "Common_Nam")
date_field_name = s.value("plugins/nnpa_reporting_plugin/date_field_name", "Sample_Dat")
precision_field_name = s.value("plugins/nnpa_reporting_plugin/precision_field_name", "Precision")
grid_refer_field_name = s.value("plugins/nnpa_reporting_plugin/grid_refer_field_name", "grid refer")
latin_name_field_name = s.value("plugins/nnpa_reporting_plugin/latin_name_field_name", "latin name")
recorder_field_name = s.value("plugins/nnpa_reporting_plugin/recorder_field_name", "recorder")
survey_field_name = s.value("plugins/nnpa_reporting_plugin/survey_field_name", "survey nam")

self.ui.name_cbo.setCurrentText(name_field_name)
self.ui.date_cbo.setCurrentText(date_field_name)
self.ui.precision_cbo.setCurrentText(precision_field_name)
self.ui.grid_refer_cbo.setCurrentText(grid_refer_field_name)
self.ui.latin_name_cbo.setCurrentText(latin_name_field_name)
self.ui.recorder_cbo.setCurrentText(recorder_field_name)
self.ui.survey_cbo.setCurrentText(survey_field_name)

self.ui.nameComboBox.setCurrentText(nameFieldName)
self.ui.dateComboBox.setCurrentText(dateFieldName)
self.ui.precisionComboBox.setCurrentText(precisionFieldName)
@property
def field_selection_widgets(self):
field_combo_boxes = [
self.ui.name_cbo,
self.ui.date_cbo,
self.ui.precision_cbo,
self.ui.grid_refer_cbo,
self.ui.latin_name_cbo,
self.ui.recorder_cbo,
self.ui.survey_cbo,
]
return field_combo_boxes

def accept(self):
if self.ui.nameComboBox.currentIndex() < 0 or \
self.ui.dateComboBox.currentIndex() < 0 or \
self.ui.precisionComboBox.currentIndex() < 0:
if any(combo_box.currentIndex() < 0 for combo_box in self.field_selection_widgets):
return

nameFieldName = self.ui.nameComboBox.currentText()
dateFieldName = self.ui.dateComboBox.currentText()
precisionFieldName = self.ui.precisionComboBox.currentText()
name_field_name = self.ui.name_cbo.currentText()
date_field_name = self.ui.date_cbo.currentText()
precision_field_name = self.ui.precision_cbo.currentText()
grid_refer_field_name = self.ui.grid_refer_cbo.currentText()
latin_name_field_name = self.ui.latin_name_cbo.currentText()
recorder_field_name = self.ui.recorder_cbo.currentText()
survey_field_name = self.ui.survey_cbo.currentText()
s = QgsSettings()
s.setValue('plugins/nnpa_reporting_plugin/name_field_name', nameFieldName)
s.setValue('plugins/nnpa_reporting_plugin/date_field_name', dateFieldName)
s.setValue('plugins/nnpa_reporting_plugin/precision_field_name', precisionFieldName)
s.setValue("plugins/nnpa_reporting_plugin/name_field_name", name_field_name)
s.setValue("plugins/nnpa_reporting_plugin/date_field_name", date_field_name)
s.setValue("plugins/nnpa_reporting_plugin/precision_field_name", precision_field_name)
s.setValue("plugins/nnpa_reporting_plugin/grid_refer_field_name", grid_refer_field_name)
s.setValue("plugins/nnpa_reporting_plugin/latin_name_field_name", latin_name_field_name)
s.setValue("plugins/nnpa_reporting_plugin/recorder_field_name", recorder_field_name)
s.setValue("plugins/nnpa_reporting_plugin/survey_field_name", survey_field_name)
super().accept()
63 changes: 56 additions & 7 deletions NnpaReporting/fields_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<height>180</height>
<width>475</width>
<height>250</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -22,7 +22,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="nameComboBox"/>
<widget class="QComboBox" name="name_cbo"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
Expand All @@ -32,7 +32,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="dateComboBox"/>
<widget class="QComboBox" name="date_cbo"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
Expand All @@ -42,9 +42,9 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="precisionComboBox"/>
<widget class="QComboBox" name="precision_cbo"/>
</item>
<item row="4" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -54,7 +54,19 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="3" column="1">
<widget class="QComboBox" name="grid_refer_cbo"/>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="latin_name_cbo"/>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="recorder_cbo"/>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="survey_cbo"/>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -67,8 +79,45 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Grid Reference</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Latin Name</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Sample Recorder</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Survey Name</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>name_cbo</tabstop>
<tabstop>date_cbo</tabstop>
<tabstop>precision_cbo</tabstop>
<tabstop>grid_refer_cbo</tabstop>
<tabstop>latin_name_cbo</tabstop>
<tabstop>recorder_cbo</tabstop>
<tabstop>survey_cbo</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
Expand Down
3 changes: 2 additions & 1 deletion NnpaReporting/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name=NNPA Reporting
description=NNPA Reporting tool
about=This plugin is used by NNPA to generate species reports based on specified filters
version=1.3
version=1.4
qgisMinimumVersion=3.34
qgisMaximumVersion=3.99
author=Lutra Consulting
Expand All @@ -11,6 +11,7 @@ tracker=https://github.com/lutraconsulting/qgis-nnpa-reporting/issues
repository=https://github.com/lutraconsulting/qgis-nnpa-reporting

changelog=<p>
<p>1.4 Added Grid Reference, Latin Name, Sample Recorder and Survey Name fields.
<p>1.3 Identify by Point/Rectangle/Polygon/Polygon from a layer
<p>1.2 Allow selecting layer fields
<p>1.1 Support QGIS < 3.34
Expand Down
Loading

0 comments on commit 1b9c788

Please sign in to comment.