summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-09 05:18:08 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-09 05:18:08 (GMT)
commit95ad31adca64f639712fa378d25aa3e552b3dc72 (patch)
treed03e2ed9999a17572be62f54fc4173608221eb9e /src
parent60e0a0b0fb6a2cf7b9fffd4ff2d30838ffa4ac84 (diff)
downloadQt-95ad31adca64f639712fa378d25aa3e552b3dc72.zip
Qt-95ad31adca64f639712fa378d25aa3e552b3dc72.tar.gz
Qt-95ad31adca64f639712fa378d25aa3e552b3dc72.tar.bz2
TextEdit::wrap changed to TextEdit::wrapMode enumeration
Diffstat (limited to 'src')
-rw-r--r--src/declarative/QmlChanges.txt1
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp45
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h14
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h21
5 files changed, 57 insertions, 26 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 079aacb..d5910e3 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -1,6 +1,7 @@
=============================================================================
The changes below are pre Qt 4.7.0 beta
+TextEdit: wrap property is replaced by wrapMode enumeration.
Text: wrap property is replaced by wrapMode enumeration.
Removed Q-prefix from validators (IntValidator, DoubleValidator, and RegExpValidator)
PathView: offset property now uses range 0-1.0 rather than 0-100
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index c950e31..1f53b75 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -362,7 +362,7 @@ bool QDeclarativeText::wrap() const
void QDeclarativeText::setWrap(bool w)
{
qmlInfo(this) << "\"wrap\" property is deprecated and will soon be removed. Use wrapMode";
- setWrapMode(WordWrap);
+ setWrapMode(w ? WordWrap : NoWrap);
}
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 7374bc8..1db5ffe 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -44,6 +44,7 @@
#include "private/qdeclarativeevents_p_p.h"
#include <private/qdeclarativeglobal_p.h>
+#include <qdeclarativeinfo.h>
#include <QTextLayout>
#include <QTextLine>
@@ -360,29 +361,47 @@ void QDeclarativeTextEdit::setVAlign(QDeclarativeTextEdit::VAlignment alignment)
emit verticalAlignmentChanged(d->vAlign);
}
-bool QDeclarativeTextEdit::wrap() const
-{
- Q_D(const QDeclarativeTextEdit);
- return d->wrap;
-}
-
/*!
- \qmlproperty bool TextEdit::wrap
+ \qmlproperty enumeration TextEdit::wrapMode
Set this property to wrap the text to the TextEdit item's width.
The text will only wrap if an explicit width has been set.
- Wrapping is done on word boundaries (i.e. it is a "word-wrap"). Wrapping is off by default.
+ \list
+ \o NoWrap - no wrapping will be performed.
+ \o WordWrap - wrapping is done on word boundaries.
+ \endlist
+
+ The default is NoWrap.
*/
-void QDeclarativeTextEdit::setWrap(bool w)
+QDeclarativeTextEdit::WrapMode QDeclarativeTextEdit::wrapMode() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->wrapMode;
+}
+
+void QDeclarativeTextEdit::setWrapMode(WrapMode mode)
{
Q_D(QDeclarativeTextEdit);
- if (w == d->wrap)
+ if (mode == d->wrapMode)
return;
- d->wrap = w;
+ d->wrapMode = mode;
d->updateDefaultTextOption();
updateSize();
- emit wrapChanged(d->wrap);
+ emit wrapModeChanged();
+}
+
+bool QDeclarativeTextEdit::wrap() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ return d->wrapMode != QDeclarativeTextEdit::NoWrap;
+}
+
+void QDeclarativeTextEdit::setWrap(bool w)
+{
+
+ qmlInfo(this) << "\"wrap\" property is deprecated and will soon be removed. Use wrapMode";
+ setWrapMode(w ? WordWrap : NoWrap);
}
/*!
@@ -1021,7 +1040,7 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption()
QTextOption::WrapMode oldWrapMode = opt.wrapMode();
- if (wrap)
+ if (wrapMode == QDeclarativeTextEdit::WordWrap)
opt.setWrapMode(QTextOption::WordWrap);
else
opt.setWrapMode(QTextOption::NoWrap);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index 0e91e73..3ac2b42 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -64,6 +64,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
Q_ENUMS(VAlignment)
Q_ENUMS(HAlignment)
Q_ENUMS(TextFormat)
+ Q_ENUMS(WrapMode)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
@@ -72,7 +73,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
- Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged) //### other wrap modes
+ Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged) //### deprecated
+ Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
@@ -107,6 +109,12 @@ public:
AutoText = Qt::AutoText
};
+ enum WrapMode { NoWrap = QTextOption::NoWrap,
+ WordWrap = QTextOption::WordWrap
+// WrapAnywhere = QTextOption::WrapAnywhere,
+// WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere
+ };
+
QString text() const;
void setText(const QString &);
@@ -133,6 +141,8 @@ public:
bool wrap() const;
void setWrap(bool w);
+ WrapMode wrapMode() const;
+ void setWrapMode(WrapMode w);
bool isCursorVisible() const;
void setCursorVisible(bool on);
@@ -185,7 +195,7 @@ Q_SIGNALS:
void fontChanged(const QFont &font);
void horizontalAlignmentChanged(HAlignment alignment);
void verticalAlignmentChanged(VAlignment alignment);
- void wrapChanged(bool isWrapped);
+ void wrapModeChanged();
void textFormatChanged(TextFormat textFormat);
void readOnlyChanged(bool isReadOnly);
void cursorVisibleChanged(bool isCursorVisible);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
index 310db48..8d4b611 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -68,10 +68,11 @@ class QDeclarativeTextEditPrivate : public QDeclarativePaintedItemPrivate
public:
QDeclarativeTextEditPrivate()
- : color("black"), imgDirty(true), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop),
- dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(true),
+ : color("black"), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop),
+ imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
persistentSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
- cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0)
+ cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0),
+ wrapMode(QDeclarativeTextEdit::NoWrap)
{
}
@@ -89,17 +90,16 @@ public:
QColor selectedTextColor;
QString style;
QColor styleColor;
- bool imgDirty;
QPixmap imgCache;
QPixmap imgStyleCache;
QDeclarativeTextEdit::HAlignment hAlign;
QDeclarativeTextEdit::VAlignment vAlign;
- bool dirty;
- bool wrap;
- bool richText;
- bool cursorVisible;
- bool focusOnPress;
- bool persistentSelection;
+ bool imgDirty : 1;
+ bool dirty : 1;
+ bool richText : 1;
+ bool cursorVisible : 1;
+ bool focusOnPress : 1;
+ bool persistentSelection : 1;
qreal textMargin;
int lastSelectionStart;
int lastSelectionEnd;
@@ -108,6 +108,7 @@ public:
QDeclarativeTextEdit::TextFormat format;
QTextDocument *document;
QTextControl *control;
+ QDeclarativeTextEdit::WrapMode wrapMode;
};
QT_END_NAMESPACE