]> git.lyx.org Git - features.git/commitdiff
merge QViewSource and QViewSourceDialog
authorAndré Pönitz <poenitz@gmx.net>
Tue, 24 Apr 2007 14:08:53 +0000 (14:08 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 24 Apr 2007 14:08:53 +0000 (14:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17947 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Dialogs.C
src/frontends/qt4/Makefile.dialogs
src/frontends/qt4/QDocumentDialog.C
src/frontends/qt4/QViewSource.C
src/frontends/qt4/QViewSource.h
src/frontends/qt4/QViewSourceDialog.C [deleted file]
src/frontends/qt4/QViewSourceDialog.h [deleted file]

index 2eab9ae84ad0c182873018d0cf8c1bd9fe4a1f37..318507e7c1b59f36a293cc487d1c31b7bbf374b7 100644 (file)
@@ -68,7 +68,6 @@
 #include "QNomencl.h"
 #include "QLog.h"
 #include "QViewSource.h"
-#include "QViewSourceDialog.h"
 #include "QNote.h"
 #include "QParagraph.h"
 #include "QPrefs.h"
index aa893004d4185736bf0f6c396de8118b363d8721..668e5c2cd749d010988f98fdba199784a7fee6c4 100644 (file)
@@ -108,7 +108,6 @@ MOCFILES = \
        QIndexDialog.C QIndexDialog.h \
        QLog.C QLog.h \
        QLogDialog.C QLogDialog.h \
-       QViewSourceDialog.C QViewSourceDialog.h \
        QViewSource.C QViewSource.h \
        QLMenubar.C QLMenubar.h \
        QLPopupMenu.C QLPopupMenu.h \
index da839968fedf12fe088e8247cf4f2b322ea59dcb..a54766449626b884282682d1b5d3b4fec9100977 100644 (file)
@@ -374,10 +374,11 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
 
        // preamble
        preambleModule = new UiWidget<Ui::PreambleUi>;
-       connect(preambleModule->preambleTE, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
+       connect(preambleModule->preambleTE, SIGNAL(textChanged()),
+               this, SLOT(change_adaptor()));
        // This is not a memory leak. The object will be destroyed
        // with preambleModule.
-       new latexHighlighter(preambleModule->preambleTE->document());
+       (void) new LaTeXHighlighter(preambleModule->preambleTE->document());
 
 
        // bullets
index c9ada5c6baa8ac8892ce25f2ce4e8e458475d4e3..e8c5263edafc7f1c67d1eb9829fa852bad28af03 100644 (file)
 #include <config.h>
 
 #include "QViewSource.h"
-#include "QViewSourceDialog.h"
 #include "qt_helpers.h"
 
+#include <QTextDocument>
+
 namespace lyx {
 namespace frontend {
 
+/////////////////////////////////////////////////////////////////////
+//
+// QViewSourceDialog
+//
+/////////////////////////////////////////////////////////////////////
+
+QViewSourceDialog::QViewSourceDialog(QViewSource * form)
+       : form_(form)
+{
+       setupUi(this);
+
+       connect(viewFullSourceCB, SIGNAL(clicked()),
+               this, SLOT(update()));
+       connect(autoUpdateCB, SIGNAL(toggled(bool)),
+               updatePB, SLOT(setDisabled(bool)));
+       connect(updatePB, SIGNAL(clicked()),
+               this, SLOT(update()));
 
-latexHighlighter::latexHighlighter(QTextDocument * parent) :
-       QSyntaxHighlighter(parent)
+       // setting a document at this point trigger an assertion in Qt
+       // so we disable the signals here:
+       form_->document()->blockSignals(true);
+       viewSourceTV->setDocument(form_->document());
+       form_->document()->blockSignals(false);
+       viewSourceTV->setReadOnly(true);
+       ///dialog_->viewSourceTV->setAcceptRichText(false);
+       // this is personal. I think source code should be in fixed-size font
+       QFont font(toqstr(theApp()->typewriterFontName()));
+       font.setKerning(false);
+       font.setFixedPitch(true);
+       font.setStyleHint(QFont::TypeWriter);
+       viewSourceTV->setFont(font);
+       // again, personal taste
+       viewSourceTV->setWordWrapMode(QTextOption::NoWrap);
+}
+
+
+void QViewSourceDialog::update()
+{
+       if (autoUpdateCB->isChecked())
+               form_->update(viewFullSourceCB->isChecked());
+
+       QWidget::update();
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// LaTeXHighlighter
+//
+/////////////////////////////////////////////////////////////////////
+
+
+LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent)
+       : QSyntaxHighlighter(parent)
 {
        keywordFormat.setForeground(Qt::darkBlue);
        keywordFormat.setFontWeight(QFont::Bold);
@@ -30,7 +82,7 @@ latexHighlighter::latexHighlighter(QTextDocument * parent) :
 }
 
 
-void latexHighlighter::highlightBlock(QString const & text)
+void LaTeXHighlighter::highlightBlock(QString const & text)
 {
        // $ $ 
        QRegExp exprMath("\\$[^\\$]*\\$");
@@ -91,7 +143,7 @@ void latexHighlighter::highlightBlock(QString const & text)
        QRegExp exprComment("(^|[^\\\\])%.*$");
        index = text.indexOf(exprComment);
        while (index >= 0) {
-               int length = exprComment.matchedLength();
+               int const length = exprComment.matchedLength();
                setFormat(index, length, commentFormat);
                index = text.indexOf(exprComment, index + length);
        }
@@ -102,11 +154,16 @@ QViewSource::QViewSource(Dialog & parent)
        : ControlViewSource(parent)
 {
        document_ = new QTextDocument(this);
-       // set syntex highlighting
-       highlighter_ = new latexHighlighter(document_);
+       highlighter_ = new LaTeXHighlighter(document_);
 }
 
 
+/////////////////////////////////////////////////////////////////////
+//
+// QViewSource
+//
+/////////////////////////////////////////////////////////////////////
+
 void QViewSource::update(bool full_source)
 {
        document_->setPlainText(toqstr(updateContent(full_source)));
index 3c2d9e421dcba41ca48dcacfdf77f5829f72eb9d..7871e10e10fe8eef56738cf703e095ab2961d2da 100644 (file)
 #define QVIEWSOURCE_H
 
 #include "frontends/controllers/ControlViewSource.h"
+#include "frontends/Application.h"
+#include "ui/ViewSourceUi.h"
 
-#include <QObject>
+#include <QWidget>
 #include <QSyntaxHighlighter>
 #include <QTextCharFormat>
-#include <QTextDocument>
+
+class QTextDocument;
 
 namespace lyx {
 namespace frontend {
 
-/// LaTeX syntax highlighting.
-/// \todo FIXME: extract the latexHighlighter class into its 
-/// own .[Ch] files.
-class latexHighlighter : public QSyntaxHighlighter
+// used already twice...
+class LaTeXHighlighter : public QSyntaxHighlighter
 {
-       Q_OBJECT        
 public:
-       latexHighlighter(QTextDocument * parent);
+       LaTeXHighlighter(QTextDocument * parent);
 
 protected:
        void highlightBlock(QString const & text);
@@ -42,24 +42,39 @@ private:
        QTextCharFormat mathFormat;
 };
 
-///
-class QViewSource: public QObject, public ControlViewSource
-{
+
+
+class QViewSource;
+
+class QViewSourceDialog : public QWidget, public Ui::QViewSourceUi {
        Q_OBJECT
 public:
-       QViewSource(Dialog &);
-       virtual ~QViewSource() {}
+       QViewSourceDialog(QViewSource * form);
+
+public Q_SLOTS:
+       // update content
+       void update();
+
+private:
+       QViewSource * form_;
+};
 
-       QTextDocument * document() { return document_; }
 
+///
+class QViewSource : public QObject, public ControlViewSource {
+public:
+       ///
+       QViewSource(Dialog &);
+       ///
+       QTextDocument * document() { return document_; }
+       ///
        void update(bool full_source);
 
 private:
        ///
        QTextDocument * document_;
-
-       /// latex syntax highlighter
-       latexHighlighter * highlighter_;
+       /// LaTeX syntax highlighter
+       LaTeXHighlighter * highlighter_;
 };
 
 
diff --git a/src/frontends/qt4/QViewSourceDialog.C b/src/frontends/qt4/QViewSourceDialog.C
deleted file mode 100644 (file)
index 4ce778e..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * \file QViewSourceDialog.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Bo Peng
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QViewSourceDialog.h"
-
-#include "QViewSource.h"
-
-
-namespace lyx {
-namespace frontend {
-
-QViewSourceDialog::QViewSourceDialog(QViewSource * form)
-       : form_(form)
-{
-       setupUi(this);
-
-       connect(viewFullSourceCB, SIGNAL(clicked()),
-               this, SLOT(update()));
-       connect(autoUpdateCB, SIGNAL(toggled(bool)),
-               updatePB, SLOT(setDisabled(bool)));
-       connect(updatePB, SIGNAL(clicked()),
-               this, SLOT(update()));
-
-       // setting a document at this point trigger an assertion in Qt
-       // so we disable the signals here:
-       form_->document()->blockSignals(true);
-       viewSourceTV->setDocument(form_->document());
-       form_->document()->blockSignals(false);
-       viewSourceTV->setReadOnly(true);
-       ///dialog_->viewSourceTV->setAcceptRichText(false);
-       // this is personal. I think source code should be in fixed-size font
-       QFont font(toqstr(theApp()->typewriterFontName()));
-       font.setKerning(false);
-       font.setFixedPitch(true);
-       font.setStyleHint(QFont::TypeWriter);
-       viewSourceTV->setFont(font);
-       // again, personal taste
-       viewSourceTV->setWordWrapMode(QTextOption::NoWrap);
-}
-
-
-void QViewSourceDialog::update()
-{
-       if (autoUpdateCB->isChecked())
-               form_->update(viewFullSourceCB->isChecked());
-
-       QWidget::update();
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "QViewSourceDialog_moc.cpp"
diff --git a/src/frontends/qt4/QViewSourceDialog.h b/src/frontends/qt4/QViewSourceDialog.h
deleted file mode 100644 (file)
index 1330f9e..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// -*- C++ -*-
-/**
- * \file QViewSourceDialog.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Bo Peng
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QVIEWSOURCEDIALOG_H
-#define QVIEWSOURCEDIALOG_H
-
-#include "ui/ViewSourceUi.h"
-
-#include "frontends/Application.h"
-
-#include <QWidget>
-
-namespace lyx {
-namespace frontend {
-
-class QViewSource;
-
-class QViewSourceDialog : public QWidget, public Ui::QViewSourceUi {
-       Q_OBJECT
-public:
-       QViewSourceDialog(QViewSource * form);
-
-public Q_SLOTS:
-       // update content
-       void update();
-
-private:
-       QViewSource * form_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // QVIEWSOURCEDIALOG_H