Skip to content

Commit

Permalink
Temporarily replace tjm slider
Browse files Browse the repository at this point in the history
  • Loading branch information
marioba committed Oct 14, 2021
1 parent 1b9f371 commit ec16890
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
13 changes: 9 additions & 4 deletions comptages/comptages.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,13 @@ def do_filter_action(self):
if self.filter_sensor:
dlg.sensor.setCurrentIndex(self.filter_sensor)
if self.filter_tjm:
dlg.tjm.setRange(self.filter_tjm[0], self.filter_tjm[1])
# dlg.tjm.setRange(self.filter_tjm[0], self.filter_tjm[1])
dlg.tjm_min.setValue(self.filter_tjm[0])
dlg.tjm_max.setValue(self.filter_tjm[1])
else:
dlg.tjm.setRange(0, 30000)
# dlg.tjm.setRange(0, 30000)
dlg.tjm_min.setValue(0)
dlg.tjm_max.setValue(30000)
if self.filter_axe:
dlg.axe.setCurrentIndex(self.filter_axe)

Expand All @@ -312,7 +316,8 @@ def do_filter_action(self):
self.filter_end_date = dlg.end_date.dateTime()
self.filter_installation = dlg.installation.currentIndex()
self.filter_sensor = dlg.sensor.currentIndex()
self.filter_tjm = [dlg.tjm.lowerValue(), dlg.tjm.upperValue()]
# self.filter_tjm = [dlg.tjm.lowerValue(), dlg.tjm.upperValue()]
self.filter_tjm = [dlg.tjm_min.value(), dlg.tjm_max.value()]
self.filter_axe = dlg.axe.currentIndex()

self.layers.apply_filter(
Expand All @@ -325,7 +330,7 @@ def do_filter_action(self):
)

if (not dlg.start_date.dateTime()) and (not dlg.end_date.dateTime()) and (dlg.installation.currentIndex() == 0) and \
(dlg.sensor.currentIndex() == 0) and (dlg.tjm.lowerValue() == 0) and (dlg.tjm.upperValue() == 30000) and \
(dlg.sensor.currentIndex() == 0) and (dlg.tjm_min.value() == 0) and (dlg.tjm_max.value() == 30000) and \
(dlg.axe.currentText() == 'Tous'):
self.filter_action.setIcon(
QIcon(':/plugins/Comptages/images/filter.png'))
Expand Down
18 changes: 11 additions & 7 deletions comptages/core/filter_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ def update_tjm_labels(min, max):
if max == 30000:
self.max_tjm.setText("∞")

self.tjm.setMinimum(0)
self.tjm.setMaximum(30000)
self.tjm.setSingleStep(100)
self.tjm.setTickInterval(5000)
self.tjm.setTickPosition(QSlider.TicksBothSides)
self.tjm.rangeChanged.connect(update_tjm_labels)
# self.tjm_min.setValue(0)
# self.tjm_max.setValue(30000)
# self.tjm.setMinimum(0)
# self.tjm.setMaximum(30000)
# self.tjm.setSingleStep(100)
# self.tjm.setTickInterval(5000)
# self.tjm.setTickPosition(QSlider.TicksBothSides)
# self.tjm.rangeChanged.connect(update_tjm_labels)

# Populate axe filter
self.axe.addItem('Tous', None)
Expand All @@ -38,7 +40,9 @@ def reset_dialog(button):
self.end_date.clear()
self.installation.setCurrentIndex(0)
self.sensor.setCurrentIndex(0)
self.tjm.setRange(0, 90000)
# self.tjm.setRange(0, 90000)
self.tjm_min.setValue(0)
self.tjm_max.setValue(30000)
self.axe.setCurrentIndex(0)

self.buttons.button(
Expand Down
26 changes: 17 additions & 9 deletions comptages/ui/filter.ui
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</size>
</property>
<property name="text">
<string>TextLabel</string>
<string>max</string>
</property>
</widget>
</item>
Expand All @@ -130,12 +130,26 @@
</size>
</property>
<property name="text">
<string>TextLabel</string>
<string>min</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsRangeSlider" name="tjm" native="true"/>
<widget class="QSpinBox" name="tjm_min">
<property name="maximum">
<number>30000</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="tjm_max">
<property name="maximum">
<number>30000</number>
</property>
<property name="value">
<number>30000</number>
</property>
</widget>
</item>
</layout>
</item>
Expand Down Expand Up @@ -190,12 +204,6 @@
<extends>QDateTimeEdit</extends>
<header>qgsdatetimeedit.h</header>
</customwidget>
<customwidget>
<class>QgsRangeSlider</class>
<extends>QWidget</extends>
<header>qgis.gui.QgsRangeSlider</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
Expand Down

0 comments on commit ec16890

Please sign in to comment.