Skip to content

Commit

Permalink
Merge pull request #10 from Gui0delp/v1.3.0
Browse files Browse the repository at this point in the history
V1.3.0
  • Loading branch information
Gui0delp committed Jan 11, 2022
2 parents 98fd07e + d501481 commit 7aad47b
Show file tree
Hide file tree
Showing 12 changed files with 714 additions and 414 deletions.
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

29 changes: 22 additions & 7 deletions french_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from .resources import *

from .french_address_dockwidget import FrenchAddressDockWidget
from .french_address_widget_result_setting import FrenchAddressWidgetResultSetting


class FrenchAddress:
Expand Down Expand Up @@ -76,13 +77,15 @@ def __init__(self, iface):
#print "** INITIALIZING FrenchAddress"
self.pluginIsActive = False
self.dockwidget = None
self.widgetResultSetting = None

self.data_from_api = ""
self.tool = None
self.catch_tool_activate = False
self.catch_tool_icon = QgsApplication.iconPath("cursors/mCapturePoint.svg")
self.copy_icon = QgsApplication.iconPath("mActionEditCopy.svg")
self.show_url_icon = QgsApplication.iconPath("mIconWms.svg")
self.result_setting_icon = QgsApplication.iconPath("mActionOptions.svg")
self.clipboard = QApplication.clipboard()

# noinspection PyMethodMayBeStatic
Expand Down Expand Up @@ -190,7 +193,7 @@ def clear(self):

