Skip to content

Commit

Permalink
[MetaSearch] add overwrite OWS connection naming setting and logic (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Mar 19, 2015
1 parent 250eb74 commit 519830e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 9 deletions.
32 changes: 26 additions & 6 deletions python/plugins/MetaSearch/dialogs/maindialog.py
Expand Up @@ -125,6 +125,11 @@ def __init__(self, iface):
self.btnAddToWcs.clicked.connect(self.add_to_ows)
self.btnShowXml.clicked.connect(self.show_xml)

# settings
self.radioTitleAsk.clicked.connect(self.set_ows_save_title_ask)
self.radioTitleNoAsk.clicked.connect(self.set_ows_save_title_no_ask)
self.radioTempName.clicked.connect(self.set_ows_save_temp_name)

self.manageGui()

def manageGui(self):
Expand All @@ -143,6 +148,16 @@ def manageGui(self):

self.reset_buttons()

# get preferred connection save strategy from settings and set it
save_strat = self.settings.value('/MetaSearch/ows_save_strategy',
'title_ask')
if save_strat == 'temp_name':
self.radioTempName.setChecked(True)
elif save_strat == 'title_no_ask':
self.radioTitleNoAsk.setChecked(True)
else:
self.radioTitleAsk.setChecked(True)

# install proxy handler if specified in QGIS settings
self.install_proxy()

Expand Down Expand Up @@ -685,14 +700,19 @@ def add_to_ows(self):
if key.startswith(sname):
conn_name_matches.append(key)
if conn_name_matches:
sname = matches[-1]
sname = conn_name_matches[-1]

# check for duplicates
if sname in keys:
msg = self.tr('Connection %s exists. Overwrite?') % sname
res = QMessageBox.warning(self, self.tr('Saving server'), msg,
QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes: # assign new name with serial
if sname in keys: # duplicate found
if self.radioTitleAsk.isChecked(): # ask to overwrite
msg = self.tr('Connection %s exists. Overwrite?') % sname
res = QMessageBox.warning(self, self.tr('Saving server'), msg,
QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes: # assign new name with serial
sname = serialize_string(sname)
elif self.radioTitleNoAsk.isChecked(): # don't ask to overwrite
pass
elif self.radioTempName.isChecked(): # use temp name
sname = serialize_string(sname)

# no dups detected or overwrite is allowed
Expand Down
52 changes: 49 additions & 3 deletions python/plugins/MetaSearch/ui/maindialog.ui
Expand Up @@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tabSearch">
<attribute name="title">
Expand Down Expand Up @@ -428,12 +428,58 @@
<attribute name="title">
<string>Settings</string>
</attribute>
<widget class="QGroupBox" name="groupBox_3">
<widget class="QGroupBox" name="saveStrategyGroup">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>571</width>
<height>131</height>
</rect>
</property>
<property name="title">
<string>Connection naming</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="lblSaveStrategy">
<property name="text">
<string>When saving the connection of an OWS service</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioTitleAsk">
<property name="text">
<string>Ask before overwriting</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioTitleNoAsk">
<property name="text">
<string>Always overwrite if already available</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioTempName">
<property name="text">
<string>Use a temporary name, which you can change later</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>10</x>
<y>230</y>
<width>571</width>
<height>71</height>
</rect>
</property>
Expand Down Expand Up @@ -484,7 +530,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<y>150</y>
<width>571</width>
<height>71</height>
</rect>
Expand Down

0 comments on commit 519830e

Please sign in to comment.