Esempio n. 1
0
 def setModelData(self, editor: '_IntervalWidget',
                  model: QAbstractItemModel, index: QModelIndex) -> None:
     datetimes: List[QDateTime]
     datetimes, byDate, byTime = editor.getOptions()
     # Do some validation
     errors = list()
     if len(datetimes) < 2:
         errors.append(('e1', 'Error: at least one range must be defined'))
     if any([a >= b for a, b in zip(datetimes, datetimes[1:])]):
         errors.append(
             ('e2', 'Error: datetime points must be strictly increasing'))
     if errors:
         editor.handleErrors(errors)
         # Avoid setting options and leave editor open
         return
     options = ([
         pd.Timestamp(date.toPython(), tz='UTC') for date in datetimes
     ], byDate, byTime)
     model.setData(index, options, Qt.EditRole)
     # Resize rows. This assumes that the TableView is the delegate parent
     f = QFontMetrics(QFont())
     rowHeight = f.height() * len(options[0])
     table: QTableView = self.parent()
     table.setRowHeight(index.row(), rowHeight)
     # Close editor. Works because it's the delegate that tells the view to close it with this signal
     self.closeEditor.emit(self.w, QStyledItemDelegate.NoHint)
Esempio n. 2
0
 def setModelData(self, editor: QtWidgets.QWidget, model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex):
     """ Take the editor, read the given value and set it in the model
     """
     dialog = editor.findChild(OrderedListInputDialog)
     value = dialog.items_selected()
     model.setData(index, value, QtCore.Qt.EditRole)
 def setModelData(self, editor: QtWidgets.QComboBox,
                  model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex):
     """ Read the current text and look up the actual ID of that uncertainty type.
     """
     uc_id = self.choices.get(editor.currentText(), 0)
     model.setData(index, uc_id, QtCore.Qt.EditRole)
Esempio n. 4
0
 def setModelData(self, editor: QLineEdit, model: QAbstractItemModel, index: QModelIndex) -> None:
     stringList: str = editor.text()
     stringEdges: List[str] = splitString(stringList, sep=' ')
     # If number are valid set them, otherwise leave them unchanged
     if all(map(isFloat, stringEdges)):
         edges: List[float] = [float(x) for x in stringEdges]
         model.setData(index, edges, Qt.EditRole)
Esempio n. 5
0
 def setModelData(self, editor: QtWidgets.QComboBox,
                  model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex):
     """ Take the editor, read the given value and set it in the model.
     """
     value = editor.currentText()
     model.setData(index, value, QtCore.Qt.EditRole)
Esempio n. 6
0
    def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                     index: QModelIndex):
        """Set the data for the item at the given index in the model to the
        contents of the given editor.
        """
        if isinstance(editor, QComboBox):
            model.setData(index, editor.currentData())

            if index.column() == 2 or index.column() == 3:
                row = index.row()
                model = index.model()
                # Detect parthenogenesis: same mother and father
                father_id = model.samples_data[row][2]
                # Only for not unknown parents
                if father_id != "0" and father_id == model.samples_data[row][3]:
                    self.erroneous_samples.add(row)
                elif row in self.erroneous_samples:
                    # Reset interface
                    self.parthenogenesis_detected.emit("")
                    self.erroneous_samples.remove(row)

            for row in self.erroneous_samples:
                self.parthenogenesis_detected.emit(
                    self.tr("<b>Same father and mother for sample '{}'</b>").
                    format(model.samples_data[row][1]))
            return

        # Basic text not editable
        return super().setModelData(editor, model, index)
Esempio n. 7
0
 def setModelData(self, editor: QComboBox, model: QAbstractItemModel,
                  index: QModelIndex) -> None:
     selectedIndex: int = editor.currentIndex()
     mi = QPersistentModelIndex()
     if selectedIndex is not None and selectedIndex >= 0:
         mi = QPersistentModelIndex(
             self.__timeLabelModel.index(selectedIndex))
     model.setData(index, mi, Qt.EditRole)
Esempio n. 8
0
 def _set_time(
     model: QAbstractItemModel,
     current_index: Union[File, FileWriter],
     current_time: str,
     time_str: str,
 ):
     model.setData(model.index(current_index.row, 1), time_str)
     current_index.last_time = current_time
