|
|
|
@ -29,17 +29,33 @@
|
|
|
|
|
#include <QtGui/QUndoStack>
|
|
|
|
|
#include <QtGui/QTextEdit>
|
|
|
|
|
#include <QtGui/QSyntaxHighlighter>
|
|
|
|
|
#include <QtGui/QErrorMessage>
|
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
|
|
|
|
|
// Project includes
|
|
|
|
|
#include "translation_manager_editor.h"
|
|
|
|
|
|
|
|
|
|
namespace Plugin {
|
|
|
|
|
namespace TranslationManager {
|
|
|
|
|
|
|
|
|
|
class CTextEdit : public QTextEdit
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
private:
|
|
|
|
|
QUndoStack* m_undoStack;
|
|
|
|
|
public:
|
|
|
|
|
CTextEdit(QWidget* parent = 0) : QTextEdit(parent) { }
|
|
|
|
|
//void keyPressEvent(QKeyEvent *event);
|
|
|
|
|
void setUndoStack(QUndoStack* undoStack)
|
|
|
|
|
{
|
|
|
|
|
m_undoStack = undoStack;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CEditorPhrase : public CEditor
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
QTextEdit *text_edit;
|
|
|
|
|
CTextEdit *text_edit;
|
|
|
|
|
public:
|
|
|
|
|
CEditorPhrase(QMdiArea* parent) : CEditor(parent) {}
|
|
|
|
|
CEditorPhrase() : CEditor() {}
|
|
|
|
@ -49,7 +65,6 @@ public:
|
|
|
|
|
void activateWindow();
|
|
|
|
|
void closeEvent(QCloseEvent *event);
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
|
void contentsChangeNow(int, int, int);
|
|
|
|
|
void docContentsChanged();
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
@ -127,30 +142,12 @@ public:
|
|
|
|
|
{
|
|
|
|
|
HighlightingRule rule;
|
|
|
|
|
|
|
|
|
|
keywordFormat.setForeground(Qt::darkBlue);
|
|
|
|
|
keywordFormat.setFontWeight(QFont::Bold);
|
|
|
|
|
QStringList keywordPatterns;
|
|
|
|
|
keywordPatterns << "\\bchar\\b" << "\\bclass\\b" << "\\bconst\\b"
|
|
|
|
|
<< "\\bdouble\\b" << "\\benum\\b" << "\\bexplicit\\b"
|
|
|
|
|
<< "\\bfriend\\b" << "\\binline\\b" << "\\bint\\b"
|
|
|
|
|
<< "\\blong\\b" << "\\bnamespace\\b" << "\\boperator\\b"
|
|
|
|
|
<< "\\bprivate\\b" << "\\bprotected\\b" << "\\bpublic\\b"
|
|
|
|
|
<< "\\bshort\\b" << "\\bsignals\\b" << "\\bsigned\\b"
|
|
|
|
|
<< "\\bslots\\b" << "\\bstatic\\b" << "\\bstruct\\b"
|
|
|
|
|
<< "\\btemplate\\b" << "\\btypedef\\b" << "\\btypename\\b"
|
|
|
|
|
<< "\\bunion\\b" << "\\bunsigned\\b" << "\\bvirtual\\b"
|
|
|
|
|
<< "\\bvoid\\b" << "\\bvolatile\\b";
|
|
|
|
|
Q_FOREACH(const QString &pattern, keywordPatterns) {
|
|
|
|
|
rule.pattern = QRegExp(pattern);
|
|
|
|
|
rule.format = keywordFormat;
|
|
|
|
|
highlightingRules.append(rule);
|
|
|
|
|
}
|
|
|
|
|
translateStringFormat.setFontWeight(QFont::Bold);
|
|
|
|
|
translateStringFormat.setForeground(Qt::darkMagenta);
|
|
|
|
|
rule.pattern = QRegExp("\\[.+\\]");
|
|
|
|
|
rule.format = translateStringFormat;
|
|
|
|
|
highlightingRules.append(rule);
|
|
|
|
|
|
|
|
|
|
classFormat.setFontWeight(QFont::Bold);
|
|
|
|
|
classFormat.setForeground(Qt::darkMagenta);
|
|
|
|
|
rule.pattern = QRegExp("\\bQ[A-Za-z]+\\b");
|
|
|
|
|
rule.format = classFormat;
|
|
|
|
|
highlightingRules.append(rule);
|
|
|
|
|
|
|
|
|
|
singleLineCommentFormat.setForeground(Qt::red);
|
|
|
|
|
rule.pattern = QRegExp("//[^\n]*");
|
|
|
|
@ -166,7 +163,7 @@ public:
|
|
|
|
|
|
|
|
|
|
functionFormat.setFontItalic(true);
|
|
|
|
|
functionFormat.setForeground(Qt::blue);
|
|
|
|
|
rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()");
|
|
|
|
|
rule.pattern = QRegExp("\\(.+\\)");
|
|
|
|
|
rule.format = functionFormat;
|
|
|
|
|
highlightingRules.append(rule);
|
|
|
|
|
|
|
|
|
@ -223,6 +220,7 @@ public:
|
|
|
|
|
QTextCharFormat multiLineCommentFormat;
|
|
|
|
|
QTextCharFormat quotationFormat;
|
|
|
|
|
QTextCharFormat functionFormat;
|
|
|
|
|
QTextCharFormat translateStringFormat;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|