BALL
1.4.2
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
include
BALL
VIEW
WIDGETS
propertyEditor.h
Go to the documentation of this file.
1
#ifndef BALL_VIEW_WIDGETS_PROPERTYEDITOR_H
2
#define BALL_VIEW_WIDGETS_PROPERTYEDITOR_H
3
4
#ifndef BALL_COMMON_GLOBAL_H
5
# include <
BALL/COMMON/global.h
>
6
#endif
7
8
#ifndef BALL_DATATYPE_HASHMAP_H
9
# include <
BALL/DATATYPE/hashMap.h
>
10
#endif
11
12
#include <BALL/VIEW/UIC/ui_propertyEditor.h>
13
#include <BALL/VIEW/UIC/ui_propEditorWidget.h>
14
#include <BALL/VIEW/UIC/ui_editorPDBInfoDialog.h>
15
16
#ifndef BALL_FORMAT_PDBINFO_H
17
# include <
BALL/FORMAT/PDBInfo.h
>
18
#endif
19
20
#include <QtGui/QWidget>
21
22
class
QLabel;
23
class
QSpinBox;
24
class
QLineEdit
;
25
class
QCheckBox;
26
27
namespace
BALL
28
{
29
class
NamedProperty;
30
class
PropertyManager;
31
32
namespace
VIEW
33
{
38
class
PropEditorWidget
:
public
QWidget
39
{
40
Q_OBJECT
41
42
public
:
46
PropEditorWidget
(
const
std::string& name,
QWidget
* parent);
47
51
virtual
const
QString&
getName
()
const
;
52
56
void
setEditable
(
bool
mode);
57
61
bool
isEditable
()
const
;
62
70
void
apply
(
PropertyManager
* man,
bool
create =
false
);
71
75
void
reset
(
PropertyManager
* man);
76
81
virtual
PropEditorWidget
*
clone
(
const
std::string& name,
QWidget
* parent) = 0;
82
83
signals:
87
void
deleteProperty
();
88
92
void
duplicateProperty
();
93
97
void
valueChanged
();
98
99
protected
:
100
void
setupUi_
();
101
105
bool
addWidget_
(
int
i,
QWidget
* w);
106
111
virtual
void
apply_
(
PropertyManager
* man) = 0;
112
117
virtual
void
reset_
(
const
NamedProperty
& prop) = 0;
118
119
QString
name_
;
120
Ui::PropEditorWidget
ui_
;
121
};
122
123
class
BoolEditorWidget
:
public
PropEditorWidget
124
{
125
Q_OBJECT
126
127
public
:
128
BoolEditorWidget
(
const
NamedProperty
& prop,
QWidget
* parent);
129
virtual
BoolEditorWidget
*
clone
(
const
std::string& name,
QWidget
* parent);
130
131
protected
:
132
virtual
void
apply_
(
PropertyManager
* man);
133
virtual
void
reset_
(
const
NamedProperty
& prop);
134
135
private
:
136
QCheckBox*
box_
;
137
};
138
139
class
IntEditorWidget
:
public
PropEditorWidget
140
{
141
Q_OBJECT
142
143
public
:
144
IntEditorWidget
(
const
NamedProperty
& prop,
QWidget
* parent);
145
virtual
IntEditorWidget
*
clone
(
const
std::string& name,
QWidget
* parent);
146
147
protected
:
148
virtual
void
apply_
(
PropertyManager
* man);
149
virtual
void
reset_
(
const
NamedProperty
& prop);
150
151
152
private
:
153
QSpinBox*
box_
;
154
};
155
156
class
UIntEditorWidget
:
public
PropEditorWidget
157
{
158
Q_OBJECT
159
160
public
:
161
UIntEditorWidget
(
const
NamedProperty
& prop,
QWidget
* parent);
162
virtual
UIntEditorWidget
*
clone
(
const
std::string& name,
QWidget
* parent);
163
164
protected
:
165
virtual
void
apply_
(
PropertyManager
* man);
166
virtual
void
reset_
(
const
NamedProperty
& prop);
167
168
private
:
169
QSpinBox*
box_
;
170
};
171
172
class
FloatEditorWidget
:
public
PropEditorWidget
173
{
174
Q_OBJECT
175
176
public
:
177
FloatEditorWidget
(
const
NamedProperty
& prop,
QWidget
* parent);
178
virtual
FloatEditorWidget
*
clone
(
const
std::string& name,
QWidget
* parent);
179
180
protected
:
181
virtual
void
apply_
(
PropertyManager
* man);
182
virtual
void
reset_
(
const
NamedProperty
& prop);
183
184
private
:
185
QLineEdit
*
edit_
;
186
};
187
188
class
DoubleEditorWidget
:
public
PropEditorWidget
189
{
190
Q_OBJECT
191
192
public
:
193
DoubleEditorWidget
(
const
NamedProperty
& prop,
QWidget
* parent);
194
virtual
DoubleEditorWidget
*
clone
(
const
std::string& name,
QWidget
* parent);
195
196
protected
:
197
virtual
void
apply_
(
PropertyManager
* man);
198
virtual
void
reset_
(
const
NamedProperty
& prop);
199
200
private
:
201
QLineEdit
*
edit_
;
202
};
203
204
class
StringEditorWidget
:
public
PropEditorWidget
205
{
206
Q_OBJECT
207
208
public
:
209
StringEditorWidget
(
const
NamedProperty
& prop,
QWidget
* parent);
210
virtual
StringEditorWidget
*
clone
(
const
std::string& name,
QWidget
* parent);
211
212
protected
:
213
virtual
void
apply_
(
PropertyManager
* man);
214
virtual
void
reset_
(
const
NamedProperty
& prop);
215
216
private
:
217
QLineEdit
*
edit_
;
218
};
219
223
class
PropDeleteWidget
:
public
PropEditorWidget
224
{
225
public
:
226
PropDeleteWidget
(
const
NamedProperty
& prop,
QWidget
* parent)
227
:
PropEditorWidget
(prop.
getName
(), parent)
228
{
229
addWidget_
(1,
new
QLabel(tr(
"(not editable)"
),
this
));
230
ui_
.duplicate_button->setEnabled(
false
);
231
}
232
virtual
PropEditorWidget
*
clone
(
const
std::string&,
QWidget
*)
233
{
234
return
NULL;
235
}
236
protected
:
237
virtual
void
apply_
(
PropertyManager
*) {}
238
virtual
void
reset_
(
const
NamedProperty
&) {}
239
};
240
241
class
PDBInfoEditorWidget
:
public
PropEditorWidget
242
{
243
Q_OBJECT
244
245
public
:
246
PDBInfoEditorWidget
(
const
PDBInfo
& info,
QWidget
* parent);
247
virtual
PDBInfoEditorWidget
*
clone
(
const
std::string& name,
QWidget
* parent);
248
249
protected
slots:
250
void
startEditorDialog
();
251
252
protected
:
253
virtual
void
apply_
(
PropertyManager
* man);
254
virtual
void
reset_
(
const
NamedProperty
& prop);
255
256
private
:
257
// TODO: This should maybe become a generic TextEditor and not be as hackish.
258
class
EditorPDBInfoDialog
:
public
QDialog
{
259
public
:
260
EditorPDBInfoDialog
(
QWidget
* parent) :
QDialog
(parent)
261
{
262
ui_
.setupUi(
this
);
263
QFont mono(
"Monaco"
); mono.setStyleHint(QFont::TypeWriter);
264
ui_
.textEditor->setFont(mono);
265
}
266
protected
:
267
friend
class
PDBInfoEditorWidget
;
268
Ui::editorPDBInfoDialog
ui_
;
269
};
270
271
PDBInfo
localCopy_
;
272
EditorPDBInfoDialog
*
editorDialog_
;
273
};
274
281
class
BALL_VIEW_EXPORT
PropertyEditor
:
public
QWidget
282
{
283
Q_OBJECT
284
285
public
:
292
explicit
PropertyEditor
(
QWidget
* parent = 0,
bool
editable =
true
);
293
301
PropertyEditor
(
PropertyManager
* manager,
QWidget
* parent,
bool
editable =
true
);
302
308
void
setPropertyManager(
PropertyManager
* man);
309
313
void
setEditable(
bool
mode);
314
318
bool
isEditable()
const
;
319
323
bool
hasChanges()
const
;
324
325
public
slots:
329
void
apply();
330
334
void
reset();
335
336
signals:
340
void
valueChanged();
341
342
protected
:
343
void
setupUi_();
344
345
PropEditorWidget
* addProperty_(
const
NamedProperty
& prop);
346
PropEditorWidget
* addProperty_(
PropEditorWidget
* editor);
347
PropEditorWidget
* createEditorWidget_(
const
NamedProperty
& prop);
348
QString chooseName_(
const
QString& initial);
349
void
deleteProperty_(
PropEditorWidget
* editor);
350
351
protected
slots:
352
void
scheduleDelete_();
353
void
scheduleDuplicate_();
354
void
valueChanged_();
355
356
void
createNewBool_();
357
void
createNewInt_();
358
void
createNewUInt_();
359
void
createNewFloat_();
360
void
createNewDouble_();
361
void
createNewString_();
362
363
private
:
364
bool
has_changes_
;
365
bool
is_editable_
;
366
PropertyManager
*
manager_
;
367
QList<PropEditorWidget*>
new_properties_
;
368
QList<PropEditorWidget*>
deleted_properties_
;
369
370
Ui::PropertyEditor
ui_
;
371
};
372
373
}
374
}
375
376
#endif //BALL_VIEW_WIDGETS_PROPERTYEDITOR_H
Generated by
1.8.3.1