mirror of https://gitlab.com/pamhyr/pamhyr2
MainWindow: Add feature edit study.
parent
7ca373262f
commit
42a0a01c8d
|
|
@ -13,7 +13,6 @@ class Study(Serializable):
|
|||
# Study general information
|
||||
self.name = ""
|
||||
self.description = ""
|
||||
self.solver = ""
|
||||
|
||||
self.creation_date = datetime.now()
|
||||
self.last_modification_date = datetime.now()
|
||||
|
|
@ -27,9 +26,8 @@ class Study(Serializable):
|
|||
return cls()
|
||||
|
||||
@classmethod
|
||||
def new(cls, name, description, solver):
|
||||
def new(cls, name, description):
|
||||
me = cls()
|
||||
me.name = name
|
||||
me.description = description
|
||||
me.solver = solver
|
||||
return me
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ no_model_action = [
|
|||
]
|
||||
|
||||
model_action = [
|
||||
"action_menu_close", "action_menu_save_maille", "action_menu_save",
|
||||
"action_menu_close", "action_menu_edit", "action_menu_save",
|
||||
"action_menu_save_as", "action_toolBar_close", "action_toolBar_save",
|
||||
]
|
||||
|
||||
|
|
@ -83,6 +83,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow):
|
|||
# Menu action
|
||||
"action_menu_config": self.open_configure,
|
||||
"action_menu_new": self.open_new_study,
|
||||
"action_menu_edit": self.open_edit_study,
|
||||
"action_menu_open": self.open_model,
|
||||
"action_menu_save": self.save_study,
|
||||
"action_menu_save_as": self.save_as_study,
|
||||
|
|
@ -255,6 +256,17 @@ class ApplicationWindow(QMainWindow, ListedSubWindow):
|
|||
self.new_study = NewStudyWindow(parent=self)
|
||||
self.new_study.show()
|
||||
|
||||
def open_edit_study(self):
|
||||
"""Open dialog to set new study
|
||||
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
if not self.model is None:
|
||||
self.new_study = NewStudyWindow(study=self.model, parent=self)
|
||||
self.new_study.show()
|
||||
|
||||
|
||||
# TODO: Delete me !
|
||||
###############
|
||||
# DUMMY STUFF #
|
||||
|
|
|
|||
|
|
@ -4,19 +4,25 @@ from model.Study import Study
|
|||
from view.ASubWindow import ASubWindow
|
||||
|
||||
class NewStudyWindow(ASubWindow):
|
||||
def __init__(self, title="New Study", parent=None):
|
||||
def __init__(self, study=None, title="New Study", parent=None):
|
||||
super(NewStudyWindow, self).__init__(name=title, ui="NewStudy", parent=parent)
|
||||
self.ui.setWindowTitle(title)
|
||||
|
||||
self.parent = parent
|
||||
|
||||
self.study = study
|
||||
|
||||
if not self.study is None:
|
||||
self.set_line_edit_text("lineEdit_name", study.name)
|
||||
self.set_text_edit_text("textEdit_description", study.description)
|
||||
|
||||
def accept(self):
|
||||
name = self.get_line_edit_text("lineEdit_name")
|
||||
description = self.get_text_edit_text("textEdit_description")
|
||||
if self.get_radio_button("radioButton_mage"):
|
||||
solver = "mage"
|
||||
else:
|
||||
solver = "rubarbe"
|
||||
|
||||
self.parent.set_model(Study.new(name, description, solver))
|
||||
self.close()
|
||||
if self.study is None:
|
||||
self.parent.set_model(Study.new(name, description))
|
||||
else:
|
||||
self.study.name = name
|
||||
self.study.description = description
|
||||
self.done(True)
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@
|
|||
<addaction name="separator"/>
|
||||
<addaction name="action_menu_close"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_menu_save_maille"/>
|
||||
<addaction name="action_menu_edit"/>
|
||||
<addaction name="action_menu_save"/>
|
||||
<addaction name="action_menu_save_as"/>
|
||||
<addaction name="action_menu_archive"/>
|
||||
|
|
@ -896,6 +896,18 @@
|
|||
<string>Ouvrir l'éditeur des ouvrages (seuils, vannes, etc.), singularités et pompes</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_menu_edit">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/edit.png</normaloff>ressources/edit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Éditer l'étude</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Éditer l'étude</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
|
|
@ -34,16 +34,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QTextEdit" name="textEdit_description">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tabChangesFocus">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
|
|
@ -58,32 +48,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Solver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_mage">
|
||||
<property name="text">
|
||||
<string>Mage</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_rubarbe">
|
||||
<property name="enabled">
|
||||
<item row="1" column="1">
|
||||
<widget class="QTextEdit" name="textEdit_description">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rubarbe</string>
|
||||
<property name="tabChangesFocus">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -91,8 +62,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
|
|
|
|||
Loading…
Reference in New Issue