• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jjgomera / pychemqt / fba2e5b7-3165-4f83-8c1b-8d20f9958ce0

29 Sep 2025 06:15AM UTC coverage: 72.469% (-0.02%) from 72.488%
fba2e5b7-3165-4f83-8c1b-8d20f9958ce0

push

circleci

jjgomera
Merge branch 'master' of https://github.com/jjgomera/pychemqt

2 of 29 new or added lines in 3 files covered. (6.9%)

700 existing lines in 11 files now uncovered.

28576 of 39432 relevant lines covered (72.47%)

0.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

34.62
/UI/delegate.py
1
#!/usr/bin/python3
2
# -*- coding: utf-8 -*-
3

4
'''Pychemqt, Chemical Engineering Process simulator
5
Copyright (C) 2009-2025, Juan José Gómez Romera <jjgomera@gmail.com>
6

7
This program is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11

12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16

17
You should have received a copy of the GNU General Public License
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.
19

20

21
Module to implement delegate special editing in tables
22

23
  * :class:`CellEditor`: Numeric editor of tableitem, with numeric validator
24
  * :class:`SpinEditor`: Spinbox editor for tableitem
25
  * :class:`CheckEditor`: Checkbox editor for tableitem
26
  * :class:`ComboEditor`: Combobox Editor for tableitem
27

28
'''
29

30

31
from tools.qt import QtCore, QtGui, QtWidgets
1✔
32

33

34
class CellEditor(QtWidgets.QItemDelegate):
1✔
35
    """Numeric editor of tableitem, with numeric validator"""
36
    def __init__(self, parent=None):
1✔
UNCOV
37
        super(CellEditor, self).__init__(parent)
×
38

39
    def createEditor(self, parent, option, index):
1✔
UNCOV
40
        widget = QtWidgets.QLineEdit(parent)
×
41
        widget.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
×
42
        validator = QtGui.QDoubleValidator(self)
×
43
        locale = QtCore.QLocale("en")
×
44
        validator.setLocale(locale)
×
45
        widget.setValidator(validator)
×
46
        return widget
×
47

48

49
class SpinEditor(QtWidgets.QItemDelegate):
1✔
50
    """Spinbox editor for tableitem"""
51
    def __init__(self, parent=None):
1✔
UNCOV
52
        super(SpinEditor, self).__init__(parent)
×
53

54
    def createEditor(self, parent, option, index):
1✔
UNCOV
55
        widget = QtWidgets.QSpinBox(parent)
×
56
        widget.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
×
57
        widget.setMinimum(1)
×
58
        return widget
×
59

60

61
class CheckEditor(QtWidgets.QItemDelegate):
1✔
62
    """Checkbox editor for tableitem"""
63
    def __init__(self, parent=None):
1✔
UNCOV
64
        super(CheckEditor, self).__init__(parent)
×
65

66
    def createEditor(self, parent, option, index):
1✔
UNCOV
67
        widget = QtWidgets.QCheckBox(parent)
×
68
        return widget
×
69

70
    def setEditorData(self, editor, index):
1✔
UNCOV
71
        value = bool(index.data(QtCore.Qt.ItemDataRole.DisplayRole))
×
72
        editor.setChecked(value)
×
73

74
    def setModelData(self, editor, model, index):
1✔
UNCOV
75
        value = editor.isChecked()
×
NEW
76
        model.setData(
×
77
            index, QtCore.QVariant(value), QtCore.Qt.ItemDataRole.DisplayRole)
78

79

80
class ComboEditor(QtWidgets.QItemDelegate):
1✔
81
    """Combobox Editor for tableitem"""
82
    def __init__(self, owner, items=None):
1✔
UNCOV
83
        super(ComboEditor, self).__init__(owner)
×
UNCOV
84
        self.setItems(items)
×
85

86
    def setItems(self, items):
1✔
UNCOV
87
        self.items = items
×
88

89
    def createEditor(self, parent, option, index):
1✔
UNCOV
90
        self.editor = QtWidgets.QComboBox(parent)
×
UNCOV
91
        self.editor.addItems(self.items)
×
92
        return self.editor
×
93

94
    def setEditorData(self, editor, index):
1✔
UNCOV
95
        value = str(index.data(QtCore.Qt.ItemDataRole.DisplayRole).toString())
×
UNCOV
96
        try:
×
97
            num = self.items.index(value)
×
98
        except ValueError:
×
99
            num = -1
×
100
        editor.setCurrentIndex(num)
×
101

102
    def setModelData(self, editor, model, index):
1✔
UNCOV
103
        value = editor.currentText()
×
NEW
104
        model.setData(
×
105
            index, QtCore.QVariant(value), QtCore.Qt.ItemDataRole.DisplayRole)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc