00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#ifndef PURE_QT
00020
#include <klocale.h>
00021
#include <kdebug.h>
00022
#else
00023
#include "qlocale.h"
00024
#endif
00025
00026
#include <qtable.h>
00027
#include <qlayout.h>
00028
00029
#include "propertyeditor.h"
00030
#include "property.h"
00031
00032 PropertyEditor::PropertyEditor(
QWidget * parent,
const char * name, WFlags f):
00033
QWidget(parent, name, f)
00034 {
00035
kdDebug() <<
"Creating property editor" <<
endl;
00036
00037
00038
00039
table =
new QTable(
this);
00040
table->setNumRows(0);
00041
table->setNumCols(2);
00042
table->horizontalHeader()->setLabel(0, i18n(
"Property"));
00043
table->horizontalHeader()->setLabel(1, i18n(
"Value"));
00044
table->setLeftMargin(0);
00045
table->setColumnReadOnly(0, TRUE);
00046
00047
QGridLayout *gl =
new QGridLayout(
this);
00048 gl->addWidget(
table, 0, 0);
00049
00050
props = 0;
00051 }
00052
00053
00054 PropertyEditor::~PropertyEditor(){
00055 }
00056
00057 void PropertyEditor::populateProperties(
QMap<QString, PropPtr > *v_props)
00058 {
00059
table->hide();
00060
props = v_props;
00061
00062
table->setNumRows(0);
00063
00064
for (
QMap<QString, PropPtr >::const_iterator it =
props->begin(); it !=
props->end(); ++it)
00065 {
00066
int row =
table->numRows() + 1;
00067
table->setNumRows(row);
00068
00069
table->setText(row-1, 0, it.key());
00070
00071
QWidget *w = it.data()->editorOfType(
this);
00072
table->setCellWidget(row-1, 1, w);
00073 }
00074
table->show();
00075 }
00076
00077 void PropertyEditor::clearProperties()
00078 {
00079
props->clear();
00080
delete props;
00081
props = 0;
00082
table->setNumRows(0);
00083 }
00084
00085 void PropertyEditor::emitPropertyChange(
QString name,
QVariant newValue)
00086 {
00087 qWarning(
"editor: assign %s to %s", name.latin1(), newValue.toString().latin1());
00088 emit
propertyChanged(name, newValue);
00089 }
00090
00091
#include "propertyeditor.moc"