-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
239 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>FilterEditor</class> | ||
<widget class="QDialog" name="FilterEditor"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>129</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="4" column="1"> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Discard|QDialogButtonBox::Save</set> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="0"> | ||
<widget class="QLabel" name="label_spalte"> | ||
<property name="text"> | ||
<string>Spalte</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="0"> | ||
<widget class="QLabel" name="label_filter"> | ||
<property name="text"> | ||
<string>Filter</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="1"> | ||
<spacer name="verticalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item row="0" column="1"> | ||
<widget class="QComboBox" name="combobox_column"/> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QComboBox" name="combobox_filteroption"/> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="label_filteroption"> | ||
<property name="text"> | ||
<string>Filteroption</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>FilterEditor</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>FilterEditor</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from datetime import datetime | ||
from typing import Dict | ||
|
||
from PySide6.QtCore import Qt | ||
from PySide6.QtWidgets import QDialog, QLineEdit, QCheckBox, QDateEdit, QSpinBox | ||
|
||
from src.datatypes import QuestionParameters | ||
from src.ui_filter_editor import Ui_FilterEditor | ||
|
||
|
||
class FilterEditor(QDialog, Ui_FilterEditor): | ||
def __init__(self, filter_configuration: Dict[str, QuestionParameters], current_filter=None, parent=None, | ||
window_flags=Qt.Dialog): | ||
super(FilterEditor, self).__init__(parent, window_flags) | ||
self.ui = Ui_FilterEditor() | ||
self.ui.setupUi(self) | ||
self.filter = None | ||
|
||
if current_filter: | ||
self.setWindowTitle("Filter bearbeiten") | ||
else: | ||
self.setWindowTitle("Filter erstellen") | ||
|
||
self.filter_configuration = filter_configuration | ||
|
||
self.ui.combobox_column.addItems( | ||
[filterparams.table_header for filterparams in self.filter_configuration.values()]) | ||
self.update_filteroptions(self.ui.combobox_column.currentIndex()) | ||
|
||
self.ui.combobox_column.currentIndexChanged.connect(self.update_filteroptions) | ||
|
||
def update_filteroptions(self, index): | ||
self.ui.combobox_filteroption.clear() | ||
|
||
current_params = list(self.filter_configuration.values())[index] | ||
self.ui.combobox_filteroption.addItems([str(options) for options in current_params.filter_options]) | ||
|
||
if self.filter: | ||
self.ui.gridLayout.removeWidget(self.filter) | ||
self.filter.deleteLater() | ||
self.filter = None | ||
|
||
if current_params.datatype == str: | ||
self.filter = QLineEdit() | ||
elif current_params.datatype == bool: | ||
self.filter = QCheckBox() | ||
elif current_params.datatype == datetime: | ||
self.filter = QDateEdit() | ||
elif current_params.datatype == int: | ||
self.filter = QSpinBox() | ||
else: | ||
return | ||
|
||
self.ui.gridLayout.addWidget(self.filter, 2, 1, 1, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
################################################################################ | ||
## Form generated from reading UI file 'filter_editor.ui' | ||
## | ||
## Created by: Qt User Interface Compiler version 6.2.2 | ||
## | ||
## WARNING! All changes made in this file will be lost when recompiling UI file! | ||
################################################################################ | ||
|
||
from PySide6.QtCore import (QCoreApplication, QMetaObject, Qt) | ||
from PySide6.QtWidgets import (QComboBox, QDialogButtonBox, QGridLayout, QLabel, QSizePolicy, | ||
QSpacerItem) | ||
|
||
|
||
class Ui_FilterEditor(object): | ||
def setupUi(self, FilterEditor): | ||
if not FilterEditor.objectName(): | ||
FilterEditor.setObjectName(u"FilterEditor") | ||
FilterEditor.resize(400, 129) | ||
self.gridLayout = QGridLayout(FilterEditor) | ||
self.gridLayout.setObjectName(u"gridLayout") | ||
self.buttonBox = QDialogButtonBox(FilterEditor) | ||
self.buttonBox.setObjectName(u"buttonBox") | ||
self.buttonBox.setOrientation(Qt.Horizontal) | ||
self.buttonBox.setStandardButtons(QDialogButtonBox.Discard | QDialogButtonBox.Save) | ||
|
||
self.gridLayout.addWidget(self.buttonBox, 4, 1, 1, 1) | ||
|
||
self.label_spalte = QLabel(FilterEditor) | ||
self.label_spalte.setObjectName(u"label_spalte") | ||
|
||
self.gridLayout.addWidget(self.label_spalte, 0, 0, 1, 1) | ||
|
||
self.label_filter = QLabel(FilterEditor) | ||
self.label_filter.setObjectName(u"label_filter") | ||
|
||
self.gridLayout.addWidget(self.label_filter, 2, 0, 1, 1) | ||
|
||
self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) | ||
|
||
self.gridLayout.addItem(self.verticalSpacer, 3, 1, 1, 1) | ||
|
||
self.combobox_column = QComboBox(FilterEditor) | ||
self.combobox_column.setObjectName(u"combobox_column") | ||
|
||
self.gridLayout.addWidget(self.combobox_column, 0, 1, 1, 1) | ||
|
||
self.combobox_filteroption = QComboBox(FilterEditor) | ||
self.combobox_filteroption.setObjectName(u"combobox_filteroption") | ||
|
||
self.gridLayout.addWidget(self.combobox_filteroption, 1, 1, 1, 1) | ||
|
||
self.label_filteroption = QLabel(FilterEditor) | ||
self.label_filteroption.setObjectName(u"label_filteroption") | ||
|
||
self.gridLayout.addWidget(self.label_filteroption, 1, 0, 1, 1) | ||
|
||
self.retranslateUi(FilterEditor) | ||
self.buttonBox.accepted.connect(FilterEditor.accept) | ||
self.buttonBox.rejected.connect(FilterEditor.reject) | ||
|
||
QMetaObject.connectSlotsByName(FilterEditor) | ||
|
||
# setupUi | ||
|
||
def retranslateUi(self, FilterEditor): | ||
FilterEditor.setWindowTitle(QCoreApplication.translate("FilterEditor", u"Dialog", None)) | ||
self.label_spalte.setText(QCoreApplication.translate("FilterEditor", u"Spalte", None)) | ||
self.label_filter.setText(QCoreApplication.translate("FilterEditor", u"Filter", None)) | ||
self.label_filteroption.setText(QCoreApplication.translate("FilterEditor", u"Filteroption", None)) | ||
# retranslateUi |