import com.trolltech.qt.core.QIODevice;\r
import com.trolltech.qt.core.QMimeData;\r
import com.trolltech.qt.core.QTextCodec;\r
+import com.trolltech.qt.core.QTimer;\r
import com.trolltech.qt.core.QUrl;\r
import com.trolltech.qt.core.Qt;\r
import com.trolltech.qt.core.Qt.Key;\r
public Signal0 unblockApplication;\r
public boolean awaitingHttpResponse;\r
public long unblockTime;\r
+ private final QTimer setSourceTimer;\r
String latexGuid; // This is set if we are editing an existing LaTeX formula. Useful to track guid.\r
\r
\r
blockApplication = new Signal1<BrowserWindow>();\r
unblockApplication = new Signal0();\r
\r
+ setSourceTimer = new QTimer();\r
+ setSourceTimer.timeout.connect(this, "setSource()");\r
+ \r
logger.log(logger.HIGH, "Browser setup complete");\r
}\r
\r
public void setContent(QByteArray data) {\r
sourceEdit.blockSignals(true);\r
browser.setContent(data);\r
- setSource(getBrowser().page().mainFrame().toHtml());\r
+ setSource();\r
}\r
// get/set current note\r
public void setNote(Note n) {\r
// The note contents have changed\r
public void contentChanged() {\r
String content = getContent();\r
- setSource(content);\r
+ \r
+ // This puts in a 1/2 second delay\r
+ // before updating the source editor.\r
+ // It improves response when someone is doing\r
+ // frequent updates on a large note.\r
+ // If the source editor isn't visible, then there\r
+ // is no point to doing any of this.\r
+ if (sourceEdit.isVisible()) {\r
+ setSourceTimer.stop();\r
+ setSourceTimer.setInterval(500);\r
+ setSourceTimer.setSingleShot(true);\r
+ setSourceTimer.start();\r
+ }\r
\r
checkNoteTitle();\r
noteSignal.noteChanged.emit(currentNote.getGuid(), content); \r
noteSignal.noteChanged.emit(currentNote.getGuid(), sourceEdit.toPlainText()); \r
}\r
\r
- private void setSource(String text) {\r
+ private void setSource() {\r
+ String text = getContent();\r
sourceEdit.blockSignals(true);\r
int body = text.indexOf("<body");\r
if (body > 0) {\r
text = text.replace("</body></html>", "");\r
sourceEdit.setPlainText(text);\r
sourceEdit.setReadOnly(!getBrowser().page().isContentEditable());\r
- syntaxHighlighter.rehighlight();\r
+ //syntaxHighlighter.rehighlight();\r
sourceEdit.blockSignals(false);\r
}\r
\r
// show/hide view source window\r
public void showSource(boolean value) {\r
+ if (sourceEdit.isVisible()) \r
+ setSource();\r
sourceEdit.setVisible(value);\r
}\r
\r