summaryrefslogtreecommitdiff
path: root/qmake/include/private/qrichtext_p.h
Side-by-side diff
Diffstat (limited to 'qmake/include/private/qrichtext_p.h') (more/less context) (show whitespace changes)
-rw-r--r--qmake/include/private/qrichtext_p.h59
1 files changed, 41 insertions, 18 deletions
diff --git a/qmake/include/private/qrichtext_p.h b/qmake/include/private/qrichtext_p.h
index 8e29804..9ed87cf 100644
--- a/qmake/include/private/qrichtext_p.h
+++ b/qmake/include/private/qrichtext_p.h
@@ -135,68 +135,70 @@ public:
QString anchorName;
QString anchorHref;
};
#ifndef QT_NO_TEXTCUSTOMITEM
void loseCustomItem();
#endif
union {
QTextFormat* format;
CustomData* custom;
} d;
bool isAnchor() const { return ( type & Anchor) != 0; }
bool isLink() const { return isAnchor() && !!d.custom->anchorHref; }
QString anchorName() const;
QString anchorHref() const;
void setAnchor( const QString& name, const QString& href );
private:
QTextStringChar &operator=( const QTextStringChar & ) {
//abort();
return *this;
}
+ QTextStringChar( const QTextStringChar & ) {
+ }
friend class QComplexText;
friend class QTextParagraph;
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<QTextStringChar>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextString
{
public:
QTextString();
QTextString( const QTextString &s );
virtual ~QTextString();
- static QString toString( const QMemArray<QTextStringChar> &data );
- QString toString() const;
+ static QString toString( const QMemArray<QTextStringChar> &data, bool fixspaces = TRUE );
+ QString toString( bool fixspaces = TRUE ) const;
QTextStringChar &at( int i ) const;
#if defined(Q_STRICT_INLINING_RULES)
// This is for the IRIX MIPSpro o32 ABI - it fails, claiming the
// implementation to be a redefinition.
inline int length() const;
#else
int length() const;
#endif
int width( int idx ) const;
void insert( int index, const QString &s, QTextFormat *f );
void insert( int index, const QChar *unicode, int len, QTextFormat *f );
void insert( int index, QTextStringChar *c, bool doAddRefFormat = FALSE );
void truncate( int index );
void remove( int index, int len );
void clear();
void setFormat( int index, QTextFormat *f, bool useCollection );
void setBidi( bool b ) { bidi = b; }
bool isBidi() const;
bool isRightToLeft() const;
@@ -265,89 +267,89 @@ public:
// implementation to be a redefinition.
inline QTextParagraph *paragraph() const;
#else
QTextParagraph *paragraph() const;
#endif
void setParagraph( QTextParagraph*p ) { gotoPosition(p, 0 ); }
QTextDocument *document() const;
int index() const;
void setIndex( int index ) { gotoPosition(paragraph(), index ); }
void gotoPosition( QTextParagraph* p, int index = 0);
void gotoLeft();
void gotoRight();
void gotoNextLetter();
void gotoPreviousLetter();
void gotoUp();
void gotoDown();
void gotoLineEnd();
void gotoLineStart();
void gotoHome();
void gotoEnd();
void gotoPageUp( int visibleHeight );
void gotoPageDown( int visibleHeight );
- void gotoNextWord();
- void gotoPreviousWord();
+ void gotoNextWord( bool onlySpace = FALSE );
+ void gotoPreviousWord( bool onlySpace = FALSE );
void gotoWordLeft();
void gotoWordRight();
void insert( const QString &s, bool checkNewLine, QMemArray<QTextStringChar> *formatting = 0 );
void splitAndInsertEmptyParagraph( bool ind = TRUE, bool updateIds = TRUE );
bool remove();
void indent();
bool atParagStart();
bool atParagEnd();
int x() const; // x in current paragraph
int y() const; // y in current paragraph
int globalX() const;
int globalY() const;
QTextParagraph *topParagraph() const { return paras.isEmpty() ? para : paras.first(); }
int offsetX() const { return ox; } // inner document offset
int offsetY() const { return oy; } // inner document offset
int totalOffsetX() const; // total document offset
int totalOffsetY() const; // total document offset
bool place( const QPoint &pos, QTextParagraph *s ) { return place( pos, s, FALSE ); }
bool place( const QPoint &pos, QTextParagraph *s, bool link );
void restoreState();
int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast
void oneUp() { if ( !indices.isEmpty() ) pop(); }
void setValid( bool b ) { valid = b; }
bool isValid() const { return valid; }
private:
enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down };
void push();
void pop();
- void processNesting( Operation op );
+ bool processNesting( Operation op );
void invalidateNested();
void gotoIntoNested( const QPoint &globalPos );
QTextParagraph *para;
int idx, tmpIndex;
int ox, oy;
QValueStack<int> indices;
QValueStack<QTextParagraph*> paras;
QValueStack<int> xOffsets;
QValueStack<int> yOffsets;
uint valid : 1;
};
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Q_EXPORT QTextCommand
{
public:
enum Commands { Invalid, Insert, Delete, Format, Style };
QTextCommand( QTextDocument *d ) : doc( d ), cursor( d ) {}
virtual ~QTextCommand();
@@ -682,48 +684,49 @@ private:
int cellspacing;
int border;
int outerborder;
int stretch;
int innerborder;
int us_cp, us_ib, us_b, us_ob, us_cs;
QMap<QString, QString> attributes;
QMap<QTextCursor*, int> currCell;
Placement place;
void adjustCells( int y , int shift );
int pageBreakFor;
};
#endif
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#ifndef QT_NO_TEXTCUSTOMITEM
class QTextTableCell;
class QTextParagraph;
#endif
struct Q_EXPORT QTextDocumentSelection
{
QTextCursor startCursor, endCursor;
bool swapped;
+ Q_DUMMY_COMPARISON_OPERATOR(QTextDocumentSelection)
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QColor>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, bool>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextDocumentSelection>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextDocument>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextDocument : public QObject
{
Q_OBJECT
#ifndef QT_NO_TEXTCUSTOMITEM
friend class QTextTableCell;
#endif
friend class QTextCursor;
friend class QTextEdit;
friend class QTextParagraph;
public:
enum SelectionIds {
@@ -818,48 +821,51 @@ public:
bool inSelection( int selId, const QPoint &pos ) const;
QStyleSheet *styleSheet() const { return sheet_; }
#ifndef QT_NO_MIME
QMimeSourceFactory *mimeSourceFactory() const { return factory_; }
#endif
QString context() const { return contxt; }
void setStyleSheet( QStyleSheet *s );
void setDefaultFormat( const QFont &font, const QColor &color );
#ifndef QT_NO_MIME
void setMimeSourceFactory( QMimeSourceFactory *f ) { if ( f ) factory_ = f; }
#endif
void setContext( const QString &c ) { if ( !c.isEmpty() ) contxt = c; }
void setUnderlineLinks( bool b );
bool underlineLinks() const { return underlLinks; }
void setPaper( QBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; }
QBrush *paper() const { return backBrush; }
void doLayout( QPainter *p, int w );
void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 );
+ void eraseParagraphEmptyArea( QTextParagraph *parag, QPainter *p, const QColorGroup &cg );
+ bool useDoubleBuffer( QTextParagraph *parag, QPainter *p );
+
void drawParagraph( QPainter *p, QTextParagraph *parag, int cx, int cy, int cw, int ch,
QPixmap *&doubleBuffer, const QColorGroup &cg,
bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE );
QTextParagraph *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg,
bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0,
bool resetChanged = TRUE );
#ifndef QT_NO_TEXTCUSTOMITEM
void registerCustomItem( QTextCustomItem *i, QTextParagraph *p );
void unregisterCustomItem( QTextCustomItem *i, QTextParagraph *p );
#endif
void setFlow( QTextFlow *f );
void takeFlow();
QTextFlow *flow() const { return flow_; }
bool isPageBreakEnabled() const { return pages; }
void setPageBreakEnabled( bool b ) { pages = b; }
void setUseFormatCollection( bool b ) { useFC = b; }
bool useFormatCollection() const { return useFC; }
#ifndef QT_NO_TEXTCUSTOMITEM
QTextTableCell *tableCell() const { return tc; }
void setTableCell( QTextTableCell *c ) { tc = c; }
@@ -1046,48 +1052,49 @@ protected:
class Q_EXPORT QTextStyleCommand : public QTextCommand
{
public:
QTextStyleCommand( QTextDocument *d, int fParag, int lParag, const QByteArray& beforeChange );
virtual ~QTextStyleCommand() {}
Commands type() const { return Style; }
QTextCursor *execute( QTextCursor *c );
QTextCursor *unexecute( QTextCursor *c );
static QByteArray readStyleInformation( QTextDocument* d, int fParag, int lParag );
static void writeStyleInformation( QTextDocument* d, int fParag, const QByteArray& style );
private:
int firstParag, lastParag;
QByteArray before;
QByteArray after;
};
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
struct Q_EXPORT QTextParagraphSelection
{
int start, end;
+ Q_DUMMY_COMPARISON_OPERATOR(QTextParagraphSelection)
};
struct Q_EXPORT QTextLineStart
{
QTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 )
#ifndef QT_NO_COMPLEXTEXT
, bidicontext( 0 )
#endif
{ }
QTextLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ),
w( 0 )
#ifndef QT_NO_COMPLEXTEXT
, bidicontext( 0 )
#endif
{ }
#ifndef QT_NO_COMPLEXTEXT
QTextLineStart( QBidiContext *c, QBidiStatus s ) : y(0), baseLine(0), h(0),
status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); }
#endif
virtual ~QTextLineStart()
{
#ifndef QT_NO_COMPLEXTEXT
if ( bidicontext && bidicontext->deref() )
@@ -1115,89 +1122,87 @@ public:
#endif
int w;
private:
#ifndef QT_NO_COMPLEXTEXT
QBidiContext *bidicontext;
#endif
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextParagraphSelection>;
Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextLineStart*>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextParagraphData
{
public:
QTextParagraphData() {}
virtual ~QTextParagraphData();
virtual void join( QTextParagraphData * );
};
-class Q_EXPORT QTextParagraphPseudoDocument
-{
-public:
- QTextParagraphPseudoDocument();
- ~QTextParagraphPseudoDocument();
- QRect docRect;
- QTextFormatter *pFormatter;
- QTextCommandHistory *commandHistory;
- int minw;
- int wused;
-};
+class QTextParagraphPseudoDocument;
+
+class QSyntaxHighlighter;
-//nase
class Q_EXPORT QTextParagraph
{
friend class QTextDocument;
friend class QTextCursor;
+ friend class QSyntaxHighlighter;
public:
QTextParagraph( QTextDocument *d, QTextParagraph *pr = 0, QTextParagraph *nx = 0, bool updateIds = TRUE );
virtual ~QTextParagraph();
QTextString *string() const;
QTextStringChar *at( int i ) const; // maybe remove later
int leftGap() const;
int length() const; // maybe remove later
void setListStyle( QStyleSheetItem::ListStyle ls ) { lstyle = ls; changed = TRUE; }
QStyleSheetItem::ListStyle listStyle() const { return lstyle; }
void setListItem( bool li );
bool isListItem() const { return litem; }
void setListValue( int v ) { list_val = v; }
int listValue() const { return list_val > 0 ? list_val : -1; }
void setListDepth( int depth );
int listDepth() const { return ldepth; }
// void setFormat( QTextFormat *fm );
// QTextFormat *paragFormat() const;
+#if defined(Q_STRICT_INLINING_RULES)
+ // This is for the IRIX MIPSpro o32 ABI - it fails, claiming the
+ // implementation to be a redefinition.
+ inline QTextDocument *document() const;
+#else
QTextDocument *document() const;
+#endif
QTextParagraphPseudoDocument *pseudoDocument() const;
QRect rect() const;
void setHeight( int h ) { r.setHeight( h ); }
void show();
void hide();
bool isVisible() const { return visible; }
QTextParagraph *prev() const;
QTextParagraph *next() const;
void setPrev( QTextParagraph *s );
void setNext( QTextParagraph *s );
void insert( int index, const QString &s );
void insert( int index, const QChar *unicode, int len );
void append( const QString &s, bool reallyAtEnd = FALSE );
void truncate( int index );
void remove( int index, int len );
void join( QTextParagraph *s );
void invalidate( int chr );
void move( int &dy );
void format( int start = -1, bool doMove = TRUE );
@@ -1575,68 +1580,80 @@ private:
// MOC_SKIP_BEGIN
Q_TEMPLATE_EXTERN template class Q_EXPORT QDict<QTextFormat>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTextFormatCollection
{
friend class QTextDocument;
friend class QTextFormat;
public:
QTextFormatCollection();
virtual ~QTextFormatCollection();
void setDefaultFormat( QTextFormat *f );
QTextFormat *defaultFormat() const;
virtual QTextFormat *format( QTextFormat *f );
virtual QTextFormat *format( QTextFormat *of, QTextFormat *nf, int flags );
virtual QTextFormat *format( const QFont &f, const QColor &c );
virtual void remove( QTextFormat *f );
virtual QTextFormat *createFormat( const QTextFormat &f ) { return new QTextFormat( f ); }
virtual QTextFormat *createFormat( const QFont &f, const QColor &c ) { return new QTextFormat( f, c, this ); }
void updateDefaultFormat( const QFont &font, const QColor &c, QStyleSheet *sheet );
- QDict<QTextFormat> dict() const { return cKey; }
QPaintDevice *paintDevice() const { return paintdevice; }
void setPaintDevice( QPaintDevice * );
private:
void updateKeys();
private:
QTextFormat *defFormat, *lastFormat, *cachedFormat;
QDict<QTextFormat> cKey;
QTextFormat *cres;
QFont cfont;
QColor ccol;
QString kof, knf;
int cflags;
QPaintDevice *paintdevice;
};
+class Q_EXPORT QTextParagraphPseudoDocument
+{
+public:
+ QTextParagraphPseudoDocument();
+ ~QTextParagraphPseudoDocument();
+ QRect docRect;
+ QTextFormatter *pFormatter;
+ QTextCommandHistory *commandHistory;
+ int minw;
+ int wused;
+ QTextFormatCollection collection;
+};
+
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline int QTextString::length() const
{
return data.size();
}
inline int QTextParagraph::length() const
{
return str->length();
}
inline QRect QTextParagraph::rect() const
{
return r;
}
inline QTextParagraph *QTextCursor::paragraph() const
{
return para;
}
inline int QTextCursor::index() const
{
@@ -1807,48 +1824,54 @@ inline void QTextDocument::setTabArray( int *a )
inline void QTextDocument::setTabStops( int tw )
{
tStopWidth = tw;
}
inline QString QTextDocument::originalText() const
{
if ( oTextValid )
return oText;
return text();
}
inline void QTextDocument::setFlow( QTextFlow *f )
{
if ( flow_ )
delete flow_;
flow_ = f;
}
inline void QTextDocument::takeFlow()
{
flow_ = 0;
}
+inline bool QTextDocument::useDoubleBuffer( QTextParagraph *parag, QPainter *p )
+{
+ return ( !parag->document()->parent() || parag->document()->nextDoubleBuffered ) &&
+ ( !p || !p->device() || p->device()->devType() != QInternal::Printer );
+}
+
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline QColor QTextFormat::color() const
{
return col;
}
inline QFont QTextFormat::font() const
{
return fn;
}
inline bool QTextFormat::isMisspelled() const
{
return missp;
}
inline QTextFormat::VerticalAlignment QTextFormat::vAlign() const
{
return ha;
}
inline bool QTextFormat::operator==( const QTextFormat &f ) const
{