21#include <tqpopupmenu.h>
22#include <tqscrollview.h>
27#include <kgenericfactory.h>
30#include <kiconloader.h>
31#include <tdeactioncollection.h>
32#include <kstdaction.h>
34#include <formeditor/container.h>
35#include <formeditor/form.h>
36#include <formeditor/formIO.h>
37#include <formeditor/formmanager.h>
38#include <formeditor/objecttree.h>
39#include <formeditor/utils.h>
40#include <kexidb/utils.h>
41#include <kexidb/connection.h>
43#include <formeditor/widgetlibrary.h>
44#include <kexigradientwidget.h>
45#include <keximainwindow.h>
46#include <kexiutils/utils.h>
47#include <widget/kexicustompropertyfactory.h>
48#include <widget/utils/kexicontextmenuutils.h>
50#include "kexiformview.h"
51#include "widgets/kexidbautofield.h"
52#include "widgets/kexidbcheckbox.h"
53#include "widgets/kexidbimagebox.h"
56#include "widgets/kexiframe.h"
57#include "widgets/kexidblabel.h"
58#include "widgets/kexidblineedit.h"
59#include "widgets/kexidbtextedit.h"
60#include "widgets/kexidbcombobox.h"
61#include "widgets/kexipushbutton.h"
62#include "widgets/kexidbform.h"
63#include "widgets/kexidbsubform.h"
64#include "kexidataawarewidgetinfo.h"
66#include "kexidbfactory.h"
72KexiDBFactory::KexiDBFactory(TQObject *parent, const char *name, const TQStringList &)
77 wi->setPixmap( "form");
78 wi->setClassName( "KexiDBForm");
79 wi->setName(i18n( "Form"));
81 i18n( "Widget name. This string will be used to name widgets of this class. "
82 "It must _not_ contain white spaces and non latin1 characters.", "form"));
83 wi->setDescription(i18n( "A data-aware form widget"));
86#ifndef KEXI_NO_SUBFORM
88 wi->setPixmap( "subform");
89 wi->setClassName( "KexiDBSubForm");
91 wi->setName(i18n( "Sub Form"));
93 i18n( "Widget name. This string will be used to name widgets of this class. "
94 "It must _not_ contain white spaces and non latin1 characters.", "subForm"));
95 wi->setDescription(i18n( "A form widget included in another Form"));
102 wi->setPixmap( "lineedit");
103 wi->setClassName( "KexiDBLineEdit");
107 wi->setName(i18n( "Text Box"));
109 i18n( "Widget name. This string will be used to name widgets of this class. "
110 "It must _not_ contain white spaces and non latin1 characters.", "textBox"));
111 wi->setDescription(i18n( "A widget for entering and displaying text"));
116 wi->setPixmap( "textedit");
117 wi->setClassName( "KexiDBTextEdit");
121 wi->setName(i18n( "Text Editor"));
123 i18n( "Widget name. This string will be used to name widgets of this class. "
124 "It must _not_ contain white spaces and non latin1 characters.", "textEditor"));
125 wi->setDescription(i18n( "A multiline text editor"));
129 this, "containers", "TQFrame" );
130 wi->setPixmap( "frame");
131 wi->setClassName( "KexiFrame");
133 wi->setName(i18n( "Frame"));
135 i18n( "Widget name. This string will be used to name widgets of this class. "
136 "It must _not_ contain white spaces and non latin1 characters.", "frame"));
137 wi->setDescription(i18n( "A simple frame widget"));
141 this, "stdwidgets", "TQLabel" );
142 wi->setPixmap( "label");
143 wi->setClassName( "KexiDBLabel");
146 wi->setName(i18n( "Text Label", "Label"));
148 i18n( "Widget name. This string will be used to name widgets of this class. "
149 "It must _not_ contain white spaces and non latin1 characters.", "label"));
150 wi->setDescription(i18n( "A widget for displaying text"));
153#ifndef KEXI_NO_IMAGEBOX_WIDGET
155 this, "stdwidgets", "KexiPictureLabel" );
156 wi->setPixmap( "pixmaplabel");
157 wi->setClassName( "KexiDBImageBox");
160 wi->setName(i18n( "Image Box"));
162 i18n( "Widget name. This string will be used to name widgets of this class. "
163 "It must _not_ contain white spaces and non latin1 characters.", "image"));
164 wi->setDescription(i18n( "A widget for displaying images"));
169 setInternalProperty( "KexiDBImageBox", "dontStartEditingOnInserting", "1");
173#ifdef KEXI_DB_COMBOBOX_WIDGET
175 this, "stdwidgets", "KComboBox" );
176 wi->setPixmap( "combo");
177 wi->setClassName( "KexiDBComboBox");
179 wi->setName(i18n( "Combo Box"));
181 i18n( "Widget name. This string will be used to name widgets of this class. "
182 "It must _not_ contain white spaces and non latin1 characters.", "comboBox"));
183 wi->setDescription(i18n( "A combo box widget"));
188 wi->setPixmap( "check");
189 wi->setClassName( "KexiDBCheckBox");
191 wi->setName(i18n( "Check Box"));
193 i18n( "Widget name. This string will be used to name widgets of this class. "
194 "It must _not_ contain white spaces and non latin1 characters.", "checkBox"));
195 wi->setDescription(i18n( "A check box with text label"));
198#ifndef KEXI_NO_AUTOFIELD_WIDGET
200 wi->setPixmap( "autofield");
201 wi->setClassName( "KexiDBAutoField");
203 wi->setName(i18n( "Auto Field"));
205 i18n( "Widget name. This string will be used to name widgets of this class. "
206 "It must _not_ contain white spaces and non latin1 characters", "autoField"));
207 wi->setDescription(i18n( "A widget containing an automatically selected editor "
208 "and a label to edit the value of a database field of any type."));
282 this, "stdwidgets", "KPushButton");
284 wi->setName(i18n( "Command Button"));
286 i18n( "Widget name. This string will be used to name widgets of this class. "
287 "It must _not_ contain white spaces and non latin1 characters.", "button"));
288 wi->setDescription(i18n( "A command button to execute actions"));
291 m_propDesc[ "dataSource"] = i18n( "Data Source");
292 m_propDesc[ "formName"] = i18n( "Form Name");
293 m_propDesc[ "onClickAction"] = i18n( "On Click");
294 m_propDesc[ "onClickActionOption"] = i18n( "On Click Option");
295 m_propDesc[ "autoTabStops"] = i18n( "Auto Tab Order");
296 m_propDesc[ "shadowEnabled"] = i18n( "Shadow Enabled");
297 m_propDesc[ "on"] = i18n( "On: button", "On");
299 m_propDesc[ "widgetType"] = i18n( "Editor Type");
301 m_propValDesc[ "Auto"] = i18n( "AutoField editor's type", "Auto");
309 m_propValDesc[ "MultiLineText"] = i18n( "AutoField editor's type", "Multiline Text");
310 m_propValDesc[ "ComboBox"] = i18n( "AutoField editor's type", "Drop-Down List");
311 m_propValDesc[ "Image"] = i18n( "AutoField editor's type", "Image");
314 m_propDesc[ "autoCaption"] = i18n( "Auto Label");
315 m_propDesc[ "foregroundLabelColor"] = i18n( "Label Text Color");
316 m_propDesc[ "backgroundLabelColor"] = i18n( "(a property name, keep the text narrow!)",
317 "Label Background\nColor");
319 m_propDesc[ "labelPosition"] = i18n( "Label Position");
320 m_propValDesc[ "Left"] = i18n( "Label Position", "Left");
321 m_propValDesc[ "Top"] = i18n( "Label Position", "Top");
322 m_propValDesc[ "NoLabel"] = i18n( "Label Position", "No Label");
324 m_propDesc[ "sizeInternal"] = i18n( "Size");
326 m_propDesc[ "pixmapId"] = i18n( "Image");
327 m_propDesc[ "scaledContents"] = i18n( "Scaled Contents");
328 m_propDesc[ "keepAspectRatio"] = i18n( "Keep Aspect Ratio (short)", "Keep Ratio");
331 hideClass( "KexiPictureLabel");
332 hideClass( "KComboBox");
335 m_propDesc[ "frameColor"] = i18n( "Frame Color");
336 m_propDesc[ "dropDownButtonVisible"] =
337 i18n( "Drop-Down Button for Image Box Visible (a property name, keep the text narrow!)",
338 "Drop-Down\nButton Visible");
341 m_propValDesc[ "TristateDefault"] = i18n( "Tristate checkbox, default", "Default");
342 m_propValDesc[ "TristateOn"] = i18n( "Tristate checkbox, yes", "Yes");
343 m_propValDesc[ "TristateOff"] = i18n( "Tristate checkbox, no", "No");
346 m_propDesc[ "editable"] = i18n( "Editable combobox", "Editable");
349KexiDBFactory::~KexiDBFactory()
357 kexipluginsdbg << "KexiDBFactory::createWidget() " << this << endl;
360 TQString text( container-> form()-> library()->textForWidgetName(n, c) );
363 if(c == "KexiDBSubForm")
365 else if(c == "KexiDBLineEdit")
369 w->setCursor(TQCursor(TQt::ArrowCursor));
371 else if(c == "KexiDBTextEdit")
375 w->setCursor(TQCursor(TQt::ArrowCursor));
377 else if(c == "TQFrame" || c == "KexiFrame")
382 else if(c == "KexiDBLabel")
384#ifndef KEXI_NO_IMAGEBOX_WIDGET
385 else if(c == "KexiDBImageBox") {
390#ifndef KEXI_NO_AUTOFIELD_WIDGET
391 else if(c == "KexiDBAutoField")
394 else if(c == "KexiDBCheckBox")
396 else if(c == "KexiDBComboBox")
408 else if(c == "KPushButton" || c == "KexiPushButton")
418 if(classname == "TQPushButton" || classname == "KPushButton" || classname == "KexiPushButton")
421 m_assignAction->plug( menu );
424 else if(classname == "KexiDBImageBox")
427 imageBox->contextMenu()->updateActionsAvailability();
428 TDEActionCollection *ac = imageBox->contextMenu()->actionCollection();
429 TDEPopupMenu *subMenu = new TDEPopupMenu();
431 menu->insertItem(i18n( "&Image"), subMenu);
432 ac->action( "insert")->plug(subMenu);
433 ac->action( "file_save_as")->plug(subMenu);
434 subMenu->insertSeparator();
435 ac->action( "edit_cut")->plug(subMenu);
436 ac->action( "edit_copy")->plug(subMenu);
437 ac->action( "edit_paste")->plug(subMenu);
438 ac->action( "delete")->plug(subMenu);
439 if (ac->action( "properties")) {
440 subMenu->insertSeparator();
441 ac->action( "properties")->plug(subMenu);
451 m_assignAction = new TDEAction( i18n( "&Assign Action..."), SmallIconSet( "form_action"),
452 0, 0, 0, col, "widget_assign_action");
458 m_container = container;
459 if(classname == "KexiDBLineEdit")
463 KLineEdit *lineedit = static_cast<KLineEdit* >(w);
464 createEditor(classname, lineedit->text(), lineedit, container,
465 lineedit->geometry(), lineedit->alignment(), true);
468 if(classname == "KexiDBTextEdit")
472 KTextEdit *textedit = static_cast<KTextEdit* >(w);
473 createEditor(classname, textedit->text(), textedit, container,
474 textedit->geometry(), textedit->alignment(), true, true);
476 KTextEdit *ed = dynamic_cast<KTextEdit * >( editor(w) );
477 ed->setWrapPolicy(textedit->wrapPolicy());
478 ed->setWordWrap(textedit->wordWrap());
479 ed->setTabStopWidth(textedit->tabStopWidth());
480 ed->setWrapColumnOrWidth(textedit->wrapColumnOrWidth());
481 ed->setLinkUnderline(textedit->linkUnderline());
482 ed->setTextFormat(textedit->textFormat());
483 ed->setHScrollBarMode(textedit->hScrollBarMode());
484 ed->setVScrollBarMode(textedit->vScrollBarMode());
487 else if ( classname == "KexiDBLabel" ) {
490 if(label->textFormat() == RichText)
492 TQString text = label->text();
499 if ( classname == "KexiDBLabel" )
500 w->resize(w->sizeHint());
504 createEditor(classname, label->text(), label, container,
505 label->geometry(), label->alignment(),
506 false, label->alignment() & TQt::WordBreak );
510 else if (classname == "KexiDBSubForm") {
515 bool openingCancelled;
522 else if( (classname == "KexiDBDateEdit") || (classname == "KexiDBDateTimeEdit") || (classname == "KexiDBTimeEdit")
528 else if(classname == "KexiDBAutoField") {
532 createEditor(classname, label->text(), label, container, label->geometry(), label->alignment());
535 else if (classname == "KexiDBCheckBox") {
537 TQRect r( cb->geometry() );
538 r.setLeft( r.left() + 2 + cb->style().subRect( TQStyle::SR_CheckBoxIndicator, cb ).width() );
539 createEditor(classname, cb->text(), cb, container, r, TQt::AlignAuto);
542 else if(classname == "KexiDBImageBox") {
567TQValueList<TQCString>
570 TQValueList<TQCString> lst;
582 const TQCString& property, bool isTopLevel)
585 if (property== "dataSource" || property== "dataSourceMimeType") {
591 if(classname == "KexiPushButton") {
592 ok = property!= "isDragEnabled"
593#ifdef KEXI_NO_UNFINISHED
594 && property!= "onClickAction"
595 && property!= "onClickActionOption"
596 && property!= "iconSet"
597 && property!= "stdItem"
601 else if(classname == "KexiDBLineEdit")
602 ok = property!= "urlDropsEnabled"
603 && property!= "vAlign"
604#ifdef KEXI_NO_UNFINISHED
605 && property!= "inputMask"
606 && property!= "maxLength"
609 else if(classname == "KexiDBComboBox")
610 ok = property!= "autoCaption"
611 && property!= "labelPosition"
612 && property!= "widgetType"
613 && property!= "fieldTypeInternal"
614 && property!= "fieldCaptionInternal";
615 else if(classname == "KexiDBTextEdit")
616 ok = property!= "undoDepth"
617 && property!= "undoRedoEnabled"
618 && property!= "dragAutoScroll"
619 && property!= "overwriteMode"
620 && property!= "resizePolicy"
621 && property!= "autoFormatting"
622#ifdef KEXI_NO_UNFINISHED
626 else if(classname == "KexiDBSubForm")
627 ok = property!= "dragAutoScroll"
628 && property!= "resizePolicy"
629 && property!= "focusPolicy";
630 else if(classname == "KexiDBForm")
631 ok = property!= "iconText"
632 && property!= "geometry" ;
633 else if(classname == "KexiDBLabel")
634 ok = property!= "focusPolicy";
635 else if(classname == "KexiDBAutoField") {
636 if (!isTopLevel && property== "caption")
638 if (property== "fieldTypeInternal" || property== "fieldCaptionInternal"
640 || property== "widgetType")
642 ok = property!= "text";
644 else if (classname == "KexiDBImageBox") {
645 ok = property!= "font" && property!= "wordbreak";
647 else if(classname == "KexiDBCheckBox") {
651 ok = property!= "autoRepeat";
654 return ok && WidgetFactory::isPropertyVisibleInternal(classname, w, property, isTopLevel);
659 TQWidget *w, const TQCString& property)
663 if (property== "fieldTypeInternal" || property== "widgetType")
678 if(n == "KexiDBAutoField") {
692 if(classname == "KexiDBAutoField")
693 editor->setGeometry( static_cast<KexiDBAutoField* >(w)->label()->geometry() );
713#include "kexidbfactory.moc"
long Id_t long integer for unique identifying blobs
@ PixmapId Shared Kexi pixmap.
Universal "Auto Field" widget for Kexi forms.
Combo box widget for Kexi forms.
Kexi Factory (DB widgets + subform)
virtual TQValueList< TQCString > autoSaveProperties(const TQCString &classname)
virtual TQWidget * createWidget(const TQCString &classname, TQWidget *parent, const char *name, KFormDesigner::Container *container, int options=DefaultOptions) Creates a widget (and if needed a KFormDesigner::Container)
virtual bool startEditing(const TQCString &classname, TQWidget *w, KFormDesigner::Container *container)
virtual void resizeEditor(TQWidget *editor, TQWidget *widget, const TQCString &classname)
virtual bool previewWidget(const TQCString &, TQWidget *, KFormDesigner::Container *)
virtual bool createMenuActions(const TQCString &classname, TQWidget *w, TQPopupMenu *menu, KFormDesigner::Container *container)
virtual void createCustomActions(TDEActionCollection *col)
virtual bool changeText(const TQString &newText)
virtual bool isPropertyVisibleInternal(const TQCString &classname, TQWidget *w, const TQCString &property, bool isTopLevel)
virtual bool propertySetShouldBeReloadedAfterPropertyChange(const TQCString &classname, TQWidget *w, const TQCString &property) Sometimes property sets should be reloaded when a given property value changed.
void slotImageBoxIdChanged(long id)
virtual bool clearWidgetContent(const TQCString &classname, TQWidget *w)
A data-aware, editable image box.
void insertFromFile() Forces execution of "insert from file" action.
An extended, data-aware, read-only text label.
Line edit widget for Kexi forms.
Multiline edit widget for Kexi forms.
TQString typeName() const
virtual void clear()=0 clears item's data, so the data will contain NULL data
Frame widget for Kexi forms.
Kexi's main window interface This interface is implemented by KexiMainWindowImpl class.
virtual KexiDialogBase * openObject(KexiPart::Item *item, int viewMode, bool &openingCancelled, TQMap< TQString, TQString > *staticObjectArgs=0, TQString *errorMessage=0)=0 Opens object pointed by item in a view viewMode.
type * findParent(TQObject *o, const char *className)
|