~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kexi/plugins/forms/kexidataprovider.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
   You should have received a copy of the GNU Library General Public License
15
15
   along with this library; see the file COPYING.LIB.  If not, write to
16
 
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
   Boston, MA 02111-1307, USA.
 
16
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
 * Boston, MA 02110-1301, USA.
18
18
*/
19
19
 
20
20
#include "kexidataprovider.h"
28
28
#include <tableview/kexitableitem.h>
29
29
#include <tableview/kexitableviewdata.h>
30
30
#include <kexidb/queryschema.h>
31
 
#include <kexi_utils.h>
 
31
#include <kexiutils/utils.h>
32
32
 
33
 
#include "kexidbform.h"
 
33
#include "widgets/kexidbform.h"
34
34
 
35
35
KexiFormDataProvider::KexiFormDataProvider()
36
36
 : KexiDataItemChangesListener()
62
62
                if (!dynamic_cast<KexiFormDataItemInterface*>(obj))
63
63
                        continue;
64
64
#if 0 //! @todo reenable when subform is moved to KexiDBForm
65
 
                KexiDBForm *dbForm = Kexi::findParent<KexiDBForm>(obj, "KexiDBForm"); //form's surface...
 
65
                KexiDBForm *dbForm = KexiUtils::findParent<KexiDBForm>(obj, "KexiDBForm"); //form's surface...
66
66
                if (dbForm!=m_mainWidget) //only set data for this form's data items
67
67
                        continue;
68
68
#else
69
69
                //tmp: reject widgets within subforms
70
 
                if (Kexi::findParent<KexiDBForm>(obj, "KexiSubForm"))
 
70
                if (KexiUtils::findParent<KexiDBForm>(obj, "KexiDBSubForm"))
71
71
                        continue;
72
72
#endif
73
73
                QString dataSource( dynamic_cast<KexiFormDataItemInterface*>(obj)->dataSource().lower() );
92
92
        for (KexiFormDataItemInterfaceToIntMap::ConstIterator it = m_fieldNumbersForDataItems.constBegin(); 
93
93
                it!=m_fieldNumbersForDataItems.constEnd(); ++it)
94
94
        {
95
 
                kdDebug() << "fill data of '" << it.key()->dataSource() <<  "' at idx=" << it.data() << endl;
 
95
                kexipluginsdbg << "fill data of '" << it.key()->dataSource() <<  "' at idx=" << it.data() << endl;
96
96
                it.key()->setValue( row.at(it.data()) );
97
97
        }
98
98
}
106
106
                QMap<KexiDB::Field*,int> tmpDuplicatedItems;
107
107
                QMapIterator<KexiDB::Field*,int> it_dup;
108
108
                for (QPtrListIterator<KexiFormDataItemInterface> it(m_dataItems); it.current(); ++it) {
109
 
                        it_dup = tmpDuplicatedItems.find( it.current()->field() );
 
109
                        it_dup = tmpDuplicatedItems.find( it.current()->columnInfo()->field );
110
110
                        uint count;
111
111
                        if (it_dup==tmpDuplicatedItems.end())
112
112
                                count = 0;
113
113
                        else
114
114
                                count = it_dup.data();
115
 
                        tmpDuplicatedItems.insert( it.current()->field(), ++count );
 
115
                        tmpDuplicatedItems.insert( it.current()->columnInfo()->field, ++count );
116
116
                }
117
117
                m_duplicatedItems = new QPtrDict<char>(101);
118
118
                for (it_dup = tmpDuplicatedItems.begin(); it_dup!=tmpDuplicatedItems.end(); ++it_dup) {
119
119
                        if (it_dup.data() > 1) {
120
 
        m_duplicatedItems->insert( it_dup.key(), (char*)1 );
121
 
                                kdDebug() << "duplicated item: " << static_cast<KexiDB::Field*>(it_dup.key())->name() 
 
120
                                m_duplicatedItems->insert( it_dup.key(), (char*)1 );
 
121
                                kexipluginsdbg << "duplicated item: " << static_cast<KexiDB::Field*>(it_dup.key())->name() 
122
122
                                        << " (" << it_dup.data() << " times)" << endl;
123
123
                        }
124
124
                }
125
125
        }
126
 
        if (m_duplicatedItems->find( item->field() )) {
 
126
        if (m_duplicatedItems->find( item->columnInfo()->field )) {
127
127
                for (QPtrListIterator<KexiFormDataItemInterface> it(m_dataItems); it.current(); ++it) {
128
 
                        if (it.current()!=item && item->field() == it.current()->field()) {
129
 
                                kdDebug() << "- setting value for item '" 
 
128
                        if (it.current()!=item && item->columnInfo()->field == it.current()->columnInfo()->field) {
 
129
                                kexipluginsdbg << "- setting value for item '" 
130
130
                                        << dynamic_cast<QObject*>(it.current())->name() << " == " << value.toString() << endl;
131
131
                                it.current()->setValue( value );
132
132
                        }
136
136
 
137
137
void KexiFormDataProvider::valueChanged(KexiDataItemInterface* item)
138
138
{
 
139
        Q_UNUSED( item );
 
140
}
 
141
 
 
142
bool KexiFormDataProvider::cursorAtNewRow()
 
143
{
 
144
        return false;
139
145
}
140
146
 
141
147
void KexiFormDataProvider::invalidateDataSources( const QValueList<uint>& invalidSources,
148
154
        if (query) {
149
155
                fieldsExpanded = query->fieldsExpanded();
150
156
                dataFieldsCount = fieldsExpanded.count();
151
 
                QMap<KexiDB::QueryColumnInfo*,uint> fieldsOrder( query->fieldsOrder() );
152
 
                for (QMapConstIterator<KexiDB::QueryColumnInfo*,uint> it = fieldsOrder.constBegin(); it!=fieldsOrder.constEnd(); ++it) {
153
 
                        kdDebug() << "query->fieldsOrder()[ " << it.key()->field->name() << " ] = " << it.data() << endl;
 
157
                QMap<KexiDB::QueryColumnInfo*,int> fieldsOrder( query->fieldsOrder() );
 
158
                for (QMapConstIterator<KexiDB::QueryColumnInfo*,int> it = fieldsOrder.constBegin(); it!=fieldsOrder.constEnd(); ++it) {
 
159
                        kexipluginsdbg << "query->fieldsOrder()[ " << it.key()->field->name() << " ] = " << it.data() << endl;
154
160
                }
155
161
                for (QPtrListIterator<KexiFormDataItemInterface> it(m_dataItems); it.current(); ++it) {
156
162
                        KexiFormDataItemInterface *item = it.current();
157
163
                        KexiDB::QueryColumnInfo* ci = query->columnInfo( it.current()->dataSource() );
158
164
                        int index = ci ? query->fieldsOrder()[ ci ] : -1;
159
 
                        kdDebug() << "query->fieldsOrder()[ " << (ci ? ci->field->name() : "") << " ] = " << index 
 
165
                        kexipluginsdbg << "query->fieldsOrder()[ " << (ci ? ci->field->name() : "") << " ] = " << index 
160
166
                                << " (dataSource: " << item->dataSource() << ", name=" << dynamic_cast<QObject*>(item)->name() << ")" << endl;
161
167
                        if (index!=-1)
162
168
                                m_fieldNumbersForDataItems.insert( item, index );
227
233
                uint fieldNumber = m_fieldNumbersForDataItems[ item ];
228
234
                if (query) {
229
235
                        KexiDB::QueryColumnInfo *ci = fieldsExpanded[fieldNumber];
230
 
//! @todo what about using QueryColumnInfo here?
231
 
                        KexiDB::Field *f = ci->field;
232
 
                        it.current()->setField(f);
233
 
                        kdDebug() << "- item=" << dynamic_cast<QObject*>(it.current())->name() 
 
236
//                      KexiDB::Field *f = ci->field;
 
237
                        it.current()->setColumnInfo(ci);
 
238
                        kexipluginsdbg << "- item=" << dynamic_cast<QObject*>(it.current())->name() 
234
239
                                << " dataSource=" << it.current()->dataSource()
235
 
                                << " field=" << f->name() << endl;
 
240
                                << " field=" << ci->field->name() << endl;
236
241
                }
237
242
                tmpUsedDataSources.replace( it.current()->dataSource().lower(), (char*)1 );
238
243
        }