mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-20 06:06:13 +00:00
Changed: #1307 Added tab view on QMdiArea, new syntax highliter and added base functions for Undo/Redo framework
This commit is contained in:
parent
72b338d6f4
commit
a9778a62a1
21 changed files with 79 additions and 80 deletions
|
@ -35,14 +35,15 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace Plugin {
|
namespace TranslationManager {
|
||||||
|
|
||||||
void CEditorPhrase::open(QString filename)
|
void CEditorPhrase::open(QString filename)
|
||||||
{
|
{
|
||||||
vector<STRING_MANAGER::TPhrase> phrases;
|
vector<STRING_MANAGER::TPhrase> phrases;
|
||||||
if(readPhraseFile(filename.toStdString(), phrases, false))
|
if(readPhraseFile(filename.toStdString(), phrases, false))
|
||||||
{
|
{
|
||||||
text_edit = new QTextEdit(this);
|
text_edit = new CTextEdit(this);
|
||||||
|
text_edit->setUndoStack(current_stack);
|
||||||
SyntaxHighlighter *highlighter = new SyntaxHighlighter(text_edit);
|
SyntaxHighlighter *highlighter = new SyntaxHighlighter(text_edit);
|
||||||
text_edit->setUndoRedoEnabled(true);
|
text_edit->setUndoRedoEnabled(true);
|
||||||
text_edit->document()->setUndoRedoEnabled(true);
|
text_edit->document()->setUndoRedoEnabled(true);
|
||||||
|
@ -58,7 +59,6 @@ void CEditorPhrase::open(QString filename)
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
editor_type = Constants::ED_PHRASE;
|
editor_type = Constants::ED_PHRASE;
|
||||||
current_file = filename;
|
current_file = filename;
|
||||||
connect(text_edit->document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(contentsChangeNow(int position, int charsRemoved, int charsAdded)));
|
|
||||||
connect(text_edit->document(), SIGNAL(contentsChanged()), this, SLOT(docContentsChanged()));
|
connect(text_edit->document(), SIGNAL(contentsChanged()), this, SLOT(docContentsChanged()));
|
||||||
} else {
|
} else {
|
||||||
QErrorMessage error;
|
QErrorMessage error;
|
||||||
|
@ -67,13 +67,28 @@ void CEditorPhrase::open(QString filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEditorPhrase::contentsChangeNow(int position, int charsRemoved, int charsAdded)
|
/* void CTextEdit::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if(charsRemoved > 0)
|
QString chars = event->text();
|
||||||
current_stack->push(new CUndoPhraseRemoveCommand(position-charsRemoved, charsRemoved, text_edit));
|
int index = textCursor().position();
|
||||||
else if(charsAdded > 0)
|
|
||||||
current_stack->push(new CUndoPhraseInsertCommand(position, text_edit->toPlainText().right(charsAdded), text_edit));
|
switch(event->key())
|
||||||
}
|
{
|
||||||
|
case Qt::Key_Backspace:
|
||||||
|
if (index > 0)
|
||||||
|
m_undoStack->push(new CUndoPhraseRemoveCommand(index--, 1, this));
|
||||||
|
break;
|
||||||
|
case Qt::Key_Delete:
|
||||||
|
if (index < toPlainText().length())
|
||||||
|
m_undoStack->push(new CUndoPhraseRemoveCommand(index, 1, this));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (!chars.isEmpty())
|
||||||
|
m_undoStack->push(new CUndoPhraseInsertCommand(index, chars, this));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} */
|
||||||
|
|
||||||
void CEditorPhrase::docContentsChanged()
|
void CEditorPhrase::docContentsChanged()
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,17 +29,33 @@
|
||||||
#include <QtGui/QUndoStack>
|
#include <QtGui/QUndoStack>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QtGui/QTextEdit>
|
||||||
#include <QtGui/QSyntaxHighlighter>
|
#include <QtGui/QSyntaxHighlighter>
|
||||||
|
#include <QtGui/QErrorMessage>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "translation_manager_editor.h"
|
#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
|
class CEditorPhrase : public CEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QTextEdit *text_edit;
|
CTextEdit *text_edit;
|
||||||
public:
|
public:
|
||||||
CEditorPhrase(QMdiArea* parent) : CEditor(parent) {}
|
CEditorPhrase(QMdiArea* parent) : CEditor(parent) {}
|
||||||
CEditorPhrase() : CEditor() {}
|
CEditorPhrase() : CEditor() {}
|
||||||
|
@ -49,7 +65,6 @@ public:
|
||||||
void activateWindow();
|
void activateWindow();
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void contentsChangeNow(int, int, int);
|
|
||||||
void docContentsChanged();
|
void docContentsChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -127,30 +142,12 @@ public:
|
||||||
{
|
{
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
keywordFormat.setForeground(Qt::darkBlue);
|
translateStringFormat.setFontWeight(QFont::Bold);
|
||||||
keywordFormat.setFontWeight(QFont::Bold);
|
translateStringFormat.setForeground(Qt::darkMagenta);
|
||||||
QStringList keywordPatterns;
|
rule.pattern = QRegExp("\\[.+\\]");
|
||||||
keywordPatterns << "\\bchar\\b" << "\\bclass\\b" << "\\bconst\\b"
|
rule.format = translateStringFormat;
|
||||||
<< "\\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);
|
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);
|
singleLineCommentFormat.setForeground(Qt::red);
|
||||||
rule.pattern = QRegExp("//[^\n]*");
|
rule.pattern = QRegExp("//[^\n]*");
|
||||||
|
@ -166,7 +163,7 @@ public:
|
||||||
|
|
||||||
functionFormat.setFontItalic(true);
|
functionFormat.setFontItalic(true);
|
||||||
functionFormat.setForeground(Qt::blue);
|
functionFormat.setForeground(Qt::blue);
|
||||||
rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()");
|
rule.pattern = QRegExp("\\(.+\\)");
|
||||||
rule.format = functionFormat;
|
rule.format = functionFormat;
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
|
@ -223,6 +220,7 @@ public:
|
||||||
QTextCharFormat multiLineCommentFormat;
|
QTextCharFormat multiLineCommentFormat;
|
||||||
QTextCharFormat quotationFormat;
|
QTextCharFormat quotationFormat;
|
||||||
QTextCharFormat functionFormat;
|
QTextCharFormat functionFormat;
|
||||||
|
QTextCharFormat translateStringFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace Plugin {
|
namespace TranslationManager {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include "translation_manager_editor.h"
|
#include "translation_manager_editor.h"
|
||||||
#include "extract_new_sheet_names.h"
|
#include "extract_new_sheet_names.h"
|
||||||
|
|
||||||
namespace Plugin {
|
namespace TranslationManager {
|
||||||
|
|
||||||
class CEditorWorksheet : public CEditor
|
class CEditorWorksheet : public CEditor
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ static bool RemoveOlds = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
|
|
||||||
TCreatureInfo *ExtractBotNames::getCreature(const std::string &sheetName)
|
TCreatureInfo *ExtractBotNames::getCreature(const std::string &sheetName)
|
||||||
|
|
|
@ -35,7 +35,7 @@ using namespace NLMISC;
|
||||||
using namespace NLLIGO;
|
using namespace NLLIGO;
|
||||||
using namespace STRING_MANAGER;
|
using namespace STRING_MANAGER;
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
|
|
||||||
struct TCreatureInfo
|
struct TCreatureInfo
|
||||||
|
|
|
@ -21,7 +21,8 @@ using namespace NLMISC;
|
||||||
using namespace NLLIGO;
|
using namespace NLLIGO;
|
||||||
using namespace STRING_MANAGER;
|
using namespace STRING_MANAGER;
|
||||||
|
|
||||||
namespace Plugin {
|
namespace TranslationManager
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ using namespace NLMISC;
|
||||||
using namespace NLLIGO;
|
using namespace NLLIGO;
|
||||||
using namespace STRING_MANAGER;
|
using namespace STRING_MANAGER;
|
||||||
|
|
||||||
namespace Plugin {
|
namespace TranslationManager
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtNetwork/QFtp>
|
#include <QtNetwork/QFtp>
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
CFtpSelection::CFtpSelection(QWidget *parent): QDialog(parent)
|
CFtpSelection::CFtpSelection(QWidget *parent): QDialog(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace Plugin {
|
namespace TranslationManager {
|
||||||
|
|
||||||
class CFtpSelection : public QDialog
|
class CFtpSelection : public QDialog
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "source_selection.h"
|
#include "source_selection.h"
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
|
|
||||||
class CSourceDialog : public QDialog
|
class CSourceDialog : public QDialog
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#ifndef TRANSLATION_MANAGER_CONSTANTS_H
|
#ifndef TRANSLATION_MANAGER_CONSTANTS_H
|
||||||
#define TRANSLATION_MANAGER_CONSTANTS_H
|
#define TRANSLATION_MANAGER_CONSTANTS_H
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
namespace Constants
|
namespace Constants
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <QtGui/QUndoStack>
|
#include <QtGui/QUndoStack>
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
|
|
||||||
namespace Plugin {
|
namespace TranslationManager {
|
||||||
|
|
||||||
class CEditor : public QMdiSubWindow {
|
class CEditor : public QMdiSubWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#include "ftp_selection.h"
|
#include "ftp_selection.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
|
|
||||||
CMainWindow::CMainWindow(QWidget *parent)
|
CMainWindow::CMainWindow(QWidget *parent)
|
||||||
|
@ -592,30 +592,6 @@ bool CMainWindow::isPhraseEditor(QString filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* void CMainWindow::keyPressEvent(QKeyEvent *event)
|
|
||||||
{
|
|
||||||
CEditorPhrase* editor = qobject_cast<CEditorPhrase*>(_ui.mdiArea->currentSubWindow());
|
|
||||||
|
|
||||||
QString chars = event->text();
|
|
||||||
int index = editor->text_edit->textCursor().position();
|
|
||||||
|
|
||||||
switch (event->key())
|
|
||||||
{
|
|
||||||
case Qt::Key_Backspace:
|
|
||||||
if (index > 0)
|
|
||||||
m_undoStack->push(new CUndoPhraseRemoveCommand(index--, 1, editor->text_edit));
|
|
||||||
break;
|
|
||||||
case Qt::Key_Delete:
|
|
||||||
if (index < editor->text_edit->toPlainText().length())
|
|
||||||
m_undoStack->push(new CUndoPhraseRemoveCommand(index, 1, editor->text_edit));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (!chars.isEmpty())
|
|
||||||
m_undoStack->push(new CUndoPhraseInsertCommand(index, chars, editor->text_edit));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
bool CCoreListener::closeMainWindow() const
|
bool CCoreListener::closeMainWindow() const
|
||||||
{
|
{
|
||||||
bool okToClose = true;
|
bool okToClose = true;
|
||||||
|
|
|
@ -52,7 +52,7 @@ class QWidget;
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
|
|
||||||
class CMainWindow : public QMainWindow
|
class CMainWindow : public QMainWindow
|
||||||
|
|
|
@ -18,7 +18,14 @@
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QMdiArea" name="mdiArea"/>
|
<widget class="QMdiArea" name="mdiArea">
|
||||||
|
<property name="viewMode">
|
||||||
|
<enum>QMdiArea::TabbedView</enum>
|
||||||
|
</property>
|
||||||
|
<property name="documentMode">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
#include <QtGui/QMenuBar>
|
#include <QtGui/QMenuBar>
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
TranslationManagerPlugin::~TranslationManagerPlugin()
|
TranslationManagerPlugin::~TranslationManagerPlugin()
|
||||||
{
|
{
|
||||||
|
@ -137,8 +137,9 @@ ExtensionSystem::IPluginSpec *TranslationManagerPlugin::pluginByName(const QStri
|
||||||
if (spec->name() == name)
|
if (spec->name() == name)
|
||||||
return spec;
|
return spec;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(Plugin::TranslationManagerPlugin)
|
Q_EXPORT_PLUGIN(TranslationManager::TranslationManagerPlugin)
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace ExtensionSystem
|
||||||
class IPluginSpec;
|
class IPluginSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
|
|
||||||
class CTranslationManagerContext;
|
class CTranslationManagerContext;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
|
|
||||||
QString lastDir = ".";
|
QString lastDir = ".";
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
namespace Plugin
|
namespace TranslationManager
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@class CTranslationManagerSettingsPage
|
@class CTranslationManagerSettingsPage
|
||||||
|
|
Loading…
Reference in a new issue