KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kexiformpart.cpp 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. /* This file is part of the KDE project
  2. Copyright (C) 2004 Lucijan Busch <lucijan@kde.org>
  3. Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
  4. Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public License
  14. along with this library; see the file COPYING.LIB. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. * Boston, MA 02110-1301, USA.
  17. */
  18. #include <kdebug.h>
  19. #include <kgenericfactory.h>
  20. #include <kdialogbase.h>
  21. #include <tdelistview.h>
  22. #include <ktabwidget.h>
  23. #include <kiconloader.h>
  24. #include <kcombobox.h>
  25. #include <tdeapplication.h>
  26. #include <tdeconfig.h>
  27. #include <kexiviewbase.h>
  28. #include <keximainwindow.h>
  29. #include <kexiproject.h>
  30. #include <kexipartitem.h>
  31. #include <kexidialogbase.h>
  32. #include <kexidatasourcecombobox.h>
  33. #include <kexidb/connection.h>
  34. #include <kexidb/fieldlist.h>
  35. #include <kexidb/field.h>
  36. #include <kexiutils/utils.h>
  37. #include <form.h>
  38. #include <formIO.h>
  39. #include <widgetpropertyset.h>
  40. #include <widgetlibrary.h>
  41. #include <objecttreeview.h>
  42. #include <koproperty/property.h>
  43. #include "kexiformview.h"
  44. #include "widgets/kexidbform.h"
  45. #include "kexiformscrollview.h"
  46. #include "kexiactionselectiondialog.h"
  47. #include "kexiformmanager.h"
  48. #include "kexiformpart.h"
  49. #include "kexidatasourcepage.h"
  50. //! @todo #define KEXI_SHOW_SPLITTER_WIDGET
  51. KFormDesigner::WidgetLibrary* KexiFormPart::static_formsLibrary = 0L;
  52. //! @internal
  53. class KexiFormPart::Private
  54. {
  55. public:
  56. Private()
  57. {
  58. }
  59. ~Private()
  60. {
  61. delete static_cast<KFormDesigner::ObjectTreeView*>(objectTreeView);
  62. delete static_cast<KexiDataSourcePage*>(dataSourcePage);
  63. }
  64. // TQGuardedPtr<KFormDesigner::FormManager> manager;
  65. TQGuardedPtr<KFormDesigner::ObjectTreeView> objectTreeView;
  66. TQGuardedPtr<KexiDataSourcePage> dataSourcePage;
  67. KexiDataSourceComboBox *dataSourceCombo;
  68. };
  69. KexiFormPart::KexiFormPart(TQObject *parent, const char *name, const TQStringList &l)
  70. : KexiPart::Part(parent, name, l)
  71. , d(new Private())
  72. {
  73. // REGISTERED ID:
  74. m_registeredPartID = (int)KexiPart::FormObjectType;
  75. kexipluginsdbg << "KexiFormPart::KexiFormPart()" << endl;
  76. m_names["instanceName"]
  77. = i18n("Translate this word using only lowercase alphanumeric characters (a..z, 0..9). "
  78. "Use '_' character instead of spaces. First character should be a..z character. "
  79. "If you cannot use latin characters in your language, use english word.",
  80. "form");
  81. m_names["instanceCaption"] = i18n("Form");
  82. m_supportedViewModes = Kexi::DataViewMode | Kexi::DesignViewMode;
  83. m_newObjectsAreDirty = true;
  84. // Only create form manager if it's not yet created.
  85. // KexiReportPart could have created it already.
  86. KFormDesigner::FormManager *formManager = KFormDesigner::FormManager::self();
  87. if (!formManager)
  88. formManager = new KexiFormManager(this, "kexi_form_and_report_manager");
  89. // Create and store a handle to forms' library. Reports will have their own library too.
  90. /* @todo add configuration for supported factory groups */
  91. TQStringList supportedFactoryGroups;
  92. supportedFactoryGroups += "kexi";
  93. static_formsLibrary = KFormDesigner::FormManager::createWidgetLibrary(
  94. formManager, supportedFactoryGroups);
  95. static_formsLibrary->setAdvancedPropertiesVisible(false);
  96. connect(static_formsLibrary, TQT_SIGNAL(widgetCreated(TQWidget*)),
  97. this, TQT_SLOT(slotWidgetCreatedByFormsLibrary(TQWidget*)));
  98. connect(KFormDesigner::FormManager::self()->propertySet(), TQT_SIGNAL(widgetPropertyChanged(TQWidget *, const TQCString &, const TQVariant&)),
  99. this, TQT_SLOT(slotPropertyChanged(TQWidget *, const TQCString &, const TQVariant&)));
  100. connect(KFormDesigner::FormManager::self(), TQT_SIGNAL(autoTabStopsSet(KFormDesigner::Form*,bool)),
  101. this, TQT_SLOT(slotAutoTabStopsSet(KFormDesigner::Form*,bool)));
  102. }
  103. KexiFormPart::~KexiFormPart()
  104. {
  105. delete d;
  106. }
  107. KFormDesigner::WidgetLibrary* KexiFormPart::library()
  108. {
  109. return static_formsLibrary;
  110. }
  111. #if 0
  112. void KexiFormPart::initPartActions(TDEActionCollection *collection)
  113. {
  114. //this is automatic? -no
  115. //create child guicilent: guiClient()->setXMLFile("kexidatatableui.rc");
  116. kexipluginsdbg<<"FormPart INIT ACTIONS***********************************************************************"<<endl;
  117. //TODO
  118. //guiClient()->setXMLFile("kexiformui.rc");
  119. //js m_manager->createActions(collection, 0);
  120. }
  121. void KexiFormPart::initInstanceActions( int mode, TDEActionCollection *col )
  122. {
  123. if (mode==Kexi::DesignViewMode) {
  124. KFormDesigner::FormManager::self()->createActions(col, 0);
  125. new TDEAction(i18n("Edit Tab Order..."), "tab_order", TDEShortcut(0), KFormDesigner::FormManager::self(), TQT_SLOT(editTabOrder()), col, "taborder");
  126. new TDEAction(i18n("Adjust Size"), "zoom-fit-best", TDEShortcut(0), KFormDesigner::FormManager::self(), TQT_SLOT(ajustWidgetSize()), col, "adjust");
  127. }
  128. //TODO
  129. }
  130. #endif
  131. void KexiFormPart::initPartActions()
  132. {
  133. // new TDEAction(i18n("Show Form UI Code"), "show_form_ui", CTRL+Key_U, m_manager, TQT_SLOT(showFormUICode()),
  134. // guiClient()->actionCollection(), "show_form_ui");
  135. }
  136. void KexiFormPart::initInstanceActions()
  137. {
  138. #ifdef KEXI_DEBUG_GUI
  139. kapp->config()->setGroup("General");
  140. if (kapp->config()->readBoolEntry("showInternalDebugger", false)) {
  141. new TDEAction(i18n("Show Form UI Code"), "compfile",
  142. CTRL+Key_U, KFormDesigner::FormManager::self(), TQT_SLOT(showFormUICode()),
  143. actionCollectionForMode(Kexi::DesignViewMode), "show_form_ui");
  144. }
  145. #endif
  146. TDEActionCollection *col = actionCollectionForMode(Kexi::DesignViewMode);
  147. KFormDesigner::FormManager::self()->createActions( library(), col, (KXMLGUIClient*)col->parentGUIClient() ); //guiClient() );
  148. //connect actions provided by widget factories
  149. connect( col->action("widget_assign_action"), TQT_SIGNAL(activated()), this, TQT_SLOT(slotAssignAction()));
  150. createSharedAction(Kexi::DesignViewMode, i18n("Clear Widget Contents"), "edit-clear", 0, "formpart_clear_contents");
  151. createSharedAction(Kexi::DesignViewMode, i18n("Edit Tab Order..."), "tab_order", 0, "formpart_taborder");
  152. //TODO createSharedAction(Kexi::DesignViewMode, i18n("Edit Pixmap Collection"), "icons", 0, "formpart_pixmap_collection");
  153. //TODO createSharedAction(Kexi::DesignViewMode, i18n("Edit Form Connections"), "connections", 0, "formpart_connections");
  154. // KFormDesigner::CreateLayoutCommand
  155. TDEAction *action = createSharedAction(Kexi::DesignViewMode, i18n("Layout Widgets"), "", 0, "formpart_layout_menu", "TDEActionMenu");
  156. TDEActionMenu *menu = static_cast<TDEActionMenu*>(action);
  157. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("&Horizontally"),
  158. TQString(), 0, "formpart_layout_hbox"));
  159. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("&Vertically"),
  160. TQString(), 0, "formpart_layout_vbox"));
  161. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("In &Grid"),
  162. TQString(), 0, "formpart_layout_grid"));
  163. #ifdef KEXI_SHOW_SPLITTER_WIDGET
  164. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("Horizontally in &Splitter"),
  165. TQString(), 0, "formpart_layout_hsplitter"));
  166. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("Verti&cally in Splitter"),
  167. TQString(), 0, "formpart_layout_vsplitter"));
  168. #endif
  169. createSharedAction(Kexi::DesignViewMode, i18n("&Break Layout"), TQString(), 0, "formpart_break_layout");
  170. /*
  171. createSharedAction(Kexi::DesignViewMode, i18n("Lay Out Widgets &Horizontally"), TQString(), 0, "formpart_layout_hbox");
  172. createSharedAction(Kexi::DesignViewMode, i18n("Lay Out Widgets &Vertically"), TQString(), 0, "formpart_layout_vbox");
  173. createSharedAction(Kexi::DesignViewMode, i18n("Lay Out Widgets in &Grid"), TQString(), 0, "formpart_layout_grid");
  174. */
  175. createSharedAction(Kexi::DesignViewMode, i18n("Bring Widget to Front"), "raise", 0, "formpart_format_raise");
  176. createSharedAction(Kexi::DesignViewMode, i18n("Send Widget to Back"), "lower", 0, "formpart_format_lower");
  177. #ifndef KEXI_NO_UNFINISHED
  178. action = createSharedAction(Kexi::DesignViewMode, i18n("Other Widgets"), "", 0, "other_widgets_menu", "TDEActionMenu");
  179. #endif
  180. action = createSharedAction(Kexi::DesignViewMode, i18n("Align Widgets Position"), "aoleft", 0, "formpart_align_menu", "TDEActionMenu");
  181. menu = static_cast<TDEActionMenu*>(action);
  182. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Left"), "aoleft", 0, "formpart_align_to_left") );
  183. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Right"), "aoright", 0, "formpart_align_to_right") );
  184. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Top"), "aotop", 0, "formpart_align_to_top") );
  185. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Bottom"), "aobottom", 0, "formpart_align_to_bottom") );
  186. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Grid"), "aopos2grid", 0, "formpart_align_to_grid") );
  187. action = createSharedAction(Kexi::DesignViewMode, i18n("Adjust Widgets Size"), "aogrid", 0, "formpart_adjust_size_menu", "TDEActionMenu");
  188. menu = static_cast<TDEActionMenu*>(action);
  189. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Fit"), "aofit", 0, "formpart_adjust_to_fit") );
  190. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Grid"), "aogrid", 0, "formpart_adjust_size_grid") );
  191. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Shortest"), "aoshortest", 0, "formpart_adjust_height_small") );
  192. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Tallest"), "aotallest", 0, "formpart_adjust_height_big") );
  193. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Narrowest"), "aonarrowest", 0, "formpart_adjust_width_small") );
  194. menu->insert( createSharedAction(Kexi::DesignViewMode, i18n("To Widest"), "aowidest", 0, "formpart_adjust_width_big") );
  195. }
  196. KexiDialogTempData*
  197. KexiFormPart::createTempData(KexiDialogBase* dialog)
  198. {
  199. return new KexiFormPart::TempData(TQT_TQOBJECT(dialog));
  200. }
  201. KexiViewBase* KexiFormPart::createView(TQWidget *parent, KexiDialogBase* dialog,
  202. KexiPart::Item &item, int viewMode, TQMap<TQString,TQString>*)
  203. {
  204. Q_UNUSED( viewMode );
  205. kexipluginsdbg << "KexiFormPart::createView()" << endl;
  206. KexiMainWindow *win = dialog->mainWin();
  207. if (!win || !win->project() || !win->project()->dbConnection())
  208. return 0;
  209. KexiFormView *view = new KexiFormView(win, parent, item.name().latin1(),
  210. win->project()->dbConnection() );
  211. return view;
  212. }
  213. void
  214. KexiFormPart::generateForm(KexiDB::FieldList *list, TQDomDocument &domDoc)
  215. {
  216. //this form generates a .ui from FieldList list
  217. //basically that is a Label and a LineEdit for each field
  218. domDoc = TQDomDocument("UI");
  219. TQDomElement uiElement = domDoc.createElement("UI");
  220. domDoc.appendChild(uiElement);
  221. uiElement.setAttribute("version", "3.1");
  222. uiElement.setAttribute("stdsetdef", 1);
  223. TQDomElement baseClass = domDoc.createElement("class");
  224. uiElement.appendChild(baseClass);
  225. TQDomText baseClassV = domDoc.createTextNode(TQWIDGET_OBJECT_NAME_STRING);
  226. baseClass.appendChild(baseClassV);
  227. TQDomElement baseWidget = domDoc.createElement("widget");
  228. baseWidget.setAttribute("class", TQWIDGET_OBJECT_NAME_STRING);
  229. int y=0;
  230. for(unsigned int i=0; i < list->fieldCount(); i++)
  231. {
  232. TQDomElement lclass = domDoc.createElement("widget");
  233. baseWidget.appendChild(lclass);
  234. lclass.setAttribute("class", TQLABEL_OBJECT_NAME_STRING);
  235. TQDomElement lNameProperty = domDoc.createElement("property");
  236. lNameProperty.setAttribute("name", "name");
  237. TQDomElement lType = domDoc.createElement("cstring");
  238. TQDomText lClassN = domDoc.createTextNode(TQString("l%1").arg(list->field(i)->name()));
  239. lType.appendChild(lClassN);
  240. lNameProperty.appendChild(lType);
  241. lclass.appendChild(lNameProperty);
  242. TQDomElement gNameProperty = domDoc.createElement("property");
  243. gNameProperty.setAttribute("name", "geometry");
  244. TQDomElement lGType = domDoc.createElement("rect");
  245. TQDomElement lx = domDoc.createElement("x");
  246. TQDomText lxV = domDoc.createTextNode("10");
  247. lx.appendChild(lxV);
  248. TQDomElement ly = domDoc.createElement("y");
  249. TQDomText lyV = domDoc.createTextNode(TQString::number(y + 10));
  250. ly.appendChild(lyV);
  251. TQDomElement lWidth = domDoc.createElement("width");
  252. TQDomText lWidthV = domDoc.createTextNode("100");
  253. lWidth.appendChild(lWidthV);
  254. TQDomElement lHeight = domDoc.createElement("height");
  255. TQDomText lHeightV = domDoc.createTextNode("20");
  256. lHeight.appendChild(lHeightV);
  257. lGType.appendChild(lx);
  258. lGType.appendChild(ly);
  259. lGType.appendChild(lWidth);
  260. lGType.appendChild(lHeight);
  261. gNameProperty.appendChild(lGType);
  262. lclass.appendChild(gNameProperty);
  263. TQDomElement tNameProperty = domDoc.createElement("property");
  264. tNameProperty.setAttribute("name", "text");
  265. TQDomElement lTType = domDoc.createElement("string");
  266. TQDomText lTextV = domDoc.createTextNode(list->field(i)->name());
  267. lTType.appendChild(lTextV);
  268. tNameProperty.appendChild(lTType);
  269. lclass.appendChild(tNameProperty);
  270. ///line edit!
  271. TQDomElement vclass = domDoc.createElement("widget");
  272. baseWidget.appendChild(vclass);
  273. vclass.setAttribute("class", "KLineEdit");
  274. TQDomElement vNameProperty = domDoc.createElement("property");
  275. vNameProperty.setAttribute("name", "name");
  276. TQDomElement vType = domDoc.createElement("cstring");
  277. TQDomText vClassN = domDoc.createTextNode(list->field(i)->name());
  278. vType.appendChild(vClassN);
  279. vNameProperty.appendChild(vType);
  280. vclass.appendChild(vNameProperty);
  281. TQDomElement vgNameProperty = domDoc.createElement("property");
  282. vgNameProperty.setAttribute("name", "geometry");
  283. TQDomElement vGType = domDoc.createElement("rect");
  284. TQDomElement vx = domDoc.createElement("x");
  285. TQDomText vxV = domDoc.createTextNode("110");
  286. vx.appendChild(vxV);
  287. TQDomElement vy = domDoc.createElement("y");
  288. TQDomText vyV = domDoc.createTextNode(TQString::number(y + 10));
  289. vy.appendChild(vyV);
  290. TQDomElement vWidth = domDoc.createElement("width");
  291. TQDomText vWidthV = domDoc.createTextNode("200");
  292. vWidth.appendChild(vWidthV);
  293. TQDomElement vHeight = domDoc.createElement("height");
  294. TQDomText vHeightV = domDoc.createTextNode("20");
  295. vHeight.appendChild(vHeightV);
  296. vGType.appendChild(vx);
  297. vGType.appendChild(vy);
  298. vGType.appendChild(vWidth);
  299. vGType.appendChild(vHeight);
  300. vgNameProperty.appendChild(vGType);
  301. vclass.appendChild(vgNameProperty);
  302. y += 20;
  303. }
  304. TQDomElement lNameProperty = domDoc.createElement("property");
  305. lNameProperty.setAttribute("name", "name");
  306. TQDomElement lType = domDoc.createElement("cstring");
  307. TQDomText lClassN = domDoc.createTextNode("DBForm");
  308. lType.appendChild(lClassN);
  309. lNameProperty.appendChild(lType);
  310. baseWidget.appendChild(lNameProperty);
  311. TQDomElement wNameProperty = domDoc.createElement("property");
  312. wNameProperty.setAttribute("name", "geometry");
  313. TQDomElement wGType = domDoc.createElement("rect");
  314. TQDomElement wx = domDoc.createElement("x");
  315. TQDomText wxV = domDoc.createTextNode("0");
  316. wx.appendChild(wxV);
  317. TQDomElement wy = domDoc.createElement("y");
  318. TQDomText wyV = domDoc.createTextNode("0");
  319. wy.appendChild(wyV);
  320. TQDomElement wWidth = domDoc.createElement("width");
  321. TQDomText wWidthV = domDoc.createTextNode("340");
  322. wWidth.appendChild(wWidthV);
  323. TQDomElement wHeight = domDoc.createElement("height");
  324. TQDomText wHeightV = domDoc.createTextNode(TQString::number(y + 30));
  325. wHeight.appendChild(wHeightV);
  326. wGType.appendChild(wx);
  327. wGType.appendChild(wy);
  328. wGType.appendChild(wWidth);
  329. wGType.appendChild(wHeight);
  330. wNameProperty.appendChild(wGType);
  331. baseWidget.appendChild(wNameProperty);
  332. uiElement.appendChild(baseWidget);
  333. }
  334. void KexiFormPart::slotAutoTabStopsSet(KFormDesigner::Form *form, bool set)
  335. {
  336. Q_UNUSED( form );
  337. KoProperty::Property &p = (*KFormDesigner::FormManager::self()->propertySet())["autoTabStops"];
  338. if (!p.isNull())
  339. p.setValue(TQVariant(set, 4));
  340. }
  341. void KexiFormPart::slotAssignAction()
  342. {
  343. KexiDBForm *dbform;
  344. if (!KFormDesigner::FormManager::self()->activeForm() || !KFormDesigner::FormManager::self()->activeForm()->designMode()
  345. || !(dbform = dynamic_cast<KexiDBForm*>(KFormDesigner::FormManager::self()->activeForm()->formWidget())))
  346. return;
  347. KFormDesigner::WidgetPropertySet * propSet = KFormDesigner::FormManager::self()->propertySet();
  348. KoProperty::Property &onClickActionProp = propSet->property("onClickAction");
  349. if (onClickActionProp.isNull())
  350. return;
  351. KoProperty::Property &onClickActionOptionProp = propSet->property("onClickActionOption");
  352. KexiFormEventAction::ActionData data;
  353. data.string = onClickActionProp.value().toString();
  354. if (!onClickActionOptionProp.isNull())
  355. data.option = onClickActionOptionProp.value().toString();
  356. KexiFormScrollView *scrollViewWidget = dynamic_cast<KexiFormScrollView*>(dbform->dataAwareObject());
  357. if (!scrollViewWidget)
  358. return;
  359. KexiFormView* formViewWidget = dynamic_cast<KexiFormView*>(scrollViewWidget->parent());
  360. if (!formViewWidget)
  361. return;
  362. KexiMainWindow * mainWin = formViewWidget->parentDialog()->mainWin();
  363. KexiActionSelectionDialog dlg(mainWin, dbform, data,
  364. propSet->property("name").value().toCString());
  365. if(dlg.exec() == TQDialog::Accepted) {
  366. data = dlg.currentAction();
  367. //update property value
  368. propSet->property("onClickAction").setValue(data.string);
  369. propSet->property("onClickActionOption").setValue(data.option);
  370. }
  371. }
  372. TQString
  373. KexiFormPart::i18nMessage(const TQCString& englishMessage, KexiDialogBase* dlg) const
  374. {
  375. Q_UNUSED(dlg);
  376. if (englishMessage=="Design of object \"%1\" has been modified.")
  377. return i18n("Design of form \"%1\" has been modified.");
  378. if (englishMessage=="Object \"%1\" already exists.")
  379. return i18n("Form \"%1\" already exists.");
  380. return englishMessage;
  381. }
  382. void
  383. KexiFormPart::slotPropertyChanged(TQWidget *w, const TQCString &name, const TQVariant &value)
  384. {
  385. Q_UNUSED( w );
  386. if (!KFormDesigner::FormManager::self()->activeForm())
  387. return;
  388. if (name == "autoTabStops") {
  389. //TQWidget *w = KFormDesigner::FormManager::self()->activeForm()->selectedWidget();
  390. //update autoTabStops setting at KFD::Form level
  391. KFormDesigner::FormManager::self()->activeForm()->setAutoTabStops( value.toBool() );
  392. }
  393. if (KFormDesigner::FormManager::self()->activeForm()->widget() && name == "geometry") {
  394. //fall back to sizeInternal property....
  395. if (KFormDesigner::FormManager::self()->propertySet()->contains("sizeInternal"))
  396. KFormDesigner::FormManager::self()->propertySet()->property("sizeInternal").setValue(TQSize(value.toRect().size()));
  397. }
  398. }
  399. /*KFormDesigner::FormManager*
  400. KexiFormPart::manager() const
  401. {
  402. return d->manager;
  403. }*/
  404. KexiDataSourcePage* KexiFormPart::dataSourcePage() const
  405. {
  406. return d->dataSourcePage;
  407. }
  408. void KexiFormPart::setupCustomPropertyPanelTabs(KTabWidget *tab, KexiMainWindow* mainWin)
  409. {
  410. if (!d->objectTreeView) {
  411. d->objectTreeView = new KFormDesigner::ObjectTreeView(0, "KexiFormPart:ObjectTreeView");
  412. KFormDesigner::FormManager::self()->setObjectTreeView(d->objectTreeView); //important: assign to manager
  413. d->dataSourcePage = new KexiDataSourcePage(0, "dataSourcePage");
  414. connect(d->dataSourcePage, TQT_SIGNAL(jumpToObjectRequested(const TQCString&, const TQCString&)),
  415. mainWin, TQT_SLOT(highlightObject(const TQCString&, const TQCString&)));
  416. connect(d->dataSourcePage, TQT_SIGNAL(formDataSourceChanged(const TQCString&, const TQCString&)),
  417. KFormDesigner::FormManager::self(), TQT_SLOT(setFormDataSource(const TQCString&, const TQCString&)));
  418. connect(d->dataSourcePage, TQT_SIGNAL(dataSourceFieldOrExpressionChanged(const TQString&, const TQString&, KexiDB::Field::Type)),
  419. KFormDesigner::FormManager::self(), TQT_SLOT(setDataSourceFieldOrExpression(const TQString&, const TQString&, KexiDB::Field::Type)));
  420. connect(d->dataSourcePage, TQT_SIGNAL(insertAutoFields(const TQString&, const TQString&, const TQStringList&)),
  421. KFormDesigner::FormManager::self(), TQT_SLOT(insertAutoFields(const TQString&, const TQString&, const TQStringList&)));
  422. }
  423. KexiProject *prj = mainWin->project();
  424. d->dataSourcePage->setProject(prj);
  425. tab->addTab( d->dataSourcePage, SmallIconSet("application-vnd.oasis.opendocument.database"), "");
  426. tab->setTabToolTip( d->dataSourcePage, i18n("Data Source"));
  427. tab->addTab( d->objectTreeView, SmallIconSet("widgets"), "");
  428. tab->setTabToolTip( d->objectTreeView, i18n("Widgets"));
  429. }
  430. void KexiFormPart::slotWidgetCreatedByFormsLibrary(TQWidget* widget)
  431. {
  432. TQStrList signalNames(widget->metaObject()->signalNames());
  433. if (!signalNames.isEmpty()) {
  434. const char *handleDragMoveEventSignal = "handleDragMoveEvent(TQDragMoveEvent*)";
  435. const char *handleDropEventSignal = "handleDropEvent(TQDropEvent*)";
  436. for (TQStrListIterator it(signalNames); it.current(); ++it) {
  437. if (0==qstrcmp(it.current(), handleDragMoveEventSignal)) {
  438. kdDebug() << it.current() << endl;
  439. KexiFormView *formView = KexiUtils::findParent<KexiFormView>(widget, "KexiFormView");
  440. if (formView) {
  441. connect(widget, TQT_SIGNAL(handleDragMoveEvent(TQDragMoveEvent*)),
  442. formView, TQT_SLOT(slotHandleDragMoveEvent(TQDragMoveEvent*)));
  443. }
  444. }
  445. else if (0==qstrcmp(it.current(), handleDropEventSignal)) {
  446. kdDebug() << it.current() << endl;
  447. KexiFormView *formView = KexiUtils::findParent<KexiFormView>(widget, "KexiFormView");
  448. if (formView) {
  449. connect(widget, TQT_SIGNAL(handleDropEvent(TQDropEvent*)),
  450. formView, TQT_SLOT(slotHandleDropEvent(TQDropEvent*)));
  451. }
  452. }
  453. }
  454. }
  455. }
  456. //----------------
  457. KexiFormPart::TempData::TempData(TQObject* parent)
  458. : KexiDialogTempData(parent)
  459. {
  460. }
  461. KexiFormPart::TempData::~TempData()
  462. {
  463. }
  464. #include "kexiformpart.moc"