[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    qt-copy
From:       Laurent Montel <montel () kde ! org>
Date:       2006-01-25 9:13:29
Message-ID: 1138180409.156438.4111.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 502214 by mlaurent:

Add patch from Simon (qt-4.2) to support rehighlight function
was missing into qt-4.1.x
(necessary to finish port to ksyntaxhighlighter)
Thanks Simon.


 A             patches/0112-ksyntaxhighlighter-rehighlight-document.diff  
 M  +1 -1      patches/README  
 M  +17 -15    src/gui/text/qsyntaxhighlighter.cpp  
 M  +3 -1      src/gui/text/qsyntaxhighlighter.h  


--- trunk/qt-copy/patches/README #502213:502214
@@ -1,5 +1,5 @@
 Please assign the numbers incrementally, and don't reuse them. The next one:
-#0112
+#0113
 
 This directory contains patches for Qt that haven't been accepted by TrollTech
 yet. All patches in this directory itself shouldn't make qt-copy incompatible
--- trunk/qt-copy/src/gui/text/qsyntaxhighlighter.cpp #502213:502214
@@ -42,8 +42,6 @@
 
     QPointer<QTextDocument> doc;
 
-    void reformatDocument();
-
     void reformatBlocks(int from, int charsRemoved, int charsAdded);
     void reformatBlock(QTextBlock block);
 
@@ -52,18 +50,6 @@
     QTextBlock currentBlock;
 };
 
-void QSyntaxHighlighterPrivate::reformatDocument()
-{
-    if (!doc)
-        return;
-
-    QTextCursor cursor(doc);
-    cursor.beginEditBlock();
-    cursor.movePosition(QTextCursor::End);
-    reformatBlocks(0, 0, cursor.position());
-    cursor.endEditBlock();
-}
-
 void QSyntaxHighlighterPrivate::applyFormatChanges()
 {
     QList<QTextLayout::FormatRange> ranges;
@@ -338,7 +324,7 @@
     if (d->doc) {
         connect(d->doc, SIGNAL(contentsChange(int, int, int)),
                 this, SLOT(reformatBlocks(int, int, int)));
-        QTimer::singleShot(0, this, SLOT(reformatDocument()));
+        QTimer::singleShot(0, this, SLOT(rehighlight()));
     }
 }
 
@@ -353,6 +339,22 @@
 }
 
 /*!
+    Redoes the highlighting of the whole document.
+*/
+void QSyntaxHighlighter::rehighlight()
+{
+    Q_D(QSyntaxHighlighter);
+    if (!d->doc)
+        return;
+
+    QTextCursor cursor(d->doc);
+    cursor.beginEditBlock();
+    cursor.movePosition(QTextCursor::End);
+    d->reformatBlocks(0, 0, cursor.position());
+    cursor.endEditBlock();
+}
+
+/*!
     \fn void QSyntaxHighlighter::highlightBlock(const QString &text)
 
     Highlights the given text block. This function is called when
--- trunk/qt-copy/src/gui/text/qsyntaxhighlighter.h #502213:502214
@@ -54,6 +54,9 @@
     void setDocument(QTextDocument *doc);
     QTextDocument *document() const;
 
+public Q_SLOTS:
+    void rehighlight();
+
 protected:
     virtual void highlightBlock(const QString &text) = 0;
 
@@ -72,7 +75,6 @@
 private:
     Q_DISABLE_COPY(QSyntaxHighlighter)
     Q_PRIVATE_SLOT(d_func(), void reformatBlocks(int from, int charsRemoved, int charsAdded))
-    Q_PRIVATE_SLOT(d_func(), void reformatDocument())
 };
 
 #endif // QT_NO_SYNTAXHIGHLIGHTER
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic