00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qpopupmenu.h>
00022 #include <qscrollview.h>
00023 #include <qcursor.h>
00024 #include <qpainter.h>
00025 #include <qstyle.h>
00026
00027 #include <kgenericfactory.h>
00028 #include <klocale.h>
00029 #include <kdebug.h>
00030 #include <kiconloader.h>
00031 #include <kactioncollection.h>
00032 #include <kstdaction.h>
00033
00034 #include <formeditor/container.h>
00035 #include <formeditor/form.h>
00036 #include <formeditor/formIO.h>
00037 #include <formeditor/formmanager.h>
00038 #include <formeditor/objecttree.h>
00039 #include <formeditor/utils.h>
00040 #include <kexidb/utils.h>
00041 #include <kexidb/connection.h>
00042 #include <kexipart.h>
00043 #include <formeditor/widgetlibrary.h>
00044 #include <kexigradientwidget.h>
00045 #include <keximainwindow.h>
00046 #include <kexiutils/utils.h>
00047 #include <widget/kexicustompropertyfactory.h>
00048
00049 #include "kexiformview.h"
00050 #include "widgets/kexidbautofield.h"
00051 #include "widgets/kexidbcheckbox.h"
00052 #include "widgets/kexidbdateedit.h"
00053 #include "widgets/kexidbdatetimeedit.h"
00054 #include "widgets/kexidbdoublespinbox.h"
00055 #include "widgets/kexidbimagebox.h"
00056 #include "widgets/kexidbintspinbox.h"
00057 #include "widgets/kexiframe.h"
00058 #include "widgets/kexidblabel.h"
00059 #include "widgets/kexidblineedit.h"
00060 #include "widgets/kexidbtextedit.h"
00061 #include "widgets/kexidbtimeedit.h"
00062 #include "widgets/kexipushbutton.h"
00063 #include "widgets/kexidbform.h"
00064 #include "widgets/kexidbsubform.h"
00065 #include "kexidataawarewidgetinfo.h"
00066
00067 #include "kexidbfactory.h"
00068 #include <core/kexi.h>
00069
00070
00072
00073 KexiDBFactory::KexiDBFactory(QObject *parent, const char *name, const QStringList &)
00074 : KFormDesigner::WidgetFactory(parent, name)
00075 {
00076
00077 KexiDataAwareWidgetInfo *wView = new KexiDataAwareWidgetInfo(this);
00078 wView->setPixmap("form");
00079 wView->setClassName("KexiDBForm");
00080 wView->setName(i18n("Form"));
00081 wView->setNamePrefix(
00082 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "form"));
00083 wView->setDescription(i18n("A data-aware form widget"));
00084 addClass(wView);
00085
00086 #ifndef KEXI_NO_SUBFORM
00087 KexiDataAwareWidgetInfo *wSubForm = new KexiDataAwareWidgetInfo(this);
00088 wSubForm->setPixmap("subform");
00089 wSubForm->setClassName("KexiDBSubForm");
00090 wSubForm->addAlternateClassName("KexiSubForm", true);
00091 wSubForm->setName(i18n("Sub Form"));
00092 wSubForm->setNamePrefix(
00093 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "subForm"));
00094 wSubForm->setDescription(i18n("A form widget included in another Form"));
00095 wSubForm->setAutoSyncForProperty( "formName", false );
00096 addClass(wSubForm);
00097 #endif
00098 KFormDesigner::WidgetInfo *wi;
00099
00100
00101 wi = new KexiDataAwareWidgetInfo(this, "stdwidgets", "KLineEdit");
00102 wi->setPixmap("lineedit");
00103 wi->setClassName("KexiDBLineEdit");
00104 wi->addAlternateClassName("QLineEdit", true);
00105 wi->addAlternateClassName("KLineEdit", true);
00106 wi->setIncludeFileName("klineedit.h");
00107 wi->setName(i18n("Text Box"));
00108 wi->setNamePrefix(
00109 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "textBox"));
00110 wi->setDescription(i18n("A widget for entering and displaying text"));
00111 addClass(wi);
00112
00113
00114 wi = new KexiDataAwareWidgetInfo(this, "stdwidgets", "KTextEdit");
00115 wi->setPixmap("textedit");
00116 wi->setClassName("KexiDBTextEdit");
00117 wi->addAlternateClassName("QTextEdit", true);
00118 wi->addAlternateClassName("KTextEdit", true);
00119 wi->setIncludeFileName("ktextedit.h");
00120 wi->setName(i18n("Text Editor"));
00121 wi->setNamePrefix(
00122 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "textEditor"));
00123 wi->setDescription(i18n("A multiline text editor"));
00124 addClass(wi);
00125
00126 wi = new KFormDesigner::WidgetInfo(
00127 this, "containers", "QFrame" );
00128 wi->setPixmap("frame");
00129 wi->setClassName("KexiFrame");
00130 wi->addAlternateClassName("QFrame", true);
00131 wi->setName(i18n("Frame"));
00132 wi->setNamePrefix(
00133 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "frame"));
00134 wi->setDescription(i18n("A simple frame widget"));
00135 addClass(wi);
00136
00137 wi = new KexiDataAwareWidgetInfo(
00138 this, "stdwidgets", "QLabel" );
00139 wi->setPixmap("label");
00140 wi->setClassName("KexiDBLabel");
00141 wi->addAlternateClassName("QLabel", true);
00142 wi->addAlternateClassName("KexiLabel", true);
00143 wi->setName(i18n("Text Label", "Label"));
00144 wi->setNamePrefix(
00145 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "label"));
00146 wi->setDescription(i18n("A widget for displaying text"));
00147 addClass(wi);
00148
00149 #ifndef KEXI_NO_IMAGEBOX_WIDGET
00150 wi = new KexiDataAwareWidgetInfo(
00151 this, "stdwidgets", "KexiPictureLabel" );
00152 wi->setPixmap("pixmaplabel");
00153 wi->setClassName("KexiDBImageBox");
00154 wi->addAlternateClassName("KexiPictureLabel", true);
00155 wi->addAlternateClassName("KexiImageBox", true);
00156 wi->setName(i18n("Image Box"));
00157 wi->setNamePrefix(
00158 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "image"));
00159 wi->setDescription(i18n("A widget for displaying images"));
00160
00161 wi->setCustomTypeForProperty("pixmapId", KexiCustomPropertyFactory::PixmapId);
00162 addClass(wi);
00163
00164 setInternalProperty("KexiDBImageBox", "dontStartEditingOnInserting", "1");
00165
00166 #endif
00167
00168 wi = new KexiDataAwareWidgetInfo(this, "stdwidgets", "QCheckBox");
00169 wi->setPixmap("check");
00170 wi->setClassName("KexiDBCheckBox");
00171 wi->addAlternateClassName("QCheckBox", true);
00172 wi->setName(i18n("Check Box"));
00173 wi->setNamePrefix(
00174 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "checkBox"));
00175 wi->setDescription(i18n("A check box with text label"));
00176 addClass(wi);
00177
00178 #ifndef KEXI_NO_AUTOFIELD_WIDGET
00179 KexiDataAwareWidgetInfo *wFieldEdit = new KexiDataAwareWidgetInfo(this);
00180 wFieldEdit->setPixmap("edit");
00181 wFieldEdit->setClassName("KexiDBAutoField");
00182 wi->addAlternateClassName("KexiDBFieldEdit", true);
00183 wFieldEdit->setName(i18n("Auto Field"));
00184 wFieldEdit->setNamePrefix(
00185 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters", "autoField"));
00186 wFieldEdit->setDescription(i18n("A widget containing an automatically selected editor and a label to edit the value of a database field of any type."));
00187 addClass(wFieldEdit);
00188 #endif
00189
00190 #if KDE_VERSION >= KDE_MAKE_VERSION(3,1,9)
00191 KexiDataAwareWidgetInfo *wDate = new KexiDataAwareWidgetInfo(this, "stdwidgets", "KDateWidget");
00192 #else
00193 KexiDataAwareWidgetInfo *wDate = new KexiDataAwareWidgetInfo(this, "stdwidgets", "QDateEdit");
00194 #endif
00195 wDate->setPixmap("dateedit");
00196 wDate->setClassName("KexiDBDateEdit");
00197 wDate->addAlternateClassName("QDateEdit", true);
00198 wDate->addAlternateClassName("KDateWidget", true);
00199 wDate->setName(i18n("Date Widget"));
00200 wDate->setNamePrefix(
00201 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "dateWidget"));
00202 wDate->setDescription(i18n("A widget to input and display a date"));
00203 addClass(wDate);
00204
00205 #if KDE_VERSION >= KDE_MAKE_VERSION(3,1,9)
00206 KexiDataAwareWidgetInfo *wTime = new KexiDataAwareWidgetInfo(this, "stdwidgets", "KTimeWidget");
00207 #else
00208 KexiDataAwareWidgetInfo *wTime = new KexiDataAwareWidgetInfo(this, "stdwidgets", "QTimeEdit");
00209 #endif
00210 wTime->setPixmap("timeedit");
00211 wTime->setClassName("KexiDBTimeEdit");
00212 wTime->addAlternateClassName("QTimeEdit", true);
00213 wTime->addAlternateClassName("KTimeWidget", true);
00214 wTime->setName(i18n("Time Widget"));
00215 wTime->setNamePrefix(
00216 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "timeWidget"));
00217 wTime->setDescription(i18n("A widget to input and display a time"));
00218 addClass(wTime);
00219
00220 #if KDE_VERSION >= KDE_MAKE_VERSION(3,1,9)
00221 KexiDataAwareWidgetInfo *wDateTime = new KexiDataAwareWidgetInfo(this, "stdwidgets", "KDateTimeWidget");
00222 #else
00223 KexiDataAwareWidgetInfo *wDateTime = new KexiDataAwareWidgetInfo(this, "stdwidgets", "KDateTimeWidget");
00224 #endif
00225 wDateTime->setPixmap("datetimeedit");
00226 wDateTime->setClassName("KexiDBDateTimeEdit");
00227 wDateTime->addAlternateClassName("QDateTimeEdit", true);
00228 wDateTime->addAlternateClassName("KDateTimeWidget", true);
00229 wDateTime->setName(i18n("Date/Time Widget"));
00230 wDateTime->setNamePrefix(
00231 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "dateTimeWidget"));
00232 wDateTime->setDescription(i18n("A widget to input and display a date and time"));
00233 addClass(wDateTime);
00234
00235 KexiDataAwareWidgetInfo *wIntSpinBox = new KexiDataAwareWidgetInfo(this, "stdwidgets", "KIntSpinBox");
00236 wIntSpinBox->setPixmap("spin");
00237 wIntSpinBox->setClassName("KexiDBIntSpinBox");
00238 wIntSpinBox->addAlternateClassName("QSpinBox", true);
00239 wIntSpinBox->addAlternateClassName("KIntSpinBox", true);
00240 wIntSpinBox->setName(i18n("Integer Number Spin Box"));
00241 wIntSpinBox->setNamePrefix(
00242 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "intSpinBox"));
00243 wIntSpinBox->setDescription(i18n("A spin box widget to input and display integer numbers"));
00244 addClass(wIntSpinBox);
00245
00246 KexiDataAwareWidgetInfo *wDoubleSpinBox = new KexiDataAwareWidgetInfo(this, "stdwidgets");
00247 wDoubleSpinBox->setPixmap("spin");
00248 wDoubleSpinBox->setClassName("KexiDBDoubleSpinBox");
00249 wDoubleSpinBox->addAlternateClassName("KDoubleSpinBox", true);
00250 wDoubleSpinBox->setName(i18n("Floating-point Number Spin Box"));
00251 wDoubleSpinBox->setNamePrefix(
00252 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "dblSpinBox"));
00253 wDoubleSpinBox->setDescription(i18n("A spin box widget to input and display floating-point numbers"));
00254 addClass(wDoubleSpinBox);
00255
00256
00257 wi = new KFormDesigner::WidgetInfo(
00258 this, "stdwidgets", "KPushButton");
00259 wi->addAlternateClassName("KexiPushButton");
00260 wi->setName(i18n("Command Button"));
00261 wi->setNamePrefix(
00262 i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "button"));
00263 wi->setDescription(i18n("A command button to execute actions"));
00264 addClass(wi);
00265
00266 m_propDesc["dataSource"] = i18n("Data Source");
00267 m_propDesc["formName"] = i18n("Form Name");
00268 m_propDesc["onClickAction"] = i18n("On Click");
00269 m_propDesc["autoTabStops"] = i18n("Auto Tab Stops");
00270 m_propDesc["shadowEnabled"] = i18n("Shadow Enabled");
00271
00272 m_propDesc["widgetType"] = i18n("Editor Type");
00273
00274 m_propValDesc["Auto"] = i18n("AutoField editor's type", "Auto");
00275 m_propValDesc["Text"] = KexiDB::Field::typeName(KexiDB::Field::Text);
00276 m_propValDesc["Integer"] = KexiDB::Field::typeName(KexiDB::Field::Integer);
00277 m_propValDesc["Double"] = KexiDB::Field::typeName(KexiDB::Field::Double);
00278 m_propValDesc["Boolean"] = KexiDB::Field::typeName(KexiDB::Field::Boolean);
00279 m_propValDesc["Date"] = KexiDB::Field::typeName(KexiDB::Field::Date);
00280 m_propValDesc["Time"] = KexiDB::Field::typeName(KexiDB::Field::Time);
00281 m_propValDesc["DateTime"] = KexiDB::Field::typeName(KexiDB::Field::DateTime);
00282 m_propValDesc["MultiLineText"] = i18n("AutoField editor's type", "Multiline Text");
00283 m_propValDesc["Enum"] = i18n("AutoField editor's type", "List of Values");
00284 m_propValDesc["Image"] = i18n("AutoField editor's type", "Image");
00285
00286
00287 m_propDesc["autoCaption"] = i18n("Auto Label");
00288
00289 m_propDesc["labelPosition"] = i18n("Label Position");
00290 m_propValDesc["Left"] = i18n("Label Position", "Left");
00291 m_propValDesc["Top"] = i18n("Label Position", "Top");
00292 m_propValDesc["NoLabel"] = i18n("Label Position", "No Label");
00293
00294 m_propDesc["sizeInternal"] = i18n("Size");
00295
00296 m_propDesc["pixmapId"] = i18n("Image");
00297 m_propDesc["scaledContents"] = i18n("Scaled Contents");
00298 m_propDesc["keepAspectRatio"] = i18n("Keep Aspect Ratio (short)", "Keep Ratio");
00299
00300 #ifdef KEXI_NO_UNFINISHED
00301
00302 hideClass("KexiPictureLabel");
00303
00304 hideClass("KComboBox");
00305 #endif
00306
00307
00308 m_propDesc["frameColor"] = i18n("Frame Color");
00309 }
00310
00311 KexiDBFactory::~KexiDBFactory()
00312 {
00313 }
00314
00315 QWidget*
00316 KexiDBFactory::createWidget(const QCString &c, QWidget *p, const char *n,
00317 KFormDesigner::Container *container, int options)
00318 {
00319 kexipluginsdbg << "KexiDBFactory::createWidget() " << this << endl;
00320
00321 QWidget *w=0;
00322 QString text( container->form()->library()->textForWidgetName(n, c) );
00323 const bool designMode = options & KFormDesigner::WidgetFactory::DesignViewMode;
00324
00325 if(c == "KexiDBSubForm")
00326 w = new KexiDBSubForm(container->form(), p, n);
00327 else if(c == "KexiDBLineEdit")
00328 {
00329 w = new KexiDBLineEdit(p, n);
00330 if (designMode)
00331 w->setCursor(QCursor(Qt::ArrowCursor));
00332 }
00333 else if(c == "KexiDBTextEdit")
00334 {
00335 w = new KexiDBTextEdit(p, n);
00336 if (designMode)
00337 w->setCursor(QCursor(Qt::ArrowCursor));
00338 }
00339 else if(c == "QFrame" || c == "KexiFrame")
00340 {
00341 w = new KexiFrame(p, n);
00342 new KFormDesigner::Container(container, w, container);
00343 }
00344 else if(c == "KexiDBLabel")
00345 w = new KexiDBLabel(text, p, n);
00346 #ifndef KEXI_NO_IMAGEBOX_WIDGET
00347 else if(c == "KexiDBImageBox") {
00348 w = new KexiDBImageBox(designMode, p, n);
00349 connect(w, SIGNAL(idChanged(long)), this, SLOT(slotImageBoxIdChanged(long)));
00350 }
00351 #endif
00352 #ifndef KEXI_NO_AUTOFIELD_WIDGET
00353 else if(c == "KexiDBAutoField")
00354 w = new KexiDBAutoField(p, n, designMode);
00355 #endif
00356 else if(c == "KexiDBCheckBox")
00357 w = new KexiDBCheckBox(text, p, n);
00358 else if(c == "KexiDBTimeEdit")
00359 w = new KexiDBTimeEdit(QTime::currentTime(), p, n);
00360 else if(c == "KexiDBDateEdit")
00361 w = new KexiDBDateEdit(QDate::currentDate(), p, n);
00362 else if(c == "KexiDBDateTimeEdit")
00363 w = new KexiDBDateTimeEdit(QDateTime::currentDateTime(), p, n);
00364 else if(c == "KexiDBIntSpinBox")
00365 w = new KexiDBIntSpinBox(p, n);
00366 else if(c == "KexiDBDoubleSpinBox")
00367 w = new KexiDBDoubleSpinBox(p, n);
00368 else if(c == "KPushButton" || c == "KexiPushButton")
00369 w = new KexiPushButton(text, p, n);
00370
00371 return w;
00372 }
00373
00374 bool
00375 KexiDBFactory::createMenuActions(const QCString &classname, QWidget *w, QPopupMenu *menu,
00376 KFormDesigner::Container *)
00377 {
00378 if(classname == "QPushButton" || classname == "KPushButton" || classname == "KexiPushButton")
00379 {
00381 m_assignAction->plug( menu );
00382 return true;
00383 }
00384 else if(classname == "KexiDBImageBox")
00385 {
00386 KexiDBImageBox *imageBox = static_cast<KexiDBImageBox*>(w);
00387 imageBox->updateActionsAvailability();
00388 KActionCollection *ac = imageBox->actionCollection();
00389 KPopupMenu *subMenu = new KPopupMenu();
00391 menu->insertItem(i18n("&Image"), subMenu);
00392 ac->action("insert")->plug(subMenu);
00393 ac->action("file_save_as")->plug(subMenu);
00394 subMenu->insertSeparator();
00395 ac->action("edit_cut")->plug(subMenu);
00396 ac->action("edit_copy")->plug(subMenu);
00397 ac->action("edit_paste")->plug(subMenu);
00398 ac->action("delete")->plug(subMenu);
00399 if (ac->action("properties")) {
00400 subMenu->insertSeparator();
00401 ac->action("properties")->plug(subMenu);
00402 }
00403 }
00404 return false;
00405 }
00406
00407 void
00408 KexiDBFactory::createCustomActions(KActionCollection* col)
00409 {
00410
00411 m_assignAction = new KAction( i18n("Assign Action..."), SmallIconSet("form_action"),
00412 0, 0, 0, col, "widget_assign_action");
00413 }
00414
00415 bool
00416 KexiDBFactory::startEditing(const QCString &classname, QWidget *w, KFormDesigner::Container *container)
00417 {
00418 m_container = container;
00419 if(classname == "KexiDBLineEdit")
00420 {
00423 KLineEdit *lineedit = static_cast<KLineEdit*>(w);
00424 createEditor(classname, lineedit->text(), lineedit, container,
00425 lineedit->geometry(), lineedit->alignment(), true);
00426 return true;
00427 }
00428 if(classname == "KexiDBTextEdit")
00429 {
00432 KTextEdit *textedit = static_cast<KTextEdit*>(w);
00433 createEditor(classname, textedit->text(), textedit, container,
00434 textedit->geometry(), textedit->alignment(), true, true);
00435
00436 KTextEdit *ed = dynamic_cast<KTextEdit *>( editor(w) );
00437 ed->setWrapPolicy(textedit->wrapPolicy());
00438 ed->setWordWrap(textedit->wordWrap());
00439 ed->setTabStopWidth(textedit->tabStopWidth());
00440 ed->setWrapColumnOrWidth(textedit->wrapColumnOrWidth());
00441 ed->setLinkUnderline(textedit->linkUnderline());
00442 ed->setTextFormat(textedit->textFormat());
00443 ed->setHScrollBarMode(textedit->hScrollBarMode());
00444 ed->setVScrollBarMode(textedit->vScrollBarMode());
00445 return true;
00446 }
00447 else if ( classname == "KexiDBLabel" ) {
00448 KexiDBLabel *label = static_cast<KexiDBLabel*>(w);
00449 m_widget = w;
00450 if(label->textFormat() == RichText)
00451 {
00452 QString text = label->text();
00453 if ( editRichText( label, text ) )
00454 {
00455 changeProperty( "textFormat", "RichText", container->form() );
00456 changeProperty( "text", text, container->form() );
00457 }
00458
00459 if ( classname == "KexiDBLabel" )
00460 w->resize(w->sizeHint());
00461 }
00462 else
00463 {
00464 createEditor(classname, label->text(), label, container,
00465 label->geometry(), label->alignment(),
00466 false, label->alignment() & Qt::WordBreak );
00467 }
00468 return true;
00469 }
00470 else if (classname == "KexiDBSubForm") {
00471
00472 KexiMainWindow *mainWin = KexiUtils::findParent<KexiMainWindow>(w, "KexiMainWindow");
00473 KexiDBSubForm *subform = static_cast<KexiDBSubForm*>(w);
00474 if(mainWin) {
00475 bool openingCancelled;
00476 mainWin->openObject("kexi/form", subform->formName(), Kexi::DesignViewMode,
00477 openingCancelled);
00478 }
00479 return true;
00480 }
00481 else if( (classname == "KexiDBDateEdit") || (classname == "KexiDBDateTimeEdit") || (classname == "KexiDBTimeEdit")
00482 || (classname == "KexiDBIntSpinBox") || (classname == "KexiDBDoubleSpinBox") ) {
00483 disableFilter(w, container);
00484 return true;
00485 }
00486 else if(classname == "KexiDBAutoField") {
00487 if(static_cast<KexiDBAutoField*>(w)->hasAutoCaption())
00488 return false;
00489 QLabel *label = static_cast<KexiDBAutoField*>(w)->label();
00490 createEditor(classname, label->text(), label, container, label->geometry(), label->alignment());
00491 return true;
00492 }
00493 else if (classname == "KexiDBCheckBox") {
00494 KexiDBCheckBox *cb = static_cast<KexiDBCheckBox*>(w);
00495 QRect r( cb->geometry() );
00496 r.setLeft( r.left() + 2 + cb->style().subRect( QStyle::SR_CheckBoxIndicator, cb ).width() );
00497 createEditor(classname, cb->text(), cb, container, r, Qt::AlignAuto);
00498 return true;
00499 }
00500 else if(classname == "KexiDBImageBox") {
00501 KexiDBImageBox *image = static_cast<KexiDBImageBox*>(w);
00502 image->insertFromFile();
00503 return true;
00504 }
00505 return false;
00506 }
00507
00508 bool
00509 KexiDBFactory::previewWidget(const QCString &, QWidget *, KFormDesigner::Container *)
00510 {
00511 return false;
00512 }
00513
00514 bool
00515 KexiDBFactory::clearWidgetContent(const QCString & , QWidget *w)
00516 {
00519 KexiFormDataItemInterface *iface = dynamic_cast<KexiFormDataItemInterface*>(w);
00520 if(iface)
00521 iface->clear();
00522 return true;
00523 }
00524
00525 QValueList<QCString>
00526 KexiDBFactory::autoSaveProperties(const QCString & )
00527 {
00528 QValueList<QCString> lst;
00529
00530
00531
00532
00533
00534
00535 return lst;
00536 }
00537
00538 bool
00539 KexiDBFactory::isPropertyVisibleInternal(const QCString& classname, QWidget *w,
00540 const QCString& property, bool isTopLevel)
00541 {
00542
00543 if (property=="dataSource" || property=="dataSourceMimeType") {
00544 return false;
00545 }
00546
00547 bool ok = true;
00548
00549 if(classname == "KexiPushButton") {
00550 ok = property!="isDragEnabled"
00551 #ifdef KEXI_NO_UNFINISHED
00552 && property!="onClickAction"
00553 && property!="iconSet"
00554 && property!="stdItem"
00555 #endif
00556 ;
00557 }
00558 else if(classname == "KexiDBLineEdit")
00559 ok = property!="urlDropsEnabled"
00560 && property != "vAlign"
00561 #ifdef KEXI_NO_UNFINISHED
00562 && property!="inputMask"
00563 && property!="maxLength"
00564 #endif
00565 ;
00566 else if(classname == "KexiDBTextEdit")
00567 ok = property!="undoDepth"
00568 && property!="undoRedoEnabled"
00569 && property!="dragAutoScroll"
00570 && property!="overwriteMode"
00571 && property!="resizePolicy"
00572 && property!="autoFormatting"
00573 #ifdef KEXI_NO_UNFINISHED
00574 && property!="paper"
00575 #endif
00576 ;
00577 else if(classname == "KexiDBSubForm")
00578 ok = property!="dragAutoScroll"
00579 && property!="resizePolicy"
00580 && property!="focusPolicy";
00581 else if(classname == "KexiDBForm")
00582 ok = property!="iconText"
00583 && property!="geometry" ;
00584 else if(classname == "KexiDBLabel")
00585 ok = property!="focusPolicy";
00586 else if(classname == "KexiDBAutoField") {
00587 if (!isTopLevel && property=="caption")
00588 return true;
00589 if (property=="fieldTypeInternal" || property=="fieldCaptionInternal")
00590 return false;
00591 }
00592 else if (classname == "KexiDBImageBox") {
00593 ok = property!="font" && property!="wordbreak";
00594 }
00595
00596 return ok && WidgetFactory::isPropertyVisibleInternal(classname, w, property, isTopLevel);
00597 }
00598
00599 bool
00600 KexiDBFactory::changeText(const QString &text)
00601 {
00602 KFormDesigner::Form *form = m_container ? m_container->form() : 0;
00603 if (!form)
00604 return false;
00605 if (!form->selectedWidget())
00606 return false;
00607 QCString n( form->selectedWidget()->className() );
00608
00609 if(n == "KexiDBAutoField") {
00610 changeProperty("caption", text, form);
00611 return true;
00612 }
00614 return false;
00615 }
00616
00617 void
00618 KexiDBFactory::resizeEditor(QWidget *editor, QWidget *w, const QCString &classname)
00619 {
00620
00621
00622
00623 if(classname == "KexiDBAutoField")
00624 editor->setGeometry( static_cast<KexiDBAutoField*>(w)->label()->geometry() );
00625 }
00626
00627 void
00628 KexiDBFactory::slotImageBoxIdChanged(KexiBLOBBuffer::Id_t id)
00629 {
00630
00631
00632
00633 KFormDesigner::Form *form = KFormDesigner::FormManager::self()->activeForm();
00634 KexiFormView *formView = form ? KexiUtils::findParent<KexiFormView>((QWidget*)form->widget(), "KexiFormView") : 0;
00635 if (formView) {
00636 changeProperty("pixmapId", (uint)id, form);
00637
00638 formView->setUnsavedLocalBLOB(form->selectedWidget(), id);
00639 }
00640 }
00641
00642 KFORMDESIGNER_WIDGET_FACTORY(KexiDBFactory, kexidbwidgets)
00643
00644 #include "kexidbfactory.moc"