From 31a40e5ca2136e06d17b867c4aa711afdc1e047a Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 15 Jan 2014 22:57:34 +0200 Subject: [PATCH] Reduce code duplication Change-Id: I077963fcb910fa705b087e35e99cd07436c034b1 Reviewed-by: Lars Knoll --- src/gui/text/qtextformat.cpp | 13 ------------- src/gui/text/qtextformat_p.h | 6 ++++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index 3d70befda3..641a2ceb8a 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -3385,19 +3385,6 @@ bool QTextFormatCollection::hasFormatCached(const QTextFormat &format) const return false; } -QTextFormat QTextFormatCollection::objectFormat(int objectIndex) const -{ - if (objectIndex == -1) - return QTextFormat(); - return format(objFormats.at(objectIndex)); -} - -void QTextFormatCollection::setObjectFormat(int objectIndex, const QTextFormat &f) -{ - const int formatIndex = indexForFormat(f); - objFormats[objectIndex] = formatIndex; -} - int QTextFormatCollection::objectFormatIndex(int objectIndex) const { if (objectIndex == -1) diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h index 6b2958a4b6..e3998d4f3f 100644 --- a/src/gui/text/qtextformat_p.h +++ b/src/gui/text/qtextformat_p.h @@ -68,8 +68,10 @@ public: QTextFormatCollection(const QTextFormatCollection &rhs); QTextFormatCollection &operator=(const QTextFormatCollection &rhs); - QTextFormat objectFormat(int objectIndex) const; - void setObjectFormat(int objectIndex, const QTextFormat &format); + inline QTextFormat objectFormat(int objectIndex) const + { return format(objectFormatIndex(objectIndex)); } + inline void setObjectFormat(int objectIndex, const QTextFormat &format) + { setObjectFormatIndex(objectIndex, indexForFormat(format)); } int objectFormatIndex(int objectIndex) const; void setObjectFormatIndex(int objectIndex, int formatIndex);