~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/text/qtextformat.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the text module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QTEXTFORMAT_H
 
30
#define QTEXTFORMAT_H
 
31
 
 
32
#include <QtGui/qcolor.h>
 
33
#include <QtGui/qfont.h>
 
34
#include <QtCore/qshareddata.h>
 
35
#include <QtCore/qvector.h>
 
36
#include <QtCore/qvariant.h>
 
37
#include <QtGui/qpen.h>
 
38
#include <QtGui/qbrush.h>
 
39
 
 
40
class QString;
 
41
class QVariant;
 
42
class QFont;
 
43
 
 
44
class QTextFormatCollection;
 
45
class QTextFormatPrivate;
 
46
class QTextBlockFormat;
 
47
class QTextCharFormat;
 
48
class QTextListFormat;
 
49
class QTextTableFormat;
 
50
class QTextFrameFormat;
 
51
class QTextImageFormat;
 
52
class QTextFormat;
 
53
class QTextObject;
 
54
class QTextCursor;
 
55
class QTextDocument;
 
56
class QTextLength;
 
57
 
 
58
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &);
 
59
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &);
 
60
 
 
61
class Q_GUI_EXPORT QTextLength
 
62
{
 
63
public:
 
64
    enum Type { VariableLength = 0, FixedLength, PercentageLength };
 
65
 
 
66
    inline QTextLength() : lengthType(VariableLength), fixedValueOrPercentage(0) {}
 
67
 
 
68
    inline explicit QTextLength(Type type, qreal value);
 
69
 
 
70
    inline Type type() const { return lengthType; }
 
71
    inline qreal value(qreal maximumLength) const
 
72
    {
 
73
        switch (lengthType) {
 
74
            case FixedLength: return fixedValueOrPercentage;
 
75
            case VariableLength: return maximumLength;
 
76
            case PercentageLength: return fixedValueOrPercentage * maximumLength / qreal(100);
 
77
        }
 
78
        return -1;
 
79
    }
 
80
 
 
81
    inline qreal rawValue() const { return fixedValueOrPercentage; }
 
82
 
 
83
    inline bool operator==(const QTextLength &other) const
 
84
    { return lengthType == other.lengthType && fixedValueOrPercentage == other.fixedValueOrPercentage; }
 
85
    inline bool operator!=(const QTextLength &other) const
 
86
    { return lengthType != other.lengthType || fixedValueOrPercentage != other.fixedValueOrPercentage; }
 
87
    operator QVariant() const;
 
88
 
 
89
private:
 
90
    Type lengthType;
 
91
    qreal fixedValueOrPercentage;
 
92
    friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &);
 
93
    friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &);
 
94
};
 
95
 
 
96
inline QTextLength::QTextLength(Type atype, qreal avalue)
 
97
    : lengthType(atype), fixedValueOrPercentage(avalue) {}
 
98
 
 
99
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &);
 
100
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &);
 
101
 
 
102
class Q_GUI_EXPORT QTextFormat
 
