diff --git a/src/main.py b/src/main.py index b9ba805d..96d065ee 100644 --- a/src/main.py +++ b/src/main.py @@ -33,13 +33,18 @@ def run(): style = settings.value("applicationStyle") app.setStyle(style) + launch() + +def launch(): from mainWindow import MainWindow main = MainWindow() main.show() - app.exec_() - app.deleteLater() + qApp.exec_() + qApp.deleteLater() + if __name__ == "__main__": + run() \ No newline at end of file diff --git a/src/mainWindow.py b/src/mainWindow.py index 1a3319cd..88b8d65f 100644 --- a/src/mainWindow.py +++ b/src/mainWindow.py @@ -180,23 +180,30 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.btnRmSubPlot.clicked.connect(self.mdlPlots.removeSubPlot) self.btnRmPlotPerso.clicked.connect(self.mdlPlots.removePlotPerso) - self.mprPlots = QDataWidgetMapper() - self.mprPlots.setModel(self.mdlPlots) - mapping = [ - #(self.txtPlotName, Plot.name.value), + #self.mprPlots = QDataWidgetMapper() + #self.mprPlots.setModel(self.mdlPlots) + #mapping = [ + ##(self.txtPlotName, Plot.name.value), + #(self.txtPlotDescription, Plot.description.value), + #(self.txtPlotResult, Plot.result.value), + #] + #for w, i in mapping: + #self.mprPlots.addMapping(w, i) + #self.mprPlots.addMapping(self.sldPlotImportance, Plot.importance.value, "importance") + #self.sldPlotImportance.importanceChanged.connect(self.mprPlots.submit) + #self.tabMain.currentChanged.connect(self.mprPlots.submit) + #self.mprPlots.setCurrentIndex(0) + #self.lstPlots.selectionModel().currentChanged.connect(self.mprPlots.setCurrentModelIndex) + + for w, c in [ + (self.txtPlotName, Plot.name.value), (self.txtPlotDescription, Plot.description.value), (self.txtPlotResult, Plot.result.value), - ] - for w, i in mapping: - self.mprPlots.addMapping(w, i) - self.mprPlots.addMapping(self.sldPlotImportance, Plot.importance.value, "importance") - self.sldPlotImportance.importanceChanged.connect(self.mprPlots.submit) - self.tabMain.currentChanged.connect(self.mprPlots.submit) - self.mprPlots.setCurrentIndex(0) - self.lstPlots.selectionModel().currentChanged.connect(self.mprPlots.setCurrentModelIndex) - - self.txtPlotName.setModel(self.mprPlots) - self.lstPlots.selectionModel().currentChanged.connect(self.txtPlotName.setCurrentModelIndex) + (self.sldPlotImportance, Plot.importance.value), + ]: + w.setModel(self.mdlPlots) + w.setColumn(c) + self.lstPlots.selectionModel().currentChanged.connect(w.setCurrentModelIndex) self.tabPlot.setEnabled(False) self.lstPlots.selectionModel().currentChanged.connect(lambda: self.tabPlot.setEnabled(self.lstPlots.selectionModel().currentIndex().isValid())) diff --git a/src/ui/mainWindow.py b/src/ui/mainWindow.py index fb8ad1d2..18e487e2 100644 --- a/src/ui/mainWindow.py +++ b/src/ui/mainWindow.py @@ -535,7 +535,7 @@ class Ui_MainWindow(object): self.label_25 = QtWidgets.QLabel(self.infos_2) self.label_25.setObjectName("label_25") self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_25) - self.txtPlotName = QtWidgets.QLineEdit(self.infos_2) + self.txtPlotName = lineEditView(self.infos_2) self.txtPlotName.setObjectName("txtPlotName") self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.txtPlotName) self.label_31 = QtWidgets.QLabel(self.infos_2) @@ -547,15 +547,9 @@ class Ui_MainWindow(object): self.label_27 = QtWidgets.QLabel(self.infos_2) self.label_27.setObjectName("label_27") self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label_27) - self.txtPlotDescription = QtWidgets.QPlainTextEdit(self.infos_2) - self.txtPlotDescription.setObjectName("txtPlotDescription") - self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.txtPlotDescription) self.label_28 = QtWidgets.QLabel(self.infos_2) self.label_28.setObjectName("label_28") self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.label_28) - self.txtPlotResult = QtWidgets.QPlainTextEdit(self.infos_2) - self.txtPlotResult.setObjectName("txtPlotResult") - self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.txtPlotResult) self.verticalLayout_12 = QtWidgets.QVBoxLayout() self.verticalLayout_12.setObjectName("verticalLayout_12") self.lstPlotPerso = QtWidgets.QListView(self.infos_2) @@ -594,6 +588,12 @@ class Ui_MainWindow(object): self.sldPlotImportance.setSizePolicy(sizePolicy) self.sldPlotImportance.setObjectName("sldPlotImportance") self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.sldPlotImportance) + self.txtPlotDescription = textEditView(self.infos_2) + self.txtPlotDescription.setObjectName("txtPlotDescription") + self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.txtPlotDescription) + self.txtPlotResult = textEditView(self.infos_2) + self.txtPlotResult.setObjectName("txtPlotResult") + self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.txtPlotResult) self.tabPlot.addTab(self.infos_2, "") self.tab_15 = QtWidgets.QWidget() self.tab_15.setObjectName("tab_15") @@ -1117,10 +1117,10 @@ class Ui_MainWindow(object): self.menubar.addAction(self.menuHelp.menuAction()) self.retranslateUi(MainWindow) - self.tabMain.setCurrentIndex(1) + self.tabMain.setCurrentIndex(3) self.tabSummary.setCurrentIndex(0) self.tabPersos.setCurrentIndex(0) - self.tabPlot.setCurrentIndex(1) + self.tabPlot.setCurrentIndex(0) self.comboBox_2.setCurrentIndex(0) self.stkPlotSummary.setCurrentIndex(0) self.tabRedacInfos.setCurrentIndex(0) @@ -1272,11 +1272,11 @@ class Ui_MainWindow(object): self.actSettings.setText(_translate("MainWindow", "Settings")) self.actSettings.setShortcut(_translate("MainWindow", "F8")) -from ui.views.treeView import treeView from ui.editors.editorWidget import editorWidget -from ui.views.lineEditView import lineEditView -from ui.views.basicItemView import basicItemView -from ui.views.metadataView import metadataView -from ui.views.textEditView import textEditView from ui.views.outlineView import outlineView +from ui.views.treeView import treeView +from ui.views.textEditView import textEditView +from ui.views.lineEditView import lineEditView from ui.sldImportance import sldImportance +from ui.views.metadataView import metadataView +from ui.views.basicItemView import basicItemView diff --git a/src/ui/mainWindow.ui b/src/ui/mainWindow.ui index 21d1a57d..635b9fdc 100644 --- a/src/ui/mainWindow.ui +++ b/src/ui/mainWindow.ui @@ -1047,9 +1047,6 @@ - - - @@ -1057,9 +1054,6 @@ - - - @@ -1131,6 +1125,12 @@ + + + + + + diff --git a/src/ui/sldImportance.py b/src/ui/sldImportance.py index 5a757bd4..17e2d2fa 100644 --- a/src/ui/sldImportance.py +++ b/src/ui/sldImportance.py @@ -1,11 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- - - - from qt import * - +from functions import * from ui.sldImportance_ui import * class sldImportance(QWidget, Ui_sldImportance): @@ -15,6 +12,9 @@ class sldImportance(QWidget, Ui_sldImportance): def __init__(self, parent=None): QWidget.__init__(self) self.setupUi(self) + self._column = 0 + self._updating = False + self._index = None self.lastValue = -1 self.sld.valueChanged.connect(self.changed) @@ -33,6 +33,12 @@ class sldImportance(QWidget, Ui_sldImportance): self.importanceChanged.emit(str(v)) + if self._index and not self._updating: + if str(v) != self._model.data(self._index): + self._updating = True + self._model.setData(self._index, str(v)) + self._updating = False + def setValue(self, v): if v != self.lastValue: self.sld.setValue(int(v) if v else 0) @@ -41,5 +47,40 @@ class sldImportance(QWidget, Ui_sldImportance): def setProperty(): pass + + # MODEL / VIEW + + def setColumn(self, column): + self._column = column + + def setModel(self, model): + self._model = model + self._model.dataChanged.connect(self.update) + + def update(self, topLeft, bottomRight): + + if self._updating: + return + + if self._index: + if topLeft.row() <= self._index.row() <= bottomRight.row(): + self.updateValue() + + def setCurrentModelIndex(self, index): + if index.isValid(): + if index.column() != self._column: + index = index.sibling(index.row(), self._column) + self._index = index + + self.updateValue() + + def updateValue(self): + if self._index: + val = toInt(self._model.data(self._index)) + if self.sld.value() != val: + self._updating = True + self.setValue(val) + self._updating = False + importance = pyqtProperty(str, fget=getImportance, fset=setValue, notify=importanceChanged) \ No newline at end of file