Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QTextTablePrivate Class Reference

#include <qtexttable_p.h>

Inheritance diagram for QTextTablePrivate:
QTextFramePrivate QTextObjectPrivate QObjectPrivate QObjectData

Public Functions

int findCellIndex (int fragment) const
 
void fragmentAdded (const QChar &type, uint fragment)
 
void fragmentRemoved (const QChar &type, uint fragment)
 
 QTextTablePrivate (QTextDocument *document)
 
void update () const
 /fn void QTextTablePrivate::update() const More...
 
 ~QTextTablePrivate ()
 
- Public Functions inherited from QTextFramePrivate
 QTextFramePrivate (QTextDocument *doc)
 
void remove_me ()
 
- Public Functions inherited from QTextObjectPrivate
 QTextObjectPrivate (QTextDocument *doc)
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static QTextTablecreateTable (QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

bool blockFragmentUpdates
 
QVector< int > cellIndices
 
QList< int > cells
 
bool dirty
 
int * grid
 
int nCols
 
int nRows
 
- Public Variables inherited from QTextFramePrivate
QList< QTextFrame * > childFrames
 
uint fragment_end
 
uint fragment_start
 
QTextFrameLayoutDatalayoutData
 
QTextFrameparentFrame
 
- Public Variables inherited from QTextObjectPrivate
int objectIndex
 
QTextDocumentPrivatepieceTable
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 61 of file qtexttable_p.h.

Constructors and Destructors

◆ QTextTablePrivate()

QTextTablePrivate::QTextTablePrivate ( QTextDocument document)
inline

Definition at line 65 of file qtexttable_p.h.

65 : QTextFramePrivate(document), grid(0), nRows(0), nCols(0), dirty(true), blockFragmentUpdates(false) {}
QTextFramePrivate(QTextDocument *doc)
Definition: qtextobject_p.h:96

◆ ~QTextTablePrivate()

QTextTablePrivate::~QTextTablePrivate ( )

Definition at line 357 of file qtexttable.cpp.

Referenced by QTextTablePrivate().

358 {
359  if (grid)
360  free(grid);
361 }

Functions

◆ createTable()

QTextTable * QTextTablePrivate::createTable ( QTextDocumentPrivate pieceTable,
int  pos,
int  rows,
int  cols,
const QTextTableFormat tableFormat 
)
static

Definition at line 364 of file qtexttable.cpp.

Referenced by QTextCursor::insertTable(), and QTextTablePrivate().

365 {
366  QTextTableFormat fmt = tableFormat;
367  fmt.setColumns(cols);
368  QTextTable *table = qobject_cast<QTextTable *>(pieceTable->createObject(fmt));
369  Q_ASSERT(table);
370 
371  pieceTable->beginEditBlock();
372 
373 // qDebug("---> createTable: rows=%d, cols=%d at %d", rows, cols, pos);
374  // add block after table
375  QTextCharFormat charFmt;
376  charFmt.setObjectIndex(table->objectIndex());
378 
379 
380  int charIdx = pieceTable->formatCollection()->indexForFormat(charFmt);
381  int cellIdx = pieceTable->formatCollection()->indexForFormat(QTextBlockFormat());
382 
383  QTextTablePrivate *d = table->d_func();
384  d->blockFragmentUpdates = true;
385 
386  d->fragment_start = pieceTable->insertBlock(QTextBeginningOfFrame, pos, cellIdx, charIdx);
387  d->cells.append(d->fragment_start);
388  ++pos;
389 
390  for (int i = 1; i < rows*cols; ++i) {
391  d->cells.append(pieceTable->insertBlock(QTextBeginningOfFrame, pos, cellIdx, charIdx));
392 // qDebug(" addCell at %d", pos);
393  ++pos;
394  }
395 
396  d->fragment_end = pieceTable->insertBlock(QTextEndOfFrame, pos, cellIdx, charIdx);
397 // qDebug(" addEOR at %d", pos);
398  ++pos;
399 
400  d->blockFragmentUpdates = false;
401  d->dirty = true;
402 
403  pieceTable->endEditBlock();
404 
405  return table;
406 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
double d
Definition: qnumeric_p.h:62
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
#define QTextBeginningOfFrame
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int insertBlock(int pos, int blockFormat, int charFormat, QTextUndoCommand::Operation=QTextUndoCommand::MoveCursor)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int objectIndex() const
Returns the object index of this object.
QTextFormatCollection * formatCollection()
QTextObject * createObject(const QTextFormat &newFormat, int objectIndex=-1)
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
QList< int > cells
Definition: qtexttable_p.h:76
void setObjectType(int type)
Sets the text format&#39;s object type to type.
Definition: qtextformat.h:367
void setColumns(int columns)
Sets the number of columns required by the table format.
Definition: qtextformat.h:885
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
The QTextTableFormat class provides formatting information for tables in a QTextDocument.
Definition: qtextformat.h:842
void setObjectIndex(int object)
Sets the format object&#39;s object index.
int indexForFormat(const QTextFormat &f)
#define QTextEndOfFrame

◆ findCellIndex()

int QTextTablePrivate::findCellIndex ( int  fragment) const

Definition at line 426 of file qtexttable.cpp.

Referenced by QTextTableCell::column(), QTextTablePrivate(), and QTextTableCell::row().

427 {
431  if (it == cells.end())
432  return -1;
433  return it - cells.begin();
434 }
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
uint position(uint node, uint field=0) const
QList< int > cells
Definition: qtexttable_p.h:76
QTextDocumentPrivate * pieceTable
Definition: qtextobject_p.h:72
const FragmentMap & fragmentMap() const
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ fragmentAdded()

void QTextTablePrivate::fragmentAdded ( const QChar type,
uint  fragment 
)
virtual

Reimplemented from QTextFramePrivate.

Definition at line 436 of file qtexttable.cpp.

Referenced by QTextTablePrivate().

437 {
438  dirty = true;
440  return;
441  if (type == QTextBeginningOfFrame) {
442  Q_ASSERT(cells.indexOf(fragment) == -1);
443  const uint pos = pieceTable->fragmentMap().position(fragment);
446  cells.insert(it, fragment);
447  if (!fragment_start || pos < pieceTable->fragmentMap().position(fragment_start))
448  fragment_start = fragment;
449  return;
450  }
451  QTextFramePrivate::fragmentAdded(type, fragment);
452 }
#define it(className, varName)
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
#define QTextBeginningOfFrame
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual void fragmentAdded(const QChar &type, uint fragment)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
unsigned int uint
Definition: qglobal.h:996
uint position(uint node, uint field=0) const
QList< int > cells
Definition: qtexttable_p.h:76
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:227
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
QTextDocumentPrivate * pieceTable
Definition: qtextobject_p.h:72
const FragmentMap & fragmentMap() const
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ fragmentRemoved()

void QTextTablePrivate::fragmentRemoved ( const QChar type,
uint  fragment 
)
virtual

Reimplemented from QTextFramePrivate.

Definition at line 454 of file qtexttable.cpp.

Referenced by QTextTablePrivate().

455 {
456  dirty = true;
458  return;
459  if (type == QTextBeginningOfFrame) {
460  Q_ASSERT(cells.indexOf(fragment) != -1);
461  cells.removeAll(fragment);
462  if (fragment_start == fragment && cells.size()) {
463  fragment_start = cells.at(0);
464  }
465  if (fragment_start != fragment)
466  return;
467  }
468  QTextFramePrivate::fragmentRemoved(type, fragment);
469 }
#define QTextBeginningOfFrame
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< int > cells
Definition: qtexttable_p.h:76
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
virtual void fragmentRemoved(const QChar &type, uint fragment)
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

◆ update()

void QTextTablePrivate::update ( ) const

/fn void QTextTablePrivate::update() const

This function is usually called when the table is "dirty". It seems to update all kind of table information.

Definition at line 478 of file qtexttable.cpp.

Referenced by QTextTableCell::column(), QTextTablePrivate(), and QTextTableCell::row().

479 {
480  Q_Q(const QTextTable);
481  nCols = q->format().columns();
482  nRows = (cells.size() + nCols-1)/nCols;
483 // qDebug(">>>> QTextTablePrivate::update, nRows=%d, nCols=%d", nRows, nCols);
484 
485  grid = q_check_ptr((int *)realloc(grid, nRows*nCols*sizeof(int)));
486  memset(grid, 0, nRows*nCols*sizeof(int));
487 
490 
492 
493  int cell = 0;
494  for (int i = 0; i < cells.size(); ++i) {
495  int fragment = cells.at(i);
497  int rowspan = fmt.tableCellRowSpan();
498  int colspan = fmt.tableCellColumnSpan();
499 
500  // skip taken cells
501  while (cell < nRows*nCols && grid[cell])
502  ++cell;
503 
504  int r = cell/nCols;
505  int c = cell%nCols;
506  cellIndices[i] = cell;
507 
508  if (r + rowspan > nRows) {
509  grid = q_check_ptr((int *)realloc(grid, sizeof(int)*(r + rowspan)*nCols));
510  memset(grid + (nRows*nCols), 0, sizeof(int)*(r+rowspan-nRows)*nCols);
511  nRows = r + rowspan;
512  }
513 
514  Q_ASSERT(c + colspan <= nCols);
515  for (int ii = 0; ii < rowspan; ++ii) {
516  for (int jj = 0; jj < colspan; ++jj) {
517  Q_ASSERT(grid[(r+ii)*nCols + c+jj] == 0);
518  grid[(r+ii)*nCols + c+jj] = fragment;
519 // qDebug(" setting cell %d span=%d/%d at %d/%d", fragment, rowspan, colspan, r+ii, c+jj);
520  }
521  }
522  }
523 // qDebug("<<<< end: nRows=%d, nCols=%d", nRows, nCols);
524 
525  dirty = false;
526 }
T * q_check_ptr(T *p)
Definition: qglobal.h:1857
QTextCharFormat charFormat(int index) const
Definition: qtextformat_p.h:85
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
unsigned char c[8]
Definition: qnumeric_p.h:62
QVector< int > cellIndices
Definition: qtexttable_p.h:79
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
FragmentMap::ConstIterator FragmentIterator
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
#define Q_Q(Class)
Definition: qglobal.h:2483
QTextFormatCollection * formatCollection()
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
QList< int > cells
Definition: qtexttable_p.h:76
int tableCellRowSpan() const
If this character format is applied to characters in a table cell, this function returns the number o...
Definition: qtextformat.h:518
QTextDocumentPrivate * pieceTable
Definition: qtextobject_p.h:72
int tableCellColumnSpan() const
If this character format is applied to characters in a table cell, this function returns the number o...
Definition: qtextformat.h:521
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const FragmentMap & fragmentMap() const

Properties

◆ blockFragmentUpdates

bool QTextTablePrivate::blockFragmentUpdates

Definition at line 84 of file qtexttable_p.h.

Referenced by createTable().

◆ cellIndices

QVector<int> QTextTablePrivate::cellIndices
mutable

Definition at line 79 of file qtexttable_p.h.

Referenced by QTextTableCell::column(), and QTextTableCell::row().

◆ cells

QList<int> QTextTablePrivate::cells

Definition at line 76 of file qtexttable_p.h.

Referenced by createTable(), and QTextTableCell::lastPosition().

◆ dirty

bool QTextTablePrivate::dirty
mutable

Definition at line 83 of file qtexttable_p.h.

Referenced by QTextTableCell::column(), createTable(), and QTextTableCell::row().

◆ grid

int* QTextTablePrivate::grid
mutable

Definition at line 80 of file qtexttable_p.h.

◆ nCols

int QTextTablePrivate::nCols
mutable

Definition at line 82 of file qtexttable_p.h.

Referenced by QTextTableCell::column(), and QTextTableCell::row().

◆ nRows

int QTextTablePrivate::nRows
mutable

Definition at line 81 of file qtexttable_p.h.


The documentation for this class was generated from the following files: