Commit 2dbf66dc authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[widgets][algorithmeditor] Use validated input widgets

parent e4d87342
......@@ -26,11 +26,9 @@
import os
import re
from PyQt5.QtCore import QRegularExpression
from PyQt5.QtCore import QSortFilterProxyModel
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtGui import QRegularExpressionValidator
from PyQt5.QtWidgets import QButtonGroup
from PyQt5.QtWidgets import QCheckBox
from PyQt5.QtWidgets import QComboBox
......@@ -60,6 +58,8 @@ from .libraries import LibrariesWidget
from .parameterwidget import ParameterWidget
from .scrollwidget import EditorListWidget
from .scrollwidget import ScrollWidget
from .validatedhelpers import NameItemDelegate
from .validatedhelpers import NameLineEdit
ALGORITHM_TYPE = "algorithm_type"
DEFAULT_SCHEMA_VERSION = 2
......@@ -83,8 +83,6 @@ ANALYZER_PROCESS_METHOD_MAP = {
LOOP_VALIDATE_METHOD = "def validate(self, result):"
NAME_REGULAREXPRESSION = QRegularExpression("^[a-zA-Z_][a-zA-Z0-9_-]*$")
def migrate_to_api_v2(asset):
status = asset.type.create_new_version(asset.prefix, asset.name)
......@@ -349,10 +347,7 @@ class ParameterEditor(DeletableEditor):
self.delete_button.setToolTip(self.tr("Remove parameter"))
self.name_lineedit = QLineEdit()
self.name_lineedit.setValidator(
QRegularExpressionValidator(NAME_REGULAREXPRESSION, self)
)
self.name_lineedit = NameLineEdit()
self.parameter_widget = ParameterWidget()
form_layout = QFormLayout()
......@@ -389,10 +384,7 @@ class ResultEditor(DeletableEditor):
proxy_model.setFilterRegExp(
"(^int32$|^float32$|^bool$|^string$|^system/[a-zA-Z0-9_-]+/[0-9]+$|^plot/[a-zA-Z0-9_-]+/[0-9]+$)"
)
self.name_lineedit = QLineEdit()
self.name_lineedit.setValidator(
QRegularExpressionValidator(NAME_REGULAREXPRESSION, self)
)
self.name_lineedit = NameLineEdit()
self.type_combobox = QComboBox()
self.type_combobox.setModel(proxy_model)
self.display_checkbox = QCheckBox()
......@@ -433,12 +425,15 @@ class IOWidget(QGroupBox):
super().__init__(title, parent)
self.dataformat_model = dataformat_model
delegate = AssetItemDelegate(self.dataformat_model)
name_delegate = NameItemDelegate(self)
asset_delegate = AssetItemDelegate(self.dataformat_model, self)
self.tablewidget = QTableWidget(0, 2)
self.tablewidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.tablewidget.setHorizontalHeaderLabels([self.tr("Name"), self.tr("Type")])
self.tablewidget.setItemDelegateForColumn(1, delegate)
self.tablewidget.setItemDelegateForColumn(0, name_delegate)
self.tablewidget.setItemDelegateForColumn(1, asset_delegate)
self.tablewidget.setMinimumHeight(250)
self.add_button = QPushButton(self.tr("+"))
self.add_button.setFixedSize(30, 30)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment