summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/forms/kexidataprovider.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/plugins/forms/kexidataprovider.h
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/plugins/forms/kexidataprovider.h')
-rw-r--r--kexi/plugins/forms/kexidataprovider.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/kexi/plugins/forms/kexidataprovider.h b/kexi/plugins/forms/kexidataprovider.h
new file mode 100644
index 00000000..64019842
--- /dev/null
+++ b/kexi/plugins/forms/kexidataprovider.h
@@ -0,0 +1,95 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Jaroslaw Staniek <[email protected]>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KEXIFORMDATAPROVIDER_H
+#define KEXIFORMDATAPROVIDER_H
+
+#include "kexiformdataiteminterface.h"
+#include <qptrdict.h>
+#include <qdict.h>
+
+class KexiTableItem;
+namespace KexiDB {
+ class QuerySchema;
+}
+
+//! @short The KexiFormDataProvider class is a data provider for Kexi Forms
+/*! This provider collects data-aware widgets using setMainWidget().
+ Then, usedDataSources() unique list of required field names is available.
+ On every call of fillDataItems() method, the provider will fill data items
+ with appropriate data from a database cursor.
+
+ Field names are collected effectively, so eg. having widgets using data sources:
+ ("name", "surname", "surname", "name") - "name" and "surname" repeated - will only
+ return ("name", "surname") list, so the cursor's query can be simplified
+ and thus more effective.
+*/
+class KEXIFORMUTILS_EXPORT KexiFormDataProvider : public KexiDataItemChangesListener
+{
+ public:
+ KexiFormDataProvider();
+ virtual ~KexiFormDataProvider();
+
+ /*! sets \a mainWidget to be a main widget for this data provider.
+ Also find widgets whose will work as data items
+ (all of them must implement KexiFormDataItemInterface), so these could be
+ filled with data on demand. */
+ void setMainDataSourceWidget(QWidget* mainWidget);
+
+ QStringList usedDataSources() const { return m_usedDataSources; }
+
+ //unused QPtrList<KexiFormDataItemInterface>& dataItems() { return m_dataItems; }
+
+ /*! Fills data items with appropriate data fetched from \a cursor.
+ \a newRowEditing == true means that we are at new (not yet inserted) database row. */
+ void fillDataItems(KexiTableItem& row, bool cursorAtNewRow);
+
+ /*! Implementation for KexiDataItemChangesListener.
+ Reaction for change of \a item. Does nothing here. */
+ virtual void valueChanged(KexiDataItemInterface* item);
+
+ /*! Implementation for KexiDataItemChangesListener.
+ Implement this to return information whether we're currently at new row or now.
+ This can be used e.g. by data-aware widgets to determine if "(autonumber)"
+ label should be displayed. Returns false here. */
+ virtual bool cursorAtNewRow() const;
+
+ /*! Invalidates data sources collected by this provided.
+ \a invalidSources is the set of data sources that should
+ be omitted for fillDataItems().
+ Used by KexiFormView::initDataSource(). */
+ void invalidateDataSources( const QDict<char>& invalidSources,
+ KexiDB::QuerySchema* query = 0 );
+
+ /*! Fills the same data provided by \a value to every data item (other than \a item)
+ having the same data source as \a item. This method is called immediately when
+ \a value is changed, so duplicated data items are quickly updated. */
+ void fillDuplicatedDataItems(KexiFormDataItemInterface* item, const QVariant& value);
+
+ protected:
+ QWidget *m_mainWidget;
+ QPtrDict<char> *m_duplicatedItems;
+ typedef QMap<KexiFormDataItemInterface*,uint> KexiFormDataItemInterfaceToIntMap;
+ QPtrList<KexiFormDataItemInterface> m_dataItems;
+ QStringList m_usedDataSources;
+ KexiFormDataItemInterfaceToIntMap m_fieldNumbersForDataItems;
+ bool m_disableFillDuplicatedDataItems : 1;
+};
+
+#endif