103
{
 
104
public:
 
105
    enum FormatType {
 
106
        InvalidFormat = -1,
 
107
        BlockFormat = 1,
 
108
        CharFormat = 2,
 
109
        ListFormat = 3,
 
110
        TableFormat = 4,
 
111
        FrameFormat = 5,
 
112
 
 
113
        UserFormat = 100
 
114
    };
 
115
 
 
116
    enum Property {
 
117
        ObjectIndex = 0x0,
 
118
 
 
119
        // paragraph and char
 
120
        CssFloat = 0x0800,
 
121
        LayoutDirection = 0x0801,
 
122
 
 
123
        OutlinePen = 0x810,
 
124
        BackgroundBrush = 0x820,
 
125
        ForegroundBrush = 0x821,
 
126
 
 
127
        // paragraph
 
128
        BlockAlignment = 0x1010,
 
129
        BlockTopMargin = 0x1030,
 
130
        BlockBottomMargin = 0x1031,
 
131
        BlockLeftMargin = 0x1032,
 
132
        BlockRightMargin = 0x1033,
 
133
        TextIndent = 0x1034,
 
134
        BlockIndent = 0x1040,
 
135
        BlockNonBreakableLines = 0x1050,
 
136
 
 
137
        // character properties
 
138
        FontFamily = 0x2000,
 
139
        FontPointSize = 0x2001,
 
140
        FontSizeIncrement = 0x2002,
 
141
        FontWeight = 0x2003,
 
142
        FontItalic = 0x2004,
 
143
        FontUnderline = 0x2005,
 
144
        FontOverline = 0x2006,
 
145
        FontStrikeOut = 0x2007,
 
146
        FontFixedPitch = 0x2008,
 
147
 
 
148
        TextUnderlineColor = 0x2010,
 
149
 
 
150
        TextVerticalAlignment = 0x2021,
 
151
 
 
152
        IsAnchor = 0x2030,
 
153
        AnchorHref = 0x2031,
 
154
        AnchorName = 0x2032,
 
155
 
 
156
        ObjectType = 0x2f00,
 
157
 
 
158
        // list properties
 
159
        ListStyle = 0x3000,
 
160
        ListIndent = 0x3001,
 
161
 
 
162
        // table and frame properties
 
163
        FrameBorder = 0x4000,
 
164
        FrameMargin = 0x4001,
 
165
        FramePadding = 0x4002,
 
166
        FrameWidth = 0x4003,
 
167
        FrameHeight = 0x4004,
 
168
        TableColumns = 0x4100,
 
169
        TableColumnWidthConstraints = 0x4101,
 
170
        TableCellSpacing = 0x4102,
 
171
        TableCellPadding = 0x4103,
 
172
 
 
173
        // table cell properties
 
174
        TableCellRowSpan = 0x4810,
 
175
        TableCellColumnSpan = 0x4811,
 
176
 
 
177
        // image properties
 
178
        ImageName = 0x5000,
 
179
        ImageWidth = 0x5010,
 
180
        ImageHeight = 0x5011,
 
181
 
 
182
        // internal properties
 
183
        DocumentFragmentMark = 0x6000,
 
184
 
 
185
        // --
 
186
        UserProperty = 0x100000
 
187
    };
 
188
 
 
189
    enum ObjectTypes {
 
190
        NoObject,
 
191
        ImageObject,
 
192
        TableObject
 
193
    };
 
194
 
 
195
    QTextFormat();
 
196
 
 
197
    explicit QTextFormat(int type);
 
198
 
 
199
    QTextFormat(const QTextFormat &rhs);
 
200
    QTextFormat &operator=(const QTextFormat &rhs);
 
201
    ~QTextFormat();
 
202
 
 
203
    void merge(const QTextFormat &other);
 
204
 
 
205
    inline bool isValid() const { return type() != InvalidFormat; }
 
206
 
 
207
    int type() const;
 
208
 
 
209
    int objectIndex() const;
 
210
    void setObjectIndex(int object);
 
211
 
 
212
    QVariant property(int propertyId) const;
 
213
    void setProperty(int propertyId, const QVariant &value);
 
214
    void clearProperty(int propertyId);
 
215
    bool hasProperty(int propertyId) const;
 
216
 
 
217
    bool boolProperty(int propertyId) const;
 
218
    int intProperty(int propertyId) const;
 
219
    qreal doubleProperty(int propertyId) const;
 
220
    QString stringProperty(int propertyId) const;
 
221
    QColor colorProperty(int propertyId) const;
 
222
    QPen penProperty(int propertyId) const;
 
223
    QBrush brushProperty(int propertyId) const;
 
224
    QTextLength lengthProperty(int propertyId) const;
 
225
    QVector<QTextLength> lengthVectorProperty(int propertyId) const;
 
226
 
 
227
    void setProperty(int propertyId, const QVector<QTextLength> &lengths);
 
228
 
 
229
 
 
230
    QMap<int, QVariant> properties() const;
 
231
 
 
232
    inline void setObjectType(int type);
 
233
    inline int objectType() const
 
234
    { return intProperty(ObjectType); }
 
235
 
 
236
    inline bool isCharFormat() const { return type() == CharFormat; }
 
237
    inline bool isBlockFormat() const { return type() == BlockFormat; }
 
238
    inline bool isListFormat() const { return type() == ListFormat; }
 
239
    inline bool isFrameFormat() const { return type() == FrameFormat; }
 
240
    inline bool isImageFormat() const { return type() == CharFormat && objectType() == ImageObject; }
 
241
    inline bool isTableFormat() const { return type() == FrameFormat && objectType() == TableObject; }
 
242
 
 
243
    QTextBlockFormat toBlockFormat() const;
 
244
    QTextCharFormat toCharFormat() const;
 
245
    QTextListFormat toListFormat() const;
 
246
    QTextTableFormat toTableFormat() const;
 
247
    QTextFrameFormat toFrameFormat() const;
 
248
    QTextImageFormat toImageFormat() const;
 
249
 
 
250
    bool operator==(const QTextFormat &rhs) const;
 
251
    inline bool operator!=(const QTextFormat &rhs) const { return !operator==(rhs); }
 
252
    operator QVariant() const;
 
253
 
 
254
    inline void setLayoutDirection(Qt::LayoutDirection direction)
 
255
        { setProperty(QTextFormat::LayoutDirection, direction); }
 
256
    inline Qt::LayoutDirection layoutDirection() const
 
257
        { return Qt::LayoutDirection(intProperty(QTextFormat::LayoutDirection)); }
 
258
 
 
259
    inline void setBackground(const QBrush &brush)
 
260
    { setProperty(BackgroundBrush, brush); }
 
261
    inline QBrush background() const
 
262
    { return brushProperty(BackgroundBrush); }
 
263
    inline void clearBackground()
 
264
    { clearProperty(BackgroundBrush); }
 
265
 
 
266
    inline void setForeground(const QBrush &brush)
 
267
    { setProperty(ForegroundBrush, brush); }
 
268
    inline QBrush foreground() const
 
269
    { return brushProperty(ForegroundBrush); }
 
270
    inline void clearForeground()
 
271
    { clearProperty(ForegroundBrush); }
 
272
 
 
273
private:
 
274
    QSharedDataPointer<QTextFormatPrivate> d;
 
275
    qint32 format_type;
 
276
 
 
277
    friend class QTextFormatCollection;
 
278
    friend class QTextCharFormat;
 
279
    friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &);
 
280
    friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &);
 
281
};
 
282
 
 
283
inline void QTextFormat::setObjectType(int atype)
 
284
{ setProperty(ObjectType, atype); }
 
285
 
 
286
class Q_GUI_EXPORT QTextCharFormat : public QTextFormat
 
287
{
 
288
public:
 
289
    enum VerticalAlignment { AlignNormal = 0, AlignSuperScript, AlignSubScript };
 
290
 
 
291
    QTextCharFormat();
 
292
 
 
293
    bool isValid() const { return isCharFormat(); }
 
294
    void setFont(const QFont &font);
 
295
    QFont font() const;
 
296
 
 
297
    inline void setFontFamily(const QString &family)
 
298
    { setProperty(FontFamily, family); }
 
299
    inline QString fontFamily() const
 
300
    { return stringProperty(FontFamily); }
 
301
 
 
302
    inline void setFontPointSize(qreal size)
 
303
    { setProperty(FontPointSize, size); }
 
304
    inline qreal fontPointSize() const
 
305
    { return doubleProperty(FontPointSize); }
 
306
 
 
307
    inline void setFontWeight(int weight)
 
308
    { if (weight == QFont::Normal) weight = 0; setProperty(FontWeight, weight); }
 
309
    inline int fontWeight() const
 
310
    { int weight = intProperty(FontWeight); if (weight == 0) weight = QFont::Normal; return weight; }
 
311
    inline void setFontItalic(bool italic)
 
312
    { setProperty(FontItalic, italic); }
 
313
    inline bool fontItalic() const
 
314
    { return boolProperty(FontItalic); }
 
315
 
 
316
    inline void setFontUnderline(bool underline)
 
317
    { setProperty(FontUnderline, underline); }
 
318
    inline bool fontUnderline() const
 
319
    { return boolProperty(FontUnderline); }
 
320
 
 
321
    inline void setFontOverline(bool overline)
 
322
    { setProperty(FontOverline, overline); }
 
323
    inline bool fontOverline() const
 
324
    { return boolProperty(FontOverline); }
 
325
 
 
326
    inline void setFontStrikeOut(bool strikeOut)
 
327
    { setProperty(FontStrikeOut, strikeOut); }
 
328
    inline bool fontStrikeOut() const
 
329
    { return boolProperty(FontStrikeOut); }
 
330
 
 
331
    inline void setUnderlineColor(const QColor &color)
 
332
    { setProperty(TextUnderlineColor, color); }
 
333
    inline QColor underlineColor() const
 
334
    { return colorProperty(TextUnderlineColor); }
 
335
 
 
336
    inline void setFontFixedPitch(bool fixedPitch)
 
337
    { setProperty(FontFixedPitch, fixedPitch); }
 
338
    inline bool fontFixedPitch() const
 
339
    { return boolProperty(FontFixedPitch); }
 
340
 
 
341
    inline void setVerticalAlignment(VerticalAlignment alignment)
 
342
    { setProperty(TextVerticalAlignment, alignment); }
 
343
    inline VerticalAlignment verticalAlignment() const
 
344
    { return static_cast<VerticalAlignment>(intProperty(TextVerticalAlignment)); }
 
345
 
 
346
    inline void setAnchor(bool anchor)
 
347
    { setProperty(IsAnchor, anchor); }
 
348
    inline bool isAnchor() const
 
349
    { return boolProperty(IsAnchor); }
 
350
 
 
351
    inline void setAnchorHref(const QString &value)
 
352
    { setProperty(AnchorHref, value); }
 
353
    inline QString anchorHref() const
 
354
    { return stringProperty(AnchorHref); }
 
355
 
 
356
    inline void setAnchorName(const QString &name)
 
357
    { setProperty(AnchorName, name); }
 
358
    inline QString anchorName() const
 
359
    { return stringProperty(AnchorName); }
 
360
 
 
361
    inline void setTableCellRowSpan(int tableCellRowSpan);
 
362
    inline int tableCellRowSpan() const
 
363
    { int s = intProperty(TableCellRowSpan); if (s == 0) s = 1; return s; }
 
364
    inline void setTableCellColumnSpan(int tableCellColumnSpan);
 
365
    inline int tableCellColumnSpan() const
 
366
    { int s = intProperty(TableCellColumnSpan); if (s == 0) s = 1; return s; }
 
367
};
 
