Qt 4.8
Enumerations | Functions
qtextcursor.cpp File Reference
#include "qtextcursor.h"
#include "qtextcursor_p.h"
#include "qglobal.h"
#include "qtextdocumentfragment.h"
#include "qtextdocumentfragment_p.h"
#include "qtextlist.h"
#include "qtexttable.h"
#include "qtexttable_p.h"
#include "qtextengine_p.h"
#include "qabstracttextdocumentlayout.h"
#include <qtextlayout.h>
#include <qdebug.h>

Go to the source code of this file.

Enumerations

enum  { AdjustPrev = 0x1, AdjustUp = 0x3, AdjustNext = 0x4, AdjustDown = 0x12 }
 

Functions

static void getText (QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end)
 
static void setBlockCharFormatHelper (QTextDocumentPrivate *priv, int pos1, int pos2, const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
AdjustPrev 
AdjustUp 
AdjustNext 
AdjustDown 

Definition at line 58 of file qtextcursor.cpp.

58  {
59  AdjustPrev = 0x1,
60  AdjustUp = 0x3,
61  AdjustNext = 0x4,
62  AdjustDown = 0x12
63 };

Function Documentation

◆ getText()

static void getText ( QString text,
QTextDocumentPrivate priv,
const QString docText,
int  pos,
int  end 
)
static

Definition at line 1728 of file qtextcursor.cpp.

Referenced by QTextCursor::selectedText().

1729 {
1730  while (pos < end) {
1731  QTextDocumentPrivate::FragmentIterator fragIt = priv->find(pos);
1732  const QTextFragmentData * const frag = fragIt.value();
1733 
1734  const int offsetInFragment = qMax(0, pos - fragIt.position());
1735  const int len = qMin(int(frag->size_array[0] - offsetInFragment), end - pos);
1736 
1737  text += QString(docText.constData() + frag->stringPosition + offsetInFragment, len);
1738  pos += len;
1739  }
1740 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QString class provides a Unicode character string.
Definition: qstring.h:83
FragmentMap::ConstIterator FragmentIterator
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
FragmentIterator find(int pos) const
quint32 size_array[N]
static const KeyPair *const end
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ setBlockCharFormatHelper()

static void setBlockCharFormatHelper ( QTextDocumentPrivate priv,
int  pos1,
int  pos2,
const QTextCharFormat format,
QTextDocumentPrivate::FormatChangeMode  changeMode 
)
static

Definition at line 732 of file qtextcursor.cpp.

Referenced by QTextCursorPrivate::setBlockCharFormat().

734 {
735  QTextBlock it = priv->blocksFind(pos1);
736  QTextBlock end = priv->blocksFind(pos2);
737  if (end.isValid())
738  end = end.next();
739 
740  for (; it != end; it = it.next()) {
741  priv->setCharFormat(it.position() - 1, 1, format, changeMode);
742  }
743 }
#define it(className, varName)
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
int position() const
Returns the index of the block&#39;s first character within the document.
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
Definition: qtextobject.h:208
QTextBlock blocksFind(int pos) const
void setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode=SetFormat)
static const KeyPair *const end