Changeset View
Changeset View
Standalone View
Standalone View
src/KPropertyWidgetsFactory.cpp
- This file was copied from src/KPropertyFactory.cpp.
Show All 13 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | 20 | | |||
21 | #include "KPropertyFactory.h" | 21 | #include "KPropertyFactory.h" | ||
22 | | ||||
22 | #include "KDefaultPropertyFactory.h" | 23 | #include "KDefaultPropertyFactory.h" | ||
23 | #include "KPropertyEditorView.h" | 24 | #include "KPropertyEditorView.h" | ||
24 | #include "KPropertyEditorDataModel.h" | 25 | #include "KPropertyEditorDataModel.h" | ||
25 | 26 | | |||
26 | KPropertyLabel::KPropertyLabel(QWidget *parent, const KPropertyValueDisplayInterface *iface) | 27 | KPropertyLabel::KPropertyLabel(QWidget *parent, const KPropertyValueDisplayInterface *iface) | ||
27 | : QLabel(parent) | 28 | : QLabel(parent) | ||
28 | , m_iface(iface) | 29 | , m_iface(iface) | ||
29 | { | 30 | { | ||
Show All 11 Lines | |||||
41 | { | 42 | { | ||
42 | setText( m_iface->displayText(value) ); | 43 | setText( m_iface->displayText(value) ); | ||
43 | m_value = value; | 44 | m_value = value; | ||
44 | } | 45 | } | ||
45 | 46 | | |||
46 | void KPropertyLabel::paintEvent( QPaintEvent * event ) | 47 | void KPropertyLabel::paintEvent( QPaintEvent * event ) | ||
47 | { | 48 | { | ||
48 | QLabel::paintEvent(event); | 49 | QLabel::paintEvent(event); | ||
49 | KPropertyFactory::paintTopGridLine(this); | 50 | KPropertyWidgetsFactory::paintTopGridLine(this); | ||
50 | } | 51 | } | ||
51 | 52 | | |||
52 | //--------------- | 53 | //--------------- | ||
53 | 54 | | |||
54 | //! @internal | 55 | //! @internal | ||
55 | class KPropertyFactoryManager::Private | 56 | class KPropertyWidgetsFactoryManager::Private | ||
56 | { | 57 | { | ||
57 | public: | 58 | public: | ||
58 | Private() | 59 | Private() | ||
59 | { | 60 | { | ||
60 | } | 61 | } | ||
61 | ~Private() | 62 | ~Private() | ||
62 | { | 63 | { | ||
63 | qDeleteAll(factories); | 64 | qDeleteAll(factories); | ||
64 | } | 65 | } | ||
65 | 66 | | |||
66 | QSet<KPropertyFactory*> factories; | 67 | QSet<KPropertyFactory*> factories; | ||
67 | QHash<int, KComposedPropertyCreatorInterface*> composedPropertyCreators; | | |||
68 | QHash<int, KPropertyEditorCreatorInterface*> editorCreators; | 68 | QHash<int, KPropertyEditorCreatorInterface*> editorCreators; | ||
69 | QHash<int, KPropertyValuePainterInterface*> valuePainters; | 69 | QHash<int, KPropertyValuePainterInterface*> valuePainters; | ||
70 | QHash<int, KPropertyValueDisplayInterface*> valueDisplays; | 70 | QHash<int, KPropertyValueDisplayInterface*> valueDisplays; | ||
71 | | ||||
71 | }; | 72 | }; | ||
72 | 73 | | |||
73 | Q_GLOBAL_STATIC(KPropertyFactoryManager, _self) | 74 | Q_GLOBAL_STATIC(KPropertyWidgetsFactoryManager, _self) | ||
74 | 75 | | |||
75 | //! @internal | 76 | //! @internal | ||
76 | class KPropertyFactory::Private | 77 | class KPropertyWidgetsFactory::Private | ||
77 | { | 78 | { | ||
78 | public: | 79 | public: | ||
79 | Private() | 80 | Private() | ||
80 | { | 81 | { | ||
81 | } | 82 | } | ||
82 | ~Private() | 83 | ~Private() | ||
83 | { | 84 | { | ||
84 | qDeleteAll(editorCreatorsSet); | 85 | qDeleteAll(editorCreatorsSet); | ||
85 | qDeleteAll(valuePaintersSet); | 86 | qDeleteAll(valuePaintersSet); | ||
86 | qDeleteAll(valueDisplaysSet); | 87 | qDeleteAll(valueDisplaysSet); | ||
87 | } | 88 | } | ||
88 | 89 | | |||
89 | QHash<int, KComposedPropertyCreatorInterface*> composedPropertyCreators; | | |||
90 | QHash<int, KPropertyEditorCreatorInterface*> editorCreators; | 90 | QHash<int, KPropertyEditorCreatorInterface*> editorCreators; | ||
91 | QHash<int, KPropertyValuePainterInterface*> valuePainters; | 91 | QHash<int, KPropertyValuePainterInterface*> valuePainters; | ||
92 | QHash<int, KPropertyValueDisplayInterface*> valueDisplays; | 92 | QHash<int, KPropertyValueDisplayInterface*> valueDisplays; | ||
93 | QSet<KComposedPropertyCreatorInterface*> composedPropertyCreatorsSet; | 93 | | ||
94 | QSet<KPropertyEditorCreatorInterface*> editorCreatorsSet; | 94 | QSet<KPropertyEditorCreatorInterface*> editorCreatorsSet; | ||
95 | QSet<KPropertyValuePainterInterface*> valuePaintersSet; | 95 | QSet<KPropertyValuePainterInterface*> valuePaintersSet; | ||
96 | QSet<KPropertyValueDisplayInterface*> valueDisplaysSet; | 96 | QSet<KPropertyValueDisplayInterface*> valueDisplaysSet; | ||
97 | | ||||
97 | }; | 98 | }; | ||
98 | 99 | | |||
99 | KPropertyFactory::KPropertyFactory() | 100 | KPropertyWidgetsFactory::KPropertyWidgetsFactory() | ||
100 | : d( new Private ) | 101 | : d( new Private ) | ||
101 | { | 102 | { | ||
102 | } | 103 | } | ||
103 | 104 | | |||
104 | KPropertyFactory::~KPropertyFactory() | 105 | KPropertyWidgetsFactory::~KPropertyWidgetsFactory() | ||
105 | { | 106 | { | ||
106 | delete d; | 107 | delete d; | ||
107 | } | 108 | } | ||
108 | 109 | | |||
109 | QHash<int, KComposedPropertyCreatorInterface*> KPropertyFactory::composedPropertyCreators() const | 110 | QHash<int, KPropertyEditorCreatorInterface*> KPropertyWidgetsFactory::editorCreators() const | ||
110 | { | | |||
111 | return d->composedPropertyCreators; | | |||
112 | } | | |||
113 | | ||||
114 | QHash<int, KPropertyEditorCreatorInterface*> KPropertyFactory::editorCreators() const | | |||
115 | { | 111 | { | ||
116 | return d->editorCreators; | 112 | return d->editorCreators; | ||
117 | } | 113 | } | ||
118 | 114 | | |||
119 | QHash<int, KPropertyValuePainterInterface*> KPropertyFactory::valuePainters() const | 115 | QHash<int, KPropertyValuePainterInterface*> KPropertyWidgetsFactory::valuePainters() const | ||
120 | { | 116 | { | ||
121 | return d->valuePainters; | 117 | return d->valuePainters; | ||
122 | } | 118 | } | ||
123 | 119 | | |||
124 | QHash<int, KPropertyValueDisplayInterface*> KPropertyFactory::valueDisplays() const | 120 | QHash<int, KPropertyValueDisplayInterface*> KPropertyWidgetsFactory::valueDisplays() const | ||
125 | { | 121 | { | ||
126 | return d->valueDisplays; | 122 | return d->valueDisplays; | ||
127 | } | 123 | } | ||
128 | 124 | | |||
129 | void KPropertyFactory::addEditor(int type, KPropertyEditorCreatorInterface *creator) | 125 | void KPropertyWidgetsFactory::addEditor(int type, KPropertyEditorCreatorInterface *creator) | ||
130 | { | 126 | { | ||
131 | addEditorInternal( type, creator, true ); | 127 | addEditorInternal( type, creator, true ); | ||
132 | if (dynamic_cast<KComposedPropertyCreatorInterface*>(creator)) { | 128 | if (dynamic_cast<KComposedPropertyCreatorInterface*>(creator)) { | ||
133 | addComposedPropertyCreatorInternal( type, | 129 | addComposedPropertyCreatorInternal( type, | ||
134 | dynamic_cast<KComposedPropertyCreatorInterface*>(creator), false/* !own*/ ); | 130 | dynamic_cast<KComposedPropertyCreatorInterface*>(creator), false/* !own*/ ); | ||
135 | } | 131 | } | ||
136 | if (dynamic_cast<KPropertyValuePainterInterface*>(creator)) { | 132 | if (dynamic_cast<KPropertyValuePainterInterface*>(creator)) { | ||
137 | addPainterInternal( type, dynamic_cast<KPropertyValuePainterInterface*>(creator), false/* !own*/ ); | 133 | addPainterInternal( type, dynamic_cast<KPropertyValuePainterInterface*>(creator), false/* !own*/ ); | ||
138 | } | 134 | } | ||
139 | if (dynamic_cast<KPropertyValueDisplayInterface*>(creator)) { | 135 | if (dynamic_cast<KPropertyValueDisplayInterface*>(creator)) { | ||
140 | addDisplayInternal( type, dynamic_cast<KPropertyValueDisplayInterface*>(creator), false/* !own*/ ); | 136 | addDisplayInternal( type, dynamic_cast<KPropertyValueDisplayInterface*>(creator), false/* !own*/ ); | ||
141 | } | 137 | } | ||
142 | } | 138 | } | ||
143 | 139 | | |||
144 | void KPropertyFactory::addComposedPropertyCreator( int type, KComposedPropertyCreatorInterface* creator ) | 140 | void KPropertyWidgetsFactory::addPainter(int type, KPropertyValuePainterInterface *painter) | ||
145 | { | | |||
146 | addComposedPropertyCreatorInternal( type, creator, true ); | | |||
147 | if (dynamic_cast<KPropertyEditorCreatorInterface*>(creator)) { | | |||
148 | addEditorInternal( type, dynamic_cast<KPropertyEditorCreatorInterface*>(creator), false/* !own*/ ); | | |||
149 | } | | |||
150 | if (dynamic_cast<KPropertyValuePainterInterface*>(creator)) { | | |||
151 | addPainterInternal( type, dynamic_cast<KPropertyValuePainterInterface*>(creator), false/* !own*/ ); | | |||
152 | } | | |||
153 | if (dynamic_cast<KPropertyValueDisplayInterface*>(creator)) { | | |||
154 | addDisplayInternal( type, dynamic_cast<KPropertyValueDisplayInterface*>(creator), false/* !own*/ ); | | |||
155 | } | | |||
156 | } | | |||
157 | | ||||
158 | void KPropertyFactory::addPainter(int type, KPropertyValuePainterInterface *painter) | | |||
159 | { | 141 | { | ||
160 | addPainterInternal(type, painter, true); | 142 | addPainterInternal(type, painter, true); | ||
161 | if (dynamic_cast<KComposedPropertyCreatorInterface*>(painter)) { | 143 | if (dynamic_cast<KComposedPropertyCreatorInterface*>(painter)) { | ||
162 | addComposedPropertyCreatorInternal( type, | 144 | addComposedPropertyCreatorInternal( type, | ||
163 | dynamic_cast<KComposedPropertyCreatorInterface*>(painter), false/* !own*/ ); | 145 | dynamic_cast<KComposedPropertyCreatorInterface*>(painter), false/* !own*/ ); | ||
164 | } | 146 | } | ||
165 | if (dynamic_cast<KPropertyEditorCreatorInterface*>(painter)) { | 147 | if (dynamic_cast<KPropertyEditorCreatorInterface*>(painter)) { | ||
166 | addEditorInternal( type, dynamic_cast<KPropertyEditorCreatorInterface*>(painter), false/* !own*/ ); | 148 | addEditorInternal( type, dynamic_cast<KPropertyEditorCreatorInterface*>(painter), false/* !own*/ ); | ||
167 | } | 149 | } | ||
168 | if (dynamic_cast<KPropertyValueDisplayInterface*>(painter)) { | 150 | if (dynamic_cast<KPropertyValueDisplayInterface*>(painter)) { | ||
169 | addDisplayInternal( type, dynamic_cast<KPropertyValueDisplayInterface*>(painter), false/* !own*/ ); | 151 | addDisplayInternal( type, dynamic_cast<KPropertyValueDisplayInterface*>(painter), false/* !own*/ ); | ||
170 | } | 152 | } | ||
171 | } | 153 | } | ||
172 | 154 | | |||
173 | void KPropertyFactory::addDisplay(int type, KPropertyValueDisplayInterface *display) | 155 | void KPropertyWidgetsFactory::addDisplay(int type, KPropertyValueDisplayInterface *display) | ||
174 | { | 156 | { | ||
175 | addDisplayInternal(type, display, true); | 157 | addDisplayInternal(type, display, true); | ||
176 | if (dynamic_cast<KComposedPropertyCreatorInterface*>(display)) { | 158 | if (dynamic_cast<KComposedPropertyCreatorInterface*>(display)) { | ||
177 | addComposedPropertyCreatorInternal( type, | 159 | addComposedPropertyCreatorInternal( type, | ||
178 | dynamic_cast<KComposedPropertyCreatorInterface*>(display), false/* !own*/ ); | 160 | dynamic_cast<KComposedPropertyCreatorInterface*>(display), false/* !own*/ ); | ||
179 | } | 161 | } | ||
180 | if (dynamic_cast<KPropertyEditorCreatorInterface*>(display)) { | 162 | if (dynamic_cast<KPropertyEditorCreatorInterface*>(display)) { | ||
181 | addEditorInternal( type, dynamic_cast<KPropertyEditorCreatorInterface*>(display), false/* !own*/ ); | 163 | addEditorInternal( type, dynamic_cast<KPropertyEditorCreatorInterface*>(display), false/* !own*/ ); | ||
182 | } | 164 | } | ||
183 | if (dynamic_cast<KPropertyValueDisplayInterface*>(display)) { | 165 | if (dynamic_cast<KPropertyValueDisplayInterface*>(display)) { | ||
184 | addDisplayInternal( type, dynamic_cast<KPropertyValueDisplayInterface*>(display), false/* !own*/ ); | 166 | addDisplayInternal( type, dynamic_cast<KPropertyValueDisplayInterface*>(display), false/* !own*/ ); | ||
185 | } | 167 | } | ||
186 | } | 168 | } | ||
187 | 169 | | |||
188 | void KPropertyFactory::addEditorInternal(int type, KPropertyEditorCreatorInterface *editor, bool own) | 170 | void KPropertyWidgetsFactory::addEditorInternal(int type, KPropertyEditorCreatorInterface *editor, bool own) | ||
189 | { | 171 | { | ||
190 | if (own) | 172 | if (own) | ||
191 | d->editorCreatorsSet.insert(editor); | 173 | d->editorCreatorsSet.insert(editor); | ||
192 | d->editorCreators.insert(type, editor); | 174 | d->editorCreators.insert(type, editor); | ||
193 | } | 175 | } | ||
194 | 176 | | |||
195 | void KPropertyFactory::addComposedPropertyCreatorInternal(int type, KComposedPropertyCreatorInterface* creator, bool own) | 177 | void KPropertyWidgetsFactory::addPainterInternal(int type, KPropertyValuePainterInterface *painter, bool own) | ||
196 | { | | |||
197 | if (own) | | |||
198 | d->composedPropertyCreatorsSet.insert(creator); | | |||
199 | d->composedPropertyCreators.insert(type, creator); | | |||
200 | } | | |||
201 | | ||||
202 | void KPropertyFactory::addPainterInternal(int type, KPropertyValuePainterInterface *painter, bool own) | | |||
203 | { | 178 | { | ||
204 | if (own) | 179 | if (own) | ||
205 | d->valuePaintersSet.insert(painter); | 180 | d->valuePaintersSet.insert(painter); | ||
206 | d->valuePainters.insert(type, painter); | 181 | d->valuePainters.insert(type, painter); | ||
207 | } | 182 | } | ||
208 | 183 | | |||
209 | void KPropertyFactory::addDisplayInternal(int type, KPropertyValueDisplayInterface *display, bool own) | 184 | void KPropertyWidgetsFactory::addDisplayInternal(int type, KPropertyValueDisplayInterface *display, bool own) | ||
210 | { | 185 | { | ||
211 | if (own) | 186 | if (own) | ||
212 | d->valueDisplaysSet.insert(display); | 187 | d->valueDisplaysSet.insert(display); | ||
213 | d->valueDisplays.insert(type, display); | 188 | d->valueDisplays.insert(type, display); | ||
214 | } | 189 | } | ||
215 | 190 | | |||
216 | //static | 191 | //static | ||
217 | void KPropertyFactory::paintTopGridLine(QWidget *widget) | 192 | void KPropertyWidgetsFactory::paintTopGridLine(QWidget *widget) | ||
218 | { | 193 | { | ||
219 | // paint top grid line | 194 | // paint top grid line | ||
220 | QPainter p(widget); | 195 | QPainter p(widget); | ||
221 | QColor gridLineColor( dynamic_cast<KPropertyEditorView*>(widget->parentWidget()) ? | 196 | QColor gridLineColor( dynamic_cast<KPropertyEditorView*>(widget->parentWidget()) ? | ||
222 | dynamic_cast<KPropertyEditorView*>(widget->parentWidget())->gridLineColor() | 197 | dynamic_cast<KPropertyEditorView*>(widget->parentWidget())->gridLineColor() | ||
223 | : KPropertyEditorView::defaultGridLineColor() ); | 198 | : KPropertyEditorView::defaultGridLineColor() ); | ||
224 | p.setPen(QPen( QBrush(gridLineColor), 1)); | 199 | p.setPen(QPen( QBrush(gridLineColor), 1)); | ||
225 | p.drawLine(0, 0, widget->width()-1, 0); | 200 | p.drawLine(0, 0, widget->width()-1, 0); | ||
226 | } | 201 | } | ||
227 | 202 | | |||
228 | //static | 203 | //static | ||
229 | void KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(QWidget *widget, QWidget* parent, const QString& extraStyleSheet) | 204 | void KPropertyWidgetsFactory::setTopAndBottomBordersUsingStyleSheet(QWidget *widget, QWidget* parent, const QString& extraStyleSheet) | ||
230 | { | 205 | { | ||
231 | QColor gridLineColor( dynamic_cast<KPropertyEditorView*>(parent) ? | 206 | QColor gridLineColor( dynamic_cast<KPropertyEditorView*>(parent) ? | ||
232 | dynamic_cast<KPropertyEditorView*>(parent)->gridLineColor() | 207 | dynamic_cast<KPropertyEditorView*>(parent)->gridLineColor() | ||
233 | : KPropertyEditorView::defaultGridLineColor() ); | 208 | : KPropertyEditorView::defaultGridLineColor() ); | ||
234 | widget->setStyleSheet( | 209 | widget->setStyleSheet( | ||
235 | QString::fromLatin1("%1 { border-top: 1px solid %2;border-bottom: 1px solid %2; } %3") | 210 | QString::fromLatin1("%1 { border-top: 1px solid %2;border-bottom: 1px solid %2; } %3") | ||
236 | .arg(QLatin1String(widget->metaObject()->className())) | 211 | .arg(QLatin1String(widget->metaObject()->className())) | ||
237 | .arg(gridLineColor.name()).arg(extraStyleSheet)); | 212 | .arg(gridLineColor.name()).arg(extraStyleSheet)); | ||
238 | } | 213 | } | ||
239 | 214 | | |||
240 | //------------ | 215 | //------------ | ||
241 | 216 | | |||
242 | KPropertyFactoryManager::KPropertyFactoryManager() | 217 | KPropertyWidgetsFactoryManager::KPropertyWidgetsFactoryManager() | ||
243 | : QObject(0) | 218 | : KPropertyFactoryManager() | ||
244 | , d(new Private) | 219 | , d(new Private) | ||
245 | { | 220 | { | ||
246 | setObjectName(QLatin1String("KPropertyFactoryManager")); | 221 | setObjectName(QLatin1String("KPropertyWidgetsFactoryManager")); | ||
247 | registerFactory(new KDefaultPropertyFactory); | 222 | registerFactory(new KDefaultPropertyFactory); | ||
248 | } | 223 | } | ||
249 | 224 | | |||
250 | KPropertyFactoryManager::~KPropertyFactoryManager() | 225 | KPropertyWidgetsFactoryManager::~KPropertyWidgetsFactoryManager() | ||
251 | { | 226 | { | ||
252 | delete d; | 227 | delete d; | ||
253 | } | 228 | } | ||
254 | 229 | | |||
255 | KPropertyFactoryManager* KPropertyFactoryManager::self() | 230 | KPropertyWidgetsFactoryManager* KPropertyWidgetsFactoryManager::self() | ||
256 | { | 231 | { | ||
257 | return _self; | 232 | return _self; | ||
258 | } | 233 | } | ||
259 | 234 | | |||
260 | void KPropertyFactoryManager::registerFactory(KPropertyFactory *factory) | 235 | void KPropertyWidgetsFactoryManager::registerFactory(KPropertyWidgetsFactory *factory) | ||
261 | { | 236 | { | ||
262 | d->factories.insert(factory); | 237 | d->factories.insert(factory); | ||
263 | QHash<int, KComposedPropertyCreatorInterface*>::ConstIterator composedPropertyCreatorsItEnd | 238 | | ||
264 | = factory->composedPropertyCreators().constEnd(); | | |||
265 | for (QHash<int, KComposedPropertyCreatorInterface*>::ConstIterator it( factory->composedPropertyCreators().constBegin() ); | | |||
266 | it != composedPropertyCreatorsItEnd; ++it) | | |||
267 | { | | |||
268 | d->composedPropertyCreators.insert(it.key(), it.value()); | | |||
269 | } | | |||
270 | QHash<int, KPropertyEditorCreatorInterface*>::ConstIterator editorCreatorsItEnd | 239 | QHash<int, KPropertyEditorCreatorInterface*>::ConstIterator editorCreatorsItEnd | ||
271 | = factory->editorCreators().constEnd(); | 240 | = factory->editorCreators().constEnd(); | ||
272 | for (QHash<int, KPropertyEditorCreatorInterface*>::ConstIterator it( factory->editorCreators().constBegin() ); | 241 | for (QHash<int, KPropertyEditorCreatorInterface*>::ConstIterator it( factory->editorCreators().constBegin() ); | ||
273 | it != editorCreatorsItEnd; ++it) | 242 | it != editorCreatorsItEnd; ++it) | ||
274 | { | 243 | { | ||
275 | d->editorCreators.insert(it.key(), it.value()); | 244 | d->editorCreators.insert(it.key(), it.value()); | ||
276 | } | 245 | } | ||
277 | QHash<int, KPropertyValuePainterInterface*>::ConstIterator valuePaintersItEnd | 246 | QHash<int, KPropertyValuePainterInterface*>::ConstIterator valuePaintersItEnd | ||
278 | = factory->valuePainters().constEnd(); | 247 | = factory->valuePainters().constEnd(); | ||
279 | for (QHash<int, KPropertyValuePainterInterface*>::ConstIterator it( factory->valuePainters().constBegin() ); | 248 | for (QHash<int, KPropertyValuePainterInterface*>::ConstIterator it( factory->valuePainters().constBegin() ); | ||
280 | it != valuePaintersItEnd; ++it) | 249 | it != valuePaintersItEnd; ++it) | ||
281 | { | 250 | { | ||
282 | d->valuePainters.insert(it.key(), it.value()); | 251 | d->valuePainters.insert(it.key(), it.value()); | ||
283 | } | 252 | } | ||
284 | QHash<int, KPropertyValueDisplayInterface*>::ConstIterator valueDisplaysItEnd | 253 | QHash<int, KPropertyValueDisplayInterface*>::ConstIterator valueDisplaysItEnd | ||
285 | = factory->valueDisplays().constEnd(); | 254 | = factory->valueDisplays().constEnd(); | ||
286 | for (QHash<int, KPropertyValueDisplayInterface*>::ConstIterator it( factory->valueDisplays().constBegin() ); | 255 | for (QHash<int, KPropertyValueDisplayInterface*>::ConstIterator it( factory->valueDisplays().constBegin() ); | ||
287 | it != valueDisplaysItEnd; ++it) | 256 | it != valueDisplaysItEnd; ++it) | ||
288 | { | 257 | { | ||
289 | d->valueDisplays.insert(it.key(), it.value()); | 258 | d->valueDisplays.insert(it.key(), it.value()); | ||
290 | } | 259 | } | ||
291 | } | 260 | } | ||
292 | 261 | | |||
293 | bool KPropertyFactoryManager::isEditorForTypeAvailable( int type ) const | 262 | bool KPropertyWidgetsFactoryManager::isEditorForTypeAvailable( int type ) const | ||
294 | { | 263 | { | ||
295 | return d->editorCreators.value(type); | 264 | return d->editorCreators.value(type); | ||
296 | } | 265 | } | ||
297 | 266 | | |||
298 | QWidget * KPropertyFactoryManager::createEditor( | 267 | QWidget * KPropertyWidgetsFactoryManager::createEditor( | ||
299 | int type, QWidget *parent, | 268 | int type, QWidget *parent, | ||
300 | const QStyleOptionViewItem & option, const QModelIndex & index ) const | 269 | const QStyleOptionViewItem & option, const QModelIndex & index ) const | ||
301 | { | 270 | { | ||
302 | const KPropertyEditorCreatorInterface *creator = d->editorCreators.value(type); | 271 | const KPropertyEditorCreatorInterface *creator = d->editorCreators.value(type); | ||
303 | if (!creator) | 272 | if (!creator) | ||
304 | return 0; | 273 | return 0; | ||
305 | QWidget *w = creator->createEditor(type, parent, option, index); | 274 | QWidget *w = creator->createEditor(type, parent, option, index); | ||
306 | if (w) { | 275 | if (w) { | ||
Show All 13 Lines | 287 | QString css = | |||
320 | .arg(cssClassName).arg(gridLineColor.name()); | 289 | .arg(cssClassName).arg(gridLineColor.name()); | ||
321 | // kprDebug() << css; | 290 | // kprDebug() << css; | ||
322 | w->setStyleSheet(css); | 291 | w->setStyleSheet(css); | ||
323 | } | 292 | } | ||
324 | } | 293 | } | ||
325 | return w; | 294 | return w; | ||
326 | } | 295 | } | ||
327 | 296 | | |||
328 | bool KPropertyFactoryManager::paint( int type, QPainter * painter, | 297 | bool KPropertyWidgetsFactoryManager::paint( int type, QPainter * painter, | ||
329 | const QStyleOptionViewItem & option, const QModelIndex & index ) const | 298 | const QStyleOptionViewItem & option, const QModelIndex & index ) const | ||
330 | { | 299 | { | ||
331 | const KPropertyValuePainterInterface *_painter = d->valuePainters.value(type); | 300 | const KPropertyValuePainterInterface *_painter = d->valuePainters.value(type); | ||
332 | if (!_painter) | 301 | if (!_painter) | ||
333 | return false; | 302 | return false; | ||
334 | QStyleOptionViewItem realOption(option); | 303 | QStyleOptionViewItem realOption(option); | ||
335 | if (option.state & QStyle::State_Selected) { | 304 | if (option.state & QStyle::State_Selected) { | ||
336 | // paint background because there may be editor widget with no autoFillBackground set | 305 | // paint background because there may be editor widget with no autoFillBackground set | ||
337 | realOption.palette.setBrush(QPalette::Text, realOption.palette.highlightedText()); | 306 | realOption.palette.setBrush(QPalette::Text, realOption.palette.highlightedText()); | ||
338 | painter->fillRect(realOption.rect, realOption.palette.highlight()); | 307 | painter->fillRect(realOption.rect, realOption.palette.highlight()); | ||
339 | } | 308 | } | ||
340 | painter->setPen(realOption.palette.text().color()); | 309 | painter->setPen(realOption.palette.text().color()); | ||
341 | _painter->paint(painter, realOption, index); | 310 | _painter->paint(painter, realOption, index); | ||
342 | return true; | 311 | return true; | ||
343 | } | 312 | } | ||
344 | 313 | | |||
345 | bool KPropertyFactoryManager::canConvertValueToText( int type ) const | 314 | bool KPropertyWidgetsFactoryManager::canConvertValueToText( int type ) const | ||
346 | { | 315 | { | ||
347 | return d->valueDisplays.value(type) != 0; | 316 | return d->valueDisplays.value(type) != 0; | ||
348 | } | 317 | } | ||
349 | 318 | | |||
350 | bool KPropertyFactoryManager::canConvertValueToText( const KProperty* property ) const | 319 | bool KPropertyWidgetsFactoryManager::canConvertValueToText( const KProperty* property ) const | ||
351 | { | 320 | { | ||
352 | return d->valueDisplays.value( property->type() ) != 0; | 321 | return d->valueDisplays.value( property->type() ) != 0; | ||
353 | } | 322 | } | ||
354 | 323 | | |||
355 | QString KPropertyFactoryManager::convertValueToText( const KProperty* property ) const | 324 | QString KPropertyWidgetsFactoryManager::convertValueToText( const KProperty* property ) const | ||
356 | { | 325 | { | ||
357 | const KPropertyValueDisplayInterface *display = d->valueDisplays.value( property->type() ); | 326 | const KPropertyValueDisplayInterface *display = d->valueDisplays.value( property->type() ); | ||
358 | return display ? display->displayTextForProperty( property ) : property->value().toString(); | 327 | return display ? display->displayTextForProperty( property ) : property->value().toString(); | ||
359 | } | 328 | } | ||
360 | 329 | | |||
361 | KComposedPropertyInterface* KPropertyFactoryManager::createComposedProperty(KProperty *parent) | | |||
362 | { | | |||
363 | const KComposedPropertyCreatorInterface *creator = d->composedPropertyCreators.value( parent->type() ); | | |||
364 | return creator ? creator->createComposedProperty(parent) : 0; | | |||
365 | } | | |||
366 | | ||||
367 | //! @todo | 330 | //! @todo | ||
368 | #if 0 | 331 | #if 0 | ||
369 | const int type = parent->type(); | 332 | const int type = parent->type(); | ||
370 | /* | 333 | /* | ||
371 | CustomPropertyFactory *factory = d->registeredWidgets[type]; | 334 | CustomPropertyFactory *factory = d->registeredWidgets[type]; | ||
372 | if (factory) | 335 | if (factory) | ||
373 | return factory->createCustomProperty(parent); | 336 | return factory->createCustomProperty(parent); | ||
374 | */ | 337 | */ | ||
Show All 18 Lines | 354 | /* case SizePolicy_HorizontalStretch: | |||
393 | case SizePolicy_HorizontalPolicy: | 356 | case SizePolicy_HorizontalPolicy: | ||
394 | case SizePolicy_VerticalPolicy:*/ | 357 | case SizePolicy_VerticalPolicy:*/ | ||
395 | return new SizePolicyCustomProperty(parent); | 358 | return new SizePolicyCustomProperty(parent); | ||
396 | default:; | 359 | default:; | ||
397 | } | 360 | } | ||
398 | return 0; | 361 | return 0; | ||
399 | #endif | 362 | #endif | ||
400 | 363 | | |||
401 | KComposedPropertyInterface::KComposedPropertyInterface(KProperty *parent) | | |||
402 | : m_childValueChangedEnabled(true) | | |||
403 | { | | |||
404 | Q_UNUSED(parent) | | |||
405 | } | | |||
406 | | ||||
407 | KComposedPropertyInterface::~KComposedPropertyInterface() | | |||
408 | { | | |||
409 | } | | |||
410 | | ||||
411 | KComposedPropertyCreatorInterface::KComposedPropertyCreatorInterface() | | |||
412 | { | | |||
413 | } | | |||
414 | | ||||
415 | KComposedPropertyCreatorInterface::~KComposedPropertyCreatorInterface() | | |||
416 | { | | |||
417 | } | | |||
418 | | ||||
419 | KPropertyEditorCreatorInterface::KPropertyEditorCreatorInterface() | 364 | KPropertyEditorCreatorInterface::KPropertyEditorCreatorInterface() | ||
420 | { | 365 | { | ||
421 | } | 366 | } | ||
422 | 367 | | |||
423 | KPropertyEditorCreatorInterface::~KPropertyEditorCreatorInterface() | 368 | KPropertyEditorCreatorInterface::~KPropertyEditorCreatorInterface() | ||
424 | { | 369 | { | ||
425 | } | 370 | } | ||
426 | 371 | | |||
Show All 12 Lines | |||||
439 | 384 | | |||
440 | KPropertyValueDisplayInterface::KPropertyValueDisplayInterface() | 385 | KPropertyValueDisplayInterface::KPropertyValueDisplayInterface() | ||
441 | { | 386 | { | ||
442 | } | 387 | } | ||
443 | 388 | | |||
444 | KPropertyValueDisplayInterface::~KPropertyValueDisplayInterface() | 389 | KPropertyValueDisplayInterface::~KPropertyValueDisplayInterface() | ||
445 | { | 390 | { | ||
446 | } | 391 | } | ||
392 | |