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."));
270 this, "stdwidgets", "KPushButton");
272 wi->setName(i18n( "Command Button"));
274 i18n( "Widget name. This string will be used to name widgets of this class. "
275 "It must _not_ contain white spaces and non latin1 characters.", "button"));
276 wi->setDescription(i18n( "A command button to execute actions"));
279 m_propDesc[ "dataSource"] = i18n( "Data Source");
280 m_propDesc[ "formName"] = i18n( "Form Name");
281 m_propDesc[ "onClickAction"] = i18n( "On Click");
282 m_propDesc[ "onClickActionOption"] = i18n( "On Click Option");
283 m_propDesc[ "autoTabStops"] = i18n( "Auto Tab Order");
284 m_propDesc[ "shadowEnabled"] = i18n( "Shadow Enabled");
285 m_propDesc[ "on"] = i18n( "On: button", "On");
287 m_propDesc[ "widgetType"] = i18n( "Editor Type");
289 m_propValDesc[ "Auto"] = i18n( "AutoField editor's type", "Auto");
297 m_propValDesc[ "MultiLineText"] = i18n( "AutoField editor's type", "Multiline Text");
298 m_propValDesc[ "ComboBox"] = i18n( "AutoField editor's type", "Drop-Down List");
299 m_propValDesc[ "Image"] = i18n( "AutoField editor's type", "Image");
302 m_propDesc[ "autoCaption"] = i18n( "Auto Label");
303 m_propDesc[ "foregroundLabelColor"] = i18n( "Label Text Color");
304 m_propDesc[ "backgroundLabelColor"] = i18n( "(a property name, keep the text narrow!)",
305 "Label Background\nColor");
307 m_propDesc[ "labelPosition"] = i18n( "Label Position");
308 m_propValDesc[ "Left"] = i18n( "Label Position", "Left");
309 m_propValDesc[ "Top"] = i18n( "Label Position", "Top");
310 m_propValDesc[ "NoLabel"] = i18n( "Label Position", "No Label");
312 m_propDesc[ "sizeInternal"] = i18n( "Size");
314 m_propDesc[ "pixmapId"] = i18n( "Image");
315 m_propDesc[ "scaledContents"] = i18n( "Scaled Contents");
316 m_propDesc[ "keepAspectRatio"] = i18n( "Keep Aspect Ratio (short)", "Keep Ratio");
319 hideClass( "KexiPictureLabel");
320 hideClass( "KComboBox");
323 m_propDesc[ "frameColor"] = i18n( "Frame Color");
324 m_propDesc[ "dropDownButtonVisible"] =
325 i18n( "Drop-Down Button for Image Box Visible (a property name, keep the text narrow!)",
326 "Drop-Down\nButton Visible");
329 m_propValDesc[ "TristateDefault"] = i18n( "Tristate checkbox, default", "Default");
330 m_propValDesc[ "TristateOn"] = i18n( "Tristate checkbox, yes", "Yes");
331 m_propValDesc[ "TristateOff"] = i18n( "Tristate checkbox, no", "No");
334 m_propDesc[ "editable"] = i18n( "Editable combobox", "Editable");
337KexiDBFactory::~KexiDBFactory()
345 kexipluginsdbg << "KexiDBFactory::createWidget() " << this << endl;
348 TQString text( container-> form()-> library()->textForWidgetName(n, c) );
351 if(c == "KexiDBSubForm")
353 else if(c == "KexiDBLineEdit")
357 w->setCursor(TQCursor(TQt::ArrowCursor));
359 else if(c == "KexiDBTextEdit")
363 w->setCursor(TQCursor(TQt::ArrowCursor));
365 else if(c == "TQFrame" || c == "KexiFrame")
370 else if(c == "KexiDBLabel")
372#ifndef KEXI_NO_IMAGEBOX_WIDGET
373 else if(c == "KexiDBImageBox") {
378#ifndef KEXI_NO_AUTOFIELD_WIDGET
379 else if(c == "KexiDBAutoField")
382 else if(c == "KexiDBCheckBox")
384 else if(c == "KexiDBComboBox")
396 else if(c == "KPushButton" || c == "KexiPushButton")
406 if(classname == "TQPushButton" || classname == "KPushButton" || classname == "KexiPushButton")
409 m_assignAction->plug( menu );
412 else if(classname == "KexiDBImageBox")
415 imageBox->contextMenu()->updateActionsAvailability();
416 TDEActionCollection *ac = imageBox->contextMenu()->actionCollection();
417 TDEPopupMenu *subMenu = new TDEPopupMenu();
419 menu->insertItem(i18n( "&Image"), subMenu);
420 ac->action( "insert")->plug(subMenu);
421 ac->action( "file_save_as")->plug(subMenu);
422 subMenu->insertSeparator();
423 ac->action( "edit_cut")->plug(subMenu);
424 ac->action( "edit_copy")->plug(subMenu);
425 ac->action( "edit_paste")->plug(subMenu);
426 ac->action( "delete")->plug(subMenu);
427 if (ac->action( "properties")) {
428 subMenu->insertSeparator();
429 ac->action( "properties")->plug(subMenu);
439 m_assignAction = new TDEAction( i18n( "&Assign Action..."), SmallIconSet( "form_action"),
440 0, 0, 0, col, "widget_assign_action");
446 m_container = container;
447 if(classname == "KexiDBLineEdit")
451 KLineEdit *lineedit = static_cast<KLineEdit* >(w);
452 createEditor(classname, lineedit->text(), lineedit, container,
453 lineedit->geometry(), lineedit->alignment(), true);
456 if(classname == "KexiDBTextEdit")
460 KTextEdit *textedit = static_cast<KTextEdit* >(w);
461 createEditor(classname, textedit->text(), textedit, container,
462 textedit->geometry(), textedit->alignment(), true, true);
464 KTextEdit *ed = dynamic_cast<KTextEdit * >( editor(w) );
465 ed->setWrapPolicy(textedit->wrapPolicy());
466 ed->setWordWrap(textedit->wordWrap());
467 ed->setTabStopWidth(textedit->tabStopWidth());
468 ed->setWrapColumnOrWidth(textedit->wrapColumnOrWidth());
469 ed->setLinkUnderline(textedit->linkUnderline());
470 ed->setTextFormat(textedit->textFormat());
471 ed->setHScrollBarMode(textedit->hScrollBarMode());
472 ed->setVScrollBarMode(textedit->vScrollBarMode());
475 else if ( classname == "KexiDBLabel" ) {
478 if(label->textFormat() == RichText)
480 TQString text = label->text();
487 if ( classname == "KexiDBLabel" )
488 w->resize(w->sizeHint());
492 createEditor(classname, label->text(), label, container,
493 label->geometry(), label->alignment(),
494 false, label->alignment() & TQt::WordBreak );
498 else if (classname == "KexiDBSubForm") {
503 bool openingCancelled;
510 else if( (classname == "KexiDBDateEdit") || (classname == "KexiDBDateTimeEdit") || (classname == "KexiDBTimeEdit")
516 else if(classname == "KexiDBAutoField") {
520 createEditor(classname, label->text(), label, container, label->geometry(), label->alignment());
523 else if (classname == "KexiDBCheckBox") {
525 TQRect r( cb->geometry() );
526 r.setLeft( r.left() + 2 + cb->style().subRect( TQStyle::SR_CheckBoxIndicator, cb ).width() );
527 createEditor(classname, cb->text(), cb, container, r, TQt::AlignAuto);
530 else if(classname == "KexiDBImageBox") {
555TQValueList<TQCString>
558 TQValueList<TQCString> lst;
570 const TQCString& property, bool isTopLevel)
573 if (property== "dataSource" || property== "dataSourceMimeType") {
579 if(classname == "KexiPushButton") {
580 ok = property!= "isDragEnabled"
581#ifdef KEXI_NO_UNFINISHED
582 && property!= "onClickAction"
583 && property!= "onClickActionOption"
584 && property!= "iconSet"
585 && property!= "stdItem"
589 else if(classname == "KexiDBLineEdit")
590 ok = property!= "urlDropsEnabled"
591 && property!= "vAlign"
592#ifdef KEXI_NO_UNFINISHED
593 && property!= "inputMask"
594 && property!= "maxLength"
597 else if(classname == "KexiDBComboBox")
598 ok = property!= "autoCaption"
599 && property!= "labelPosition"
600 && property!= "widgetType"
601 && property!= "fieldTypeInternal"
602 && property!= "fieldCaptionInternal";
603 else if(classname == "KexiDBTextEdit")
604 ok = property!= "undoDepth"
605 && property!= "undoRedoEnabled"
606 && property!= "dragAutoScroll"
607 && property!= "overwriteMode"
608 && property!= "resizePolicy"
609 && property!= "autoFormatting"
610#ifdef KEXI_NO_UNFINISHED
614 else if(classname == "KexiDBSubForm")
615 ok = property!= "dragAutoScroll"
616 && property!= "resizePolicy"
617 && property!= "focusPolicy";
618 else if(classname == "KexiDBForm")
619 ok = property!= "iconText"
620 && property!= "geometry" ;
621 else if(classname == "KexiDBLabel")
622 ok = property!= "focusPolicy";
623 else if(classname == "KexiDBAutoField") {
624 if (!isTopLevel && property== "caption")
626 if (property== "fieldTypeInternal" || property== "fieldCaptionInternal"
628 || property== "widgetType")
630 ok = property!= "text";
632 else if (classname == "KexiDBImageBox") {
633 ok = property!= "font" && property!= "wordbreak";
635 else if(classname == "KexiDBCheckBox") {
639 ok = property!= "autoRepeat";
642 return ok && WidgetFactory::isPropertyVisibleInternal(classname, w, property, isTopLevel);
647 TQWidget *w, const TQCString& property)
651 if (property== "fieldTypeInternal" || property== "widgetType")
666 if(n == "KexiDBAutoField") {
680 if(classname == "KexiDBAutoField")
681 editor->setGeometry( static_cast<KexiDBAutoField* >(w)->label()->geometry() );
701#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)
|