368
 
 
369
inline void QTextCharFormat::setTableCellRowSpan(int atableCellRowSpan)
 
370
{
 
371
    if (atableCellRowSpan == 1)
 
372
        atableCellRowSpan = 0;
 
373
    setProperty(TableCellRowSpan, atableCellRowSpan);
 
374
}
 
375
 
 
376
inline void QTextCharFormat::setTableCellColumnSpan(int atableCellColumnSpan)
 
377
{
 
378
    if (atableCellColumnSpan == 1)
 
379
        atableCellColumnSpan = 0;
 
380
    setProperty(TableCellColumnSpan, atableCellColumnSpan);
 
381
}
 
382
 
 
383
class Q_GUI_EXPORT QTextBlockFormat : public QTextFormat
 
384
{
 
385
public:
 
386
    QTextBlockFormat();
 
387
 
 
388
    bool isValid() const { return isBlockFormat(); }
 
389
 
 
390
    inline void setAlignment(Qt::Alignment alignment);
 
391
    inline Qt::Alignment alignment() const
 
392
    { return QFlag(intProperty(BlockAlignment)); }
 
393
 
 
394
    inline void setTopMargin(qreal margin)
 
395
    { setProperty(BlockTopMargin, margin); }
 
396
    inline qreal topMargin() const
 
397
    { return doubleProperty(BlockTopMargin); }
 
398
 
 
399
    inline void setBottomMargin(qreal margin)
 
400
    { setProperty(BlockBottomMargin, margin); }
 
401
    inline qreal bottomMargin() const
 
402
    { return doubleProperty(BlockBottomMargin); }
 
403
 
 
404
    inline void setLeftMargin(qreal margin)
 
405
    { setProperty(BlockLeftMargin, margin); }
 
406
    inline qreal leftMargin() const
 
407
    { return doubleProperty(BlockLeftMargin); }
 
408
 
 
409
    inline void setRightMargin(qreal margin)
 
410
    { setProperty(BlockRightMargin, margin); }
 
411
    inline qreal rightMargin() const
 
412
    { return doubleProperty(BlockRightMargin); }
 
413
 
 
414
    inline void setTextIndent(qreal margin)
 
415
    { setProperty(TextIndent, margin); }
 
416
    inline qreal textIndent() const
 
417
    { return doubleProperty(TextIndent); }
 
418
 
 
419
    inline void setIndent(int indent);
 
420
    inline int indent() const
 
421
    { return intProperty(BlockIndent); }
 
422
 
 
423
    inline void setNonBreakableLines(bool b)
 
424
    { setProperty(BlockNonBreakableLines, b); }
 
425
    inline bool nonBreakableLines() const
 
426
    { return boolProperty(BlockNonBreakableLines); }
 
427
};
 
428
 
 
429
inline void QTextBlockFormat::setAlignment(Qt::Alignment aalignment)
 
430
{ setProperty(BlockAlignment, int(aalignment)); }
 
431
 
 
432
inline void QTextBlockFormat::setIndent(int aindent)
 
433
{ setProperty(BlockIndent, aindent); }
 
434
 
 
435
class Q_GUI_EXPORT QTextListFormat : public QTextFormat
 
436
{
 
437
public:
 
438
    QTextListFormat();
 
439
 
 
440
    bool isValid() const { return isListFormat(); }
 
441
 
 
442
    enum Style {
 
443
        ListDisc = -1,
 
444
        ListCircle = -2,
 
445
        ListSquare = -3,
 
446
        ListDecimal = -4,
 
447
        ListLowerAlpha = -5,
 
448
        ListUpperAlpha = -6,
 
449
        ListStyleUndefined = 0
 
450
    };
 
451
 
 
452
    inline void setStyle(Style style);
 
453
    inline Style style() const
 
454
    { return static_cast<Style>(intProperty(ListStyle)); }
 
455
 
 
456
    inline void setIndent(int indent);
 
457
    inline int indent() const
 
458
    { return intProperty(ListIndent); }
 
459
 
 
460
};
 
461
 
 
462
inline void QTextListFormat::setStyle(Style astyle)
 
463
{ setProperty(ListStyle, astyle); }
 
464
 
 
465
inline void QTextListFormat::setIndent(int aindent)
 
466
{ setProperty(ListIndent, aindent); }
 
467
 
 
468
class Q_GUI_EXPORT QTextImageFormat : public QTextCharFormat
 
469
{
 
470
public:
 
471
    QTextImageFormat();
 
472
 
 
473
    bool isValid() const { return isImageFormat(); }
 
474
 
 
475
    inline void setName(const QString &name);
 
476
    inline QString name() const
 
477
    { return stringProperty(ImageName); }
 
478
 
 
479
    inline void setWidth(qreal width);
 
480
    inline qreal width() const
 
481
    { return doubleProperty(ImageWidth); }
 
482
 
 
483
    inline void setHeight(qreal height);
 
484
    inline qreal height() const
 
485
    { return doubleProperty(ImageHeight); }
 
486
};
 
487
 
 
488
inline void QTextImageFormat::setName(const QString &aname)
 
489
{ setProperty(ImageName, aname); }
 
490
 
 
491
inline void QTextImageFormat::setWidth(qreal awidth)
 
492
{ setProperty(ImageWidth, awidth); }
 
493
 
 
494
inline void QTextImageFormat::setHeight(qreal aheight)
 
495
{ setProperty(ImageHeight, aheight); }
 
496
 
 
497
class Q_GUI_EXPORT QTextFrameFormat : public QTextFormat
 
