kexi

kexiformpart.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00004    Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <kdebug.h>
00023 #include <kgenericfactory.h>
00024 #include <kdialogbase.h>
00025 #include <klistview.h>
00026 #include <ktabwidget.h>
00027 #include <kiconloader.h>
00028 #include <kcombobox.h>
00029 #include <kapplication.h>
00030 #include <kconfig.h>
00031 
00032 #include <kexiviewbase.h>
00033 #include <keximainwindow.h>
00034 #include <kexiproject.h>
00035 #include <kexipartitem.h>
00036 #include <kexidialogbase.h>
00037 #include <kexidatasourcecombobox.h>
00038 #include <kexidb/connection.h>
00039 #include <kexidb/fieldlist.h>
00040 #include <kexidb/field.h>
00041 #include <kexiutils/utils.h>
00042 
00043 #include <form.h>
00044 #include <formIO.h>
00045 #include <widgetpropertyset.h>
00046 #include <widgetlibrary.h>
00047 #include <objecttreeview.h>
00048 #include <koproperty/property.h>
00049 
00050 #include "kexiformview.h"
00051 #include "widgets/kexidbform.h"
00052 #include "kexiformscrollview.h"
00053 #include "kexiactionselectiondialog.h"
00054 #include "kexiformmanager.h"
00055 #include "kexiformpart.h"
00056 #include "kexidatasourcepage.h"
00057 
00059 
00060 KFormDesigner::WidgetLibrary* KexiFormPart::static_formsLibrary = 0L;
00061 
00063 class KexiFormPart::Private
00064 {
00065     public:
00066         Private()
00067         {
00068         }
00069         ~Private()
00070         {
00071             delete static_cast<KFormDesigner::ObjectTreeView*>(objectTreeView);
00072             delete static_cast<KexiDataSourcePage*>(dataSourcePage);
00073         }
00074 //      QGuardedPtr<KFormDesigner::FormManager> manager;
00075         QGuardedPtr<KFormDesigner::ObjectTreeView> objectTreeView;
00076         QGuardedPtr<KexiDataSourcePage> dataSourcePage;
00077         KexiDataSourceComboBox *dataSourceCombo;
00078 };
00079 
00080 KexiFormPart::KexiFormPart(QObject *parent, const char *name, const QStringList &l)
00081  : KexiPart::Part(parent, name, l)
00082  , d(new Private())
00083 {
00084     // REGISTERED ID:
00085     m_registeredPartID = (int)KexiPart::FormObjectType;
00086 
00087     kexipluginsdbg << "KexiFormPart::KexiFormPart()" << endl;
00088     m_names["instanceName"]
00089         = i18n("Translate this word using only lowercase alphanumeric characters (a..z, 0..9). "
00090         "Use '_' character instead of spaces. First character should be a..z character. "
00091         "If you cannot use latin characters in your language, use english word.",
00092         "form");
00093     m_names["instanceCaption"] = i18n("Form");
00094     m_supportedViewModes = Kexi::DataViewMode | Kexi::DesignViewMode;
00095     m_newObjectsAreDirty = true;
00096 
00097     // Only create form manager if it's not yet created.
00098     // KexiReportPart could have created it already.
00099     KFormDesigner::FormManager *formManager = KFormDesigner::FormManager::self();
00100     if (!formManager)
00101         formManager = new KexiFormManager(this, "kexi_form_and_report_manager");
00102 
00103     // Create and store a handle to forms' library. Reports will have their own library too.
00104 /* @todo add configuration for supported factory groups */
00105     QStringList supportedFactoryGroups;
00106     supportedFactoryGroups += "kexi";
00107     static_formsLibrary = KFormDesigner::FormManager::createWidgetLibrary(
00108         formManager, supportedFactoryGroups);
00109     static_formsLibrary->setAdvancedPropertiesVisible(false);
00110     connect(static_formsLibrary, SIGNAL(widgetCreated(QWidget*)),
00111         this, SLOT(slotWidgetCreatedByFormsLibrary(QWidget*)));
00112 
00113     connect(KFormDesigner::FormManager::self()->propertySet(), SIGNAL(widgetPropertyChanged(QWidget *, const QCString &, const QVariant&)),
00114         this, SLOT(slotPropertyChanged(QWidget *, const QCString &, const QVariant&)));
00115     connect(KFormDesigner::FormManager::self(), SIGNAL(autoTabStopsSet(KFormDesigner::Form*,bool)),
00116         this, SLOT(slotAutoTabStopsSet(KFormDesigner::Form*,bool)));
00117 }
00118 
00119 KexiFormPart::~KexiFormPart()
00120 {
00121     delete d;
00122 }
00123 
00124 KFormDesigner::WidgetLibrary* KexiFormPart::library()
00125 {
00126     return static_formsLibrary;
00127 }
00128 
00129 #if 0
00130 void KexiFormPart::initPartActions(KActionCollection *collection)
00131 {
00132 //this is automatic? -no
00133 //create child guicilent: guiClient()->setXMLFile("kexidatatableui.rc");
00134 
00135     kexipluginsdbg<<"FormPart INIT ACTIONS***********************************************************************"<<endl;
00136     //TODO
00137 
00138     //guiClient()->setXMLFile("kexiformui.rc");
00139 //js    m_manager->createActions(collection, 0);
00140 }
00141 
00142 void KexiFormPart::initInstanceActions( int mode, KActionCollection *col )
00143 {
00144     if (mode==Kexi::DesignViewMode) {
00145         KFormDesigner::FormManager::self()->createActions(col, 0);
00146         new KAction(i18n("Edit Tab Order..."), "tab_order", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(editTabOrder()), col, "taborder");
00147         new KAction(i18n("Adjust Size"), "viewmagfit", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(ajustWidgetSize()), col, "adjust");
00148     }
00149     //TODO
00150 }
00151 #endif
00152 
00153 void KexiFormPart::initPartActions()
00154 {
00155 //  new KAction(i18n("Show Form UI Code"), "show_form_ui", CTRL+Key_U, m_manager, SLOT(showFormUICode()),
00156 //      guiClient()->actionCollection(), "show_form_ui");
00157 }
00158 
00159 void KexiFormPart::initInstanceActions()
00160 {
00161 #ifdef KEXI_DEBUG_GUI
00162     kapp->config()->setGroup("General");
00163     if (kapp->config()->readBoolEntry("showInternalDebugger", false)) {
00164         new KAction(i18n("Show Form UI Code"), "compfile", 
00165             CTRL+Key_U, KFormDesigner::FormManager::self(), SLOT(showFormUICode()),
00166             actionCollectionForMode(Kexi::DesignViewMode), "show_form_ui");
00167     }
00168 #endif
00169 
00170     KActionCollection *col = actionCollectionForMode(Kexi::DesignViewMode);
00171     KFormDesigner::FormManager::self()->createActions( library(), col, (KXMLGUIClient*)col->parentGUIClient() ); //guiClient() );
00172 
00173     //connect actions provided by widget factories
00174     connect( col->action("widget_assign_action"), SIGNAL(activated()), this, SLOT(slotAssignAction()));
00175 
00176     createSharedAction(Kexi::DesignViewMode, i18n("Clear Widget Contents"), "editclear", 0, "formpart_clear_contents");
00177     createSharedAction(Kexi::DesignViewMode, i18n("Edit Tab Order..."), "tab_order", 0, "formpart_taborder");
00178 //TODO  createSharedAction(Kexi::DesignViewMode, i18n("Edit Pixmap Collection"), "icons", 0, "formpart_pixmap_collection");
00179 //TODO  createSharedAction(Kexi::DesignViewMode, i18n("Edit Form Connections"), "connections", 0, "formpart_connections");
00180 
00181 //  KFormDesigner::CreateLayoutCommand
00182 
00183     KAction *action = createSharedAction(Kexi::DesignViewMode, i18n("Layout Widgets"), "", 0, "formpart_layout_menu", "KActionMenu");
00184     KActionMenu *menu = static_cast<KActionMenu*>(action);
00185 
00186     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("&Horizontally"),
00187         QString::null, 0, "formpart_layout_hbox"));
00188     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("&Vertically"),
00189         QString::null, 0, "formpart_layout_vbox"));
00190     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("In &Grid"),
00191         QString::null, 0, "formpart_layout_grid"));
00192 #ifdef KEXI_SHOW_SPLITTER_WIDGET
00193     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("Horizontally in &Splitter"),
00194         QString::null, 0, "formpart_layout_hsplitter"));
00195     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("Verti&cally in Splitter"),
00196         QString::null, 0, "formpart_layout_vsplitter"));
00197 #endif
00198 
00199     createSharedAction(Kexi::DesignViewMode, i18n("&Break Layout"), QString::null, 0, "formpart_break_layout");
00200 /*
00201     createSharedAction(Kexi::DesignViewMode, i18n("Lay Out Widgets &Horizontally"), QString::null, 0, "formpart_layout_hbox");
00202     createSharedAction(Kexi::DesignViewMode, i18n("Lay Out Widgets &Vertically"), QString::null, 0, "formpart_layout_vbox");
00203     createSharedAction(Kexi::DesignViewMode, i18n("Lay Out Widgets in &Grid"), QString::null, 0, "formpart_layout_grid");
00204 */
00205     createSharedAction(Kexi::DesignViewMode, i18n("Bring Widget to Front"), "raise", 0, "formpart_format_raise");
00206     createSharedAction(Kexi::DesignViewMode, i18n("Send Widget to Back"), "lower", 0, "formpart_format_lower");
00207 
00208 #ifndef KEXI_NO_UNFINISHED
00209     action = createSharedAction(Kexi::DesignViewMode, i18n("Other Widgets"), "", 0, "other_widgets_menu", "KActionMenu");
00210 #endif
00211 
00212     action = createSharedAction(Kexi::DesignViewMode, i18n("Align Widgets Position"), "aoleft", 0, "formpart_align_menu", "KActionMenu");
00213     menu = static_cast<KActionMenu*>(action);
00214     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Left"), "aoleft", 0, "formpart_align_to_left") );
00215     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Right"), "aoright", 0, "formpart_align_to_right") );
00216     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Top"), "aotop", 0, "formpart_align_to_top") );
00217     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Bottom"), "aobottom", 0, "formpart_align_to_bottom") );
00218     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Grid"), "aopos2grid", 0, "formpart_align_to_grid") );
00219 
00220     action = createSharedAction(Kexi::DesignViewMode, i18n("Adjust Widgets Size"), "aogrid", 0, "formpart_adjust_size_menu", "KActionMenu");
00221     menu = static_cast<KActionMenu*>(action);
00222     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Fit"), "aofit", 0, "formpart_adjust_to_fit") );
00223     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Grid"), "aogrid", 0, "formpart_adjust_size_grid") );
00224     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Shortest"), "aoshortest", 0, "formpart_adjust_height_small") );
00225     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Tallest"), "aotallest", 0, "formpart_adjust_height_big") );
00226     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Narrowest"), "aonarrowest", 0, "formpart_adjust_width_small") );
00227     menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Widest"), "aowidest", 0, "formpart_adjust_width_big") );
00228 }
00229 
00230 KexiDialogTempData*
00231 KexiFormPart::createTempData(KexiDialogBase* dialog)
00232 {
00233     return new KexiFormPart::TempData(dialog);
00234 }
00235 
00236 KexiViewBase* KexiFormPart::createView(QWidget *parent, KexiDialogBase* dialog,
00237     KexiPart::Item &item, int viewMode, QMap<QString,QString>*)
00238 {
00239     Q_UNUSED( viewMode );
00240 
00241     kexipluginsdbg << "KexiFormPart::createView()" << endl;
00242     KexiMainWindow *win = dialog->mainWin();
00243     if (!win || !win->project() || !win->project()->dbConnection())
00244         return 0;
00245 
00246     KexiFormView *view = new KexiFormView(win, parent, item.name().latin1(),
00247         win->project()->dbConnection() );
00248 
00249     return view;
00250 }
00251 
00252 void
00253 KexiFormPart::generateForm(KexiDB::FieldList *list, QDomDocument &domDoc)
00254 {
00255     //this form generates a .ui from FieldList list
00256     //basically that is a Label and a LineEdit for each field
00257     domDoc = QDomDocument("UI");
00258         QDomElement uiElement = domDoc.createElement("UI");
00259     domDoc.appendChild(uiElement);
00260     uiElement.setAttribute("version", "3.1");
00261     uiElement.setAttribute("stdsetdef", 1);
00262 
00263     QDomElement baseClass = domDoc.createElement("class");
00264     uiElement.appendChild(baseClass);
00265     QDomText baseClassV = domDoc.createTextNode("QWidget");
00266     baseClass.appendChild(baseClassV);
00267     QDomElement baseWidget = domDoc.createElement("widget");
00268     baseWidget.setAttribute("class", "QWidget");
00269 
00270     int y=0;
00271 
00272     for(unsigned int i=0; i < list->fieldCount(); i++)
00273     {
00274         QDomElement lclass = domDoc.createElement("widget");
00275         baseWidget.appendChild(lclass);
00276         lclass.setAttribute("class", "QLabel");
00277         QDomElement lNameProperty = domDoc.createElement("property");
00278         lNameProperty.setAttribute("name", "name");
00279         QDomElement lType = domDoc.createElement("cstring");
00280         QDomText lClassN = domDoc.createTextNode(QString("l%1").arg(list->field(i)->name()));
00281         lType.appendChild(lClassN);
00282         lNameProperty.appendChild(lType);
00283         lclass.appendChild(lNameProperty);
00284 
00285         QDomElement gNameProperty = domDoc.createElement("property");
00286         gNameProperty.setAttribute("name", "geometry");
00287         QDomElement lGType = domDoc.createElement("rect");
00288 
00289         QDomElement lx = domDoc.createElement("x");
00290         QDomText lxV = domDoc.createTextNode("10");
00291         lx.appendChild(lxV);
00292         QDomElement ly = domDoc.createElement("y");
00293         QDomText lyV = domDoc.createTextNode(QString::number(y + 10));
00294         ly.appendChild(lyV);
00295         QDomElement lWidth = domDoc.createElement("width");
00296         QDomText lWidthV = domDoc.createTextNode("100");
00297         lWidth.appendChild(lWidthV);
00298         QDomElement lHeight = domDoc.createElement("height");
00299         QDomText lHeightV = domDoc.createTextNode("20");
00300         lHeight.appendChild(lHeightV);
00301 
00302         lGType.appendChild(lx);
00303         lGType.appendChild(ly);
00304         lGType.appendChild(lWidth);
00305         lGType.appendChild(lHeight);
00306 
00307         gNameProperty.appendChild(lGType);
00308         lclass.appendChild(gNameProperty);
00309 
00310         QDomElement tNameProperty = domDoc.createElement("property");
00311         tNameProperty.setAttribute("name", "text");
00312         QDomElement lTType = domDoc.createElement("string");
00313         QDomText lTextV = domDoc.createTextNode(list->field(i)->name());
00314         lTType.appendChild(lTextV);
00315         tNameProperty.appendChild(lTType);
00316         lclass.appendChild(tNameProperty);
00317 
00318 
00320 
00321 
00322         QDomElement vclass = domDoc.createElement("widget");
00323         baseWidget.appendChild(vclass);
00324         vclass.setAttribute("class", "KLineEdit");
00325         QDomElement vNameProperty = domDoc.createElement("property");
00326         vNameProperty.setAttribute("name", "name");
00327         QDomElement vType = domDoc.createElement("cstring");
00328         QDomText vClassN = domDoc.createTextNode(list->field(i)->name());
00329         vType.appendChild(vClassN);
00330         vNameProperty.appendChild(vType);
00331         vclass.appendChild(vNameProperty);
00332 
00333         QDomElement vgNameProperty = domDoc.createElement("property");
00334         vgNameProperty.setAttribute("name", "geometry");
00335         QDomElement vGType = domDoc.createElement("rect");
00336 
00337         QDomElement vx = domDoc.createElement("x");
00338         QDomText vxV = domDoc.createTextNode("110");
00339         vx.appendChild(vxV);
00340         QDomElement vy = domDoc.createElement("y");
00341         QDomText vyV = domDoc.createTextNode(QString::number(y + 10));
00342         vy.appendChild(vyV);
00343         QDomElement vWidth = domDoc.createElement("width");
00344         QDomText vWidthV = domDoc.createTextNode("200");
00345         vWidth.appendChild(vWidthV);
00346         QDomElement vHeight = domDoc.createElement("height");
00347         QDomText vHeightV = domDoc.createTextNode("20");
00348         vHeight.appendChild(vHeightV);
00349 
00350         vGType.appendChild(vx);
00351         vGType.appendChild(vy);
00352         vGType.appendChild(vWidth);
00353         vGType.appendChild(vHeight);
00354 
00355         vgNameProperty.appendChild(vGType);
00356         vclass.appendChild(vgNameProperty);
00357 
00358         y += 20;
00359     }
00360 
00361     QDomElement lNameProperty = domDoc.createElement("property");
00362     lNameProperty.setAttribute("name", "name");
00363     QDomElement lType = domDoc.createElement("cstring");
00364     QDomText lClassN = domDoc.createTextNode("DBForm");
00365     lType.appendChild(lClassN);
00366     lNameProperty.appendChild(lType);
00367     baseWidget.appendChild(lNameProperty);
00368 
00369     QDomElement wNameProperty = domDoc.createElement("property");
00370     wNameProperty.setAttribute("name", "geometry");
00371     QDomElement wGType = domDoc.createElement("rect");
00372 
00373     QDomElement wx = domDoc.createElement("x");
00374     QDomText wxV = domDoc.createTextNode("0");
00375     wx.appendChild(wxV);
00376     QDomElement wy = domDoc.createElement("y");
00377     QDomText wyV = domDoc.createTextNode("0");
00378     wy.appendChild(wyV);
00379     QDomElement wWidth = domDoc.createElement("width");
00380     QDomText wWidthV = domDoc.createTextNode("340");
00381     wWidth.appendChild(wWidthV);
00382     QDomElement wHeight = domDoc.createElement("height");
00383     QDomText wHeightV = domDoc.createTextNode(QString::number(y + 30));
00384     wHeight.appendChild(wHeightV);
00385 
00386     wGType.appendChild(wx);
00387     wGType.appendChild(wy);
00388     wGType.appendChild(wWidth);
00389     wGType.appendChild(wHeight);
00390 
00391     wNameProperty.appendChild(wGType);
00392     baseWidget.appendChild(wNameProperty);
00393 
00394     uiElement.appendChild(baseWidget);
00395 }
00396 
00397 void KexiFormPart::slotAutoTabStopsSet(KFormDesigner::Form *form, bool set)
00398 {
00399     Q_UNUSED( form );
00400 
00401     KoProperty::Property &p = (*KFormDesigner::FormManager::self()->propertySet())["autoTabStops"];
00402     if (!p.isNull())
00403         p.setValue(QVariant(set, 4));
00404 }
00405 
00406 void KexiFormPart::slotAssignAction()
00407 {
00408     KexiDBForm *dbform;
00409     if (!KFormDesigner::FormManager::self()->activeForm() || !KFormDesigner::FormManager::self()->activeForm()->designMode()
00410         || !(dbform = dynamic_cast<KexiDBForm*>(KFormDesigner::FormManager::self()->activeForm()->formWidget())))
00411         return;
00412 
00413     KFormDesigner::WidgetPropertySet * propSet = KFormDesigner::FormManager::self()->propertySet();
00414 
00415     KoProperty::Property &onClickActionProp = propSet->property("onClickAction");
00416     if (onClickActionProp.isNull())
00417         return;
00418     KoProperty::Property &onClickActionOptionProp = propSet->property("onClickActionOption");
00419     KexiFormEventAction::ActionData data;
00420     data.string = onClickActionProp.value().toString();
00421     if (!onClickActionOptionProp.isNull())
00422         data.option = onClickActionOptionProp.value().toString();
00423 
00424     KexiFormScrollView *scrollViewWidget = dynamic_cast<KexiFormScrollView*>(dbform->dataAwareObject());
00425     if (!scrollViewWidget)
00426         return;
00427     KexiFormView* formViewWidget = dynamic_cast<KexiFormView*>(scrollViewWidget->parent());
00428     if (!formViewWidget)
00429         return;
00430 
00431     KexiMainWindow * mainWin = formViewWidget->parentDialog()->mainWin();
00432     KexiActionSelectionDialog dlg(mainWin, dbform, data, 
00433         propSet->property("name").value().toCString());
00434 
00435     if(dlg.exec() == QDialog::Accepted) {
00436         data = dlg.currentAction();
00437         //update property value
00438         propSet->property("onClickAction").setValue(data.string);
00439         propSet->property("onClickActionOption").setValue(data.option);
00440     }
00441 }
00442 
00443 QString
00444 KexiFormPart::i18nMessage(const QCString& englishMessage, KexiDialogBase* dlg) const
00445 {
00446     Q_UNUSED(dlg);
00447     if (englishMessage=="Design of object \"%1\" has been modified.")
00448         return i18n("Design of form \"%1\" has been modified.");
00449     if (englishMessage=="Object \"%1\" already exists.")
00450         return i18n("Form \"%1\" already exists.");
00451 
00452     return englishMessage;
00453 }
00454 
00455 void
00456 KexiFormPart::slotPropertyChanged(QWidget *w, const QCString &name, const QVariant &value)
00457 {
00458     Q_UNUSED( w );
00459 
00460     if (!KFormDesigner::FormManager::self()->activeForm())
00461         return;
00462     if (name == "autoTabStops") {
00463         //QWidget *w = KFormDesigner::FormManager::self()->activeForm()->selectedWidget();
00464         //update autoTabStops setting at KFD::Form level
00465         KFormDesigner::FormManager::self()->activeForm()->setAutoTabStops( value.toBool() );
00466     }
00467     if (KFormDesigner::FormManager::self()->activeForm()->widget() && name == "geometry") {
00468         //fall back to sizeInternal property....
00469         if (KFormDesigner::FormManager::self()->propertySet()->contains("sizeInternal"))
00470             KFormDesigner::FormManager::self()->propertySet()->property("sizeInternal").setValue(value.toRect().size());
00471     }
00472 }
00473 
00474 /*KFormDesigner::FormManager*
00475 KexiFormPart::manager() const
00476 {
00477     return d->manager;
00478 }*/
00479 
00480 KexiDataSourcePage* KexiFormPart::dataSourcePage() const
00481 {
00482     return d->dataSourcePage;
00483 }
00484 
00485 void KexiFormPart::setupCustomPropertyPanelTabs(KTabWidget *tab, KexiMainWindow* mainWin)
00486 {
00487     if (!d->objectTreeView) {
00488         d->objectTreeView = new KFormDesigner::ObjectTreeView(0, "KexiFormPart:ObjectTreeView");
00489         KFormDesigner::FormManager::self()->setObjectTreeView(d->objectTreeView); //important: assign to manager
00490         d->dataSourcePage = new KexiDataSourcePage(0, "dataSourcePage");
00491         connect(d->dataSourcePage, SIGNAL(jumpToObjectRequested(const QCString&, const QCString&)),
00492             mainWin, SLOT(highlightObject(const QCString&, const QCString&)));
00493         connect(d->dataSourcePage, SIGNAL(formDataSourceChanged(const QCString&, const QCString&)),
00494             KFormDesigner::FormManager::self(), SLOT(setFormDataSource(const QCString&, const QCString&)));
00495         connect(d->dataSourcePage, SIGNAL(dataSourceFieldOrExpressionChanged(const QString&, const QString&, KexiDB::Field::Type)),
00496             KFormDesigner::FormManager::self(), SLOT(setDataSourceFieldOrExpression(const QString&, const QString&, KexiDB::Field::Type)));
00497         connect(d->dataSourcePage, SIGNAL(insertAutoFields(const QString&, const QString&, const QStringList&)),
00498             KFormDesigner::FormManager::self(), SLOT(insertAutoFields(const QString&, const QString&, const QStringList&)));
00499     }
00500 
00501     KexiProject *prj = mainWin->project();
00502     d->dataSourcePage->setProject(prj);
00503 
00504     tab->addTab( d->dataSourcePage, SmallIconSet("database"), "");
00505     tab->setTabToolTip( d->dataSourcePage, i18n("Data Source"));
00506 
00507     tab->addTab( d->objectTreeView, SmallIconSet("widgets"), "");
00508     tab->setTabToolTip( d->objectTreeView, i18n("Widgets"));
00509 }
00510 
00511 void KexiFormPart::slotWidgetCreatedByFormsLibrary(QWidget* widget)
00512 {
00513     QStrList signalNames(widget->metaObject()->signalNames());
00514     if (!signalNames.isEmpty()) {
00515         const char *handleDragMoveEventSignal = "handleDragMoveEvent(QDragMoveEvent*)";
00516         const char *handleDropEventSignal = "handleDropEvent(QDropEvent*)";
00517 
00518         for (QStrListIterator it(signalNames); it.current(); ++it) {
00519             if (0==qstrcmp(it.current(), handleDragMoveEventSignal)) {
00520                 kdDebug() << it.current() <<  endl;
00521                 KexiFormView *formView = KexiUtils::findParent<KexiFormView>(widget, "KexiFormView");
00522                 if (formView) {
00523                     connect(widget, SIGNAL(handleDragMoveEvent(QDragMoveEvent*)), 
00524                         formView, SLOT(slotHandleDragMoveEvent(QDragMoveEvent*)));
00525                 }
00526             }
00527             else if (0==qstrcmp(it.current(), handleDropEventSignal)) {
00528                 kdDebug() << it.current() <<  endl;
00529                 KexiFormView *formView = KexiUtils::findParent<KexiFormView>(widget, "KexiFormView");
00530                 if (formView) {
00531                     connect(widget, SIGNAL(handleDropEvent(QDropEvent*)), 
00532                         formView, SLOT(slotHandleDropEvent(QDropEvent*)));
00533                 }
00534             }
00535         }
00536     }
00537 }
00538 
00539 //----------------
00540 
00541 KexiFormPart::TempData::TempData(QObject* parent)
00542  : KexiDialogTempData(parent)
00543 {
00544 }
00545 
00546 KexiFormPart::TempData::~TempData()
00547 {
00548 }
00549 
00550 #include "kexiformpart.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys