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

« back to all changes in this revision

Viewing changes to kspread/database/Database.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
{
40
40
public:
41
41
    Private()
42
 
        : source( 0 )
43
 
        , sort( 0 )
44
 
        , filter(new Filter())
45
 
        , subtotalRules( 0 )
46
 
        , isSelection( false )
47
 
        , onUpdateKeepStyles( false )
48
 
        , onUpdateKeepSize( true )
49
 
        , hasPersistentData( true )
50
 
        , orientation( Row )
51
 
        , containsHeader( true )
52
 
        , displayFilterButtons( false )
53
 
        , refreshDelay( 0 )
54
 
    {
 
42
            : source(0)
 
43
            , sort(0)
 
44
            , filter(new Filter())
 
45
            , subtotalRules(0)
 
46
            , isSelection(false)
 
47
            , onUpdateKeepStyles(false)
 
48
            , onUpdateKeepSize(true)
 
49
            , hasPersistentData(true)
 
50
            , orientation(Row)
 
51
            , containsHeader(true)
 
52
            , displayFilterButtons(false)
 
53
            , refreshDelay(0) {
55
54
    }
56
55
 
57
56
    Private(const Private& other)
58
 
        : QSharedData(other)
59
 
        , source(/*other.source ? new DatabaseSource(*other.source) : */0)
60
 
        , sort(/*other.sort ? new Sort(*other.sort) : */0)
61
 
        , filter(other.filter ? new Filter(*other.filter) : 0)
62
 
        , subtotalRules(/*other.subtotalRules ? new SubtotalRules(*other.subtotalRules) : */0)
63
 
        , name(other.name)
64
 
        , isSelection(other.isSelection)
65
 
        , onUpdateKeepStyles(other.onUpdateKeepStyles)
66
 
        , onUpdateKeepSize(other.onUpdateKeepSize)
67
 
        , hasPersistentData(other.hasPersistentData)
68
 
        , orientation(other.orientation)
69
 
        , containsHeader(other.containsHeader)
70
 
        , displayFilterButtons(other.displayFilterButtons)
71
 
        , targetRangeAddress(other.targetRangeAddress)
72
 
        , refreshDelay(other.refreshDelay)
73
 
    {
 
57
            : QSharedData(other)
 
58
            , source(/*other.source ? new DatabaseSource(*other.source) : */0)
 
59
            , sort(/*other.sort ? new Sort(*other.sort) : */0)
 
60
            , filter(other.filter ? new Filter(*other.filter) : 0)
 
61
            , subtotalRules(/*other.subtotalRules ? new SubtotalRules(*other.subtotalRules) : */0)
 
62
            , name(other.name)
 
63
            , isSelection(other.isSelection)
 
64
            , onUpdateKeepStyles(other.onUpdateKeepStyles)
 
65
            , onUpdateKeepSize(other.onUpdateKeepSize)
 
66
            , hasPersistentData(other.hasPersistentData)
 
67
            , orientation(other.orientation)
 
68
            , containsHeader(other.containsHeader)
 
69
            , displayFilterButtons(other.displayFilterButtons)
 
70
            , targetRangeAddress(other.targetRangeAddress)
 
71
            , refreshDelay(other.refreshDelay) {
74
72
    }
75
73
 
76
 
    virtual ~Private()
77
 
    {
 
74
    virtual ~Private() {
78
75
//         delete source;
79
76
//         delete sort;
80
77
        delete filter;
86
83
    Filter* filter;
87
84
    SubtotalRules* subtotalRules;
88
85
    QString name;
89
 
    bool isSelection                    : 1;
90
 
    bool onUpdateKeepStyles             : 1;
91
 
    bool onUpdateKeepSize               : 1;
92
 
    bool hasPersistentData              : 1;
93
 
    enum { Row, Column } orientation    : 1;
94
 
    bool containsHeader                 : 1;
95
 
    bool displayFilterButtons           : 1;
 
86
bool isSelection                    : 1;
 
87
bool onUpdateKeepStyles             : 1;
 
88
bool onUpdateKeepSize               : 1;
 
89
bool hasPersistentData              : 1;
 
90
enum { Row, Column } orientation    : 1;
 
91
bool containsHeader                 : 1;
 
92
bool displayFilterButtons           : 1;
96
93
    Region targetRangeAddress;
97
94
    int refreshDelay;
98
95
 
101
98
};
102
99
 
103
100
Database::Database()
104
 
    : d( new Private )
 
101
        : d(new Private)
105
102
{
106
103
}
107
104
 
108
 
Database::Database( const QString& name )
109
 
    : d( new Private )
 
105
Database::Database(const QString& name)
 
106
        : d(new Private)
110
107
{
111
108
    d->name = name;
112
109
}
113
110
 
114
111
Database::Database(const Database& other)
115
 
    : d(other.d)
 
112
        : d(other.d)
116
113
{
117
114
}
118
115
 
155
152
    return d->displayFilterButtons;
156
153
}
157
154
 
158
 
void Database::setDisplayFilterButtons( bool enable )
 
155
void Database::setDisplayFilterButtons(bool enable)
159
156
{
160
157
    d->displayFilterButtons = enable;
161
158
}
165
162
    return d->targetRangeAddress;
166
163
}
167
164
 
168
 
void Database::setRange( const Region& region )
 
165
void Database::setRange(const Region& region)
169
166
{
170
 
    Q_ASSERT( region.isContiguous() );
 
167
    Q_ASSERT(region.isContiguous());
171
168
    d->targetRangeAddress = region;
172
169
}
173
170
 
196
193
{
197
194
    if (element.hasAttributeNS(KoXmlNS::table, "name"))
198
195
        d->name = element.attributeNS(KoXmlNS::table, "name", QString());
199
 
    if (element.hasAttributeNS(KoXmlNS::table, "is-selection"))
200
 
    {
 
196
    if (element.hasAttributeNS(KoXmlNS::table, "is-selection")) {
201
197
        if (element.attributeNS(KoXmlNS::table, "is-selection", "false") == "true")
202
198
            d->isSelection = true;
203
199
        else
204
200
            d->isSelection = false;
205
201
    }
206
 
    if (element.hasAttributeNS(KoXmlNS::table, "on-update-keep-styles"))
207
 
    {
 
202
    if (element.hasAttributeNS(KoXmlNS::table, "on-update-keep-styles")) {
208
203
        if (element.attributeNS(KoXmlNS::table, "on-update-keep-styles", "false") == "true")
209
204
            d->onUpdateKeepStyles = true;
210
205
        else
211
206
            d->onUpdateKeepStyles = false;
212
207
    }
213
 
    if (element.hasAttributeNS(KoXmlNS::table, "on-update-keep-size"))
214
 
    {
 
208
    if (element.hasAttributeNS(KoXmlNS::table, "on-update-keep-size")) {
215
209
        if (element.attributeNS(KoXmlNS::table, "on-update-keep-size", "true") == "false")
216
210
            d->onUpdateKeepSize = false;
217
211
        else
218
212
            d->onUpdateKeepSize = true;
219
213
    }
220
 
    if (element.hasAttributeNS(KoXmlNS::table, "has-persistent-data"))
221
 
    {
 
214
    if (element.hasAttributeNS(KoXmlNS::table, "has-persistent-data")) {
222
215
        if (element.attributeNS(KoXmlNS::table, "has-persistent-data", "true") == "false")
223
216
            d->hasPersistentData = false;
224
217
        else
225
218
            d->hasPersistentData = true;
226
219
    }
227
 
    if (element.hasAttributeNS(KoXmlNS::table, "orientation"))
228
 
    {
 
220
    if (element.hasAttributeNS(KoXmlNS::table, "orientation")) {
229
221
        if (element.attributeNS(KoXmlNS::table, "orientation", "row") == "column")
230
222
            d->orientation = Private::Column;
231
223
        else
232
224
            d->orientation = Private::Row;
233
225
    }
234
 
    if (element.hasAttributeNS(KoXmlNS::table, "contains-header"))
235
 
    {
 
226
    if (element.hasAttributeNS(KoXmlNS::table, "contains-header")) {
236
227
        if (element.attributeNS(KoXmlNS::table, "contains-header", "true") == "false")
237
228
            d->containsHeader = false;
238
229
        else
239
230
            d->containsHeader = true;
240
231
    }
241
 
    if (element.hasAttributeNS(KoXmlNS::table, "display-filter-buttons"))
242
 
    {
 
232
    if (element.hasAttributeNS(KoXmlNS::table, "display-filter-buttons")) {
243
233
        if (element.attributeNS(KoXmlNS::table, "display-filter-buttons", "false") == "true")
244
234
            d->displayFilterButtons = true;
245
235
        else
246
236
            d->displayFilterButtons = false;
247
237
    }
248
 
    if (element.hasAttributeNS(KoXmlNS::table, "target-range-address"))
249
 
    {
 
238
    if (element.hasAttributeNS(KoXmlNS::table, "target-range-address")) {
250
239
        const QString address = element.attributeNS(KoXmlNS::table, "target-range-address", QString());
251
240
        // only absolute addresses allowed; no fallback sheet needed
252
241
        d->targetRangeAddress = Region(Region::loadOdf(address), map);
253
242
        if (!d->targetRangeAddress.isValid())
254
243
            return false;
255
244
    }
256
 
    if (element.hasAttributeNS(KoXmlNS::table, "refresh-delay"))
257
 
    {
 
245
    if (element.hasAttributeNS(KoXmlNS::table, "refresh-delay")) {
258
246
        bool ok = false;
259
247
        d->refreshDelay = element.attributeNS(KoXmlNS::table, "refresh-delay", QString()).toInt(&ok);
260
248
        if (!ok || d->refreshDelay < 0)
261
249
            return false;
262
250
    }
263
251
    KoXmlElement child;
264
 
    forEachElement(child, element)
265
 
    {
 
252
    forEachElement(child, element) {
266
253
        if (child.namespaceURI() != KoXmlNS::table)
267
254
            continue;
268
 
        if (child.localName() == "database-source-sql")
269
 
        {
270
 
            // TODO
271
 
        }
272
 
        else if (child.localName() == "database-source-table")
273
 
        {
274
 
            // TODO
275
 
        }
276
 
        else if (child.localName() == "database-source-query")
277
 
        {
278
 
            // TODO
279
 
        }
280
 
        else if (child.localName() == "sort")
281
 
        {
282
 
            // TODO
283
 
        }
284
 
        else if (child.localName() == "filter")
285
 
        {
 
255
        if (child.localName() == "database-source-sql") {
 
256
            // TODO
 
257
        } else if (child.localName() == "database-source-table") {
 
258
            // TODO
 
259
        } else if (child.localName() == "database-source-query") {
 
260
            // TODO
 
261
        } else if (child.localName() == "sort") {
 
262
            // TODO
 
263
        } else if (child.localName() == "filter") {
286
264
            d->filter = new Filter();
287
 
            if (!d->filter->loadOdf(child, map))
288
 
            {
 
265
            if (!d->filter->loadOdf(child, map)) {
289
266
                delete d->filter;
290
267
                d->filter = 0;
291
268
                return false;
292
269
            }
293
 
        }
294
 
        else if (child.localName() == "subtotal-rules")
295
 
        {
 
270
        } else if (child.localName() == "subtotal-rules") {
296
271
            // TODO
297
272
        }
298
273
    }
335
310
    xmlWriter.endElement();
336
311
}
337
312
 
338
 
void Database::operator=( const Database& other )
 
313
void Database::operator=(const Database & other)
339
314
{
340
315
    d = other.d;
341
316
}
342
317
 
343
 
bool Database::operator==( const Database& other ) const
 
318
bool Database::operator==(const Database& other) const
344
319
{
345
320
    // NOTE Stefan: Don't compare targetRangeAddress.
346
321
    if (d->name != other.d->name)
372
347
    return true;
373
348
}
374
349
 
375
 
bool Database::operator<( const Database& other ) const
 
350
bool Database::operator<(const Database& other) const
376
351
{
377
352
    return (d < other.d);
378
353
}