Debian Codegraph @

src/styledelegate.cpp

raw symbols SCIP
1 /***************************************************************************
2 styledelegate.cpp
3 -------------------
4 Style delegate editor
5 -------------------
6 Copyright 2006-2008, David Johnson
7 Please see the header file for copyright and license information
8 ***************************************************************************/
9
10 #include <QAbstractItemModel>
11 #include <QDoubleSpinBox>
12 #include <QLineEdit>
13 #include <QSpinBox>
14
15 #include "data.h"cxx . . $ `<file>/src/data.h`/
16 #include "style.h"cxx . . $ `<file>/src/style.h`/
17 #include "styledelegate.h"cxx . . $ `<file>/src/styledelegate.h`/
18 #include "stylemodel.h"cxx . . $ `<file>/src/stylemodel.h`/
19
20 StyleDelegatecxx . . $ StyleDelegate#::StyleDelegatecxx . . $ StyleDelegate#StyleDelegate(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) : QItemDelegatecxx . . $ QItemDelegate#(parent) {}
21
22 StyleDelegatecxx . . $ StyleDelegate#::~cxx . . $ StyleDelegate#`~StyleDelegate`(ced63f7c635d850d).StyleDelegatecxx . . $ StyleDelegate#() {}
23
24 QWidgetcxx . . $ QWidget# *StyleDelegatecxx . . $ StyleDelegate#::createEditorcxx . . $ StyleDelegate#createEditor(f2c7e294f1841167).(QWidgetcxx . . $ QWidget# *parent,
25 const QStyleOptionViewItemcxx . . $ QStyleOptionViewItem# &/*option*/,
26 const QModelIndexcxx . . $ QModelIndex# &index) const
27 {
28 QLineEditcxx . . $ QLineEdit# *edit;
29 QDoubleSpinBoxcxx . . $ QDoubleSpinBox# *dspin;
30 QSpinBoxcxx . . $ QSpinBox# *spin;
31 QStringcxx . . $ QString# suffixcxx . . $ QString#QString(ced63f7c635d850d).;
32
33 // can only edit name on blank row
34 bool blank = index.rowcxx . . $ QModelIndex#row(ea6fe5115c70a13f).() >= index.modelcxx . . $ QModelIndex#model(9e8e94cc3b959740).()->rowCountcxx . . $ QAbstractItemModel#rowCount(e3878d4d6cd9529c).();
35
36 // different kind of editor for each column
37 switch (index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).()) {
38 case StyleModelcxx . . $ StyleModel#::NAMEcxx . . $ StyleModel#NAME.:
39 edit = new QLineEditcxx . . $ QLineEdit#QLineEdit(108f35f7aa7f3cf9).(parent);
40 edit->installEventFiltercxx . . $ QObject#installEventFilter(749de1b6ae65bddd).(const_cast<StyleDelegatecxx . . $ StyleDelegate#*>(this));
41 return edit;
42
43 case StyleModelcxx . . $ StyleModel#::OGLOWcxx . . $ StyleModel#OGLOW.:
44 case StyleModelcxx . . $ StyleModel#::OGHIcxx . . $ StyleModel#OGHI.:
45 case StyleModelcxx . . $ StyleModel#::FGLOWcxx . . $ StyleModel#FGLOW.:
46 case StyleModelcxx . . $ StyleModel#::FGHIcxx . . $ StyleModel#FGHI.:
47 if (blank) return 0;
48 dspin = new QDoubleSpinBoxcxx . . $ QDoubleSpinBox#(parent);
49 dspin->setDecimalscxx . . $ QDoubleSpinBox#setDecimals(d4f767463ce0a6b3).(3);
50 dspin->setRangecxx . . $ QDoubleSpinBox#setRange(bc12c9ec15586e6a).(0.990, 1.150);
51 dspin->setSingleStepcxx . . $ QDoubleSpinBox#setSingleStep(ba8836b59fb42830).(0.001);
52 dspin->setAcceleratedcxx . . $ QAbstractSpinBox#setAccelerated(b45ddcbc8423892c).(true);
53 dspin->installEventFiltercxx . . $ QObject#installEventFilter(749de1b6ae65bddd).(const_cast<StyleDelegatecxx . . $ StyleDelegate#*>(this));
54 return dspin;
55
56 case StyleModelcxx . . $ StyleModel#::IBULOWcxx . . $ StyleModel#IBULOW.:
57 case StyleModelcxx . . $ StyleModel#::IBUHIcxx . . $ StyleModel#IBUHI.:
58 if (blank) return 0;
59 spin = new QSpinBoxcxx . . $ QSpinBox#(parent);
60 spin->setRangecxx . . $ QSpinBox#setRange(3e454b8ccf442868).(0, 120);
61 spin->setSingleStepcxx . . $ QSpinBox#setSingleStep(d4f767463ce0a6b3).(1);
62 spin->setAcceleratedcxx . . $ QAbstractSpinBox#setAccelerated(b45ddcbc8423892c).(true);
63 spin->installEventFiltercxx . . $ QObject#installEventFilter(749de1b6ae65bddd).(const_cast<StyleDelegatecxx . . $ StyleDelegate#*>(this));
64 return spin;
65
66 case StyleModelcxx . . $ StyleModel#::SRMLOWcxx . . $ StyleModel#SRMLOW.:
67 case StyleModelcxx . . $ StyleModel#::SRMHIcxx . . $ StyleModel#SRMHI.:
68 if (blank) return 0;
69 spin = new QSpinBoxcxx . . $ QSpinBox#(parent);
70 spin->setRangecxx . . $ QSpinBox#setRange(3e454b8ccf442868).(0, 50);
71 spin->setSingleStepcxx . . $ QSpinBox#setSingleStep(d4f767463ce0a6b3).(1);
72 spin->setAcceleratedcxx . . $ QAbstractSpinBox#setAccelerated(b45ddcbc8423892c).(true);
73 spin->installEventFiltercxx . . $ QObject#installEventFilter(749de1b6ae65bddd).(const_cast<StyleDelegatecxx . . $ StyleDelegate#*>(this));
74 return spin;
75
76 default:
77 return 0;
78 }
79 }
80
81 void StyleDelegatecxx . . $ StyleDelegate#::setEditorDatacxx . . $ StyleDelegate#setEditorData(bb3f73f852642966).(QWidgetcxx . . $ QWidget# *editor,
82 const QModelIndexcxx . . $ QModelIndex# &index) const
83 {
84 QLineEditcxx . . $ QLineEdit# *edit;
85 QDoubleSpinBoxcxx . . $ QDoubleSpinBox# *dspin;
86 QSpinBoxcxx . . $ QSpinBox# *spin;
87
88 QVariantcxx . . $ QVariant# value = index.modelcxx . . $ QModelIndex#model(9e8e94cc3b959740).()->datacxx . . $ QAbstractItemModel#data(69b5b18a001c0029).(index, Qtcxx . . $ Qt/::EditRolecxx . . $ Qt/EditRole.);
89
90 // different kind of editor for each column
91 switch (index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).()) {
92 case StyleModelcxx . . $ StyleModel#::NAMEcxx . . $ StyleModel#NAME.:
93 edit = static_cast<QLineEditcxx . . $ QLineEdit#*>(editor);
94 if (!edit) return;
95 edit->setTextcxx . . $ QLineEdit#setText(3520e46b33348bf6).(value.toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).());
96 break;
97
98 case StyleModelcxx . . $ StyleModel#::OGLOWcxx . . $ StyleModel#OGLOW.:
99 case StyleModelcxx . . $ StyleModel#::OGHIcxx . . $ StyleModel#OGHI.:
100 case StyleModelcxx . . $ StyleModel#::FGLOWcxx . . $ StyleModel#FGLOW.:
101 case StyleModelcxx . . $ StyleModel#::FGHIcxx . . $ StyleModel#FGHI.:
102 dspin = static_cast<QDoubleSpinBoxcxx . . $ QDoubleSpinBox#*>(editor);
103 if (!dspin) return;
104 dspin->setValuecxx . . $ QDoubleSpinBox#setValue(ba8836b59fb42830).(value.toDoublecxx . . $ QVariant#toDouble(1bd8e57dd4a29c14).());
105 break;
106
107 case StyleModelcxx . . $ StyleModel#::IBULOWcxx . . $ StyleModel#IBULOW.:
108 case StyleModelcxx . . $ StyleModel#::IBUHIcxx . . $ StyleModel#IBUHI.:
109 case StyleModelcxx . . $ StyleModel#::SRMLOWcxx . . $ StyleModel#SRMLOW.:
110 case StyleModelcxx . . $ StyleModel#::SRMHIcxx . . $ StyleModel#SRMHI.:
111 spin = static_cast<QSpinBoxcxx . . $ QSpinBox#*>(editor);
112 if (!spin) return;
113 spin->setValuecxx . . $ QSpinBox#setValue(d4f767463ce0a6b3).(value.toUIntcxx . . $ QVariant#toUInt(870b63f89c7fb98).());
114 break;
115 default:
116 QItemDelegatecxx . . $ QItemDelegate#::setEditorDatacxx . . $ QItemDelegate#setEditorData(bb3f73f852642966).(editor, index);
117 break;
118 }
119 }
120
121 void StyleDelegatecxx . . $ StyleDelegate#::setModelDatacxx . . $ StyleDelegate#setModelData(3e66fac4f8e72d1b).(QWidgetcxx . . $ QWidget# *editor, QAbstractItemModelcxx . . $ QAbstractItemModel# *model,
122 const QModelIndexcxx . . $ QModelIndex# &index) const
123 {
124 QLineEditcxx . . $ QLineEdit# *edit;
125 QDoubleSpinBoxcxx . . $ QDoubleSpinBox# *dspin;
126 QSpinBoxcxx . . $ QSpinBox# *spin;
127 QVariantcxx . . $ QVariant# valuecxx . . $ QVariant#QVariant(ced63f7c635d850d).;
128
129 // different kind of editor for each column
130 switch (index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).()) {
131 case StyleModelcxx . . $ StyleModel#::NAMEcxx . . $ StyleModel#NAME.:
132 edit = static_cast<QLineEditcxx . . $ QLineEdit#*>(editor);
133 if (!edit) return;
134 value =cxx . . $ QVariant#`operator=`(79a68221451e88b7). editcxx . . $ QVariant#QVariant(3520e46b33348bf6).->textcxx . . $ QLineEdit#text(6ef7b6c27b00b43d).();
135 model->setDatacxx . . $ QAbstractItemModel#setData(6d1d8401440d0a2c).(index, value);
136 break;
137
138 case StyleModelcxx . . $ StyleModel#::OGLOWcxx . . $ StyleModel#OGLOW.:
139 case StyleModelcxx . . $ StyleModel#::OGHIcxx . . $ StyleModel#OGHI.:
140 case StyleModelcxx . . $ StyleModel#::FGLOWcxx . . $ StyleModel#FGLOW.:
141 case StyleModelcxx . . $ StyleModel#::FGHIcxx . . $ StyleModel#FGHI.:
142 dspin = static_cast<QDoubleSpinBoxcxx . . $ QDoubleSpinBox#*>(editor);
143 if (!dspin) return;
144 value =cxx . . $ QVariant#`operator=`(79a68221451e88b7). dspincxx . . $ QVariant#QVariant(ba8836b59fb42830).->valuecxx . . $ QDoubleSpinBox#value(21b6c25e127938e2).();
145 model->setDatacxx . . $ QAbstractItemModel#setData(6d1d8401440d0a2c).(index, value);
146 break;
147
148 case StyleModelcxx . . $ StyleModel#::IBULOWcxx . . $ StyleModel#IBULOW.:
149 case StyleModelcxx . . $ StyleModel#::IBUHIcxx . . $ StyleModel#IBUHI.:
150 case StyleModelcxx . . $ StyleModel#::SRMLOWcxx . . $ StyleModel#SRMLOW.:
151 case StyleModelcxx . . $ StyleModel#::SRMHIcxx . . $ StyleModel#SRMHI.:
152 spin = static_cast<QSpinBoxcxx . . $ QSpinBox#*>(editor);
153 if (!spin) return;
154 value =cxx . . $ QVariant#`operator=`(79a68221451e88b7). spincxx . . $ QVariant#QVariant(d4f767463ce0a6b3).->valuecxx . . $ QSpinBox#value(455f465bc33b4cdf).();
155 model->setDatacxx . . $ QAbstractItemModel#setData(6d1d8401440d0a2c).(index, value);
156 break;
157
158 default:
159 QItemDelegatecxx . . $ QItemDelegate#::setModelDatacxx . . $ QItemDelegate#setModelData(3e66fac4f8e72d1b).(editor, model,index);
160 break;
161 }
162 }
163
164 void StyleDelegatecxx . . $ StyleDelegate#::updateEditorGeometrycxx . . $ StyleDelegate#updateEditorGeometry(8e076d6424181c8e).(QWidgetcxx . . $ QWidget# *editor,
165 const QStyleOptionViewItemcxx . . $ QStyleOptionViewItem# &option,
166 const QModelIndexcxx . . $ QModelIndex# &/*index*/) const
167 {
168 editor->setGeometrycxx . . $ QWidget#setGeometry(22ba0428947158b).(option.rectcxx . . $ QStyleOption#rect.);
169 }