Remove QTextControl and QLineControl.
QtWidgets and QtDeclarative now both have their own versions of these so there's no need to keep them around any longer. Change-Id: I9c2201c8495a0a0816e2af16c8f647fcad991479 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
aee1f6cc41
commit
4dae8c1aff
@ -122,7 +122,6 @@ protected:
|
||||
|
||||
private:
|
||||
friend class QWidgetTextControl;
|
||||
friend class QTextControl;
|
||||
friend class QTextDocument;
|
||||
friend class QTextDocumentPrivate;
|
||||
friend class QTextEngine;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,455 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QLINECONTROL_P_H
|
||||
#define QLINECONTROL_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtCore/qglobal.h"
|
||||
|
||||
#include "QtGui/qtextlayout.h"
|
||||
#include "QtCore/qpointer.h"
|
||||
#include "QtGui/qclipboard.h"
|
||||
#include "QtGui/qvalidator.h"
|
||||
#include "QtGui/qpalette.h"
|
||||
#include "QtGui/qguiapplication.h"
|
||||
#include "QtGui/qinputpanel.h"
|
||||
#include "QtCore/qpoint.h"
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class Q_GUI_EXPORT QLineControl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QLineControl(const QString &txt = QString())
|
||||
: m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LayoutDirectionAuto),
|
||||
m_hideCursor(false), m_separator(0), m_readOnly(0),
|
||||
m_dragEnabled(0), m_echoMode(Normal), m_textDirty(0), m_selDirty(0),
|
||||
m_validInput(1), m_blinkStatus(0), m_blinkPeriod(0), m_blinkTimer(0), m_deleteAllTimer(0),
|
||||
m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1),
|
||||
m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0),
|
||||
m_selstart(0), m_selend(0), m_passwordEchoEditing(false)
|
||||
{
|
||||
init(txt);
|
||||
}
|
||||
|
||||
enum EchoMode {
|
||||
Normal,
|
||||
NoEcho,
|
||||
Password,
|
||||
PasswordEchoOnEdit
|
||||
};
|
||||
|
||||
|
||||
~QLineControl()
|
||||
{
|
||||
delete [] m_maskData;
|
||||
}
|
||||
|
||||
int nextMaskBlank(int pos)
|
||||
{
|
||||
int c = findInMask(pos, true, false);
|
||||
m_separator |= (c != pos);
|
||||
return (c != -1 ? c : m_maxLength);
|
||||
}
|
||||
|
||||
int prevMaskBlank(int pos)
|
||||
{
|
||||
int c = findInMask(pos, false, false);
|
||||
m_separator |= (c != pos);
|
||||
return (c != -1 ? c : 0);
|
||||
}
|
||||
|
||||
bool isUndoAvailable() const { return !m_readOnly && m_undoState; }
|
||||
bool isRedoAvailable() const { return !m_readOnly && m_undoState < (int)m_history.size(); }
|
||||
void clearUndo() { m_history.clear(); m_modifiedState = m_undoState = 0; }
|
||||
|
||||
bool isModified() const { return m_modifiedState != m_undoState; }
|
||||
void setModified(bool modified) { m_modifiedState = modified ? -1 : m_undoState; }
|
||||
|
||||
bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); }
|
||||
bool hasSelectedText() const { return !m_text.isEmpty() && m_selend > m_selstart; }
|
||||
|
||||
int width() const { return qRound(m_textLayout.lineAt(0).width()) + 1; }
|
||||
int height() const { return qRound(m_textLayout.lineAt(0).height()) + 1; }
|
||||
int ascent() const { return m_ascent; }
|
||||
qreal naturalTextWidth() const { return m_textLayout.lineAt(0).naturalTextWidth(); }
|
||||
|
||||
void setSelection(int start, int length);
|
||||
|
||||
inline QString selectedText() const { return hasSelectedText() ? m_text.mid(m_selstart, m_selend - m_selstart) : QString(); }
|
||||
QString textBeforeSelection() const { return hasSelectedText() ? m_text.left(m_selstart) : QString(); }
|
||||
QString textAfterSelection() const { return hasSelectedText() ? m_text.mid(m_selend) : QString(); }
|
||||
|
||||
int selectionStart() const { return hasSelectedText() ? m_selstart : -1; }
|
||||
int selectionEnd() const { return hasSelectedText() ? m_selend : -1; }
|
||||
bool inSelection(int x) const
|
||||
{
|
||||
if (m_selstart >= m_selend)
|
||||
return false;
|
||||
int pos = xToPos(x, QTextLine::CursorOnCharacter);
|
||||
return pos >= m_selstart && pos < m_selend;
|
||||
}
|
||||
|
||||
void removeSelection()
|
||||
{
|
||||
int priorState = m_undoState;
|
||||
removeSelectedText();
|
||||
finishChange(priorState);
|
||||
}
|
||||
|
||||
int start() const { return 0; }
|
||||
int end() const { return m_text.length(); }
|
||||
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
void copy(QClipboard::Mode mode = QClipboard::Clipboard) const;
|
||||
void paste(QClipboard::Mode mode = QClipboard::Clipboard);
|
||||
#endif
|
||||
|
||||
int cursor() const{ return m_cursor; }
|
||||
int preeditCursor() const { return m_preeditCursor; }
|
||||
|
||||
int cursorWidth() const { return m_cursorWidth; }
|
||||
void setCursorWidth(int value) { m_cursorWidth = value; }
|
||||
|
||||
Qt::CursorMoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
|
||||
void setCursorMoveStyle(Qt::CursorMoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
|
||||
|
||||
void moveCursor(int pos, bool mark = false);
|
||||
void cursorForward(bool mark, int steps)
|
||||
{
|
||||
int c = m_cursor;
|
||||
if (steps > 0) {
|
||||
while (steps--)
|
||||
c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c)
|
||||
: m_textLayout.nextCursorPosition(c);
|
||||
} else if (steps < 0) {
|
||||
while (steps++)
|
||||
c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c)
|
||||
: m_textLayout.previousCursorPosition(c);
|
||||
}
|
||||
moveCursor(c, mark);
|
||||
}
|
||||
|
||||
void cursorWordForward(bool mark) { moveCursor(m_textLayout.nextCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
|
||||
void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
|
||||
|
||||
void home(bool mark) { moveCursor(0, mark); }
|
||||
void end(bool mark) { moveCursor(text().length(), mark); }
|
||||
|
||||
int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
|
||||
QRect cursorRect() const;
|
||||
|
||||
qreal cursorToX(int cursor) const { return m_textLayout.lineAt(0).cursorToX(cursor); }
|
||||
qreal cursorToX() const
|
||||
{
|
||||
int cursor = m_cursor;
|
||||
if (m_preeditCursor != -1)
|
||||
cursor += m_preeditCursor;
|
||||
return cursorToX(cursor);
|
||||
}
|
||||
|
||||
bool isReadOnly() const { return m_readOnly; }
|
||||
void setReadOnly(bool enable) { m_readOnly = enable; }
|
||||
|
||||
QString text() const;
|
||||
QString realText() const;
|
||||
void setText(const QString &txt);
|
||||
void commitPreedit();
|
||||
|
||||
QString displayText() const { return m_textLayout.text(); }
|
||||
|
||||
void backspace();
|
||||
void del();
|
||||
void deselect() { internalDeselect(); finishChange(); }
|
||||
void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.length(), true); }
|
||||
|
||||
void insert(const QString &);
|
||||
void clear();
|
||||
void undo() { internalUndo(); finishChange(-1, true); }
|
||||
void redo() { internalRedo(); finishChange(); }
|
||||
void selectWordAtPos(int);
|
||||
|
||||
EchoMode echoMode() const { return EchoMode(m_echoMode); }
|
||||
void setEchoMode(EchoMode mode)
|
||||
{
|
||||
m_echoMode = mode;
|
||||
m_passwordEchoEditing = false;
|
||||
updateDisplayText();
|
||||
}
|
||||
|
||||
int maxLength() const { return m_maxLength; }
|
||||
void setMaxLength(int maxLength)
|
||||
{
|
||||
if (m_maskData)
|
||||
return;
|
||||
m_maxLength = maxLength;
|
||||
setText(m_text);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_VALIDATOR
|
||||
const QValidator *validator() const { return m_validator; }
|
||||
void setValidator(const QValidator *v) { m_validator = const_cast<QValidator*>(v); }
|
||||
#endif
|
||||
|
||||
int cursorPosition() const { return m_cursor; }
|
||||
void setCursorPosition(int pos) { if (pos <= m_text.length()) moveCursor(qMax(0, pos)); }
|
||||
|
||||
bool hasAcceptableInput() const { return hasAcceptableInput(m_text); }
|
||||
bool fixup();
|
||||
|
||||
QString inputMask() const { return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString(); }
|
||||
void setInputMask(const QString &mask)
|
||||
{
|
||||
parseInputMask(mask);
|
||||
if (m_maskData)
|
||||
moveCursor(nextMaskBlank(0));
|
||||
}
|
||||
|
||||
// input methods
|
||||
#ifndef QT_NO_IM
|
||||
bool composeMode() const { return !m_textLayout.preeditAreaText().isEmpty(); }
|
||||
void setPreeditArea(int cursor, const QString &text) { m_textLayout.setPreeditArea(cursor, text); }
|
||||
#endif
|
||||
|
||||
QString preeditAreaText() const { return m_textLayout.preeditAreaText(); }
|
||||
|
||||
void updatePasswordEchoEditing(bool editing);
|
||||
bool passwordEchoEditing() const { return m_passwordEchoEditing; }
|
||||
|
||||
QChar passwordCharacter() const { return m_passwordCharacter; }
|
||||
void setPasswordCharacter(const QChar &character) { m_passwordCharacter = character; updateDisplayText(); }
|
||||
|
||||
Qt::LayoutDirection layoutDirection() const {
|
||||
if (m_layoutDirection == Qt::LayoutDirectionAuto) {
|
||||
if (m_text.isEmpty())
|
||||
return qApp->inputPanel()->inputDirection();
|
||||
return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
|
||||
}
|
||||
return m_layoutDirection;
|
||||
}
|
||||
void setLayoutDirection(Qt::LayoutDirection direction)
|
||||
{
|
||||
if (direction != m_layoutDirection) {
|
||||
m_layoutDirection = direction;
|
||||
updateDisplayText();
|
||||
}
|
||||
}
|
||||
|
||||
void setFont(const QFont &font) { m_textLayout.setFont(font); updateDisplayText(); }
|
||||
|
||||
void processInputMethodEvent(QInputMethodEvent *event);
|
||||
void processMouseEvent(QMouseEvent* ev);
|
||||
void processKeyEvent(QKeyEvent* ev);
|
||||
|
||||
int cursorBlinkPeriod() const { return m_blinkPeriod; }
|
||||
void setCursorBlinkPeriod(int msec);
|
||||
void resetCursorBlinkTimer();
|
||||
|
||||
bool cursorBlinkStatus() const { return m_blinkStatus; }
|
||||
|
||||
QString cancelText() const { return m_cancelText; }
|
||||
void setCancelText(const QString &text) { m_cancelText = text; }
|
||||
|
||||
const QPalette &palette() const { return m_palette; }
|
||||
void setPalette(const QPalette &p) { m_palette = p; }
|
||||
|
||||
enum DrawFlags {
|
||||
DrawText = 0x01,
|
||||
DrawSelections = 0x02,
|
||||
DrawCursor = 0x04,
|
||||
DrawAll = DrawText | DrawSelections | DrawCursor
|
||||
};
|
||||
void draw(QPainter *, const QPoint &, const QRect &, int flags = DrawAll);
|
||||
|
||||
bool processEvent(QEvent *ev);
|
||||
|
||||
QTextLayout *textLayout()
|
||||
{
|
||||
return &m_textLayout;
|
||||
}
|
||||
|
||||
private:
|
||||
void init(const QString &txt);
|
||||
void removeSelectedText();
|
||||
void internalSetText(const QString &txt, int pos = -1, bool edited = true);
|
||||
void updateDisplayText(bool forceUpdate = false);
|
||||
|
||||
void internalInsert(const QString &s);
|
||||
void internalDelete(bool wasBackspace = false);
|
||||
void internalRemove(int pos);
|
||||
|
||||
inline void internalDeselect()
|
||||
{
|
||||
m_selDirty |= (m_selend > m_selstart);
|
||||
m_selstart = m_selend = 0;
|
||||
}
|
||||
|
||||
void internalUndo(int until = -1);
|
||||
void internalRedo();
|
||||
|
||||
QString m_text;
|
||||
QPalette m_palette;
|
||||
int m_cursor;
|
||||
int m_preeditCursor;
|
||||
int m_cursorWidth;
|
||||
QString m_tentativeCommit;
|
||||
Qt::LayoutDirection m_layoutDirection;
|
||||
uint m_hideCursor : 1; // used to hide the m_cursor inside preedit areas
|
||||
uint m_separator : 1;
|
||||
uint m_readOnly : 1;
|
||||
uint m_dragEnabled : 1;
|
||||
uint m_echoMode : 2;
|
||||
uint m_textDirty : 1;
|
||||
uint m_selDirty : 1;
|
||||
uint m_validInput : 1;
|
||||
uint m_blinkStatus : 1;
|
||||
int m_blinkPeriod; // 0 for non-blinking cursor
|
||||
int m_blinkTimer;
|
||||
int m_deleteAllTimer;
|
||||
int m_ascent;
|
||||
int m_maxLength;
|
||||
int m_lastCursorPos;
|
||||
QList<int> m_transactions;
|
||||
QPoint m_tripleClick;
|
||||
int m_tripleClickTimer;
|
||||
QString m_cancelText;
|
||||
|
||||
void emitCursorPositionChanged();
|
||||
|
||||
bool finishChange(int validateFromState = -1, bool update = false, bool edited = true);
|
||||
|
||||
#ifndef QT_NO_VALIDATOR
|
||||
QPointer<QValidator> m_validator;
|
||||
#endif
|
||||
|
||||
struct MaskInputData {
|
||||
enum Casemode { NoCaseMode, Upper, Lower };
|
||||
QChar maskChar; // either the separator char or the inputmask
|
||||
bool separator;
|
||||
Casemode caseMode;
|
||||
};
|
||||
QString m_inputMask;
|
||||
QChar m_blank;
|
||||
MaskInputData *m_maskData;
|
||||
|
||||
// undo/redo handling
|
||||
enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection };
|
||||
struct Command {
|
||||
inline Command() {}
|
||||
inline Command(CommandType t, int p, QChar c, int ss, int se) : type(t),uc(c),pos(p),selStart(ss),selEnd(se) {}
|
||||
uint type : 4;
|
||||
QChar uc;
|
||||
int pos, selStart, selEnd;
|
||||
};
|
||||
int m_modifiedState;
|
||||
int m_undoState;
|
||||
QVector<Command> m_history;
|
||||
void addCommand(const Command& cmd);
|
||||
|
||||
inline void separate() { m_separator = true; }
|
||||
|
||||
// selection
|
||||
int m_selstart;
|
||||
int m_selend;
|
||||
|
||||
// masking
|
||||
void parseInputMask(const QString &maskFields);
|
||||
bool isValidInput(QChar key, QChar mask) const;
|
||||
bool hasAcceptableInput(const QString &text) const;
|
||||
QString maskString(uint pos, const QString &str, bool clear = false) const;
|
||||
QString clearString(uint pos, uint len) const;
|
||||
QString stripString(const QString &str) const;
|
||||
int findInMask(int pos, bool forward, bool findSeparator, QChar searchChar = QChar()) const;
|
||||
|
||||
// complex text layout
|
||||
QTextLayout m_textLayout;
|
||||
|
||||
bool m_passwordEchoEditing;
|
||||
QChar m_passwordCharacter;
|
||||
|
||||
Q_SIGNALS:
|
||||
void cursorPositionChanged(int, int);
|
||||
void selectionChanged();
|
||||
|
||||
void displayTextChanged(const QString &);
|
||||
void textChanged(const QString &);
|
||||
void textEdited(const QString &);
|
||||
|
||||
void resetInputContext();
|
||||
void updateMicroFocus();
|
||||
|
||||
void accepted();
|
||||
void editingFinished();
|
||||
void updateNeeded(const QRect &);
|
||||
|
||||
#ifdef QT_KEYPAD_NAVIGATION
|
||||
void editFocusChange(bool);
|
||||
#endif
|
||||
protected:
|
||||
virtual void timerEvent(QTimerEvent *event);
|
||||
|
||||
private Q_SLOTS:
|
||||
void _q_clipboardChanged();
|
||||
void _q_deleteSelected();
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QLineControl_P_H
|
File diff suppressed because it is too large
Load Diff
@ -1,287 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTEXTCONTROL_P_H
|
||||
#define QTEXTCONTROL_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtGui/qtextdocument.h>
|
||||
#include <QtGui/qtextoption.h>
|
||||
#include <QtGui/qtextcursor.h>
|
||||
#include <QtGui/qtextformat.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <QtGui/qabstracttextdocumentlayout.h>
|
||||
#include <QtGui/qtextdocumentfragment.h>
|
||||
#include <QtGui/qclipboard.h>
|
||||
#include <QtCore/qmimedata.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class QStyleSheet;
|
||||
class QTextDocument;
|
||||
class QTextControlPrivate;
|
||||
class QAbstractScrollArea;
|
||||
class QEvent;
|
||||
class QTimerEvent;
|
||||
class QPagedPaintDevice;
|
||||
|
||||
class Q_GUI_EXPORT QTextControl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QTextControl)
|
||||
#ifndef QT_NO_TEXTHTMLPARSER
|
||||
Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
|
||||
#endif
|
||||
Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
|
||||
Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
|
||||
Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
|
||||
Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
|
||||
Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
|
||||
Q_PROPERTY(bool ignoreUnusedNavigationEvents READ ignoreUnusedNavigationEvents WRITE setIgnoreUnusedNavigationEvents)
|
||||
public:
|
||||
explicit QTextControl(QObject *parent = 0);
|
||||
explicit QTextControl(const QString &text, QObject *parent = 0);
|
||||
explicit QTextControl(QTextDocument *doc, QObject *parent = 0);
|
||||
virtual ~QTextControl();
|
||||
|
||||
void setView(QObject *view);
|
||||
QObject *view() const;
|
||||
|
||||
void setDocument(QTextDocument *document);
|
||||
QTextDocument *document() const;
|
||||
|
||||
void setTextCursor(const QTextCursor &cursor);
|
||||
QTextCursor textCursor() const;
|
||||
|
||||
void setTextInteractionFlags(Qt::TextInteractionFlags flags);
|
||||
Qt::TextInteractionFlags textInteractionFlags() const;
|
||||
|
||||
void mergeCurrentCharFormat(const QTextCharFormat &modifier);
|
||||
|
||||
void setCurrentCharFormat(const QTextCharFormat &format);
|
||||
QTextCharFormat currentCharFormat() const;
|
||||
|
||||
bool find(const QString &exp, QTextDocument::FindFlags options = 0);
|
||||
|
||||
inline QString toPlainText() const
|
||||
{ return document()->toPlainText(); }
|
||||
#ifndef QT_NO_TEXTHTMLPARSER
|
||||
inline QString toHtml() const
|
||||
{ return document()->toHtml(); }
|
||||
#endif
|
||||
|
||||
virtual void ensureCursorVisible();
|
||||
|
||||
virtual QVariant loadResource(int type, const QUrl &name);
|
||||
|
||||
QTextCursor cursorForPosition(const QPointF &pos) const;
|
||||
QRectF cursorRect(const QTextCursor &cursor) const;
|
||||
QRectF cursorRect() const;
|
||||
QRectF selectionRect(const QTextCursor &cursor) const;
|
||||
QRectF selectionRect() const;
|
||||
|
||||
QString anchorAt(const QPointF &pos) const;
|
||||
QPointF anchorPosition(const QString &name) const;
|
||||
|
||||
QString anchorAtCursor() const;
|
||||
|
||||
bool overwriteMode() const;
|
||||
void setOverwriteMode(bool overwrite);
|
||||
|
||||
int cursorWidth() const;
|
||||
void setCursorWidth(int width);
|
||||
|
||||
bool acceptRichText() const;
|
||||
void setAcceptRichText(bool accept);
|
||||
|
||||
void setExtraSelections(const QVector<QAbstractTextDocumentLayout::Selection> &selections);
|
||||
QVector<QAbstractTextDocumentLayout::Selection> extraSelections() const;
|
||||
|
||||
void setTextWidth(qreal width);
|
||||
qreal textWidth() const;
|
||||
QSizeF size() const;
|
||||
|
||||
void setOpenExternalLinks(bool open);
|
||||
bool openExternalLinks() const;
|
||||
|
||||
void setIgnoreUnusedNavigationEvents(bool ignore);
|
||||
bool ignoreUnusedNavigationEvents() const;
|
||||
|
||||
void moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
|
||||
|
||||
bool canPaste() const;
|
||||
|
||||
void setCursorIsFocusIndicator(bool b);
|
||||
bool cursorIsFocusIndicator() const;
|
||||
|
||||
void setDragEnabled(bool enabled);
|
||||
bool isDragEnabled() const;
|
||||
|
||||
bool isWordSelectionEnabled() const;
|
||||
void setWordSelectionEnabled(bool enabled);
|
||||
|
||||
void print(QPagedPaintDevice *printer) const;
|
||||
|
||||
virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const;
|
||||
virtual QRectF blockBoundingRect(const QTextBlock &block) const;
|
||||
QAbstractTextDocumentLayout::PaintContext getPaintContext() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setPlainText(const QString &text);
|
||||
void setHtml(const QString &text);
|
||||
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
void cut();
|
||||
void copy();
|
||||
void paste(QClipboard::Mode mode = QClipboard::Clipboard);
|
||||
#endif
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
void clear();
|
||||
void selectAll();
|
||||
|
||||
void insertPlainText(const QString &text);
|
||||
#ifndef QT_NO_TEXTHTMLPARSER
|
||||
void insertHtml(const QString &text);
|
||||
#endif
|
||||
|
||||
void append(const QString &text);
|
||||
void appendHtml(const QString &html);
|
||||
void appendPlainText(const QString &text);
|
||||
|
||||
void adjustSize();
|
||||
|
||||
Q_SIGNALS:
|
||||
void textChanged();
|
||||
void undoAvailable(bool b);
|
||||
void redoAvailable(bool b);
|
||||
void currentCharFormatChanged(const QTextCharFormat &format);
|
||||
void copyAvailable(bool b);
|
||||
void selectionChanged();
|
||||
void cursorPositionChanged();
|
||||
|
||||
// control signals
|
||||
void updateCursorRequest(const QRectF &rect = QRectF());
|
||||
void updateRequest(const QRectF &rect = QRectF());
|
||||
void documentSizeChanged(const QSizeF &);
|
||||
void blockCountChanged(int newBlockCount);
|
||||
void visibilityRequest(const QRectF &rect);
|
||||
void microFocusChanged();
|
||||
void linkActivated(const QString &link);
|
||||
void linkHovered(const QString &);
|
||||
void modificationChanged(bool m);
|
||||
|
||||
public:
|
||||
// control properties
|
||||
QPalette palette() const;
|
||||
void setPalette(const QPalette &pal);
|
||||
|
||||
virtual void processEvent(QEvent *e, const QMatrix &matrix);
|
||||
void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF());
|
||||
|
||||
// control methods
|
||||
void drawContents(QPainter *painter, const QRectF &rect = QRectF());
|
||||
|
||||
void setFocus(bool focus, Qt::FocusReason = Qt::OtherFocusReason);
|
||||
|
||||
virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
|
||||
|
||||
virtual QMimeData *createMimeDataFromSelection() const;
|
||||
virtual bool canInsertFromMimeData(const QMimeData *source) const;
|
||||
virtual void insertFromMimeData(const QMimeData *source);
|
||||
|
||||
bool setFocusToAnchor(const QTextCursor &newCursor);
|
||||
bool setFocusToNextOrPreviousAnchor(bool next);
|
||||
bool findNextPrevAnchor(const QTextCursor& from, bool next, QTextCursor& newAnchor);
|
||||
|
||||
bool cursorOn() const;
|
||||
|
||||
protected:
|
||||
virtual void timerEvent(QTimerEvent *e);
|
||||
|
||||
virtual bool event(QEvent *e);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QTextControl)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentCharFormatAndSelection())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_emitCursorPosChanged(const QTextCursor &))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_copyLink())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_updateBlock(const QTextBlock &))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_documentLayoutChanged())
|
||||
};
|
||||
|
||||
|
||||
// also used by QLabel
|
||||
class QTextEditMimeData : public QMimeData
|
||||
{
|
||||
public:
|
||||
inline QTextEditMimeData(const QTextDocumentFragment &aFragment) : fragment(aFragment) {}
|
||||
|
||||
virtual QStringList formats() const;
|
||||
protected:
|
||||
virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
|
||||
private:
|
||||
void setup() const;
|
||||
|
||||
mutable QTextDocumentFragment fragment;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QTextControl_H
|
@ -1,232 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTEXTCONTROL_P_P_H
|
||||
#define QTEXTCONTROL_P_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtGui/qtextdocumentfragment.h"
|
||||
#include "QtGui/qtextcursor.h"
|
||||
#include "QtGui/qtextformat.h"
|
||||
#include "QtGui/qabstracttextdocumentlayout.h"
|
||||
#include "QtCore/qbasictimer.h"
|
||||
#include "QtCore/qpointer.h"
|
||||
#include "private/qobject_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMimeData;
|
||||
class QAbstractScrollArea;
|
||||
class QInputContext;
|
||||
|
||||
class QTextControlPrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QTextControl)
|
||||
public:
|
||||
QTextControlPrivate();
|
||||
|
||||
bool cursorMoveKeyEvent(QKeyEvent *e);
|
||||
|
||||
void updateCurrentCharFormat();
|
||||
|
||||
void indent();
|
||||
void outdent();
|
||||
|
||||
void gotoNextTableCell();
|
||||
void gotoPreviousTableCell();
|
||||
|
||||
void createAutoBulletList();
|
||||
|
||||
void init(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
|
||||
QTextDocument *document = 0);
|
||||
void setContent(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
|
||||
QTextDocument *document = 0);
|
||||
void startDrag();
|
||||
|
||||
void paste(const QMimeData *source);
|
||||
|
||||
void setCursorPosition(const QPointF &pos);
|
||||
void setCursorPosition(int pos, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
|
||||
|
||||
void repaintCursor();
|
||||
inline void repaintSelection()
|
||||
{ repaintOldAndNewSelection(QTextCursor()); }
|
||||
void repaintOldAndNewSelection(const QTextCursor &oldSelection);
|
||||
|
||||
void selectionChanged(bool forceEmitSelectionChanged = false);
|
||||
|
||||
void _q_updateCurrentCharFormatAndSelection();
|
||||
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
void setClipboardSelection();
|
||||
#endif
|
||||
|
||||
void _q_emitCursorPosChanged(const QTextCursor &someCursor);
|
||||
|
||||
void setBlinkingCursorEnabled(bool enable);
|
||||
|
||||
void extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition);
|
||||
void extendBlockwiseSelection(int suggestedNewPosition);
|
||||
|
||||
void _q_deleteSelected();
|
||||
|
||||
void _q_setCursorAfterUndoRedo(int undoPosition, int charsAdded, int charsRemoved);
|
||||
|
||||
QRectF cursorRectPlusUnicodeDirectionMarkers(const QTextCursor &cursor) const;
|
||||
QRectF rectForPosition(int position) const;
|
||||
QRectF selectionRect(const QTextCursor &cursor) const;
|
||||
inline QRectF selectionRect() const
|
||||
{ return selectionRect(this->cursor); }
|
||||
|
||||
QString anchorForCursor(const QTextCursor &anchor) const;
|
||||
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
|
||||
Qt::KeyboardModifiers modifiers,
|
||||
Qt::MouseButtons buttons,
|
||||
const QPoint &globalPos);
|
||||
void mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
|
||||
Qt::KeyboardModifiers modifiers,
|
||||
Qt::MouseButtons buttons,
|
||||
const QPoint &globalPos);
|
||||
void mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
|
||||
Qt::KeyboardModifiers modifiers,
|
||||
Qt::MouseButtons buttons,
|
||||
const QPoint &globalPos);
|
||||
void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
|
||||
Qt::KeyboardModifiers modifiers,
|
||||
Qt::MouseButtons buttons,
|
||||
const QPoint &globalPos);
|
||||
bool sendMouseEventToInputContext(QEvent *e, QEvent::Type eventType, Qt::MouseButton button,
|
||||
const QPointF &pos,
|
||||
Qt::KeyboardModifiers modifiers,
|
||||
Qt::MouseButtons buttons,
|
||||
const QPoint &globalPos);
|
||||
void contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget);
|
||||
void focusEvent(QFocusEvent *e);
|
||||
#ifdef QT_KEYPAD_NAVIGATION
|
||||
void editFocusEvent(QEvent *e);
|
||||
#endif
|
||||
bool dragEnterEvent(QEvent *e, const QMimeData *mimeData);
|
||||
void dragLeaveEvent();
|
||||
bool dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos);
|
||||
bool dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QObject *source);
|
||||
|
||||
void inputMethodEvent(QInputMethodEvent *);
|
||||
|
||||
void activateLinkUnderCursor(QString href = QString());
|
||||
|
||||
void append(const QString &text, Qt::TextFormat format = Qt::AutoText);
|
||||
|
||||
QInputContext *inputContext();
|
||||
|
||||
QTextDocument *doc;
|
||||
bool cursorOn;
|
||||
QTextCursor cursor;
|
||||
bool cursorIsFocusIndicator;
|
||||
QTextCharFormat lastCharFormat;
|
||||
|
||||
QTextCursor dndFeedbackCursor;
|
||||
|
||||
Qt::TextInteractionFlags interactionFlags;
|
||||
|
||||
QBasicTimer cursorBlinkTimer;
|
||||
QBasicTimer trippleClickTimer;
|
||||
QPointF trippleClickPoint;
|
||||
|
||||
bool dragEnabled;
|
||||
|
||||
bool mousePressed;
|
||||
|
||||
bool mightStartDrag;
|
||||
QPoint dragStartPos;
|
||||
QPointer<QObject> contextObject;
|
||||
|
||||
bool lastSelectionState;
|
||||
|
||||
bool ignoreAutomaticScrollbarAdjustement;
|
||||
|
||||
QTextCursor selectedWordOnDoubleClick;
|
||||
QTextCursor selectedBlockOnTrippleClick;
|
||||
|
||||
bool overwriteMode;
|
||||
bool acceptRichText;
|
||||
|
||||
int preeditCursor;
|
||||
bool hideCursor; // used to hide the cursor in the preedit area
|
||||
|
||||
QVector<QAbstractTextDocumentLayout::Selection> extraSelections;
|
||||
|
||||
QPalette palette;
|
||||
bool hasFocus;
|
||||
#ifdef QT_KEYPAD_NAVIGATION
|
||||
bool hasEditFocus;
|
||||
#endif
|
||||
bool isEnabled;
|
||||
|
||||
QString highlightedAnchor; // Anchor below cursor
|
||||
QString anchorOnMousePress;
|
||||
bool hadSelectionOnMousePress;
|
||||
|
||||
bool ignoreUnusedNavigationEvents;
|
||||
bool openExternalLinks;
|
||||
|
||||
bool wordSelectionEnabled;
|
||||
|
||||
QString linkToCopy;
|
||||
void _q_copyLink();
|
||||
void _q_updateBlock(const QTextBlock &);
|
||||
void _q_documentLayoutChanged();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QTextControl_P_H
|
@ -9,7 +9,6 @@ HEADERS += \
|
||||
text/qfontmetrics.h \
|
||||
text/qfont_p.h \
|
||||
text/qfontsubset_p.h \
|
||||
text/qlinecontrol_p.h \
|
||||
text/qtextengine_p.h \
|
||||
text/qtextlayout.h \
|
||||
text/qtextformat.h \
|
||||
@ -23,8 +22,6 @@ HEADERS += \
|
||||
text/qtexthtmlparser_p.h \
|
||||
text/qabstracttextdocumentlayout.h \
|
||||
text/qtextdocumentlayout_p.h \
|
||||
text/qtextcontrol_p.h \
|
||||
text/qtextcontrol_p_p.h \
|
||||
text/qtextcursor.h \
|
||||
text/qtextcursor_p.h \
|
||||
text/qtextdocumentfragment.h \
|
||||
@ -53,8 +50,6 @@ SOURCES += \
|
||||
text/qfontsubset.cpp \
|
||||
text/qfontmetrics.cpp \
|
||||
text/qfontdatabase.cpp \
|
||||
text/qlinecontrol.cpp \
|
||||
text/qtextcontrol.cpp \
|
||||
text/qtextengine.cpp \
|
||||
text/qtextlayout.cpp \
|
||||
text/qtextformat.cpp \
|
||||
|
@ -4243,14 +4243,14 @@ void tst_QGraphicsItem::textControlGetterSetter()
|
||||
{
|
||||
QGraphicsTextItem *item = new QGraphicsTextItem;
|
||||
QVERIFY(item->textControl()->parent() == item);
|
||||
QPointer<QTextControl> control = item->textControl();
|
||||
QPointer<QWidgetTextControl> control = item->textControl();
|
||||
delete item;
|
||||
QVERIFY(!control);
|
||||
|
||||
item = new QGraphicsTextItem;
|
||||
|
||||
QPointer<QTextControl> oldControl = control;
|
||||
control = new QTextControl;
|
||||
QPointer<QWidgetTextControl> oldControl = control;
|
||||
control = new QWidgetTextControl;
|
||||
|
||||
item->setTextControl(control);
|
||||
QVERIFY(item->textControl() == control);
|
||||
@ -4269,7 +4269,7 @@ void tst_QGraphicsItem::textControlGetterSetter()
|
||||
// test that on setting a control the item size
|
||||
// is adjusted
|
||||
oldControl = control;
|
||||
control = new QTextControl;
|
||||
control = new QWidgetTextControl;
|
||||
control->setPlainText("foo!");
|
||||
item->setTextControl(control);
|
||||
QCOMPARE(item->boundingRect().size(), control->document()->documentLayout()->documentSize());
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include <QTextDocumentWriter>
|
||||
#include <QTextLayout>
|
||||
#include <QTextCursor>
|
||||
#include <private/qtextcontrol_p.h>
|
||||
#include <qmath.h>
|
||||
#include <QFile>
|
||||
#include <QPainter>
|
||||
@ -73,7 +72,6 @@ private slots:
|
||||
void odfWriting_text();
|
||||
void odfWriting_images();
|
||||
|
||||
void constructControl();
|
||||
void constructDocument();
|
||||
|
||||
void newLineReplacement();
|
||||
@ -90,10 +88,6 @@ private slots:
|
||||
void paintDocToPixmap();
|
||||
void paintDocToPixmap_painterFill();
|
||||
|
||||
void control();
|
||||
void paintControlToPixmap();
|
||||
void paintControlToPixmap_painterFill();
|
||||
|
||||
private:
|
||||
QSize setupTextLayout(QTextLayout *layout, bool wrap = true, int wrapWidth = 100);
|
||||
|
||||
@ -255,17 +249,6 @@ QSize tst_QText::setupTextLayout(QTextLayout *layout, bool wrap, int wrapWidth)
|
||||
return QSize(qCeil(widthUsed), height);
|
||||
}
|
||||
|
||||
void tst_QText::constructControl()
|
||||
{
|
||||
QTextControl *control = new QTextControl;
|
||||
delete control;
|
||||
|
||||
QBENCHMARK {
|
||||
QTextControl *control = new QTextControl;
|
||||
delete control;
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QText::constructDocument()
|
||||
{
|
||||
QTextDocument *doc = new QTextDocument;
|
||||
@ -441,52 +424,6 @@ void tst_QText::paintDocToPixmap_painterFill()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QText::control()
|
||||
{
|
||||
QTextControl *control = new QTextControl(m_shortLorem);
|
||||
Q_UNUSED(control);
|
||||
|
||||
QBENCHMARK {
|
||||
QTextControl *control = new QTextControl;
|
||||
QTextDocument *doc = control->document();
|
||||
doc->setHtml(m_shortLorem);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QText::paintControlToPixmap()
|
||||
{
|
||||
QTextControl *control = new QTextControl;
|
||||
QTextDocument *doc = control->document();
|
||||
doc->setHtml(m_shortLorem);
|
||||
doc->setTextWidth(300);
|
||||
QSize size = doc->size().toSize();
|
||||
|
||||
QBENCHMARK {
|
||||
QPixmap img(size);
|
||||
img.fill(Qt::transparent);
|
||||
QPainter p(&img);
|
||||
control->drawContents(&p, QRectF(QPointF(0, 0), QSizeF(size)));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QText::paintControlToPixmap_painterFill()
|
||||
{
|
||||
QTextControl *control = new QTextControl;
|
||||
QTextDocument *doc = control->document();
|
||||
doc->setHtml(m_shortLorem);
|
||||
doc->setTextWidth(300);
|
||||
QSize size = doc->size().toSize();
|
||||
|
||||
QBENCHMARK {
|
||||
QPixmap img(size);
|
||||
QPainter p(&img);
|
||||
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
p.fillRect(0, 0, img.width(), img.height(), Qt::transparent);
|
||||
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
control->drawContents(&p, QRectF(QPointF(0, 0), QSizeF(size)));
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QText)
|
||||
|
||||
#include "main.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user