cfg editor: fixes

Change-Id: I1ea9f96f6c39c25ff8d4c51163aabccc5698dace
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30507
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
This commit is contained in:
Georg Brandl 2023-02-23 13:23:07 +01:00 committed by Markus Zolliker
parent 05cf4a791a
commit ef1664e1a2
7 changed files with 38 additions and 34 deletions

View File

@ -83,8 +83,8 @@ def write_config(file_name, tree_widget):
def read_config(file_path):
# TODO datatype of params and properties
node = TreeWidgetItem(NODE)
ifs = TreeWidgetItem(name='interfaces')
mods = TreeWidgetItem(name='modules')
ifs = TreeWidgetItem(name='Interfaces')
mods = TreeWidgetItem(name='Modules')
node.addChild(ifs)
node.addChild(mods)
config = configparser.ConfigParser()

View File

@ -167,7 +167,7 @@ class ValueWidget(QWidget):
self.value_display.textChanged.connect(self.emit_save_status_changed)
self.set_value(value)
else:
self.value_display = QLabel(value)
self.value_display = QLabel(str(value))
self.layout.addWidget(self.value_display)
self.setLayout(self.layout)

View File

@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>239</width>
<height>81</height>
<height>84</height>
</rect>
</property>
<property name="windowTitle">
<string>change name</string>
<string>Change name</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
@ -20,7 +20,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>name:</string>
<string>Name:</string>
</property>
</widget>
</item>

View File

@ -34,7 +34,7 @@
<string>create new SEC node</string>
</property>
<property name="text">
<string>new</string>
<string>New</string>
</property>
<property name="icon">
<iconset resource="icons/cfg-editor.qrc">
@ -67,7 +67,7 @@
<string>open file</string>
</property>
<property name="text">
<string>open</string>
<string>Open</string>
</property>
<property name="icon">
<iconset resource="icons/cfg-editor.qrc">
@ -100,7 +100,7 @@
<string>save</string>
</property>
<property name="text">
<string>save</string>
<string>Save</string>
</property>
<property name="icon">
<iconset resource="icons/cfg-editor.qrc">
@ -140,7 +140,7 @@
<string>add interface</string>
</property>
<property name="text">
<string>add interface</string>
<string>Add interface</string>
</property>
<property name="icon">
<iconset resource="icons/cfg-editor.qrc">
@ -173,7 +173,7 @@
<string>add module</string>
</property>
<property name="text">
<string>add module</string>
<string>Add module</string>
</property>
<property name="icon">
<iconset resource="icons/cfg-editor.qrc">
@ -206,7 +206,7 @@
<string>add parameter</string>
</property>
<property name="text">
<string>add parameter</string>
<string>Add parameter</string>
</property>
<property name="icon">
<iconset resource="icons/cfg-editor.qrc">
@ -239,7 +239,7 @@
<string>add property</string>
</property>
<property name="text">
<string>add property</string>
<string>Add property</string>
</property>
<property name="icon">
<iconset>
@ -272,7 +272,7 @@
<string>add comment</string>
</property>
<property name="text">
<string>add comment</string>
<string>Add comment</string>
</property>
<property name="icon">
<iconset resource="icons/cfg-editor.qrc">
@ -319,7 +319,7 @@
<string>duplicate module or interface</string>
</property>
<property name="text">
<string>duplicate</string>
<string>Duplicate</string>
</property>
<property name="icon">
<iconset resource="icons/cfg-editor.qrc">
@ -352,7 +352,7 @@
<string>delete</string>
</property>
<property name="text">
<string>delete</string>
<string>Delete</string>
</property>
<property name="icon">
<iconset resource="icons/cfg-editor.qrc">
@ -409,7 +409,7 @@
<x>0</x>
<y>0</y>
<width>977</width>
<height>20</height>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">

View File

@ -106,6 +106,7 @@ def get_file_paths(widget, open_file=True):
def get_modules():
modules = {}
generalConfig.init()
base_path = generalConfig.basedir
# pylint: disable=too-many-nested-blocks
for dirname in listdir(base_path):
@ -156,6 +157,7 @@ def get_interface_class_from_name(name):
def get_interfaces():
# TODO class must be found out like for modules
interfaces = []
generalConfig.init()
interface_path = path.join(generalConfig.basedir, 'frappy',
'protocol', 'interface')
for filename in listdir(interface_path):