Esempio n. 9
0
 def setModelData(self, editor: QtWidgets.QLineEdit, model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex):
     """ Take the editor, read the given value and set it in the model
     """
     try:
         value = float(editor.text())
         model.setData(index, value, QtCore.Qt.EditRole)
     except ValueError:
         pass
Esempio n. 10
0
 def editorEvent(self, event: QEvent, model: QAbstractItemModel, option: QStyleOptionViewItem, index: QModelIndex) -> bool:
     if index.column() == 2:
         if event.type() is QEvent.MouseButtonPress:
             v = bool(model.data(index, Qt.CheckStateRole))
             model.setData(index, not v, Qt.CheckStateRole)
             event.accept()
     else:
         pass
     return super().editorEvent(event, model, option, index)
Esempio n. 11
0
 def setModelData(self, editor: QLineEdit, model: QAbstractItemModel,
                  index: QModelIndex) -> None:
     rangeText: str = editor.text().strip()
     floatList: List[str] = splitString(rangeText, ' ')[:2]
     if not all(map(isFloat, floatList)) or len(floatList) != 2:
         d = None
     else:
         d = (float(floatList[0]), float(floatList[1]))
     model.setData(index, d, Qt.EditRole)
Esempio n. 12
0
    def setModelData(self, editor: QtWidgets.QWidget,
                     model: QtCore.QAbstractItemModel,
                     index: QtCore.QModelIndex):
        """ Take the editor, read the given value and set it in the model.

        If the new formula is the same as the existing one, do not call setData
        """
        dialog = editor.findChild(FormulaDialog)
        if dialog.result() == QtWidgets.QDialog.Rejected:
            # Cancel was clicked, do not store anything.
            return
        model.setData(index, dialog.formula, QtCore.Qt.EditRole)
    def setModelData(self, editor, model: QAbstractItemModel, index):
        """
        Overriding inherited setModelData class
        Args:
            editor: Current editor for the data
            model: Current model whose data is being set
            index: Current index being modified

        """
        if index.column() == TreeModelParamEntry.TYPE:
            model.setData(index, editor.getTypeName())
            # get type
            # get corresponding dict entry
            # update type (OrderedDict, str, etc.)  as necessary
            # get value
        else:
            QItemDelegate.setModelData(self, editor, model, index)
 def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex):
     if self.is_text_equals_none == False:
         model.setData(index, editor.value(), Qt.EditRole)
     else:
         model.setData(index, None, Qt.EditRole)
Esempio n. 15
0
 def setModelData(self, editor: QtWidgets.QWidget, model: QtCore.QAbstractItemModel, index: QtCore.QModelIndex):
     prim = index.data(QtCore.Qt.UserRole)
     prim.SetTypeName(editor.currentText())
     model.setData(index, editor.currentText(), QtCore.Qt.EditRole)
Esempio n. 16
0
 def setModelData(self, editor: QWidget, model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex) -> None:
     editor.interpretText()
     model.setData(index, editor.value(), Qt.EditRole)
Esempio n. 17
0
 def setModelData(self, editor: QWidget, model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex) -> None:
     if index.isValid() and index.column() == 0:
         editor.interpretText()
         model.setData(index, editor.value(), Qt.EditRole)
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex):
     value = editor.text()
     model.setData(index, value, Qt.EditRole)
Esempio n. 19
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex):
     editor: ColorEditWidget
     model.setData(index, editor.get_color(), Qt.DecorationRole)
Esempio n. 20
0
 def setModelData(self, editor: QLineEdit, model: QAbstractItemModel,
                  index: QModelIndex) -> None:
     text = editor.text()
     strings: List[str] = splitString(text, ' ') if text else list()
     model.setData(index, strings, Qt.EditRole)
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex):
     model.setData(index, editor.currentText(), Qt.EditRole)
Esempio n. 22
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex) -> None:
     model.setData(index, not index.data(Qt.EditRole))
Esempio n. 23
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex):
     editor: PathBrowseWidget
     model.setData(index, editor.get_path(), Qt.EditRole)