#include "QNomencl.h"
#include "QLog.h"
#include "QViewSource.h"
-#include "QViewSourceDialog.h"
#include "QNote.h"
#include "QParagraph.h"
#include "QPrefs.h"
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 \
// 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
#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);
}
-void latexHighlighter::highlightBlock(QString const & text)
+void LaTeXHighlighter::highlightBlock(QString const & text)
{
// $ $
QRegExp exprMath("\\$[^\\$]*\\$");
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);
}
: 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)));
#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);
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_;
};
+++ /dev/null
-/**
- * \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"
+++ /dev/null
-// -*- 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