def ajouter(self): """Attention aux unités. Dans la base xml la couleur est en srm, dans la liste de la base la couleur est convertie en EBC""" f = Fermentable() f.name = self.ui.lineEditNom.text() f.fyield = self.ui.spinBoxRendmt.value() self.ui.radioButtonSRM.setChecked(True) f.color = self.ui.spinBoxCouleur.value() * 1.97 if self.ui.comboBoxType.currentIndex() is 0: f.type = model.constants.FERMENTABLE_TYPE_GRAIN elif self.ui.comboBoxType.currentIndex() is 1: f.type = model.constants.FERMENTABLE_TYPE_EXTRACT elif self.ui.comboBoxType.currentIndex() is 2: f.type = model.constants.FERMENTABLE_TYPE_DRY_EXTRACT elif self.ui.comboBoxType.currentIndex() is 3: f.type = model.constants.FERMENTABLE_TYPE_SUGAR elif self.ui.comboBoxType.currentIndex() is 4: f.type = model.constants.FERMENTABLE_TYPE_ADJUNCT if self.ui.comboBoxReco.currentIndex() is 0: f.useAfterBoil = False else: f.useAfterBoil = True ImportBase.addFermentable(f) self.setModel()
def parseFile(self, s): fichierBeerXML = s try: self.arbre = ET.parse(fichierBeerXML) presentation = self.arbre.find('.//RECIPE') # noqa fermentables = self.arbre.findall('.//FERMENTABLE') hops = self.arbre.findall('.//HOP') levures = self.arbre.findall('.//YEAST') misc = self.arbre.findall('.//MISC') for element in hops: ImportBase.addHop(Hop.parse(element)) for element in fermentables: ImportBase.addFermentable(Fermentable.parse(element)) for element in misc: ImportBase.addMisc(Misc.parse(element)) for element in levures: ImportBase.addYeast(Yeast.parse(element)) except: self.warningFile() self.hopsNum = len(hops) self.fermNum = len(fermentables) self.miscNum = len(misc) self.yeastNum = len(levures) self.info()
def ajouter(self): h = Hop() h.name = self.ui.lineEditNom.text() h.alpha = self.ui.spinBoxAlpha.value() if self.ui.comboBoxForme.currentIndex() is 0: h.form = model.constants.HOP_FORM_LEAF elif self.ui.comboBoxForme.currentIndex() is 1: h.form = model.constants.HOP_FORM_PELLET elif self.ui.comboBoxForme.currentIndex() is 2: h.form = model.constants.HOP_FORM_PLUG else: h.form = model.constants.HOP_FORM_LEAF ImportBase.addHop(h) self.setModel()
def getMiscsQtModel(): model = QtGui.QStandardItemModel() for m in ImportBase().listeMiscs: item = QtGui.QStandardItem(m.name) item.setData(m, view.constants.MODEL_DATA_ROLE) model.appendRow(item) return model
def getYeastsQtModel(): model = QtGui.QStandardItemModel() for y in ImportBase().listeYeasts: item = QtGui.QStandardItem(YeastView(y).yeastDetailDisplay()) item.setData(y, view.constants.MODEL_DATA_ROLE) model.appendRow(item) return model
def __init__(self, parent=None): QtWidgets.QDialog.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) self.base = ImportBase() self.ui.listViewLevures.setModel(view.base.getYeastsQtModel()) self.ui.comboBoxForme.addItem(self.tr('Liquide')) self.ui.comboBoxForme.addItem(self.tr('Poudre')) self.ui.comboBoxForme.addItem(self.tr('Gélose')) self.ui.comboBoxForme.addItem(self.tr('Culture')) self.selectionModel = self.ui.listViewLevures.selectionModel() self.selectionModel.currentChanged.connect(self.voir) self.ui.pushButtonNouveau.clicked.connect(self.nouveau) self.ui.pushButtonEnlever.clicked.connect(self.enlever) self.ui.pushButtonAjouter.clicked.connect(self.ajouter) self.ui.buttonBox.rejected.connect(self.rejected) self.ui.lineEditNom.setEnabled(False) self.ui.comboBoxForme.setEnabled(False) self.ui.lineEditLabo.setEnabled(False) self.ui.lineEditID.setEnabled(False) self.ui.spinBoxAtten.setEnabled(False) self.ui.pushButtonAjouter.setEnabled(False)
def getFermentablesQtModel(): model = QtGui.QStandardItemModel() for f in ImportBase().listeFermentables: item = QtGui.QStandardItem(f.name) item.setData(f, view.constants.MODEL_DATA_ROLE) model.appendRow(item) return model
def getHopsQtModel(): model = QtGui.QStandardItemModel() for h in ImportBase().listeHops : item = QtGui.QStandardItem(h.name) item.setData(h, view.constants.MODEL_DATA_ROLE) model.appendRow(item) return model
def addMash(self): new_mash = Mash() new_mash.name = 'Nouveau profil' new_mash.grainTemp = '0' new_mash.tunTemp = '0' new_mash.spargeTemp = '78' new_mash.ph = 5.4 new_step = MashStep() new_step.name = 'Nouveau Palier' new_step.type = 'Infusion' new_step.time = '0' new_step.temp = '0' new_mash.listeSteps.append(new_step) ImportBase().listeMashes.append(new_mash) self.seeMash() self.listWidgetMashProfiles.setCurrentRow( len(ImportBase().listeMashes) - 1)
def removeStep(self): index = self.listWidgetMashProfiles.currentRow() if index > -1: selected_mash = ImportBase().listeMashes[index] i = self.listWidgetSteps.currentRow() if i > -1: item = self.listWidgetSteps.currentItem() del selected_mash.listeSteps[i] self.listWidgetSteps.setCurrentRow(i - 1) self.seeMash()
def stepEdit(self): index = self.listWidgetMashProfiles.currentRow() if index > -1: selected_mash = ImportBase().listeMashes[index] i = self.listWidgetSteps.currentRow() if i > -1: selected_step = selected_mash.listeSteps[i] self.dlgStep.show() self.dlgStep.fields(selected_step)
def mashComboChanged(self): self.brewdayLock = 0 try: i = self.comboBoxMashProfiles.currentIndex() self.currentMash = ImportBase().listeMashes[i] except: self.currentMash = self.currentRecipeMash if i == -1: self.currentMash = Mash() self.recipe.mash = self.currentMash
def ajouter(self): m = Misc() m.name = self.ui.lineEditNom.text() if self.ui.comboBoxType.currentIndex() is 0: m.type = 'Spice' elif self.ui.comboBoxType.currentIndex() is 1: m.type = 'Fining' elif self.ui.comboBoxType.currentIndex() is 2: m.type = 'Water Agent' elif self.ui.comboBoxType.currentIndex() is 3: m.type = 'Herb' elif self.ui.comboBoxType.currentIndex() is 4: m.type = 'Flavor' elif self.ui.comboBoxType.currentIndex() is 5: m.type = 'Other' else: m.type = 'Spice' ImportBase.addMisc(m) self.setModel()
def ajouter(self): y = Yeast() y.name = self.ui.lineEditNom.text() y.labo = self.ui.lineEditLabo.text() y.productId = self.ui.lineEditID.text() y.attenuation = self.ui.spinBoxAtten.value() if self.ui.comboBoxForme.currentIndex() is 0: y.form = 'Liquid' elif self.ui.comboBoxForme.currentIndex() is 1: y.form = 'Dry' elif self.ui.comboBoxForme.currentIndex() is 2: y.form = 'Slant' elif self.ui.comboBoxForme.currentIndex() is 3: y.form = 'Culture' else: y.form = 'Dry' ImportBase.addYeast(y) self.setModel()
def mashReload(self, mash): self.brewdayLock = 0 f = self.listWidgetMashProfiles.currentRow() selected_mash = ImportBase().listeMashes[f] selected_mash.name = mash.name selected_mash.ph = mash.ph selected_mash.grainTemp = 20 selected_mash.tunTemp = 20 selected_mash.spargeTemp = mash.spargeTemp self.popMashList() self.listWidgetMashProfiles.setCurrentRow(f)
def seeMash(self): self.switchToMash() index = self.listWidgetMashProfiles.currentRow() i = self.listWidgetSteps.currentRow() self.listWidgetMashProfiles.clear() self.listWidgetSteps.clear() self.numMash = len(ImportBase().listeMashes) self.popMashList() self.pushButtonMashEdit.setEnabled(False) self.pushButtonRemoveProfile.setEnabled(False) self.pushButtonStepRemove.setEnabled(False) self.pushButtonStepEdit.setEnabled(False) self.listWidgetMashProfiles.setCurrentRow(index) self.listWidgetSteps.setCurrentRow(i)
def stepReload(self, step): index = self.listWidgetMashProfiles.currentRow() if index > -1: selected_mash = ImportBase().listeMashes[index] i = self.listWidgetSteps.currentRow() if i > -1: selected_step = selected_mash.listeSteps[i] selected_step.name = step.name selected_step.type = step.type selected_step.temp = step.temp selected_step.time = step.time self.seeMash() self.stepDetails() self.listWidgetMashProfiles.setCurrentRow(index) self.listWidgetSteps.setCurrentRow(i)
def addStep(self): index = self.listWidgetMashProfiles.currentRow() selected_mash = ImportBase().listeMashes[index] i = self.listWidgetSteps.currentRow() step = MashStep() step.name = 'Nouveau palier' step.type = 'Infusion' step.time = '0' step.temp = '0' step.vol = '0' selected_mash.listeSteps.append(step) self.listWidgetMashProfiles.setCurrentRow(index) self.seeMash() self.stepDetails() self.listWidgetMashProfiles.setCurrentRow(index)
def stepDetails(self): index = self.listWidgetMashProfiles.currentRow() if index > -1: selected_mash = ImportBase().listeMashes[index] i = self.listWidgetSteps.currentRow() if i > -1: try: selected_step = selected_mash.listeSteps[i] self.labelStepName.setTextFormat(QtCore.Qt.RichText) self.labelStepName.setText("<b>" + selected_step.name + "</b>") self.labelStepType.setText(selected_step.type) self.labelStepTemp.setText( MashStepView.temp_to_display(selected_step.temp)) self.labelStepTime.setText( MashStepView.time_to_display(selected_step.time)) self.pushButtonStepRemove.setEnabled(True) self.pushButtonStepEdit.setEnabled(True) except: pass
def mashClicked(self): self.listWidgetSteps.clear() index = self.listWidgetMashProfiles.currentRow() if index > -1: mash = ImportBase().listeMashes[index] for step in mash.listeSteps: self.listWidgetSteps.addItem(step.name) self.labelStepName.setTextFormat(QtCore.Qt.RichText) self.labelMashName.setText("<b>" + mash.name + "</b>") self.labelMashPh.setText("%.1f" % float(mash.ph)) try: self.labelMashSpargeTemp.setText("%.1f" % float(mash.spargeTemp)) except: pass try: self.listWidgetSteps.setCurrentRow(0) except: pass self.pushButtonMashEdit.setEnabled(True) self.pushButtonRemoveProfile.setEnabled(True)
def __init__(self, parent=None): QtWidgets.QDialog.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) self.base = ImportBase() self.ui.listViewHoublons.setModel(getHopsQtModel()) self.ui.comboBoxForme.addItem(self.tr('Feuille')) self.ui.comboBoxForme.addItem(self.tr('Pellet')) self.ui.comboBoxForme.addItem(self.tr('Cône')) self.selectionModel = self.ui.listViewHoublons.selectionModel() self.selectionModel.currentChanged.connect(self.voir) self.ui.pushButtonNouveau.clicked.connect(self.nouveau) self.ui.pushButtonEnlever.clicked.connect(self.enlever) self.ui.pushButtonAjouter.clicked.connect(self.ajouter) self.ui.buttonBox.rejected.connect(self.rejected) self.ui.lineEditNom.setEnabled(False) self.ui.spinBoxAlpha.setEnabled(False) self.ui.comboBoxForme.setEnabled(False) self.ui.pushButtonAjouter.setEnabled(False)
def __init__(self, parent=None): QtWidgets.QDialog.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) self.base = ImportBase() self.ui.listViewDivers.setModel(view.base.getMiscsQtModel()) self.ui.comboBoxType.addItem(self.tr("Epice")) self.ui.comboBoxType.addItem(self.tr("Clarifiant")) self.ui.comboBoxType.addItem(self.tr("Traitement Eau")) self.ui.comboBoxType.addItem(self.tr("Herbe")) self.ui.comboBoxType.addItem(self.tr("Arôme")) self.ui.comboBoxType.addItem(self.tr("Autre")) self.selectionModel = self.ui.listViewDivers.selectionModel() self.selectionModel.currentChanged.connect(self.voir) self.ui.pushButtonNouveau.clicked.connect(self.nouveau) self.ui.pushButtonEnlever.clicked.connect(self.enlever) self.ui.pushButtonAjouter.clicked.connect(self.ajouter) self.ui.buttonBox.rejected.connect(self.rejected) self.ui.lineEditNom.setEnabled(False) self.ui.comboBoxType.setEnabled(False) self.ui.pushButtonAjouter.setEnabled(False)
def __init__(self, parent=None): QtWidgets.QDialog.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) self.base = ImportBase() logger.debug("init Dialog") self.ui.listViewGrains.setModel(view.base.getFermentablesQtModel()) self.ui.comboBoxType.addItem(self.tr('Grain')) self.ui.comboBoxType.addItem(self.tr('Extrait')) self.ui.comboBoxType.addItem(self.tr('Extrait sec')) self.ui.comboBoxType.addItem(self.tr('Sucre')) self.ui.comboBoxType.addItem(self.tr("Complément")) self.ui.comboBoxReco.addItem(self.tr('Oui')) self.ui.comboBoxReco.addItem(self.tr('Non')) self.ui.spinBoxCouleur.setMaximum(10000) self.ui.spinBoxRendmt.setMaximum(1000) self.selectionModel = self.ui.listViewGrains.selectionModel() self.selectionModel.currentChanged.connect(self.voir) self.ui.pushButtonNouveau.clicked.connect(self.nouveau) self.ui.pushButtonEnlever.clicked.connect(self.enlever) self.ui.pushButtonAjouter.clicked.connect(self.ajouter) self.ui.radioButtonEBC.toggled.connect(self.toggleUnits) self.ui.buttonBox.rejected.connect(self.rejected) self.ui.lineEditNom.setEnabled(False) self.ui.comboBoxType.setEnabled(False) self.ui.spinBoxRendmt.setEnabled(False) self.ui.comboBoxReco.setEnabled(False) self.ui.spinBoxCouleur.setEnabled(False) self.ui.pushButtonAjouter.setEnabled(False) self.ui.pushButtonAjouter.setEnabled(False) self.ui.radioButtonSRM.setEnabled(False) self.ui.radioButtonEBC.setEnabled(False)
def enlever(self): selection = self.ui.listViewGrains.selectionModel().selectedIndexes() for index in selection: f = index.data(view.constants.MODEL_DATA_ROLE) ImportBase().delFermentable(f) self.setModel()
def saveProfile(self): self.mashProfileExport.export(ImportBase().listeMashes) self.mashProfileExport.enregistrer(mash_file)
def mashEdit(self): index = self.listWidgetMashProfiles.currentRow() selected_mash = ImportBase().listeMashes[index] self.dlgMash.show() self.dlgMash.fields(selected_mash)
def removeMash(self): i = self.listWidgetMashProfiles.currentRow() del ImportBase().listeMashes[i] self.seeMash() self.listWidgetSteps.clear()
def __init__(self, parent=None): QtWidgets.QMainWindow.__init__(self, parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setupUi(self) self.settings = Settings() self.initRep() self.dlgEditG = Dialog(self) self.dlgEditH = DialogH(self) self.dlgEditD = DialogD(self) self.dlgEditY = DialogL(self) self.dlgPref = DialogPref(self) self.dlgStep = DialogStep(self) self.dlgMash = DialogMash(self) self.base = ImportBase() self.mashProfileExport = ExportMash() self.s = 0 self.recipe = None # les connexions self.actionEnregistrer.triggered.connect(self.enregistrer) self.actionQuitter.triggered.connect(app.quit) self.actionShowJournal.triggered.connect(self.showJournal) self.actionEditGrains.triggered.connect(self.editGrains) self.actionEditHoublons.triggered.connect(self.editHoublons) self.actionEditDivers.triggered.connect(self.editDivers) self.actionEditLevures.triggered.connect(self.editLevures) self.actionRestaurerIngredients.triggered.connect(self.restoreDataBase) self.actionImportIng.triggered.connect(self.importIng) self.actionManageProfiles.triggered.connect(self.seeMash) self.actionAbout.triggered.connect(self.about) self.actionAllTools.triggered.connect(self.showTools) self.actionPreferences.triggered.connect(self.dialogPreferences) # profil de brassage self.listWidgetSteps.itemSelectionChanged.connect(self.stepDetails) self.listWidgetMashProfiles.itemSelectionChanged.connect( self.mashClicked) self.buttonBoxMashDetails.rejected.connect(self.mashRejected) self.pushButtonStepEdit.clicked.connect(self.stepEdit) self.dlgStep.stepChanged.connect(self.stepReload) self.pushButtonStepRemove.clicked.connect(self.removeStep) self.pushButtonNewStep.clicked.connect(self.addStep) self.pushButtonMashEdit.clicked.connect(self.mashEdit) self.dlgMash.mashChanged.connect(self.mashReload) self.pushButtonNewProfile.clicked.connect(self.addMash) self.pushButtonRemoveProfile.clicked.connect(self.removeMash) self.pushButtonSaveProfile.clicked.connect(self.saveProfile) # la bibliotheque self.showLib() # gestion des arguments au lancement du programme argumentsList = QtWidgets.QApplication.arguments() if len(argumentsList) > 1: logger.debug("la liste d'arguments: %s", argumentsList) logger.debug("le chemin: %s", argumentsList[1]) try: recipePath = argumentsList[1] for part in argumentsList[2:]: recipePath = recipePath + " " + part self.openRecipeFile(recipePath) except: pass else: pass # le signal émis à la fermeture de la fenêtre de préférences self.dlgPref.prefAccepted.connect(self.prefReload)
def enlever(self): selection = self.ui.listViewHoublons.selectionModel().selectedIndexes() for index in selection: h = index.data(view.constants.MODEL_DATA_ROLE) ImportBase().delHop(h) self.setModel()
def enlever(self): selection = self.ui.listViewLevures.selectionModel().selectedIndexes() for index in selection: y = index.data(view.constants.MODEL_DATA_ROLE) ImportBase().delYeast(y) self.setModel()