View File

@ -60,14 +60,14 @@ class TreeWidget(QTreeWidget):
self.customContextMenuRequested.connect(self.on_context_menu_requested)
def setup_context_actions(self):
edit = self.menu.addAction('rename')
a_m = self.menu.addAction('add module')
a_i = self.menu.addAction('add interface')
a_pa = self.menu.addAction('add parameter')
a_pr = self.menu.addAction('add property')
a_c = self.menu.addAction('add comment')
dup = self.menu.addAction('duplicate')
dele = self.menu.addAction('delete')
edit = self.menu.addAction('Rename')
a_m = self.menu.addAction('Add module')
a_i = self.menu.addAction('Add interface')
a_pa = self.menu.addAction('Add parameter')
a_pr = self.menu.addAction('Add property')
a_c = self.menu.addAction('Add comment')
dup = self.menu.addAction('Duplicate')
dele = self.menu.addAction('Delete')
self.context_actions = [edit, a_m, a_i, a_pa, a_pr, a_c, dup, dele]
setActionIcon(edit, 'edit.png')
setActionIcon(a_m, 'add_module.png')
@ -115,8 +115,8 @@ class TreeWidget(QTreeWidget):
None)
self.addTopLevelItem(sec_node)
sec_node.setExpanded(True)
self.mods = self.get_tree_widget_item(name='modules')
self.ifs = self.get_tree_widget_item(name='interfaces')
self.mods = self.get_tree_widget_item(name='Modules')
self.ifs = self.get_tree_widget_item(name='Interfaces')
sec_node.addChild(self.ifs)
sec_node.addChild(self.mods)
self.emit_save_status_changed(False)
@ -337,7 +337,7 @@ class AddDialog(QDialog):
the value from self.value"""
super().__init__(parent)
loadUi(self, 'add_dialog.ui')
self.setWindowTitle('add %s' % kind)
self.setWindowTitle('Add %s' % kind)
self.kind = kind
self.invalid_names = invalid_names
if self.invalid_names:
@ -348,15 +348,15 @@ class AddDialog(QDialog):
self.name = QLineEdit()
# TODO: input mask
self.name.textChanged.connect(self.check_input)
self.add_layout.addWidget(QLabel('name:'), 0, 0)
self.add_layout.addWidget(QLabel('Name:'), 0, 0)
self.add_layout.addWidget(self.name, 0, 1)
if kind == NODE:
label_text = 'description:'
label_text = 'Description:'
self.value = QTextEdit()
self.get_value = self.value.toPlainText
self.value.text = self.value.toPlainText
else:
label_text = 'kind:'
label_text = 'Kind:'
self.value = QComboBox()
self.get_value = self.value.currentText
if type(possible_values) == dict:
@ -368,18 +368,20 @@ class AddDialog(QDialog):
self.value.setCurrentIndex(len(possible_values)-1)
self.add_layout.addWidget(QLabel(label_text), 1, 0)
self.add_layout.addWidget(self.value, 1, 1)
self.name.setFocus()
else:
if kind in [PARAMETER, PROPERTY]:
label_text = 'kind:'
label_text = 'Kind:'
self.value = QComboBox()
self.get_value = self.value.currentText
self.value.addItems(possible_values)
else:
label_text = 'comment:'
label_text = 'Comment:'
self.value = QTextEdit()
self.get_value = self.value.toPlainText
self.add_layout.addWidget(QLabel(label_text), 0, 0)
self.add_layout.addWidget(self.value, 0, 1)
self.value.setFocus()
if self.add_layout.rowCount() == 2:
self.setTabOrder(self.name, self.value)
self.setTabOrder(self.value, self.button_box.button(QDialogButtonBox.Ok))

View File

@ -57,7 +57,7 @@ class TextWidget(QTextEdit):
self.setEnabled(False)
def get_value(self):
res = self.text()
res = self.toPlainText()
return self.datatype(res)
def set_value(self, value):