kexi

kexiformview.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2004-2005 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "kexiformview.h"
00022 
00023 #include <qobjectlist.h>
00024 #include <qfileinfo.h>
00025 
00026 #include <formeditor/form.h>
00027 #include <formeditor/formIO.h>
00028 #include <formeditor/formmanager.h>
00029 #include <formeditor/objecttree.h>
00030 #include <formeditor/container.h>
00031 #include <formeditor/widgetpropertyset.h>
00032 #include <formeditor/commands.h>
00033 
00034 #include <kexi.h>
00035 #include <kexidialogbase.h>
00036 #include <kexidragobjects.h>
00037 #include <kexidb/field.h>
00038 #include <kexidb/fieldlist.h>
00039 #include <kexidb/connection.h>
00040 #include <kexidb/cursor.h>
00041 #include <kexidb/utils.h>
00042 #include <kexidb/preparedstatement.h>
00043 #include <tableview/kexitableitem.h>
00044 #include <tableview/kexitableviewdata.h>
00045 #include <widget/kexipropertyeditorview.h>
00046 #include <formeditor/objecttree.h>
00047 
00048 #include <koproperty/set.h>
00049 #include <koproperty/property.h>
00050 
00051 #include "widgets/kexidbform.h"
00052 #include "kexiformscrollview.h"
00053 #include "kexidatasourcepage.h"
00054 #include "widgets/kexidbautofield.h"
00055 
00056 #define NO_DSWIZARD
00057 
00059 
00060 KexiFormView::KexiFormView(KexiMainWindow *mainWin, QWidget *parent,
00061     const char *name, bool /*dbAware*/)
00062  : KexiDataAwareView( mainWin, parent, name )
00063  , m_propertySet(0)
00064  , m_resizeMode(KexiFormView::ResizeDefault)
00065  , m_query(0)
00066  , m_queryIsOwned(false)
00067  , m_cursor(0)
00068 // , m_firstFocusWidget(0)
00069 {
00070     m_delayedFormContentsResizeOnShow = 0;
00071 
00072     QHBoxLayout *l = new QHBoxLayout(this);
00073     l->setAutoAdd(true);
00074 
00075     m_scrollView = new KexiFormScrollView(this, viewMode()==Kexi::DataViewMode);
00076 
00077 //moved setViewWidget(m_scrollView);
00078 //  m_scrollView->show();
00079 
00080     m_dbform = new KexiDBForm(m_scrollView->viewport(), m_scrollView, name/*, conn*/);
00081 //  m_dbform->resize( m_scrollView->viewport()->size() - QSize(20, 20) );
00082 //  m_dbform->resize(QSize(400, 300));
00083     m_scrollView->setWidget(m_dbform);
00084     m_scrollView->setResizingEnabled(viewMode()!=Kexi::DataViewMode);
00085 
00086 //  initForm();
00087 
00088     if (viewMode()==Kexi::DataViewMode) {
00089         m_scrollView->recordNavigator()->setRecordHandler( m_scrollView );
00090         m_scrollView->viewport()->setPaletteBackgroundColor(m_dbform->palette().active().background());
00091 //moved to formmanager      connect(formPart()->manager(), SIGNAL(noFormSelected()), SLOT(slotNoFormSelected()));
00092     }
00093     else
00094     {
00095         connect(KFormDesigner::FormManager::self(), SIGNAL(propertySetSwitched(KoProperty::Set*, bool)),
00096             this, SLOT(slotPropertySetSwitched(KoProperty::Set*, bool)));
00097         connect(KFormDesigner::FormManager::self(), SIGNAL(dirty(KFormDesigner::Form *, bool)),
00098             this, SLOT(slotDirty(KFormDesigner::Form *, bool)));
00099 
00100         connect(m_dbform, SIGNAL(handleDragMoveEvent(QDragMoveEvent*)), 
00101             this, SLOT(slotHandleDragMoveEvent(QDragMoveEvent*)));
00102         connect(m_dbform, SIGNAL(handleDropEvent(QDropEvent*)), 
00103             this, SLOT(slotHandleDropEvent(QDropEvent*)));
00104 
00105         // action stuff
00106         plugSharedAction("formpart_taborder", KFormDesigner::FormManager::self(), SLOT(editTabOrder()));
00107         plugSharedAction("formpart_adjust_size", KFormDesigner::FormManager::self(), SLOT(adjustWidgetSize()));
00108 //TODO      plugSharedAction("formpart_pixmap_collection", formPart()->manager(), SLOT(editFormPixmapCollection()));
00109 //TODO      plugSharedAction("formpart_connections", formPart()->manager(), SLOT(editConnections()));
00110 
00111         plugSharedAction("edit_copy", KFormDesigner::FormManager::self(), SLOT(copyWidget()));
00112         plugSharedAction("edit_cut", KFormDesigner::FormManager::self(), SLOT(cutWidget()));
00113         plugSharedAction("edit_paste", KFormDesigner::FormManager::self(), SLOT(pasteWidget()));
00114         plugSharedAction("edit_delete", KFormDesigner::FormManager::self(), SLOT(deleteWidget()));
00115         plugSharedAction("edit_select_all", KFormDesigner::FormManager::self(), SLOT(selectAll()));
00116         plugSharedAction("formpart_clear_contents", KFormDesigner::FormManager::self(), SLOT(clearWidgetContent()));
00117         plugSharedAction("edit_undo", KFormDesigner::FormManager::self(), SLOT(undo()));
00118         plugSharedAction("edit_redo", KFormDesigner::FormManager::self(), SLOT(redo()));
00119 
00120         plugSharedAction("formpart_layout_menu", KFormDesigner::FormManager::self(), 0 );
00121         plugSharedAction("formpart_layout_hbox", KFormDesigner::FormManager::self(), SLOT(layoutHBox()) );
00122         plugSharedAction("formpart_layout_vbox", KFormDesigner::FormManager::self(), SLOT(layoutVBox()) );
00123         plugSharedAction("formpart_layout_grid", KFormDesigner::FormManager::self(), SLOT(layoutGrid()) );
00124 #ifdef KEXI_SHOW_SPLITTER_WIDGET
00125         plugSharedAction("formpart_layout_hsplitter", KFormDesigner::FormManager::self(), SLOT(layoutHSplitter()) );
00126         plugSharedAction("formpart_layout_vsplitter", KFormDesigner::FormManager::self(), SLOT(layoutVSplitter()) );
00127 #endif
00128         plugSharedAction("formpart_break_layout", KFormDesigner::FormManager::self(), SLOT(breakLayout()) );
00129 
00130         plugSharedAction("formpart_format_raise", KFormDesigner::FormManager::self(), SLOT(bringWidgetToFront()) );
00131         plugSharedAction("formpart_format_lower", KFormDesigner::FormManager::self(), SLOT(sendWidgetToBack()) );
00132 
00133         plugSharedAction("other_widgets_menu", KFormDesigner::FormManager::self(), 0 );
00134         setAvailable("other_widgets_menu", true);
00135 
00136         plugSharedAction("formpart_align_menu", KFormDesigner::FormManager::self(), 0 );
00137         plugSharedAction("formpart_align_to_left", KFormDesigner::FormManager::self(),SLOT(alignWidgetsToLeft()) );
00138         plugSharedAction("formpart_align_to_right", KFormDesigner::FormManager::self(), SLOT(alignWidgetsToRight()) );
00139         plugSharedAction("formpart_align_to_top", KFormDesigner::FormManager::self(), SLOT(alignWidgetsToTop()) );
00140         plugSharedAction("formpart_align_to_bottom", KFormDesigner::FormManager::self(), SLOT(alignWidgetsToBottom()) );
00141         plugSharedAction("formpart_align_to_grid", KFormDesigner::FormManager::self(), SLOT(alignWidgetsToGrid()) );
00142 
00143         plugSharedAction("formpart_adjust_size_menu", KFormDesigner::FormManager::self(), 0 );
00144         plugSharedAction("formpart_adjust_to_fit", KFormDesigner::FormManager::self(), SLOT(adjustWidgetSize()) );
00145         plugSharedAction("formpart_adjust_size_grid", KFormDesigner::FormManager::self(), SLOT(adjustSizeToGrid()) );
00146         plugSharedAction("formpart_adjust_height_small", KFormDesigner::FormManager::self(),  SLOT(adjustHeightToSmall()) );
00147         plugSharedAction("formpart_adjust_height_big", KFormDesigner::FormManager::self(), SLOT(adjustHeightToBig()) );
00148         plugSharedAction("formpart_adjust_width_small", KFormDesigner::FormManager::self(), SLOT(adjustWidthToSmall()) );
00149         plugSharedAction("formpart_adjust_width_big", KFormDesigner::FormManager::self(), SLOT(adjustWidthToBig()) );
00150 
00151         plugSharedAction("format_font", KFormDesigner::FormManager::self(), SLOT(changeFont()) );
00152     }
00153 
00154     initForm();
00155 
00156     KexiDataAwareView::init( m_scrollView, m_scrollView, m_scrollView,
00157         /* skip data-awarness if design mode */ viewMode()==Kexi::DesignViewMode );
00158 
00159     connect(this, SIGNAL(focus(bool)), this, SLOT(slotFocus(bool)));
00161 //  m_dbform->resize( m_dbform->size()+QSize(m_scrollView->verticalScrollBar()->width(), m_scrollView->horizontalScrollBar()->height()) );
00162 }
00163 
00164 KexiFormView::~KexiFormView()
00165 {
00166     deleteQuery();
00167     if (m_cursor) {
00168         KexiDB::Connection *conn = parentDialog()->mainWin()->project()->dbConnection();
00169         conn->deleteCursor(m_cursor);
00170     }
00171 
00172     // Important: form window is closed.
00173     // Set property set to 0 because there is *only one* instance of a property set class
00174     // in Kexi, so the main window wouldn't know the set in fact has been changed.
00175     m_propertySet = 0;
00176     propertySetSwitched();
00177 }
00178 
00179 void
00180 KexiFormView::deleteQuery()
00181 {
00182     if (m_queryIsOwned) {
00183         delete m_query;
00184     } else {
00186     }
00187     m_query = 0;
00188 }
00189 
00190 KFormDesigner::Form*
00191 KexiFormView::form() const
00192 {
00193     if(viewMode()==Kexi::DataViewMode)
00194         return tempData()->previewForm;
00195     else
00196         return tempData()->form;
00197 }
00198 
00199 void
00200 KexiFormView::setForm(KFormDesigner::Form *f)
00201 {
00202     if(viewMode()==Kexi::DataViewMode)
00203         tempData()->previewForm = f;
00204     else
00205         tempData()->form = f;
00206 }
00207 
00208 void
00209 KexiFormView::initForm()
00210 {
00211     setForm( new KFormDesigner::Form(KexiFormPart::library(), 0, viewMode()==Kexi::DesignViewMode) );
00212 //  if (viewMode()==Kexi::DataViewMode)
00213         //form()->setDesignMode(false);
00214     form()->createToplevel(m_dbform, m_dbform);
00215 
00216     if (viewMode()==Kexi::DesignViewMode) {
00217         //we want to be informed about executed commands
00218         connect(form()->commandHistory(), SIGNAL(commandExecuted()),
00219             KFormDesigner::FormManager::self(), SLOT(slotHistoryCommandExecuted()));
00220     }
00221 
00222     const bool newForm = parentDialog()->id() < 0;
00223 
00224     KexiDB::FieldList *fields = 0;
00225     if (newForm) {
00226         // Show the form wizard if this is a new Form
00227 #ifndef NO_DSWIZARD
00228         KexiDataSourceWizard *w = new KexiDataSourceWizard(mainWin(), (QWidget*)mainWin(), "datasource_wizard");
00229         if(!w->exec())
00230             fields = 0;
00231         else
00232             fields = w->fields();
00233         delete w;
00234 #endif
00235     }
00236 
00237     if(fields)
00238     {
00239         QDomDocument dom;
00240         formPart()->generateForm(fields, dom);
00241         KFormDesigner::FormIO::loadFormFromDom(form(), m_dbform, dom);
00243     }
00244     else
00245         loadForm();
00246 
00247     if(form()->autoTabStops())
00248         form()->autoAssignTabStops();
00249 
00250     //collect tab order information
00251     m_dbform->updateTabStopsOrder(form());
00252 
00253 //  if (m_dbform->orderedFocusWidgets()->first())
00254     //  m_scrollView->setFocusProxy( m_dbform->orderedFocusWidgets()->first() );
00255 
00256     KFormDesigner::FormManager::self()->importForm(form(), viewMode()==Kexi::DataViewMode);
00257     m_scrollView->setForm(form());
00258 
00259 //  m_dbform->updateTabStopsOrder(form());
00260 //  QSize s = m_dbform->size();
00261 //  QApplication::sendPostedEvents();
00262 //  m_scrollView->resize( s );
00263 //  m_dbform->resize(s);
00264     m_scrollView->refreshContentsSize();
00265 //  m_scrollView->refreshContentsSizeLater(true,true);
00266 
00267     if (newForm && !fields) {
00268         /* Our form's area will be resized more than once.
00269         Let's resize form widget itself later. */
00270         m_delayedFormContentsResizeOnShow = 3;
00271     }
00272 
00273     updateDataSourcePage();
00274 
00275     if (!newForm && viewMode()==Kexi::DesignViewMode) {
00276         form()->clearCommandHistory();
00277     }
00278 }
00279 
00280 
00281 void
00282 KexiFormView::loadForm()
00283 {
00284 //@todo also load m_resizeMode !
00285 
00286     kexipluginsdbg << "KexiFormView::loadForm() Loading the form with id : " << parentDialog()->id() << endl;
00287     // If we are previewing the Form, use the tempData instead of the form stored in the db
00288     if(viewMode()==Kexi::DataViewMode && !tempData()->tempForm.isNull() )
00289     {
00290         KFormDesigner::FormIO::loadFormFromString(form(), m_dbform, tempData()->tempForm);
00291         return;
00292     }
00293 
00294     // normal load
00295     QString data;
00296     loadDataBlock(data);
00297     KFormDesigner::FormIO::loadFormFromString(form(), m_dbform, data);
00298 
00299     //"autoTabStops" property is loaded -set it within the form tree as well
00300     form()->setAutoTabStops( m_dbform->autoTabStops() );
00301 
00303     //update autofields: 
00304     //-inherit captions
00305     //-inherit data types
00306     //(this data has not been stored in the form)
00307     QString dataSourceString( m_dbform->dataSource() );
00308     QCString dataSourceMimeTypeString( m_dbform->dataSourceMimeType() );
00309     KexiDB::Connection *conn = parentDialog()->mainWin()->project()->dbConnection();
00310     KexiDB::TableOrQuerySchema tableOrQuery(
00311         conn, dataSourceString.latin1(), dataSourceMimeTypeString=="kexi/table");
00312     if (tableOrQuery.table() || tableOrQuery.query()) {
00313         for (KFormDesigner::ObjectTreeDictIterator it(*form()->objectTree()->dict());
00314             it.current(); ++it)
00315         {
00316             KexiDBAutoField *afWidget = dynamic_cast<KexiDBAutoField*>( it.current()->widget() );
00317             if (afWidget) {
00318                 KexiDB::QueryColumnInfo *colInfo = tableOrQuery.columnInfo( afWidget->dataSource() );
00319                 if (colInfo) {
00320                     afWidget->setColumnInfo(colInfo);
00321                         //setFieldTypeInternal((int)colInfo->field->type());
00322                         //afWidget->setFieldCaptionInternal(colInfo->captionOrAliasOrName());
00323                 }
00324             }
00325         }
00326     }
00327     else {
00328 //      kexipluginsdbg << "KexiFormView::loadForm(): no table/query" << endl;
00329     }
00330 }
00331 
00332 void
00333 KexiFormView::slotPropertySetSwitched(KoProperty::Set *set, bool forceReload)
00334 {
00335     //if (m_buffer == b)
00336     //  return;
00337     m_propertySet = set;
00338     if (forceReload)
00339         propertySetReloaded(true/*preservePrevSelection*/);
00340     else
00341         propertySetSwitched();
00342 
00343     formPart()->dataSourcePage()->assignPropertySet(m_propertySet);
00344 }
00345 
00346 tristate
00347 KexiFormView::beforeSwitchTo(int mode, bool &dontStore)
00348 {
00349     if (mode!=viewMode()) {
00350         if (viewMode()==Kexi::DataViewMode) {
00351             if (!m_scrollView->acceptRowEdit())
00352                 return cancelled;
00353 
00354             m_scrollView->beforeSwitchView();
00355         }
00356         else {
00357             //remember our pos
00358             tempData()->scrollViewContentsPos
00359                 = QPoint(m_scrollView->contentsX(), m_scrollView->contentsY());
00360         }
00361     }
00362 
00363     // we don't store on db, but in our TempData
00364     dontStore = true;
00365     if(dirty() && (mode == Kexi::DataViewMode) && form()->objectTree()) {
00366         KexiFormPart::TempData* temp = tempData();
00367         if (!KFormDesigner::FormIO::saveFormToString(form(), temp->tempForm))
00368             return false;
00369     }
00370 
00371     return true;
00372 }
00373 
00374 tristate
00375 KexiFormView::afterSwitchFrom(int mode)
00376 {
00377     if (mode == 0 || mode == Kexi::DesignViewMode) {
00378         if (parentDialog()->neverSaved()) {
00379             m_dbform->resize(QSize(400, 300));
00380             m_scrollView->refreshContentsSizeLater(true,true);
00381             //m_delayedFormContentsResizeOnShow = false;
00382         }
00383     }
00384 
00385     if (mode != 0 && mode != Kexi::DesignViewMode) {
00386         //preserve contents pos after switching to other view
00387         m_scrollView->setContentsPos(tempData()->scrollViewContentsPos.x(),
00388             tempData()->scrollViewContentsPos.y());
00389     }
00390 //  if (mode == Kexi::DesignViewMode) {
00391         //m_scrollView->move(0,0);
00392         //m_scrollView->setContentsPos(0,0);
00393         //m_scrollView->moveChild(m_dbform, 0, 0);
00394 //  }
00395 
00396     if((mode == Kexi::DesignViewMode) && viewMode()==Kexi::DataViewMode) {
00397         // The form may have been modified, so we must recreate the preview
00398         delete m_dbform; // also deletes form()
00399         m_dbform = new KexiDBForm(m_scrollView->viewport(), m_scrollView, "KexiDBForm");
00400         m_scrollView->setWidget(m_dbform);
00401 
00402         initForm();
00403 //moved to formmanager      slotNoFormSelected();
00404 
00405         //reset position
00406         m_scrollView->setContentsPos(0,0);
00407         m_dbform->move(0,0);
00408 
00409     }
00410 
00411     //update tab stops if needed
00412     if (viewMode()==Kexi::DataViewMode) {
00413 //      //propagate current "autoTabStops" property value to the form tree
00414 //      form()->setAutoTabStops( m_dbform->autoTabStops() );
00415 
00416 //      if(form()->autoTabStops())
00417 //          form()->autoAssignTabStops();
00418     }
00419     else {
00420         //set "autoTabStops" property
00421         m_dbform->setAutoTabStops( form()->autoTabStops() );
00422     }
00423 
00424     if (viewMode() == Kexi::DataViewMode) {
00425 //TMP!!
00426         initDataSource();
00427 
00428         //handle events for this form
00429         m_scrollView->setMainWidgetForEventHandling(parentDialog()->mainWin(), m_dbform);
00430 
00431         //set focus on 1st focusable widget which has valid dataSource property set
00432         if (!m_dbform->orderedFocusWidgets()->isEmpty()) {
00433 //          QWidget *www = focusWidget();
00434             //if (Kexi::hasParent(this, qApp->focusWidget())) {
00435                 QEvent fe( QEvent::FocusOut );
00436                 QFocusEvent::setReason(QFocusEvent::Tab);
00437                 QApplication::sendEvent( qApp->focusWidget(), &fe );
00438                 QFocusEvent::resetReason();
00439             //}
00440 
00441             QPtrListIterator<QWidget> it(*m_dbform->orderedFocusWidgets());
00442             for (;it.current(); ++it) {
00443                 KexiFormDataItemInterface *iface = dynamic_cast<KexiFormDataItemInterface*>(it.current());
00444                 if (iface)
00445                     kexipluginsdbg << iface->dataSource() << endl;
00446                 if (iface && iface->columnInfo() && !iface->isReadOnly()
00448                     /* also skip autoincremented fields:*/
00449                     && !iface->columnInfo()->field->isAutoIncrement()) 
00450                     break;
00451             }
00452             if (!it.current()) //eventually, focus first available widget if nothing other is available
00453                 it.toFirst();
00454 
00455             it.current()->setFocus();
00456             SET_FOCUS_USING_REASON(it.current(), QFocusEvent::Tab);
00457             m_setFocusInternalOnce = it.current();
00458         }
00459 
00460         if (m_query)
00461             m_scrollView->selectFirstRow();
00462     }
00463 
00464     //dirty only if it's a new object
00465     if (mode == 0)
00466         setDirty( parentDialog()->partItem()->neverSaved() );
00467 
00468     if (mode==Kexi::DataViewMode && viewMode()==Kexi::DesignViewMode) {
00469 //      slotPropertySetSwitched
00470 //      emit KFormDesigner::FormManager::self()->propertySetSwitched( KFormDesigner::FormManager::self()->propertySet()->set(), true );
00471     }
00472 
00473     return true;
00474 }
00475 
00476 void KexiFormView::initDataSource()
00477 {
00478     deleteQuery();
00479     QString dataSourceString( m_dbform->dataSource() );
00480     QCString dataSourceMimeTypeString( m_dbform->dataSourceMimeType() );
00482     bool ok = !dataSourceString.isEmpty();
00483 
00484 /*          if (m_previousDataSourceString.lower()==dataSourceString.lower() && !m_cursor) {
00485             //data source changed: delete previous cursor
00486             m_conn->deleteCursor(m_cursor);
00487             m_cursor = 0;
00488         }*/
00489 
00490     KexiDB::TableSchema *tableSchema = 0;
00491     KexiDB::Connection *conn = 0;
00492     QStringList sources;
00493 
00494     if (ok) {
00495 //      m_previousDataSourceString = dataSourceString;
00496 
00497         //collect all data-aware widgets and create query schema
00498         m_scrollView->setMainDataSourceWidget(m_dbform);
00499         sources = m_scrollView->usedDataSources();
00500         conn = parentDialog()->mainWin()->project()->dbConnection();
00501         if (dataSourceMimeTypeString.isEmpty() /*table type is the default*/ 
00502             || dataSourceMimeTypeString=="kexi/table")
00503         {
00504             tableSchema = conn->tableSchema( dataSourceString );
00505             if (tableSchema) {
00506                 /* We will build a _minimum_ query schema from selected table fields. */
00507                 m_query = new KexiDB::QuerySchema();
00508                 m_queryIsOwned = true;
00509 
00510                 if (dataSourceMimeTypeString.isEmpty())
00511                     m_dbform->setDataSourceMimeType("kexi/table"); //update for compatibility
00512             }
00513         }
00514         
00515         if (!tableSchema) {
00516             if (dataSourceMimeTypeString.isEmpty() /*also try to find a query (for compatibility with Kexi<=0.9)*/ 
00517                 || dataSourceMimeTypeString=="kexi/query")
00518             {
00519                 //try to find predefined query schema.
00520                 //Note: In general, we could not skip unused fields within this query because
00521                 //      it can have GROUP BY clause.
00523                 m_query = conn->querySchema( dataSourceString );
00524                 m_queryIsOwned = false;
00525                 ok = m_query != 0;
00526                 if (ok && dataSourceMimeTypeString.isEmpty())
00527                     m_dbform->setDataSourceMimeType("kexi/query"); //update for compatibility
00528             }
00529             else //no other mime types supported
00530                 ok = false;
00531         }
00532     }
00533 
00534     QValueList<uint> invalidSources;
00535     if (ok) {
00536         KexiDB::IndexSchema *pkey = tableSchema ? tableSchema->primaryKey() : 0;
00537         if (pkey) {
00538             //always add all fields from table's primary key
00539             // (don't worry about duplicated, unique list will be computed later)
00540             sources += pkey->names();
00541             KexiDBDbg << "KexiFormView::initDataSource(): pkey added to data sources: " << pkey->names() << endl;
00542         }
00543 
00544         uint index = 0;
00545         for (QStringList::ConstIterator it = sources.constBegin();
00546             it!=sources.constEnd(); ++it, index++) {
00548             QString fieldName( (*it).lower() );
00549             //remove "tablename." if it was prepended
00550             if (tableSchema && fieldName.startsWith( tableSchema->name().lower()+"." ))
00551                 fieldName = fieldName.mid(tableSchema->name().length()+1);
00552             //remove "queryname." if it was prepended
00553             if (!tableSchema && fieldName.startsWith( m_query->name().lower()+"." ))
00554                 fieldName = fieldName.mid(m_query->name().length()+1);
00555             KexiDB::Field *f = tableSchema ? tableSchema->field(fieldName) : m_query->field(fieldName);
00556             if (!f) {
00558                 //remove this widget from the set of data widgets in the provider
00559                 invalidSources += index;
00560                 continue;
00561             }
00562             if (tableSchema) {
00563                 if (!m_query->hasField( f )) {
00564                     //we're building a new query: add this field
00565                     m_query->addField( f );
00566                 }
00567             }
00568         }
00569         if (invalidSources.count()==sources.count()) {
00570             //all data sources are invalid! don't execute the query
00571             deleteQuery();
00572         }
00573         else {
00574             m_cursor = conn->executeQuery( *m_query );
00575         }
00576         m_scrollView->invalidateDataSources( invalidSources, m_query );
00577         ok = m_cursor!=0;
00578     }
00579 
00580     if (!invalidSources.isEmpty())
00581         m_dbform->updateTabStopsOrder();
00582 
00583     if (ok) {
00586         KexiTableViewData* data = new KexiTableViewData(m_cursor);
00587         data->preloadAllRows();
00588 
00590 //          int resultCount = -1;
00591 //          if (ok) {
00592 //              resultCount = m_conn->resultCount(m_conn->selectStatement(*m_query));
00593 //              ok = m_cursor->reopen();
00594 //          }
00595 //          if (ok)
00596 //              ok = ! (!m_cursor->moveFirst() && m_cursor->error());
00597 
00598         m_scrollView->setData( data, true /*owner*/ );
00599     }
00600     else
00601         m_scrollView->setData( 0, false );
00602 }
00603 
00604 void
00605 KexiFormView::slotDirty(KFormDesigner::Form *dirtyForm, bool isDirty)
00606 {
00607     if(dirtyForm == form())
00608         KexiViewBase::setDirty(isDirty);
00609 }
00610 
00611 KexiDB::SchemaData*
00612 KexiFormView::storeNewData(const KexiDB::SchemaData& sdata, bool &cancel)
00613 {
00614     KexiDB::SchemaData *s = KexiViewBase::storeNewData(sdata, cancel);
00615     kexipluginsdbg << "KexiDBForm::storeNewData(): new id:" << s->id() << endl;
00616 
00617     if (!s || cancel) {
00618         delete s;
00619         return 0;
00620     }
00621     if (!storeData()) {
00622         //failure: remove object's schema data to avoid garbage
00623         KexiDB::Connection *conn = parentDialog()->mainWin()->project()->dbConnection();
00624         conn->removeObject( s->id() );
00625         delete s;
00626         return 0;
00627     }
00628     return s;
00629 }
00630 
00631 tristate
00632 KexiFormView::storeData(bool dontAsk)
00633 {
00634     Q_UNUSED(dontAsk);
00635     kexipluginsdbg << "KexiDBForm::storeData(): " << parentDialog()->partItem()->name() 
00636         << " [" << parentDialog()->id() << "]" << endl;
00637 
00638     //-- first, store local BLOBs, so identifiers can be updated
00640     KexiDB::Connection *conn = parentDialog()->mainWin()->project()->dbConnection();
00641     KexiDB::TableSchema *blobsTable = conn->tableSchema("kexi__blobs");
00642     if (!blobsTable) { //compatibility check for older Kexi project versions
00644         return false;
00645     }
00646     // Not all engines accept passing NULL to PKEY o_id, so we're omitting it.
00647     QStringList blobsFieldNamesWithoutID(blobsTable->names());
00648     blobsFieldNamesWithoutID.pop_front();
00649     KexiDB::FieldList *blobsFieldsWithoutID = blobsTable->subList(blobsFieldNamesWithoutID);
00650     
00651     KexiDB::PreparedStatement::Ptr st = conn->prepareStatement(
00652         KexiDB::PreparedStatement::InsertStatement, *blobsFieldsWithoutID);
00653 //#if 0 
00655     if (!st) {
00656         delete blobsFieldsWithoutID;
00658         return false;
00659     }
00660 //#endif
00661     KexiBLOBBuffer *blobBuf = KexiBLOBBuffer::self();
00662     for (QMapConstIterator<QWidget*, KexiBLOBBuffer::Id_t> it = m_unsavedLocalBLOBs.constBegin(); 
00663         it!=m_unsavedLocalBLOBs.constEnd(); ++it)
00664     {
00665         if (!it.key()) {
00666             kexipluginswarn << "KexiFormView::storeData(): it.key()==0 !" << endl;
00667             continue;
00668         }
00669         kexipluginsdbg << "name=" << it.key()->name() << " dataID=" << it.data() << endl;
00670         KexiBLOBBuffer::Handle h( blobBuf->objectForId(it.data(), false) );
00671         if (!h)
00672             continue; //no BLOB assigned
00673 
00674         QString originalFileName(h.originalFileName());
00675         QFileInfo fi(originalFileName);
00676         QString caption(fi.baseName().replace('_', " ").simplifyWhiteSpace());
00678 
00679 //      KexiDB::PreparedStatement st(KexiDB::PreparedStatement::InsertStatement, *conn, *blobsTable);
00680         if (st) {
00681             *st /* << NO, (pgsql doesn't support this):QVariant()*/ /*id*/ 
00682                 << h.data() << originalFileName << caption 
00683                 << h.mimeType() << (uint)h.folderId();
00684             if (!st->execute()) {
00685                 delete blobsFieldsWithoutID;
00686                 kexipluginsdbg << " execute error" << endl;
00687                 return false;
00688             }
00689         }
00691 #if 0
00692         if (!conn->insertRecord(*blobsFieldsWithoutID, h.data(), originalFileName, caption, h.mimeType())) {
00693             delete blobsFieldsWithoutID;
00695             return false;
00696         }
00697 #endif
00698         delete blobsFieldsWithoutID;
00699         blobsFieldsWithoutID=0;
00700         const Q_ULLONG storedBLOBID = conn->lastInsertedAutoIncValue("o_id", "kexi__blobs");
00701         if ((Q_ULLONG)-1 == storedBLOBID) {
00703             return false;
00704         }
00705         kexipluginsdbg << " storedDataID=" << storedBLOBID << endl;
00706         h.setStoredWidthID((KexiBLOBBuffer::Id_t /*unsafe - will be fixed in Qt4*/)storedBLOBID);
00707         //set widget's internal property so it can be saved...
00708         const QVariant oldStoredPixmapId( it.key()->property("storedPixmapId") );
00709         it.key()->setProperty("storedPixmapId", 
00710             QVariant((uint /* KexiBLOBBuffer::Id_t is unsafe and unsupported by QVariant - will be fixed in Qt4*/)storedBLOBID));
00711         KFormDesigner::ObjectTreeItem *widgetItem = form()->objectTree()->lookup(it.key()->name());
00712         if (widgetItem)
00713             widgetItem->addModifiedProperty( "storedPixmapId", oldStoredPixmapId );
00714         else
00715             kexipluginswarn << "KexiFormView::storeData(): no '" << widgetItem->name() << "' widget found within a form" << endl;
00716     }
00717 //TODO: forall it.key()->setProperty(
00718 
00719     //-- now, save form's XML
00720     QString data;
00721     if (!KFormDesigner::FormIO::saveFormToString(tempData()->form, data))
00722         return false;
00723     if (!storeDataBlock(data))
00724         return false;
00725 
00726     //all blobs are now saved
00727     m_unsavedLocalBLOBs.clear();
00728 
00729     tempData()->tempForm = QString::null;
00730     return true;
00731 }
00732 
00733 #if 0
00734 
00735 void
00736 KexiFormView::slotWidgetSelected(KFormDesigner::Form *f, bool multiple)
00737 {
00738     if(f != form())
00739         return;
00740 
00741     enableFormActions();
00742     // Enable edit actions
00743     setAvailable("edit_copy", true);
00744     setAvailable("edit_cut", true);
00745     setAvailable("edit_clear", true);
00746 
00747     // 'Align Widgets' menu
00748     setAvailable("formpart_align_menu", multiple);
00749     setAvailable("formpart_align_to_left", multiple);
00750     setAvailable("formpart_align_to_right", multiple);
00751     setAvailable("formpart_align_to_top", multiple);
00752     setAvailable("formpart_align_to_bottom", multiple);
00753 
00754     setAvailable("formpart_adjust_size_menu", true);
00755     setAvailable("formpart_adjust_width_small", multiple);
00756     setAvailable("formpart_adjust_width_big", multiple);
00757     setAvailable("formpart_adjust_height_small", multiple);
00758     setAvailable("formpart_adjust_height_big", multiple);
00759 
00760     setAvailable("formpart_format_raise", true);
00761     setAvailable("formpart_format_lower", true);
00762 
00763     // If the widgets selected is a container, we enable layout actions
00764     if(!multiple)
00765     {
00766         KFormDesigner::ObjectTreeItem *item = f->objectTree()->lookup( f->selectedWidgets()->first()->name() );
00767         if(item && item->container())
00768             multiple = true;
00769     }
00770     // Layout actions
00771     setAvailable("formpart_layout_hbox", multiple);
00772     setAvailable("formpart_layout_vbox", multiple);
00773     setAvailable("formpart_layout_grid", multiple);
00774 
00775     KFormDesigner::Container *container = f->activeContainer();
00776     setAvailable("formpart_break_layout", container ?
00777         (container->layoutType() != KFormDesigner::Container::NoLayout) : false );
00778 }
00779 
00780 void
00781 KexiFormView::slotFormWidgetSelected(KFormDesigner::Form *f)
00782 {
00783     if(f != form())
00784         return;
00785 
00786     disableWidgetActions();
00787     enableFormActions();
00788 
00789     // Layout actions
00790     setAvailable("formpart_layout_hbox", true);
00791     setAvailable("formpart_layout_vbox", true);
00792     setAvailable("formpart_layout_grid", true);
00793     setAvailable("formpart_break_layout", (f->toplevelContainer()->layoutType() != KFormDesigner::Container::NoLayout));
00794 }
00795 
00796 void
00797 KexiFormView::slotNoFormSelected() // == form in preview mode
00798 {
00799     disableWidgetActions();
00800 
00801     // Disable paste action
00802     setAvailable("edit_paste", false);
00803     setAvailable("edit_undo", false);
00804     setAvailable("edit_redo", false);
00805 
00806     // Disable 'Tools' actions
00807     setAvailable("formpart_pixmap_collection", false);
00808     setAvailable("formpart_connections", false);
00809     setAvailable("formpart_taborder", false);
00810     setAvailable("formpart_change_style", false);
00811 }
00812 
00813 void
00814 KexiFormView::enableFormActions()
00815 {
00816     // Enable 'Tools' actions
00817     setAvailable("formpart_pixmap_collection", true);
00818     setAvailable("formpart_connections", true);
00819     setAvailable("formpart_taborder", true);
00820 
00821     setAvailable("edit_paste", KFormDesigner::FormManager::self()->isPasteEnabled());
00822 }
00823 
00824 void
00825 KexiFormView::disableWidgetActions()
00826 {
00827     // Disable edit actions
00828     setAvailable("edit_copy", false);
00829     setAvailable("edit_cut", false);
00830     setAvailable("edit_clear", false);
00831 
00832     // Disable format functions
00833     setAvailable("formpart_align_menu", false);
00834     setAvailable("formpart_align_to_left", false);
00835     setAvailable("formpart_align_to_right", false);
00836     setAvailable("formpart_align_to_top", false);
00837     setAvailable("formpart_align_to_bottom", false);
00838 
00839     setAvailable("formpart_adjust_size_menu", false);
00840     setAvailable("formpart_adjust_width_small", false);
00841     setAvailable("formpart_adjust_width_big", false);
00842     setAvailable("formpart_adjust_height_small", false);
00843     setAvailable("formpart_adjust_height_big", false);
00844 
00845     setAvailable("formpart_format_raise", false);
00846     setAvailable("formpart_format_lower", false);
00847 
00848     setAvailable("formpart_layout_hbox", false);
00849     setAvailable("formpart_layout_vbox", false);
00850     setAvailable("formpart_layout_grid", false);
00851     setAvailable("formpart_break_layout", false);
00852 }
00853 
00854 void
00855 KexiFormView::setUndoEnabled(bool enabled)
00856 {
00857     setAvailable("edit_undo", enabled);
00858 }
00859 
00860 void
00861 KexiFormView::setRedoEnabled(bool enabled)
00862 {
00863     setAvailable("edit_redo", enabled);
00864 }
00865 #endif //0
00866 
00867 QSize
00868 KexiFormView::preferredSizeHint(const QSize& otherSize)
00869 {
00870     if (parentDialog()->neverSaved()) {
00871         //ignore otherSize if possible
00872 //      return KexiViewBase::preferredSizeHint( (parentDialog() && parentDialog()->mdiParent()) ? QSize(10000,10000) : otherSize);
00873     }
00874 
00875     return (m_dbform->size()
00876             +QSize(m_scrollView->verticalScrollBar()->isVisible() ? m_scrollView->verticalScrollBar()->width()*3/2 : 10,
00877              m_scrollView->horizontalScrollBar()->isVisible() ? m_scrollView->horizontalScrollBar()->height()*3/2 : 10))
00878         .expandedTo( KexiViewBase::preferredSizeHint(otherSize) );
00879 }
00880 
00881 void
00882 KexiFormView::resizeEvent( QResizeEvent *e )
00883 {
00884     if (viewMode()==Kexi::DataViewMode) {
00885         m_scrollView->refreshContentsSizeLater(
00886             e->size().width()!=e->oldSize().width(),
00887             e->size().height()!=e->oldSize().height()
00888         );
00889     }
00890     KexiViewBase::resizeEvent(e);
00891     m_scrollView->updateNavPanelGeometry();
00892     if (m_delayedFormContentsResizeOnShow>0) { // && isVisible()) {
00893         m_delayedFormContentsResizeOnShow--;
00894         m_dbform->resize( e->size() - QSize(30, 30) );
00895     }
00896 }
00897 
00898 void
00899 KexiFormView::setFocusInternal()
00900 {
00901     if (viewMode() == Kexi::DataViewMode) {
00902         if (m_dbform->focusWidget()) {
00903             //better-looking focus
00904             if (m_setFocusInternalOnce) {
00905                 SET_FOCUS_USING_REASON(m_setFocusInternalOnce, QFocusEvent::Tab);
00906             }
00907             else {
00908                 SET_FOCUS_USING_REASON(m_dbform->focusWidget(), QFocusEvent::Tab);
00909             }
00910             return;
00911         }
00912     }
00913     QWidget::setFocus();
00914 }
00915 
00916 void
00917 KexiFormView::show()
00918 {
00919     KexiDataAwareView::show();
00920 
00921 //moved from KexiFormScrollView::show():
00922 
00923     //now get resize mode settings for entire form
00924     //  if (resizeMode() == KexiFormView::ResizeAuto)
00925     if (viewMode()==Kexi::DataViewMode) {
00926         if (resizeMode() == KexiFormView::ResizeAuto)
00927             m_scrollView->setResizePolicy(QScrollView::AutoOneFit);
00928     }
00929 }
00930 
00931 void
00932 KexiFormView::slotFocus(bool in)
00933 {
00934     if(in && form() && KFormDesigner::FormManager::self() && KFormDesigner::FormManager::self()->activeForm() != form()) {
00935         KFormDesigner::FormManager::self()->windowChanged(m_dbform);
00936         updateDataSourcePage();
00937     }
00938 }
00939 
00940 void
00941 KexiFormView::updateDataSourcePage()
00942 {
00943     if (viewMode()==Kexi::DesignViewMode) {
00944         QCString dataSourceMimeType, dataSource;
00945         KFormDesigner::WidgetPropertySet *set = KFormDesigner::FormManager::self()->propertySet();
00946         if (set->contains("dataSourceMimeType"))
00947             dataSourceMimeType = (*set)["dataSourceMimeType"].value().toCString();
00948         if (set->contains("dataSource"))
00949             dataSource = (*set)["dataSource"].value().toCString();
00950 
00951         formPart()->dataSourcePage()->setDataSource(dataSourceMimeType, dataSource);
00952     }
00953 }
00954 
00955 void
00956 KexiFormView::slotHandleDragMoveEvent(QDragMoveEvent* e)
00957 {
00958     if (KexiFieldDrag::canDecodeMultiple( e )) {
00959         e->accept(true);
00960         //dirty:    drawRect(QRect( e->pos(), QSize(50, 20)), 2);
00961     }
00962 }
00963 
00964 void
00965 KexiFormView::slotHandleDropEvent(QDropEvent* e)
00966 {
00967     if (KexiFieldDrag::canDecodeMultiple( e )) {
00968         QString sourceMimeType, sourceName;
00969         QStringList fields;
00970         if (!KexiFieldDrag::decodeMultiple( e, sourceMimeType, sourceName, fields ))
00971             return;
00972         insertAutoFields(sourceMimeType, sourceName, fields, e->pos());
00973     }
00974 }
00975 
00976 void
00977 KexiFormView::insertAutoFields(const QString& sourceMimeType, const QString& sourceName,
00978     const QStringList& fields, const QPoint& _pos)
00979 {
00980     if (fields.isEmpty())
00981         return;
00982 
00983     KexiDB::Connection *conn = parentDialog()->mainWin()->project()->dbConnection();
00984     KexiDB::TableOrQuerySchema tableOrQuery(conn, sourceName.latin1(), sourceMimeType=="kexi/table");
00985     if (!tableOrQuery.table() && !tableOrQuery.query()) {
00986         kexipluginswarn << "KexiFormView::insertAutoFields(): no such table/query \""
00987             << sourceName << "\"" << endl;
00988         return;
00989     }
00990 
00991     QPoint pos(_pos);
00992     //if pos is not specified, compute a new position:
00993     if (pos==QPoint(-1,-1)) {
00994         if (m_widgetGeometryForRecentInsertAutoFields.isValid()) {
00995             pos = m_widgetGeometryForRecentInsertAutoFields.bottomLeft() 
00996                 + QPoint(0,form()->gridSize());
00997         }
00998         else {
00999             pos = QPoint(40, 40); //start here
01000         }
01001     }
01002 
01004 
01005 //      KFormDesigner::WidgetList* prevSelection = form()->selectedWidgets();
01006     KFormDesigner::WidgetList widgetsToSelect;
01007     KFormDesigner::CommandGroup *group = new KFormDesigner::CommandGroup(
01008         fields.count()==1 ? i18n("Insert AutoField widget") : i18n("Insert %1 AutoField widgets").arg(fields.count()),
01009         KFormDesigner::FormManager::self()->propertySet()
01010     );
01011 
01012     foreach( QStringList::ConstIterator, it, fields ) {
01013         KexiDB::QueryColumnInfo* column = tableOrQuery.columnInfo(*it);
01014         if (!column) {
01015             kexipluginswarn << "KexiFormView::insertAutoFields(): no such field \""
01016                 << *it << "\" in table/query \"" << sourceName << "\"" << endl;
01017             continue;
01018         }
01020         KFormDesigner::InsertWidgetCommand *insertCmd
01021             = new KFormDesigner::InsertWidgetCommand(form()->toplevelContainer(),
01023                 "KexiDBAutoField",
01025             pos, column->aliasOrName()
01026         );
01027         insertCmd->execute();
01028         group->addCommand(insertCmd, false/*don't exec twice*/);
01029 
01030         KFormDesigner::ObjectTreeItem *newWidgetItem 
01031             = form()->objectTree()->dict()->find(insertCmd->widgetName());
01032         KexiDBAutoField* newWidget 
01033             = newWidgetItem ? dynamic_cast<KexiDBAutoField*>(newWidgetItem->widget()) : 0;
01034         widgetsToSelect.append(newWidget);
01035 //#if 0
01036         KFormDesigner::CommandGroup *subGroup 
01037             = new KFormDesigner::CommandGroup("", KFormDesigner::FormManager::self()->propertySet());
01038         QMap<QCString, QVariant> propValues;
01039         propValues.insert("dataSource", column->aliasOrName());
01040         propValues.insert("fieldTypeInternal", (int)column->field->type());
01041         propValues.insert("fieldCaptionInternal", column->captionOrAliasOrName());
01042         KFormDesigner::FormManager::self()->propertySet()->createPropertyCommandsInDesignMode(
01043             newWidget, propValues, subGroup, false, 
01044             true );
01045         subGroup->execute();
01046         group->addCommand( subGroup, false/*will not be executed on CommandGroup::execute()*/ );
01047 
01048 //#endif
01049         //set data source and caption
01050         //-we don't need to use PropertyCommand here beacause we don't need UNDO 
01051         // for these single commands
01052 //      newWidget->setDataSource(column->aliasOrName());
01053 //      newWidget->setFieldTypeInternal((int)column->field->type());
01054 //      newWidget->setFieldCaptionInternal(column->captionOrAliasOrName());
01055         //resize again because autofield's type changed what can lead to changed sizeHint() 
01056 //      newWidget->resize(newWidget->sizeHint());
01057         KFormDesigner::WidgetList list;
01058         list.append(newWidget);
01059         KFormDesigner::AdjustSizeCommand *adjustCommand 
01060             =   new KFormDesigner::AdjustSizeCommand(KFormDesigner::AdjustSizeCommand::SizeToFit,
01061                 list, form());
01062         adjustCommand->execute();
01063         group->addCommand( adjustCommand,
01064             false/*will not be executed on CommandGroup::execute()*/
01065         );
01066 
01067         if (newWidget) {//move position down for next widget
01068             pos.setY( pos.y() + newWidget->height() + form()->gridSize());
01069         }
01070     }
01071     if (widgetsToSelect.last()) {
01072         //resize form if needed
01073         QRect oldFormRect( m_dbform->geometry() );
01074         QRect newFormRect( oldFormRect );
01075         newFormRect.setWidth(QMAX(m_dbform->width(), widgetsToSelect.last()->geometry().right()+1));
01076         newFormRect.setHeight(QMAX(m_dbform->height(), widgetsToSelect.last()->geometry().bottom()+1));
01077         if (newFormRect != oldFormRect) {
01078             //1. resize by hand
01079             m_dbform->setGeometry( newFormRect );
01080             //2. store information about resize
01081             KFormDesigner::PropertyCommand *resizeFormCommand = new KFormDesigner::PropertyCommand(
01082                 KFormDesigner::FormManager::self()->propertySet(), m_dbform->name(),
01083                 oldFormRect, newFormRect, "geometry"); 
01084             group->addCommand(resizeFormCommand, true/*will be executed on CommandGroup::execute()*/);
01085         }
01086 
01087         //remember geometry of the last inserted widget
01088         m_widgetGeometryForRecentInsertAutoFields = widgetsToSelect.last()->geometry();
01089     }
01090 
01091     //eventually, add entire command group to active form
01092     form()->addCommand( group, true/*exec*/ );
01093 
01094 //  group->debug();
01095 
01096     //enable proper REDO usage
01097     group->resetAllowExecuteFlags();
01098 
01099     m_scrollView->repaint();
01100     m_scrollView->viewport()->repaint();
01101     m_scrollView->repaintContents();
01102     m_scrollView->updateContents();
01103     m_scrollView->clipper()->repaint();
01104     m_scrollView->refreshContentsSize();
01105 
01106     //select all inserted widgets, if multiple
01107     if (widgetsToSelect.count()>1) {
01108         form()->setSelectedWidget(0);
01109         foreach_list (KFormDesigner::WidgetListIterator, it, widgetsToSelect)
01110             form()->setSelectedWidget(it.current(), true/*add*/, true/*dontRaise*/);
01111     }
01112 }
01113 
01114 void
01115 KexiFormView::setUnsavedLocalBLOB(QWidget *widget, KexiBLOBBuffer::Id_t id)
01116 {
01118     if (id==0) 
01119         m_unsavedLocalBLOBs.remove(widget);
01120     else
01121         m_unsavedLocalBLOBs.insert(widget, id);
01122 }
01123 
01124 /*
01125 todo
01126 void KexiFormView::updateActions(bool activated)
01127 {
01128     if (viewMode()==Kexi::DesignViewMode) {
01129         if (form()->selectedWidget()) {
01130             if (form()->widget() == form()->selectedWidget())
01131                 KFormDesigner::FormManager::self()->emitFormWidgetSelected( form() );
01132             else
01133                 KFormDesigner::FormManager::self()->emitWidgetSelected( form(), false );
01134         }
01135         else if (form()->selectedWidgets()) {
01136             KFormDesigner::FormManager::self()->emitWidgetSelected( form(), true );
01137         }
01138     }
01139     KexiDataAwareView::updateActions(activated);
01140 }*/
01141 
01142 /*
01143 void KexiFormView::parentDialogDetached()
01144 {
01145     m_dbform->updateTabStopsOrder(form());
01146 }
01147 
01148 void KexiFormView::parentDialogAttached(KMdiChildFrm *)
01149 {
01150     m_dbform->updateTabStopsOrder(form());
01151 }*/
01152 
01153 #include "kexiformview.moc"
01154 
KDE Home | KDE Accessibility Home | Description of Access Keys