kexi
kexipropertyeditorview.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kexipropertyeditorview.h"
00022 #include "keximainwindow.h"
00023 #include <koproperty/set.h>
00024 #include <koproperty/editor.h>
00025 #include <koproperty/property.h>
00026
00027 #include <klocale.h>
00028 #include <kiconloader.h>
00029
00030 #include <qlayout.h>
00031 #include <qlabel.h>
00032
00033 KexiObjectInfoLabel::KexiObjectInfoLabel(QWidget* parent, const char* name)
00034 : QWidget(parent, name)
00035 {
00036 QHBoxLayout *hlyr = new QHBoxLayout(this);
00037 m_objectIconLabel = new QLabel(this);
00038 m_objectIconLabel->setMargin(2);
00039 setFixedHeight( IconSize(KIcon::Small) + 2 + 2 );
00040 hlyr->addWidget(m_objectIconLabel);
00041 m_objectNameLabel = new QLabel(this);
00042 m_objectNameLabel->setMargin(2);
00043 m_objectNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
00044 hlyr->addWidget(m_objectNameLabel);
00045 }
00046
00047 KexiObjectInfoLabel::~KexiObjectInfoLabel()
00048 {
00049 }
00050
00051 void KexiObjectInfoLabel::setObjectClassIcon(const QCString& name)
00052 {
00053 m_classIcon = name;
00054 if (m_classIcon.isEmpty())
00055 m_objectIconLabel->setFixedWidth( 0 );
00056 else
00057 m_objectIconLabel->setFixedWidth( IconSize(KIcon::Small) + 2 + 2 );
00058 m_objectIconLabel->setPixmap( SmallIcon(name) );
00059 }
00060
00061 void KexiObjectInfoLabel::setObjectClassName(const QString& name)
00062 {
00063 m_className = name;
00064 updateName();
00065 }
00066
00067 void KexiObjectInfoLabel::setObjectName(const QCString& name)
00068 {
00069 m_objectName = name;
00070 updateName();
00071 }
00072
00073 void KexiObjectInfoLabel::updateName()
00074 {
00075 QString txt = m_className;
00076 if (!m_objectName.isEmpty())
00077 txt += QString(" \"%1\"").arg(m_objectName);
00078 m_objectNameLabel->setText(txt);
00079 }
00080
00081
00082
00084 class KexiPropertyEditorView::Private
00085 {
00086 public:
00087 Private()
00088 {
00089 }
00090 KoProperty::Editor *editor;
00091
00092
00093
00094 KexiObjectInfoLabel *objectInfoLabel;
00095 };
00096
00097
00098
00099 KexiPropertyEditorView::KexiPropertyEditorView(KexiMainWindow *mainWin, QWidget* parent)
00100 : QWidget(parent, "KexiPropertyEditorView")
00101 , d(new Private())
00102 {
00103 setCaption(i18n("Properties"));
00104
00105 setIcon(*mainWin->icon());
00106
00107 QVBoxLayout *lyr = new QVBoxLayout(this);
00108
00109
00110 d->objectInfoLabel = new KexiObjectInfoLabel(this, "KexiObjectInfoLabel");
00111 lyr->addWidget(d->objectInfoLabel);
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 d->editor = new KoProperty::Editor(this, true , "propeditor");
00125 lyr->addWidget(d->editor);
00126 setFocusProxy(d->editor);
00127
00128 connect(d->editor, SIGNAL(propertySetChanged(KoProperty::Set*)),
00129 this, SLOT(slotPropertySetChanged(KoProperty::Set*)));
00130
00131
00132 slotPropertySetChanged(0);
00133 }
00134
00135 KexiPropertyEditorView::~KexiPropertyEditorView()
00136 {
00137 delete d;
00138 }
00139
00140 QSize KexiPropertyEditorView::sizeHint() const
00141 {
00142 return QSize(200,200);
00143 }
00144
00145 QSize KexiPropertyEditorView::minimumSizeHint() const
00146 {
00147 return QSize(200,200);
00148 }
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 KoProperty::Editor *KexiPropertyEditorView::editor() const
00161 {
00162 return d->editor;
00163 }
00164
00165 void KexiPropertyEditorView::slotPropertySetChanged(KoProperty::Set* set)
00166 {
00167
00168 QString className;
00169 QCString iconName, objectName;
00170 if (set) {
00171 if (set->contains("this:classString"))
00172 className = (*set)["this:classString"].value().toString();
00173 if (set->contains("this:iconName"))
00174 iconName = (*set)["this:iconName"].value().toCString();
00175 if (set->contains("name"))
00176 objectName = (*set)["name"].value().toCString();
00177 }
00178
00179 if (className.isEmpty()) {
00180 d->objectInfoLabel->hide();
00181 }
00182 else {
00183 d->objectInfoLabel->show();
00184 }
00185
00186 if (d->objectInfoLabel->objectClassName() == className
00187 && d->objectInfoLabel->objectClassIcon() == iconName
00188 && d->objectInfoLabel->objectName() == objectName)
00189 return;
00190
00191 d->objectInfoLabel->setObjectClassIcon(iconName);
00192 d->objectInfoLabel->setObjectClassName(className);
00193 d->objectInfoLabel->setObjectName(objectName);
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 }
00216
00217 #include "kexipropertyeditorview.moc"
|