498
{
 
499
public:
 
500
    QTextFrameFormat();
 
501
 
 
502
    bool isValid() const { return isFrameFormat(); }
 
503
 
 
504
    enum Position {
 
505
        InFlow,
 
506
        FloatLeft,
 
507
        FloatRight
 
508
        // ######
 
509
//        Absolute
 
510
    };
 
511
 
 
512
    inline void setPosition(Position f)
 
513
    { setProperty(CssFloat, f); }
 
514
    inline Position position() const
 
515
    { return static_cast<Position>(intProperty(CssFloat)); }
 
516
 
 
517
    inline void setBorder(qreal border);
 
518
    inline qreal border() const
 
519
    { return doubleProperty(FrameBorder); }
 
520
 
 
521
    inline void setMargin(qreal margin);
 
522
    inline qreal margin() const
 
523
    { return doubleProperty(FrameMargin); }
 
524
 
 
525
    inline void setPadding(qreal padding);
 
526
    inline qreal padding() const
 
527
    { return doubleProperty(FramePadding); }
 
528
 
 
529
    inline void setWidth(qreal width);
 
530
    inline void setWidth(const QTextLength &length)
 
531
    { setProperty(FrameWidth, length); }
 
532
    inline QTextLength width() const
 
533
    { return lengthProperty(FrameWidth); }
 
534
 
 
535
    inline void setHeight(qreal height);
 
536
    inline void setHeight(const QTextLength &height);
 
537
    inline QTextLength height() const
 
538
    { return lengthProperty(FrameHeight); }
 
539
};
 
540
 
 
541
inline void QTextFrameFormat::setBorder(qreal aborder)
 
542
{ setProperty(FrameBorder, aborder); }
 
543
 
 
544
inline void QTextFrameFormat::setMargin(qreal amargin)
 
545
{ setProperty(FrameMargin, amargin); }
 
546
 
 
547
inline void QTextFrameFormat::setPadding(qreal apadding)
 
548
{ setProperty(FramePadding, apadding); }
 
549
 
 
550
inline void QTextFrameFormat::setWidth(qreal awidth)
 
551
{ setProperty(FrameWidth, QTextLength(QTextLength::FixedLength, awidth)); }
 
552
 
 
553
inline void QTextFrameFormat::setHeight(qreal aheight)
 
554
{ setProperty(FrameHeight, QTextLength(QTextLength::FixedLength, aheight)); }
 
555
inline void QTextFrameFormat::setHeight(const QTextLength &aheight)
 
556
{ setProperty(FrameHeight, aheight); }
 
557
 
 
558
class Q_GUI_EXPORT QTextTableFormat : public QTextFrameFormat
 
559
{
 
560
public:
 
561
    QTextTableFormat();
 
562
 
 
563
    inline bool isValid() const { return isTableFormat(); }
 
564
 
 
565
    inline int columns() const
 
566
    { int cols = intProperty(TableColumns); if (cols == 0) cols = 1; return cols; }
 
567
    inline void setColumns(int columns);
 
568
 
 
569
    inline void setColumnWidthConstraints(const QVector<QTextLength> &constraints)
 
570
    { setProperty(TableColumnWidthConstraints, constraints); }
 
571
 
 
572
    inline QVector<QTextLength> columnWidthConstraints() const
 
573
    { return lengthVectorProperty(TableColumnWidthConstraints); }
 
574
 
 
575
    inline void clearColumnWidthConstraints()
 
576
    { clearProperty(TableColumnWidthConstraints); }
 
577
 
 
578
    inline qreal cellSpacing() const
 
579
    { return doubleProperty(TableCellSpacing); }
 
580
    inline void setCellSpacing(qreal spacing)
 
581
    { setProperty(TableCellSpacing, spacing); }
 
582
 
 
583
    inline qreal cellPadding() const
 
584
    { return doubleProperty(TableCellPadding); }
 
585
    inline void setCellPadding(qreal padding);
 
586
 
 
587
    inline void setAlignment(Qt::Alignment alignment);
 
588
    inline Qt::Alignment alignment() const
 
589
    { return QFlag(intProperty(BlockAlignment)); }
 
590
};
 
591
 
 
592
inline void QTextTableFormat::setColumns(int acolumns)
 
593
{
 
594
    if (acolumns == 1)
 
595
        acolumns = 0;
 
596
    setProperty(TableColumns, acolumns);
 
597
}
 
598
 
 
599
inline void QTextTableFormat::setCellPadding(qreal apadding)
 
600
{ setProperty(TableCellPadding, apadding); }
 
601
 
 
602
inline void QTextTableFormat::setAlignment(Qt::Alignment aalignment)
 
603
{ setProperty(BlockAlignment, int(aalignment)); }
 
604
 
 
605
#endif // QTEXTFORMAT_H