Qt 4.8
qtextoption.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qtextoption.h"
43 #include "qapplication.h"
44 #include "qlist.h"
45 
47 
49 {
51 };
52 
60  : align(Qt::AlignLeft),
61  wordWrap(QTextOption::WordWrap),
62  design(false),
63  unused(0),
64  f(0),
65  tab(-1),
66  d(0)
67 {
69 }
70 
77  : align(alignment),
79  design(false),
80  unused(0),
81  f(0),
82  tab(-1),
83  d(0)
84 {
86 }
87 
92 {
93  delete d;
94 }
95 
105  : align(o.align),
106  wordWrap(o.wordWrap),
107  design(o.design),
108  direction(o.direction),
109  unused(o.unused),
110  f(o.f),
111  tab(o.tab),
112  d(0)
113 {
114  if (o.d)
115  d = new QTextOptionPrivate(*o.d);
116 }
117 
128 {
129  if (this == &o)
130  return *this;
131 
132  QTextOptionPrivate* dNew = 0;
133  if (o.d)
134  dNew = new QTextOptionPrivate(*o.d);
135  delete d;
136  d = dNew;
137 
138  align = o.align;
139  wordWrap = o.wordWrap;
140  design = o.design;
141  direction = o.direction;
142  unused = o.unused;
143  f = o.f;
144  tab = o.tab;
145  return *this;
146 }
147 
154 void QTextOption::setTabArray(QList<qreal> tabStops) // Qt5: const ref
155 {
156  if (!d)
157  d = new QTextOptionPrivate;
160  foreach (qreal pos, tabStops) {
161  tab.position = pos;
162  tabs.append(tab);
163  }
164  d->tabStops = tabs;
165 }
166 
177 void QTextOption::setTabs(QList<QTextOption::Tab> tabStops) // Qt5: const ref
178 {
179  if (!d)
180  d = new QTextOptionPrivate;
181  d->tabStops = tabStops;
182 }
183 
190 {
191  if (!d)
192  return QList<qreal>();
193 
194  QList<qreal> answer;
196  while(iter != d->tabStops.constEnd()) {
197  answer.append( (*iter).position);
198  ++iter;
199  }
200  return answer;
201 }
202 
203 
205 {
206  if (!d)
207  return QList<QTextOption::Tab>();
208  return d->tabStops;
209 }
210 
double d
Definition: qnumeric_p.h:62
static Qt::LayoutDirection layoutDirection()
double qreal
Definition: qglobal.h:1193
QTextOption & operator=(const QTextOption &o)
Returns true if the text option is the same as the other text option; otherwise returns false...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setTabs(QList< Tab > tabStops)
Sets the tab positions for the text layout to those specified by tabStops.
QTextOptionPrivate * d
Definition: qtextoption.h:143
~QTextOption()
Destroys the text option.
Definition: qtextoption.cpp:91
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
QList< qreal > tabArray() const
Returns a list of tab positions defined for the text layout.
qreal position
Distance from the start of the paragraph.
Definition: qtextoption.h:84
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QList< QTextOption::Tab > tabStops
Definition: qtextoption.cpp:50
QList< Tab > tabs() const
Returns a list of tab positions defined for the text layout.
uint direction
Definition: qtextoption.h:139
void setTabArray(QList< qreal > tabStops)
Sets the tab positions for the text layout to those specified by tabStops.
Definition: qnamespace.h:54
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
QTextOption()
Constructs a text option with default properties for text.
Definition: qtextoption.cpp:59
Qt::Alignment alignment() const
Returns the text alignment defined by the option.
Definition: qtextoption.h:97
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
Each tab definition is represented by this struct.
Definition: qtextoption.h:69