def enable_disable_catch_tool(self):
if not self.catch_tool_activate:
self.tool = CatchTool(self.iface, self.dockwidget, self)
self.tool = CatchTool(self.iface, self.dockwidget, self.widgetResultSetting, self)
self.canvas.setMapTool(self.tool)
self.canvas.setCursor(QCursor(QPixmap(self.catch_tool_icon)))
self.catch_tool_activate = True
Expand Down Expand Up @@ -226,15 +229,15 @@ def address_processing(self):
response_coordinates = self.api_address.take_reverse_response_coordinates()
response_properties.update(response_coordinates)
self.api_address.populate_table_widget(response_properties)
point_wgs84 = self.api_address.take_search_response_label()
point_wgs84 = self.api_address.take_search_response_coordinates()
self.coord.set_canvas_project(self.canvas)
self.coord.set_destination_crs()
self.coord.take_crs_from_project(self.iface)
self.coord.set_x_transform_reverse()
self.coord.set_latitude_longitude_crs(point_wgs84)
self.coord.zoom_to_canvas(self.canvas)
else:
message = self.tr(' Format of the address is not correct, please check log message.')
message = ' Le format de l\'adresse est incorrecte'
self.iface.messageBar().pushMessage('Warning',
message,
level=Qgis.Warning,
Expand All @@ -249,11 +252,11 @@ def set_visible_properties(self, state):

def copy_to_clipboard(self):
text_to_copy = self.dockwidget.le_input_address.toPlainText()
message = self.tr(' Nothing to copying')
message = ' Rien à copier'

if text_to_copy != '':
self.clipboard.setText(text_to_copy)
message = self.tr(f' {text_to_copy}, copied to the clipboard')
message = f' {text_to_copy}, copié dans le presse papier'

self.iface.messageBar().pushMessage('Address',
message,
Expand All @@ -267,10 +270,10 @@ def open_map_url(self):
id_house = self.data_from_api['features'][0]['properties']['id']
url = self.api_address.set_map_url(longitude_house, latitude_house, id_house)
self.api_address.open_map_url(url)
text = self.tr(' Open in web browser ')
text = ' Ouvert dans le navigateur '
message = text + f'{url}'
except:
message = self.tr(' Nothing to open in web browser')
message = ' Rien à ouvrir dans le navigateur'

self.iface.messageBar().pushMessage('Address',
message,
Expand All @@ -293,6 +296,16 @@ def set_connections(self):
self.dockwidget.tb_open_url.clicked.connect(
self.open_map_url
)
self.dockwidget.tb_result_setting.clicked.connect(
self.show_result_setting
)

def show_result_setting(self):

if self.widgetResultSetting is None:
self.widgetResultSetting = FrenchAddressWidgetResultSetting()

self.widgetResultSetting.show()

def run(self):
"""Run method that loads and starts the plugin"""
Expand All @@ -302,13 +315,15 @@ def run(self):

if self.dockwidget is None:
self.dockwidget = FrenchAddressDockWidget()
self.widgetResultSetting = FrenchAddressWidgetResultSetting()
self.dockwidget.tw_details.setVisible(False)
self.coord = Coordinates(self.dockwidget)
self.address = Address(self.dockwidget)
self.api_address = ApiAddress(self.dockwidget)
self.dockwidget.tb_catch_tool.setIcon(QIcon(self.catch_tool_icon))
self.dockwidget.pb_copy.setIcon(QIcon(self.copy_icon))
self.dockwidget.tb_open_url.setIcon(QIcon(self.show_url_icon))
self.dockwidget.tb_result_setting.setIcon(QIcon(self.result_setting_icon))
self.set_connections()

self.dockwidget.closingPlugin.connect(self.onClosePlugin)
Expand Down
143 changes: 81 additions & 62 deletions french_address_dockwidget_base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>422</width>
<height>368</height>
<height>373</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -18,45 +18,20 @@
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<item row="2" column="0" colspan="4">
<widget class="QTextBrowser" name="le_input_address">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>48</height>
</size>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextEditorInteraction</set>
</property>
<property name="placeholderText">
<string>Your address here, like 8 Boulevard du Port 80000</string>
<item row="0" column="0">
<widget class="QLabel" name="lbl_address">
<property name="font">
<font>
<pointsize>8</pointsize>
<bold>true</bold>
</font>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QPushButton" name="pb_locate_search">
<property name="text">
<string>Research</string>
</property>
<property name="default">
<bool>true</bool>
</property>
<property name="flat">
<bool>false</bool>
<string>Résultat :</string>
</property>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="4">
<widget class="QToolButton" name="tb_catch_tool">
<property name="minimumSize">
<size>
Expand All @@ -71,7 +46,7 @@
</size>
</property>
<property name="toolTip">
<string>Click on the map to capture an address </string>
<string>Cliquer sur la carte pour capturer l'adresse</string>
</property>
<property name="text">
<string>...</string>
Expand All @@ -90,20 +65,7 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<widget class="QCheckBox" name="chb_view_details">
<property name="font">
<font>
<family>MS Shell Dlg 2</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Show more details</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="4">
<item row="5" column="0" colspan="5">
<widget class="QTableWidget" name="tw_details">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
Expand All @@ -113,7 +75,6 @@
</property>
<property name="font">
<font>
<family>MS Shell Dlg 2</family>
<pointsize>8</pointsize>
</font>
</property>
Expand All @@ -137,17 +98,42 @@
</attribute>
<column>
<property name="text">
<string>attribute</string>
<string>attributs</string>
</property>
</column>
<column>
<property name="text">
<string>value</string>
<string>valeurs</string>
</property>
</column>
</widget>
</item>
<item row="0" column="1">
<item row="2" column="0" colspan="5">
<widget class="QTextBrowser" name="le_input_address">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>48</height>
</size>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextEditorInteraction</set>
</property>
<property name="placeholderText">
<string>Votre adresse ici, comme 8 Boulevard du Port 80000</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="pb_copy">
<property name="minimumSize">
<size>
Expand All @@ -162,28 +148,39 @@
</size>
</property>
<property name="toolTip">
<string>Copy result to clipboard</string>
<string>Copier dans le presse papier</string>
</property>
<property name="text">
<string comment="Copy to clipboard" extracomment="Copy to clipboard">...</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_address">
<item row="3" column="0" colspan="5">
<widget class="QPushButton" name="pb_locate_search">
<property name="text">
<string>Rechercher</string>
</property>
<property name="default">
<bool>true</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0" colspan="5">
<widget class="QCheckBox" name="chb_view_details">
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Result:</string>
<string>Montrer plus de détails</string>
</property>
</widget>
</item>
<item row="0" column="2">
<item row="0" column="3">
<widget class="QToolButton" name="tb_open_url">
<property name="minimumSize">
<size>
Expand All @@ -198,7 +195,29 @@
</size>
</property>
<property name="toolTip">
<string>Show address on website 'adresse.data.gouv.fr'</string>
<string>Montre l'adresse sur le site 'adresse.data.gouv.fr'</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="tb_result_setting">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Paramètre résultat</string>
</property>
<property name="text">
<string>...</string>
Expand Down
Loading

0 comments on commit 7aad47b

Please sign in to comment.