diff options
author | David Faure <faure@kde.org> | 2010-06-04 22:06:15 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2010-06-04 22:06:44 (GMT) |
commit | 51fa7df978d71a366c95c732d6a8c2576690d63a (patch) | |
tree | e112d17e004c95d77c02375f0fa4d575afcda297 | |
parent | 09c6a81109d3978c1583c556202c01c1e774f11f (diff) | |
download | Qt-51fa7df978d71a366c95c732d6a8c2576690d63a.zip Qt-51fa7df978d71a366c95c732d6a8c2576690d63a.tar.gz Qt-51fa7df978d71a366c95c732d6a8c2576690d63a.tar.bz2 |
Add convenience constructor to QTextOption::Tab
Merge-request: 1734
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
-rw-r--r-- | src/gui/text/qtextoption.cpp | 10 | ||||
-rw-r--r-- | src/gui/text/qtextoption.h | 2 | ||||
-rw-r--r-- | tests/auto/qtextformat/tst_qtextformat.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qtextlayout/tst_qtextlayout.cpp | 9 | ||||
-rw-r--r-- | tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp | 9 |
5 files changed, 15 insertions, 20 deletions
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index c1e254c..a2b8022 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -145,7 +145,7 @@ QTextOption &QTextOption::operator=(const QTextOption &o) \sa tabArray(), setTabStop(), setTabs() */ -void QTextOption::setTabArray(QList<qreal> tabStops) +void QTextOption::setTabArray(QList<qreal> tabStops) // Qt5: const ref { if (!d) d = new QTextOptionPrivate; @@ -165,7 +165,7 @@ void QTextOption::setTabArray(QList<qreal> tabStops) \sa tabStops() */ -void QTextOption::setTabs(QList<QTextOption::Tab> tabStops) +void QTextOption::setTabs(QList<QTextOption::Tab> tabStops) // Qt5: const ref { if (!d) d = new QTextOptionPrivate; @@ -391,6 +391,12 @@ QList<QTextOption::Tab> QTextOption::tabs() const */ /*! + \fn Tab::Tab(qreal pos, TabType tabType, QChar delim = QChar()) + Creates a tab with the given position, tab type, and (for DelimiterTab) delimiter + \since 4.6 +*/ + +/*! \fn bool Tab::operator==(const Tab &other) const Returns true if tab \a other is equal to this tab; diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h index 1381ed1..5af7834 100644 --- a/src/gui/text/qtextoption.h +++ b/src/gui/text/qtextoption.h @@ -68,6 +68,8 @@ public: struct Q_GUI_EXPORT Tab { inline Tab() : position(80), type(QTextOption::LeftTab) { } + inline Tab(qreal pos, TabType tabType, QChar delim = QChar()) + : position(pos), type(tabType), delimiter(delim) {} inline bool operator==(const Tab &other) const { return type == other.type diff --git a/tests/auto/qtextformat/tst_qtextformat.cpp b/tests/auto/qtextformat/tst_qtextformat.cpp index ee1f4b5..9b71481 100644 --- a/tests/auto/qtextformat/tst_qtextformat.cpp +++ b/tests/auto/qtextformat/tst_qtextformat.cpp @@ -308,10 +308,7 @@ void tst_QTextFormat::getSetTabs() format.setTabPositions(tabs); Comparator c2(tabs, format.tabPositions()); - QTextOption::Tab tab2; - tab2.position = 3456; - tab2.type = QTextOption::RightTab; - tab2.delimiter = QChar('x'); + QTextOption::Tab tab2(3456, QTextOption::RightTab, QChar('x')); tabs.append(tab2); format.setTabPositions(tabs); Comparator c3(tabs, format.tabPositions()); diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index 1a5f493..a631f3d 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -980,9 +980,7 @@ void tst_QTextLayout::testCenteredTab() // test if centering the tab works. We expect the center of 'Bar.' to be at the tab point. QTextOption option = layout.textOption(); QList<QTextOption::Tab> tabs; - QTextOption::Tab tab; - tab.type = QTextOption::CenterTab; - tab.position = 150; + QTextOption::Tab tab(150, QTextOption::CenterTab); tabs.append(tab); option.setTabs(tabs); layout.setTextOption(option); @@ -1002,10 +1000,7 @@ void tst_QTextLayout::testDelimiterTab() // try the different delimiter characters to see if the alignment works there. QTextOption option = layout.textOption(); QList<QTextOption::Tab> tabs; - QTextOption::Tab tab; - tab.type = QTextOption::DelimiterTab; - tab.delimiter = QChar('.'); - tab.position = 100; + QTextOption::Tab tab(100, QTextOption::DelimiterTab, QChar('.')); tabs.append(tab); option.setTabs(tabs); layout.setTextOption(option); diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp index 64c42bb..a463d86 100644 --- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp @@ -198,14 +198,9 @@ void tst_QTextOdfWriter::testWriteStyle2() { QTextBlockFormat bf; // = cursor.blockFormat(); QList<QTextOption::Tab> tabs; - QTextOption::Tab tab1; - tab1.position = 40; - tab1.type = QTextOption::RightTab; + QTextOption::Tab tab1(40, QTextOption::RightTab); tabs << tab1; - QTextOption::Tab tab2; - tab2.position = 80; - tab2.type = QTextOption::DelimiterTab; - tab2.delimiter = 'o'; + QTextOption::Tab tab2(80, QTextOption::DelimiterTab, 'o'); tabs << tab2; bf.setTabPositions(tabs); |