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
|
# Study general information
|
||||||
self.name = ""
|
self.name = ""
|
||||||
self.description = ""
|
self.description = ""
|
||||||
self.solver = ""
|
|
||||||
|
|
||||||
self.creation_date = datetime.now()
|
self.creation_date = datetime.now()
|
||||||
self.last_modification_date = datetime.now()
|
self.last_modification_date = datetime.now()
|
||||||
|
|
@ -27,9 +26,8 @@ class Study(Serializable):
|
||||||
return cls()
|
return cls()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new(cls, name, description, solver):
|
def new(cls, name, description):
|
||||||
me = cls()
|
me = cls()
|
||||||
me.name = name
|
me.name = name
|
||||||
me.description = description
|
me.description = description
|
||||||
me.solver = solver
|
|
||||||
return me
|
return me
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ no_model_action = [
|
||||||
]
|
]
|
||||||
|
|
||||||
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",
|
"action_menu_save_as", "action_toolBar_close", "action_toolBar_save",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -83,6 +83,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow):
|
||||||
# Menu action
|
# Menu action
|
||||||
"action_menu_config": self.open_configure,
|
"action_menu_config": self.open_configure,
|
||||||
"action_menu_new": self.open_new_study,
|
"action_menu_new": self.open_new_study,
|
||||||
|
"action_menu_edit": self.open_edit_study,
|
||||||
"action_menu_open": self.open_model,
|
"action_menu_open": self.open_model,
|
||||||
"action_menu_save": self.save_study,
|
"action_menu_save": self.save_study,
|
||||||
"action_menu_save_as": self.save_as_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 = NewStudyWindow(parent=self)
|
||||||
self.new_study.show()
|
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 !
|
# TODO: Delete me !
|
||||||
###############
|
###############
|
||||||
# DUMMY STUFF #
|
# DUMMY STUFF #
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,25 @@ from model.Study import Study
|
||||||
from view.ASubWindow import ASubWindow
|
from view.ASubWindow import ASubWindow
|
||||||
|
|
||||||
class NewStudyWindow(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)
|
super(NewStudyWindow, self).__init__(name=title, ui="NewStudy", parent=parent)
|
||||||
self.ui.setWindowTitle(title)
|
self.ui.setWindowTitle(title)
|
||||||
|
|
||||||
self.parent = parent
|
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):
|
def accept(self):
|
||||||
name = self.get_line_edit_text("lineEdit_name")
|
name = self.get_line_edit_text("lineEdit_name")
|
||||||
description = self.get_text_edit_text("textEdit_description")
|
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))
|
if self.study is None:
|
||||||
self.close()
|
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="separator"/>
|
||||||
<addaction name="action_menu_close"/>
|
<addaction name="action_menu_close"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_menu_save_maille"/>
|
<addaction name="action_menu_edit"/>
|
||||||
<addaction name="action_menu_save"/>
|
<addaction name="action_menu_save"/>
|
||||||
<addaction name="action_menu_save_as"/>
|
<addaction name="action_menu_save_as"/>
|
||||||
<addaction name="action_menu_archive"/>
|
<addaction name="action_menu_archive"/>
|
||||||
|
|
@ -896,6 +896,18 @@
|
||||||
<string>Ouvrir l'éditeur des ouvrages (seuils, vannes, etc.), singularités et pompes</string>
|
<string>Ouvrir l'éditeur des ouvrages (seuils, vannes, etc.), singularités et pompes</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
|
|
@ -34,16 +34,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
@ -58,37 +48,16 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QTextEdit" name="textEdit_description">
|
||||||
<property name="text">
|
<property name="autoFillBackground">
|
||||||
<string>Solver</string>
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="tabChangesFocus">
|
||||||
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Rubarbe</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue