Fixed: #1307 Clean up code.

This commit is contained in:
dnk-88 2011-12-22 02:41:39 +03:00
parent 22be50ee4b
commit f0ec6b3fcc
22 changed files with 1858 additions and 1869 deletions

View file

@ -10,25 +10,23 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
SET(OVQT_PLUG_TRANSLATION_MANAGER_HDR translation_manager_plugin.h SET(OVQT_PLUG_TRANSLATION_MANAGER_HDR translation_manager_plugin.h
translation_manager_main_window.h translation_manager_main_window.h
translation_manager_settings_page.h translation_manager_settings_page.h
translation_manager_editor.h translation_manager_editor.h
source_selection.h source_selection.h
ftp_selection.h ftp_selection.h
editor_worksheet.h editor_worksheet.h
editor_phrase.h editor_phrase.h
extract_new_sheet_names.h )
extract_bot_names.h)
SET(OVQT_PLUG_TRANSLATION_MANAGER_UIS translation_manager_settings_page.ui SET(OVQT_PLUG_TRANSLATION_MANAGER_UIS translation_manager_settings_page.ui
translation_manager_main_window.ui translation_manager_main_window.ui
source_selection.ui source_selection.ui
ftp_selection.ui) ftp_selection.ui)
SET(OVQT_PLUG_TRANSLATION_MANAGER_RCS ftp_selection.qrc) SET(OVQT_PLUG_TRANSLATION_MANAGER_RCS ftp_selection.qrc)
SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE)
SET(QT_USE_QTNETWORK TRUE) SET(QT_USE_QTNETWORK TRUE)
QT4_WRAP_CPP(OVQT_PLUG_TRANSLATION_MANAGER_MOC_SRC ${OVQT_PLUG_TRANSLATION_MANAGER_HDR}) QT4_WRAP_CPP(OVQT_PLUG_TRANSLATION_MANAGER_MOC_SRC ${OVQT_PLUG_TRANSLATION_MANAGER_HDR})
@ -42,7 +40,7 @@ SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
ADD_LIBRARY(ovqt_plugin_translation_manager MODULE ${SRC} ${OVQT_PLUG_TRANSLATION_MANAGER_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_TRANSLATION_MANAGER_UI_HDRS}) ADD_LIBRARY(ovqt_plugin_translation_manager MODULE ${SRC} ${OVQT_PLUG_TRANSLATION_MANAGER_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_TRANSLATION_MANAGER_UI_HDRS})
TARGET_LINK_LIBRARIES(ovqt_plugin_translation_manager ovqt_plugin_core nelmisc nel3d nelligo nelgeorges ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY} ${QT_QTNETWORK_LIBRARY} ) TARGET_LINK_LIBRARIES(ovqt_plugin_translation_manager ovqt_plugin_core nelmisc nelligo nelgeorges ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY} ${QT_QTNETWORK_LIBRARY} )
NL_DEFAULT_PROPS(ovqt_plugin_translation_manager "NeL, Tools, 3D: Object Viewer Qt Plugin: Translation Manager") NL_DEFAULT_PROPS(ovqt_plugin_translation_manager "NeL, Tools, 3D: Object Viewer Qt Plugin: Translation Manager")
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_translation_manager) NL_ADD_RUNTIME_FLAGS(ovqt_plugin_translation_manager)

View file

@ -1,5 +1,4 @@
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/> // Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com> // Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
@ -15,32 +14,32 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "editor_phrase.h"
#include "translation_manager_constants.h"
// Nel includes // Nel includes
#include "nel/misc/path.h" #include "nel/misc/path.h"
#include "nel/misc/diff_tool.h" #include "nel/misc/diff_tool.h"
// Qt includes // Qt includes
#include <QtCore/QFileInfo>
#include <QtCore/QByteArray>
#include <QtCore/QTextCodec>
#include <QtCore/QTextStream>
#include <QtGui/QTextCursor>
#include <QtGui/QErrorMessage> #include <QtGui/QErrorMessage>
#include <QtCore/qfileinfo.h>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QCloseEvent> #include <QtGui/QCloseEvent>
#include <QtCore/QByteArray>
#include <QtCore/qtextcodec.h>
#include <QtGui/QTextCursor>
#include <QtCore/qtextstream.h>
#include <QtCore/qtextcodec.h>
// Project includes
#include "editor_phrase.h"
#include "translation_manager_constants.h"
using namespace std; using namespace std;
namespace TranslationManager { namespace TranslationManager
{
void CEditorPhrase::open(QString filename) void CEditorPhrase::open(QString filename)
{ {
vector<STRING_MANAGER::TPhrase> phrases; std::vector<STRING_MANAGER::TPhrase> phrases;
if(readPhraseFile(filename.toStdString(), phrases, false)) if(readPhraseFile(filename.toStdString(), phrases, false))
{ {
text_edit = new CTextEdit(this); text_edit = new CTextEdit(this);
@ -58,21 +57,23 @@ void CEditorPhrase::open(QString filename)
text_edit->append(data); text_edit->append(data);
// window settings // window settings
setCurrentFile(filename); setCurrentFile(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(contentsChanged()), this, SLOT(docContentsChanged())); connect(text_edit->document(), SIGNAL(contentsChanged()), this, SLOT(docContentsChanged()));
connect(text_edit->document(), SIGNAL(undoCommandAdded()), this, SLOT(newUndoCommandAdded())); connect(text_edit->document(), SIGNAL(undoCommandAdded()), this, SLOT(newUndoCommandAdded()));
} else { }
QErrorMessage error; else
error.showMessage("This file is not a phrase file."); {
error.exec(); QErrorMessage error;
} error.showMessage("This file is not a phrase file.");
error.exec();
}
} }
void CEditorPhrase::newUndoCommandAdded() void CEditorPhrase::newUndoCommandAdded()
{ {
current_stack->push(new CUndoPhraseNewCommand(text_edit)); current_stack->push(new CUndoPhraseNewCommand(text_edit));
} }
void CEditorPhrase::docContentsChanged() void CEditorPhrase::docContentsChanged()
@ -97,44 +98,37 @@ void CEditorPhrase::saveAs(QString filename)
QTextStream out(&file); QTextStream out(&file);
out.setCodec("UTF-8"); out.setCodec("UTF-8");
out.setGenerateByteOrderMark(true); out.setGenerateByteOrderMark(true);
out<<text_edit->toPlainText(); out << text_edit->toPlainText();
current_file = filename; current_file = filename;
setCurrentFile(current_file); setCurrentFile(current_file);
} }
void CEditorPhrase::closeEvent(QCloseEvent *event) void CEditorPhrase::closeEvent(QCloseEvent *event)
{ {
if(isWindowModified()) if(isWindowModified())
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("The document has been modified."); msgBox.setIcon(QMessageBox::Question);
msgBox.setInformativeText("Do you want to save your changes?"); msgBox.setText(tr("The document has been modified."));
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); msgBox.setInformativeText(tr("Do you want to save your changes?"));
msgBox.setDefaultButton(QMessageBox::Save); msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
int ret = msgBox.exec(); msgBox.setDefaultButton(QMessageBox::Save);
switch (ret)
{ int ret = msgBox.exec();
case QMessageBox::Save: switch (ret)
save(); {
event->accept(); case QMessageBox::Save:
close(); save();
break; break;
case QMessageBox::Discard: case QMessageBox::Discard:
event->accept(); break;
close(); case QMessageBox::Cancel:
break; event->ignore();
case QMessageBox::Cancel: return;
event->ignore(); }
break; }
default: event->accept();
break; close();
}
} else {
event->accept();
close();
}
} }
} }

View file

@ -18,6 +18,9 @@
#ifndef EDITOR_PHRASE_H #ifndef EDITOR_PHRASE_H
#define EDITOR_PHRASE_H #define EDITOR_PHRASE_H
// Project includes
#include "translation_manager_editor.h"
// Qt includes // Qt includes
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QFile> #include <QtCore/QFile>
@ -32,23 +35,23 @@
#include <QtGui/QErrorMessage> #include <QtGui/QErrorMessage>
#include <QKeyEvent> #include <QKeyEvent>
// Project includes namespace TranslationManager
#include "translation_manager_editor.h" {
namespace TranslationManager {
class CTextEdit : public QTextEdit class CTextEdit : public QTextEdit
{ {
Q_OBJECT Q_OBJECT
private: private:
QUndoStack* m_undoStack; QUndoStack *m_undoStack;
public: public:
CTextEdit(QWidget* parent = 0) : QTextEdit(parent) CTextEdit(QWidget *parent = 0) : QTextEdit(parent)
{ {
setUndoRedoEnabled(true); setUndoRedoEnabled(true);
} }
//void keyPressEvent(QKeyEvent *event); //void keyPressEvent(QKeyEvent *event);
void setUndoStack(QUndoStack* undoStack) void setUndoStack(QUndoStack *undoStack)
{ {
m_undoStack = undoStack; m_undoStack = undoStack;
} }
@ -57,20 +60,22 @@ public:
class CEditorPhrase : public CEditor class CEditorPhrase : public CEditor
{ {
Q_OBJECT Q_OBJECT
public: public:
CTextEdit *text_edit; CEditorPhrase(QMdiArea *parent) : CEditor(parent) {}
public: CEditorPhrase() : CEditor() {}
CEditorPhrase(QMdiArea* parent) : CEditor(parent) {} void open(QString filename);
CEditorPhrase() : CEditor() {} void save();
void open(QString filename); void saveAs(QString filename);
void save(); void activateWindow();
void saveAs(QString filename);
void activateWindow();
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
public Q_SLOTS: public Q_SLOTS:
void docContentsChanged(); void docContentsChanged();
void newUndoCommandAdded(); void newUndoCommandAdded();
private:
CTextEdit *text_edit;
}; };
class CUndoPhraseNewCommand : public QUndoCommand class CUndoPhraseNewCommand : public QUndoCommand
@ -79,7 +84,7 @@ public:
CUndoPhraseNewCommand(CTextEdit *textEdit, QUndoCommand *parent = 0) CUndoPhraseNewCommand(CTextEdit *textEdit, QUndoCommand *parent = 0)
: QUndoCommand("Inserting/Removing characters", parent), : QUndoCommand("Inserting/Removing characters", parent),
m_textEdit(textEdit) m_textEdit(textEdit)
{ } {}
~CUndoPhraseNewCommand() {} ~CUndoPhraseNewCommand() {}
@ -92,8 +97,9 @@ public:
{ {
m_textEdit->redo(); m_textEdit->redo();
} }
private: private:
CTextEdit* m_textEdit; CTextEdit *m_textEdit;
}; };
class SyntaxHighlighter : public QSyntaxHighlighter class SyntaxHighlighter : public QSyntaxHighlighter
@ -101,87 +107,92 @@ class SyntaxHighlighter : public QSyntaxHighlighter
public: public:
SyntaxHighlighter(QTextEdit *parent) : QSyntaxHighlighter(parent) SyntaxHighlighter(QTextEdit *parent) : QSyntaxHighlighter(parent)
{ {
HighlightingRule rule; HighlightingRule rule;
translateStringFormat.setFontWeight(QFont::Bold); translateStringFormat.setFontWeight(QFont::Bold);
translateStringFormat.setForeground(Qt::darkMagenta); translateStringFormat.setForeground(Qt::darkMagenta);
rule.pattern = QRegExp("\\[.+\\]"); rule.pattern = QRegExp("\\[.+\\]");
rule.format = translateStringFormat; rule.format = translateStringFormat;
highlightingRules.append(rule); highlightingRules.append(rule);
singleLineCommentFormat.setForeground(Qt::red);
rule.pattern = QRegExp("//[^\n]*");
rule.format = singleLineCommentFormat;
highlightingRules.append(rule);
singleLineCommentFormat.setForeground(Qt::red); multiLineCommentFormat.setForeground(Qt::red);
rule.pattern = QRegExp("//[^\n]*");
rule.format = singleLineCommentFormat;
highlightingRules.append(rule);
multiLineCommentFormat.setForeground(Qt::red); quotationFormat.setForeground(Qt::darkGreen);
rule.pattern = QRegExp("\".*\"");
rule.format = quotationFormat;
highlightingRules.append(rule);
quotationFormat.setForeground(Qt::darkGreen); functionFormat.setFontItalic(true);
rule.pattern = QRegExp("\".*\""); functionFormat.setForeground(Qt::blue);
rule.format = quotationFormat; rule.pattern = QRegExp("\\(.+\\)");
highlightingRules.append(rule); rule.format = functionFormat;
highlightingRules.append(rule);
functionFormat.setFontItalic(true); commentStartExpression = QRegExp("/\\*");
functionFormat.setForeground(Qt::blue); commentEndExpression = QRegExp("\\*/");
rule.pattern = QRegExp("\\(.+\\)");
rule.format = functionFormat;
highlightingRules.append(rule);
commentStartExpression = QRegExp("/\\*");
commentEndExpression = QRegExp("\\*/");
} }
void highlightBlock(const QString &text) void highlightBlock(const QString &text)
{ {
Q_FOREACH(const HighlightingRule &rule, highlightingRules) { Q_FOREACH(const HighlightingRule &rule, highlightingRules)
QRegExp expression(rule.pattern); {
int index = expression.indexIn(text); QRegExp expression(rule.pattern);
while (index >= 0) { int index = expression.indexIn(text);
int length = expression.matchedLength(); while (index >= 0)
setFormat(index, length, rule.format); {
index = expression.indexIn(text, index + length); int length = expression.matchedLength();
} setFormat(index, length, rule.format);
} index = expression.indexIn(text, index + length);
setCurrentBlockState(0); }
}
setCurrentBlockState(0);
int startIndex = 0; int startIndex = 0;
if (previousBlockState() != 1) if (previousBlockState() != 1)
startIndex = commentStartExpression.indexIn(text); startIndex = commentStartExpression.indexIn(text);
while (startIndex >= 0) { while (startIndex >= 0)
int endIndex = commentEndExpression.indexIn(text, startIndex); {
int commentLength; int endIndex = commentEndExpression.indexIn(text, startIndex);
if (endIndex == -1) { int commentLength;
setCurrentBlockState(1); if (endIndex == -1)
commentLength = text.length() - startIndex; {
} else { setCurrentBlockState(1);
commentLength = endIndex - startIndex commentLength = text.length() - startIndex;
+ commentEndExpression.matchedLength(); }
} else
setFormat(startIndex, commentLength, multiLineCommentFormat); {
startIndex = commentStartExpression.indexIn(text, startIndex + commentLength); commentLength = endIndex - startIndex
} + commentEndExpression.matchedLength();
} }
setFormat(startIndex, commentLength, multiLineCommentFormat);
startIndex = commentStartExpression.indexIn(text, startIndex + commentLength);
}
}
private: private:
struct HighlightingRule struct HighlightingRule
{ {
QRegExp pattern; QRegExp pattern;
QTextCharFormat format; QTextCharFormat format;
}; };
QVector<HighlightingRule> highlightingRules; QVector<HighlightingRule> highlightingRules;
QRegExp commentStartExpression; QRegExp commentStartExpression;
QRegExp commentEndExpression; QRegExp commentEndExpression;
QTextCharFormat keywordFormat; QTextCharFormat keywordFormat;
QTextCharFormat classFormat; QTextCharFormat classFormat;
QTextCharFormat singleLineCommentFormat; QTextCharFormat singleLineCommentFormat;
QTextCharFormat multiLineCommentFormat; QTextCharFormat multiLineCommentFormat;
QTextCharFormat quotationFormat; QTextCharFormat quotationFormat;
QTextCharFormat functionFormat; QTextCharFormat functionFormat;
QTextCharFormat translateStringFormat; QTextCharFormat translateStringFormat;
}; };
} }

View file

@ -15,6 +15,11 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "editor_worksheet.h"
#include "extract_bot_names.h"
#include "translation_manager_constants.h"
// Qt includes // Qt includes
#include <QtGui/QErrorMessage> #include <QtGui/QErrorMessage>
#include <QtGui/QTableWidgetItem> #include <QtGui/QTableWidgetItem>
@ -24,97 +29,103 @@
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtGui/QMenu> #include <QtGui/QMenu>
// Project includes
#include "editor_worksheet.h"
#include "extract_bot_names.h"
#include "translation_manager_constants.h"
#include <set>
using namespace std; using namespace std;
namespace TranslationManager { namespace TranslationManager
{
void CEditorWorksheet::open(QString filename) void CEditorWorksheet::open(QString filename)
{ {
STRING_MANAGER::TWorksheet wk_file; STRING_MANAGER::TWorksheet wk_file;
if(loadExcelSheet(filename.toStdString(), wk_file, true) == true) if(loadExcelSheet(filename.toStdString(), wk_file, true) == true)
{ {
bool hasHashValue = false; bool hasHashValue = false;
table_editor = new QTableWidget(); table_editor = new QTableWidget();
if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE")) if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
{ {
table_editor->setColumnCount(wk_file.ColCount - 1); table_editor->setColumnCount(wk_file.ColCount - 1);
hasHashValue = true; hasHashValue = true;
} else { }
table_editor->setColumnCount(wk_file.ColCount); else
} {
table_editor->setRowCount(wk_file.size() - 1); table_editor->setColumnCount(wk_file.ColCount);
}
table_editor->setRowCount(wk_file.size() - 1);
// read columns name // read columns name
for(unsigned int i = 0; i < wk_file.ColCount; i++) for(uint i = 0; i < wk_file.ColCount; i++)
{ {
if(hasHashValue && i == 0) if(hasHashValue && i == 0)
{ {
// we don't show the column with hash value // we don't show the column with hash value
} else { }
QTableWidgetItem *col = new QTableWidgetItem(); else
ucstring col_name = wk_file.getData(0, i); {
col->setText(QString(col_name.toString().c_str())); QTableWidgetItem *col = new QTableWidgetItem();
if(hasHashValue) ucstring col_name = wk_file.getData(0, i);
{ col->setText(QString(col_name.toString().c_str()));
table_editor->setHorizontalHeaderItem(i - 1, col); if(hasHashValue)
} else { {
table_editor->setHorizontalHeaderItem(i, col); table_editor->setHorizontalHeaderItem(i - 1, col);
} }
} else
} {
table_editor->setHorizontalHeaderItem(i, col);
// read rows }
for(unsigned int i = 1; i < wk_file.size(); i++) }
{ }
for(unsigned int j = 0; j < wk_file.ColCount; j++)
{
if(hasHashValue && j == 0)
{
// we don't show the column with hash value
} else {
QTableWidgetItem *row = new QTableWidgetItem();
ucstring row_value = wk_file.getData(i, j);
row->setText(QString::fromUtf8(row_value.toUtf8().c_str()));
if(hasHashValue)
{
table_editor->setItem(i - 1, j - 1, row);
} else {
table_editor->setItem(i - 1, j, row);
}
}
}
}
setCurrentFile(filename);
setAttribute(Qt::WA_DeleteOnClose);
setWidget(table_editor);
editor_type = Constants::ED_SHEET;
table_editor->resizeColumnsToContents();
table_editor->resizeRowsToContents();
// set editor signals
connect(table_editor, SIGNAL(itemChanged(QTableWidgetItem*) ), this, SLOT(worksheetEditorChanged(QTableWidgetItem*)));
connect(table_editor, SIGNAL(itemDoubleClicked(QTableWidgetItem*) ), this, SLOT(worksheetEditorCellEntered(QTableWidgetItem*)));
connect (table_editor,SIGNAL(customContextMenuRequested(const QPoint &)), this,SLOT(contextMenuEvent(QContextMenuEvent*)));
} else {
QErrorMessage error;
error.showMessage("This file is not a worksheet file.");
error.exec();
}
// read rows
for(unsigned int i = 1; i < wk_file.size(); i++)
{
for(unsigned int j = 0; j < wk_file.ColCount; j++)
{
if(hasHashValue && j == 0)
{
// we don't show the column with hash value
}
else
{
QTableWidgetItem *row = new QTableWidgetItem();
ucstring row_value = wk_file.getData(i, j);
row->setText(QString::fromUtf8(row_value.toUtf8().c_str()));
if(hasHashValue)
{
table_editor->setItem(i - 1, j - 1, row);
}
else
{
table_editor->setItem(i - 1, j, row);
}
}
}
}
setCurrentFile(filename);
setAttribute(Qt::WA_DeleteOnClose);
setWidget(table_editor);
editor_type = Constants::ED_SHEET;
table_editor->resizeColumnsToContents();
table_editor->resizeRowsToContents();
// set editor signals
connect(table_editor, SIGNAL(itemChanged(QTableWidgetItem *) ), this, SLOT(worksheetEditorChanged(QTableWidgetItem *)));
connect(table_editor, SIGNAL(itemDoubleClicked(QTableWidgetItem *) ), this, SLOT(worksheetEditorCellEntered(QTableWidgetItem *)));
connect(table_editor,SIGNAL(customContextMenuRequested(const QPoint &)), this,SLOT(contextMenuEvent(QContextMenuEvent *)));
}
else
{
QErrorMessage error;
error.showMessage(tr("This file is not a worksheet file."));
error.exec();
}
} }
void CEditorWorksheet::contextMenuEvent(QContextMenuEvent *e) void CEditorWorksheet::contextMenuEvent(QContextMenuEvent *e)
{ {
QAction *insertRowAct = new QAction("Insert new row", this); QAction *insertRowAct = new QAction(tr("Insert new row"), this);
connect(insertRowAct, SIGNAL(triggered()), this, SLOT(insertRow())); connect(insertRowAct, SIGNAL(triggered()), this, SLOT(insertRow()));
QAction *deleteRowAct = new QAction("Delete row", this); QAction *deleteRowAct = new QAction(tr("Delete row"), this);
connect(deleteRowAct, SIGNAL(triggered()), this, SLOT(deleteRow())); connect(deleteRowAct, SIGNAL(triggered()), this, SLOT(deleteRow()));
QMenu *contextMenu = new QMenu(this); QMenu *contextMenu = new QMenu(this);
contextMenu->addAction(insertRowAct); contextMenu->addAction(insertRowAct);
@ -127,7 +138,7 @@ void CEditorWorksheet::contextMenuEvent(QContextMenuEvent *e)
void CEditorWorksheet::activateWindow() void CEditorWorksheet::activateWindow()
{ {
showMaximized(); showMaximized();
} }
void CEditorWorksheet::save() void CEditorWorksheet::save()
@ -137,170 +148,171 @@ void CEditorWorksheet::save()
void CEditorWorksheet::saveAs(QString filename) void CEditorWorksheet::saveAs(QString filename)
{ {
STRING_MANAGER::TWorksheet new_file, wk_file; STRING_MANAGER::TWorksheet new_file, wk_file;
loadExcelSheet(current_file.toStdString(), wk_file, true); loadExcelSheet(current_file.toStdString(), wk_file, true);
// set columns // set columns
new_file.resize(new_file.size() + 1); new_file.resize(new_file.size() + 1);
for(unsigned int i = 0; i < wk_file.ColCount; i++) for(unsigned int i = 0; i < wk_file.ColCount; i++)
{ {
ucstring col_name = wk_file.getData(0, i); ucstring col_name = wk_file.getData(0, i);
new_file.insertColumn(new_file.ColCount); new_file.insertColumn(new_file.ColCount);
new_file.setData(0, new_file.ColCount - 1, col_name); new_file.setData(0, new_file.ColCount - 1, col_name);
} }
// read all the rows from table // read all the rows from table
uint rowIdx; uint rowIdx;
uint colIdx = 0; uint colIdx = 0;
bool hasHashValue = false; bool hasHashValue = false;
if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE")) if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
{ {
hasHashValue = true; hasHashValue = true;
colIdx = 1; colIdx = 1;
} }
for(int i = 0; i < table_editor->rowCount(); i++) for(int i = 0; i < table_editor->rowCount(); i++)
{ {
rowIdx = new_file.size(); rowIdx = new_file.size();
new_file.resize(new_file.size() + 1); new_file.resize(new_file.size() + 1);
ucstring tvalue; ucstring tvalue;
for(int j = 0; j < table_editor->columnCount(); j++) for(int j = 0; j < table_editor->columnCount(); j++)
{ {
QTableWidgetItem* item = table_editor->item(i, j); QTableWidgetItem *item = table_editor->item(i, j);
tvalue.fromUtf8(std::string(item->text().toUtf8())); tvalue.fromUtf8(std::string(item->text().toUtf8()));
new_file.setData(rowIdx, j + colIdx, tvalue); new_file.setData(rowIdx, j + colIdx, tvalue);
} }
} }
if(hasHashValue) if(hasHashValue)
{ {
// rewrite the hash codes // rewrite the hash codes
makeHashCode(wk_file, true); makeHashCode(wk_file, true);
} }
ucstring s = prepareExcelSheet(new_file); ucstring s = prepareExcelSheet(new_file);
NLMISC::CI18N::writeTextFile(filename.toStdString(), s, false); NLMISC::CI18N::writeTextFile(filename.toStdString(), s, false);
current_file = filename; current_file = filename;
setCurrentFile(filename); setCurrentFile(filename);
} }
void CEditorWorksheet::insertRow() void CEditorWorksheet::insertRow()
{ {
int last_row = table_editor->rowCount(); int last_row = table_editor->rowCount();
current_stack->push(new CUndoWorksheetNewCommand(table_editor, last_row)); current_stack->push(new CUndoWorksheetNewCommand(table_editor, last_row));
} }
void CEditorWorksheet::deleteRow() void CEditorWorksheet::deleteRow()
{ {
int selected_row = table_editor->currentRow(); int selected_row = table_editor->currentRow();
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("The row will be deleted.")); msgBox.setIcon(QMessageBox::Question);
msgBox.setInformativeText(tr("Do you want to delete the selected row ?")); msgBox.setText(tr("The row will be deleted."));
msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes); msgBox.setInformativeText(tr("Do you want to delete the selected row ?"));
msgBox.setDefaultButton(QMessageBox::No); msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
int ret = msgBox.exec(); msgBox.setDefaultButton(QMessageBox::No);
if(ret == QMessageBox::Yes)
{
current_stack->push(new CUndoWorksheetDeleteCommand(table_editor, selected_row));
}
table_editor->clearFocus(); int ret = msgBox.exec();
table_editor->clearSelection(); if(ret == QMessageBox::Yes)
return; {
current_stack->push(new CUndoWorksheetDeleteCommand(table_editor, selected_row));
}
table_editor->clearFocus();
table_editor->clearSelection();
return;
} }
void CEditorWorksheet::worksheetEditorCellEntered(QTableWidgetItem * item) void CEditorWorksheet::worksheetEditorCellEntered(QTableWidgetItem *item)
{ {
temp_content = item->text(); temp_content = item->text();
current_stack->push(new CUndoWorksheetCommand(table_editor, item, temp_content)); current_stack->push(new CUndoWorksheetCommand(table_editor, item, temp_content));
} }
void CEditorWorksheet::worksheetEditorChanged(QTableWidgetItem * item) void CEditorWorksheet::worksheetEditorChanged(QTableWidgetItem *item)
{ {
if(temp_content != item->text()) if(temp_content != item->text())
{ {
//current_stack->push(new CUndoWorksheetCommand(table_editor, item, temp_content)); //current_stack->push(new CUndoWorksheetCommand(table_editor, item, temp_content));
} }
if(!isWindowModified()) if(!isWindowModified())
setWindowModified(true); setWindowModified(true);
} }
void CEditorWorksheet::extractBotNames(list<string> filters, string level_design_path, NLLIGO::CLigoConfig ligoConfig) void CEditorWorksheet::extractBotNames(list<string> filters, string level_design_path, NLLIGO::CLigoConfig ligoConfig)
{ {
bool modified = false; bool modified = false;
QList<CTableWidgetItemStore> new_items; QList<CTableWidgetItemStore> new_items;
ExtractBotNames ebn; ExtractBotNames ebn;
ebn.setRequiredSettings(filters, level_design_path); ebn.setRequiredSettings(filters, level_design_path);
ebn.extractBotNamesFromPrimitives(ligoConfig); ebn.extractBotNamesFromPrimitives(ligoConfig);
// get SimpleNames // get SimpleNames
{ {
map<string, TEntryInfo> SimpleNames = ebn.getSimpleNames(); map<string, TEntryInfo> SimpleNames = ebn.getSimpleNames();
map<string, TEntryInfo>::iterator it(SimpleNames.begin()), last(SimpleNames.end()); map<string, TEntryInfo>::iterator it(SimpleNames.begin()), last(SimpleNames.end());
for (; it != last; ++it) for (; it != last; ++it)
{ {
QList<QTableWidgetItem*> search_results = table_editor->findItems(QString(it->first.c_str()), Qt::MatchExactly); QList<QTableWidgetItem *> search_results = table_editor->findItems(QString(it->first.c_str()), Qt::MatchExactly);
if(search_results.size() == 0) if(search_results.size() == 0)
{ {
QList<QString> records; QList<QString> records;
records.push_back(QString(it->first.c_str())); records.push_back(QString(it->first.c_str()));
records.push_back(QString(it->first.c_str())); records.push_back(QString(it->first.c_str()));
records.push_back(QString(it->second.SheetName.c_str())); records.push_back(QString(it->second.SheetName.c_str()));
insertTableRecords(records, new_items); insertTableRecords(records, new_items);
if(!modified) modified = true; if(!modified) modified = true;
} }
} }
ebn.cleanSimpleNames(); ebn.cleanSimpleNames();
} }
// get GenericNames // get GenericNames
{ {
set<string> GenericNames = ebn.getGenericNames(); set<string> GenericNames = ebn.getGenericNames();
set<string>::iterator it(GenericNames.begin()), last(GenericNames.end()); set<string>::iterator it(GenericNames.begin()), last(GenericNames.end());
for (; it != last; ++it) for (; it != last; ++it)
{ {
string gnName = "gn_" + ebn.cleanupName(*it); string gnName = "gn_" + ebn.cleanupName(*it);
QList<QTableWidgetItem*> search_results = table_editor->findItems(QString((*it).c_str()), Qt::MatchExactly); QList<QTableWidgetItem *> search_results = table_editor->findItems(QString((*it).c_str()), Qt::MatchExactly);
if(search_results.size() == 0) if(search_results.size() == 0)
{ {
QList<QString> records; QList<QString> records;
records.push_back(QString((*it).c_str())); records.push_back(QString((*it).c_str()));
records.push_back(QString(gnName.c_str())); records.push_back(QString(gnName.c_str()));
records.push_back(" "); records.push_back(" ");
insertTableRecords(records, new_items); insertTableRecords(records, new_items);
if(!modified) modified = true; if(!modified) modified = true;
} }
} }
ebn.cleanGenericNames(); ebn.cleanGenericNames();
} }
current_stack->push(new CUndoWorksheetExtraction(new_items, table_editor)); current_stack->push(new CUndoWorksheetExtraction(new_items, table_editor));
if(modified) if(modified)
{ {
setWindowModified(true); setWindowModified(true);
table_editor->scrollToBottom(); table_editor->scrollToBottom();
} }
} }
void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordListBuilder& wordListBuilder) void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordListBuilder &wordListBuilder)
{ {
uint i; uint i;
// **** Load the excel sheet // **** Load the excel sheet
// load // load
TWorksheet workSheet; STRING_MANAGER::TWorksheet workSheet;
if(!loadExcelSheet(filename.toStdString(), workSheet, true)) if(!loadExcelSheet(filename.toStdString(), workSheet, true))
{ {
nlwarning("Error reading '%s'. Aborted", filename.toStdString().c_str()); nlwarning("Error reading '%s'. Aborted", filename.toStdString().c_str());
return; return;
} }
// get the key column index // get the key column index
uint keyColIndex = 0; uint keyColIndex = 0;
if(!workSheet.findCol(columnId.toStdString(), keyColIndex)) if(!workSheet.findCol(columnId.toStdString(), keyColIndex))
{ {
nlwarning("Error: Don't find the column '%s'. '%s' Aborted", columnId.toStdString().c_str(), filename.toStdString().c_str()); nlwarning("Error: Don't find the column '%s'. '%s' Aborted", columnId.toStdString().c_str(), filename.toStdString().c_str());
return; return;
} }
// get the name column index // get the name column index
uint nameColIndex; uint nameColIndex;
if(!workSheet.findCol(ucstring("name"), nameColIndex)) if(!workSheet.findCol(ucstring("name"), nameColIndex))
{ {
nlwarning("Error: Don't find the column 'name'. '%s' Aborted", filename.toStdString().c_str()); nlwarning("Error: Don't find the column 'name'. '%s' Aborted", filename.toStdString().c_str());
@ -308,42 +320,44 @@ void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordLis
} }
// **** List all words with the builder given // **** List all words with the builder given
std::vector<string> allWords; std::vector<std::string> allWords;
if(!wordListBuilder.buildWordList(allWords, filename.toStdString())) if(!wordListBuilder.buildWordList(allWords, filename.toStdString()))
{ {
return; return;
} }
bool modified = false; bool modified = false;
QList<CTableWidgetItemStore> new_items; QList<CTableWidgetItemStore> new_items;
for(i = 0; i < allWords.size(); i++) for(i = 0; i < allWords.size(); i++)
{ {
string keyName = allWords[i]; string keyName = allWords[i];
QList<QTableWidgetItem*> search_results = table_editor->findItems(QString(keyName.c_str()), Qt::MatchExactly); QList<QTableWidgetItem *> search_results = table_editor->findItems(QString(keyName.c_str()), Qt::MatchExactly);
if(search_results.size() == 0) if(search_results.size() == 0)
{ {
int knPos = 0, nPos = 0; int knPos = 0, nPos = 0;
if(workSheet.getData(0, 0) == ucstring("*HASH_VALUE")) if(workSheet.getData(0, 0) == ucstring("*HASH_VALUE"))
{ {
knPos = keyColIndex - 1; knPos = keyColIndex - 1;
nPos = nameColIndex - 1; nPos = nameColIndex - 1;
} else { }
knPos = keyColIndex; else
nPos = nameColIndex; {
} knPos = keyColIndex;
nPos = nameColIndex;
}
QList<QString> records; QList<QString> records;
records.push_back(QString(keyName.c_str())); records.push_back(QString(keyName.c_str()));
records.push_back(QString("<GEN>") + QString(keyName.c_str())); records.push_back(QString("<GEN>") + QString(keyName.c_str()));
insertTableRecords(records, new_items); insertTableRecords(records, new_items);
if(!modified) modified = true; if(!modified) modified = true;
} }
} }
current_stack->push(new CUndoWorksheetExtraction(new_items, table_editor)); current_stack->push(new CUndoWorksheetExtraction(new_items, table_editor));
if(modified) if(modified)
{ {
setWindowModified(true); setWindowModified(true);
table_editor->scrollToBottom(); table_editor->scrollToBottom();
} }
} }
void CEditorWorksheet::insertTableRecords(QList<QString> records, QList<CTableWidgetItemStore> new_items) void CEditorWorksheet::insertTableRecords(QList<QString> records, QList<CTableWidgetItemStore> new_items)
@ -360,149 +374,151 @@ void CEditorWorksheet::insertTableRecords(QList<QString> records, QList<CTableWi
new_items.push_back(rec_s); new_items.push_back(rec_s);
n++; n++;
} }
} }
bool CEditorWorksheet::compareWorksheetFile(QString filename) bool CEditorWorksheet::compareWorksheetFile(QString filename)
{ {
STRING_MANAGER::TWorksheet wk_file; STRING_MANAGER::TWorksheet wk_file;
int colIndex = 0; int colIndex = 0;
if(loadExcelSheet(filename.toStdString(), wk_file, true) == true) if(loadExcelSheet(filename.toStdString(), wk_file, true) == true)
{ {
if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE")) if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
{ {
colIndex = 1; colIndex = 1;
} }
if(wk_file.ColCount - colIndex != table_editor->columnCount()) if(wk_file.ColCount - colIndex != table_editor->columnCount())
{ {
return false; return false;
} }
for(int i = 0; i < table_editor->columnCount(); i++) for(int i = 0; i < table_editor->columnCount(); i++)
{ {
QString item = table_editor->horizontalHeaderItem(i)->text(); QString item = table_editor->horizontalHeaderItem(i)->text();
ucstring itemC = wk_file.getData(0, i+ colIndex); ucstring itemC = wk_file.getData(0, i+ colIndex);
if(item.toStdString() != itemC.toString()) if(item.toStdString() != itemC.toString())
{ {
nlwarning(item.toStdString().c_str()); nlwarning(item.toStdString().c_str());
nlwarning(itemC.toString().c_str()); nlwarning(itemC.toString().c_str());
return false; return false;
} }
} }
} else { }
return false; else
} {
return false;
return true; }
return true;
} }
void CEditorWorksheet::mergeWorksheetFile(QString filename) void CEditorWorksheet::mergeWorksheetFile(QString filename)
{ {
STRING_MANAGER::TWorksheet wk_file; STRING_MANAGER::TWorksheet wk_file;
if(loadExcelSheet(filename.toStdString(), wk_file, true) == true) if(loadExcelSheet(filename.toStdString(), wk_file, true) == true)
{ {
bool hasHashValue = false; bool hasHashValue = false;
int colIndex = 0; int colIndex = 0;
if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE")) if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
{ {
hasHashValue = true; hasHashValue = true;
colIndex = 1; colIndex = 1;
} }
// read rows // read rows
for(unsigned int i = 1; i < wk_file.size(); i++) for(unsigned int i = 1; i < wk_file.size(); i++)
{ {
// search with the first column // search with the first column
ucstring rowId = wk_file.getData(i,colIndex); ucstring rowId = wk_file.getData(i,colIndex);
QList<QTableWidgetItem*> search_results = table_editor->findItems(QString(rowId.toString().c_str()), Qt::MatchExactly); QList<QTableWidgetItem *> search_results = table_editor->findItems(QString(rowId.toString().c_str()), Qt::MatchExactly);
if(search_results.size() == 0) if(search_results.size() == 0)
{ {
const int lastRow = table_editor->rowCount(); const int lastRow = table_editor->rowCount();
table_editor->setRowCount(lastRow + 1); table_editor->setRowCount(lastRow + 1);
for(unsigned int j = 0; j < table_editor->columnCount(); j++) for(int j = 0; j < table_editor->columnCount(); j++)
{ {
ucstring rowValue = wk_file.getData(i, j + colIndex); // get the value ucstring rowValue = wk_file.getData(i, j + colIndex); // get the value
QTableWidgetItem *row = new QTableWidgetItem(); QTableWidgetItem *row = new QTableWidgetItem();
row->setText(QString(rowValue.toString().c_str())); // set the value in table item row->setText(QString(rowValue.toString().c_str())); // set the value in table item
table_editor->setItem(lastRow, j, row); table_editor->setItem(lastRow, j, row);
} }
} }
} }
} else { }
QErrorMessage error; else
error.showMessage(tr("This file is not a worksheet file.")); {
error.exec(); QErrorMessage error;
} error.showMessage(tr("This file is not a worksheet file."));
error.exec();
}
} }
void CEditorWorksheet::closeEvent(QCloseEvent *event) void CEditorWorksheet::closeEvent(QCloseEvent *event)
{ {
if(isWindowModified()) if(isWindowModified())
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("The document has been modified.")); msgBox.setIcon(QMessageBox::Question);
msgBox.setInformativeText(tr("Do you want to save your changes?")); msgBox.setText(tr("The document has been modified."));
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); msgBox.setInformativeText(tr("Do you want to save your changes?"));
msgBox.setDefaultButton(QMessageBox::Save); msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
int ret = msgBox.exec(); msgBox.setDefaultButton(QMessageBox::Save);
switch (ret) int ret = msgBox.exec();
{ switch (ret)
case QMessageBox::Save: {
save(); case QMessageBox::Save:
event->accept(); save();
close(); break;
break; case QMessageBox::Discard:
case QMessageBox::Discard: break;
event->accept(); case QMessageBox::Cancel:
close(); event->ignore();
break; return;
case QMessageBox::Cancel: }
event->ignore(); }
break; event->accept();
default: close();
break;
}
} else {
event->accept();
close();
}
} }
bool CEditorWorksheet::isBotNamesTable() bool CEditorWorksheet::isBotNamesTable()
{ {
bool status = true; bool status = true;
if(table_editor->horizontalHeaderItem(0)->text() != "bot name" if(table_editor->horizontalHeaderItem(0)->text() != "bot name"
|| table_editor->horizontalHeaderItem(1)->text() != "translated name" || table_editor->horizontalHeaderItem(1)->text() != "translated name"
|| table_editor->horizontalHeaderItem(2)->text() != "sheet_name") || table_editor->horizontalHeaderItem(2)->text() != "sheet_name")
{ {
status = false; status = false;
} }
return status;
return status;
} }
bool CEditorWorksheet::isSheetTable(QString type) bool CEditorWorksheet::isSheetTable(QString type)
{ {
QString column_name; QString column_name;
if(type.toAscii() == Constants::WK_ITEM) if(type.toAscii() == Constants::WK_ITEM)
{ {
column_name = "item ID"; column_name = "item ID";
} else if(type.toAscii() == Constants::WK_CREATURE) { }
column_name = "creature ID"; else if(type.toAscii() == Constants::WK_CREATURE)
} else if(type.toAscii() == Constants::WK_SBRICK) { {
column_name = "sbrick ID"; column_name = "creature ID";
} else if(type.toAscii() == Constants::WK_SPHRASE) { }
column_name = "sphrase ID"; else if(type.toAscii() == Constants::WK_SBRICK)
} else if(type.toAscii() == Constants::WK_PLACE) { {
column_name = "placeId"; column_name = "sbrick ID";
} }
bool status = true; else if(type.toAscii() == Constants::WK_SPHRASE)
if(table_editor->horizontalHeaderItem(0)->text() != column_name {
|| table_editor->horizontalHeaderItem(1)->text() != "name") column_name = "sphrase ID";
{ }
status = false; else if(type.toAscii() == Constants::WK_PLACE)
} {
column_name = "placeId";
return status; }
bool status = true;
if(table_editor->horizontalHeaderItem(0)->text() != column_name
|| table_editor->horizontalHeaderItem(1)->text() != "name")
{
status = false;
}
return status;
} }
} }

View file

@ -18,6 +18,10 @@
#ifndef EDITOR_WORKSHEET_H #ifndef EDITOR_WORKSHEET_H
#define EDITOR_WORKSHEET_H #define EDITOR_WORKSHEET_H
// Project includes
#include "translation_manager_editor.h"
#include "extract_new_sheet_names.h"
// Nel includes // Nel includes
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/sheet_id.h" #include "nel/misc/sheet_id.h"
@ -34,11 +38,9 @@
#include <QtGui/QUndoCommand> #include <QtGui/QUndoCommand>
#include <QtGui/QUndoStack> #include <QtGui/QUndoStack>
// Project includes
#include "translation_manager_editor.h"
#include "extract_new_sheet_names.h"
namespace TranslationManager { namespace TranslationManager
{
struct CTableWidgetItemStore struct CTableWidgetItemStore
{ {
@ -47,6 +49,7 @@ public:
m_item(item), m_item(item),
m_row(row), m_row(row),
m_column(column) { } m_column(column) { }
QTableWidgetItem *m_item; QTableWidgetItem *m_item;
int m_row; int m_row;
int m_column; int m_column;
@ -54,38 +57,40 @@ public:
class CEditorWorksheet : public CEditor class CEditorWorksheet : public CEditor
{ {
Q_OBJECT Q_OBJECT
private:
QString temp_content;
public: public:
CEditorWorksheet(QMdiArea* parent) : CEditor(parent) {} CEditorWorksheet(QMdiArea *parent) : CEditor(parent) {}
CEditorWorksheet() : CEditor() {} CEditorWorksheet() : CEditor() {}
QTableWidget* table_editor; QTableWidget *table_editor;
void open(QString filename); void open(QString filename);
void save(); void save();
void saveAs(QString filename); void saveAs(QString filename);
void activateWindow(); void activateWindow();
void mergeWorksheetFile(QString filename); void mergeWorksheetFile(QString filename);
bool compareWorksheetFile(QString filename); bool compareWorksheetFile(QString filename);
void extractBotNames(list<string> filters, string level_design_path, NLLIGO::CLigoConfig ligoConfig); void extractBotNames(std::list<std::string> filters, std::string level_design_path, NLLIGO::CLigoConfig ligoConfig);
void extractWords(QString filename, QString columnId, IWordListBuilder &wordListBuilder); void extractWords(QString filename, QString columnId, IWordListBuilder &wordListBuilder);
void insertTableRecords(QList<QString> records, QList<CTableWidgetItemStore> new_items); void insertTableRecords(QList<QString> records, QList<CTableWidgetItemStore> new_items);
bool isBotNamesTable(); bool isBotNamesTable();
bool isSheetTable(QString type); bool isSheetTable(QString type);
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
private Q_SLOTS: private Q_SLOTS:
void worksheetEditorCellEntered(QTableWidgetItem * item); void worksheetEditorCellEntered(QTableWidgetItem *item);
void worksheetEditorChanged(QTableWidgetItem * item); void worksheetEditorChanged(QTableWidgetItem *item);
void insertRow(); void insertRow();
void deleteRow(); void deleteRow();
void contextMenuEvent(QContextMenuEvent *e); void contextMenuEvent(QContextMenuEvent *e);
private:
QString temp_content;
}; };
class CUndoWorksheetCommand : public QUndoCommand class CUndoWorksheetCommand : public QUndoCommand
{ {
public: public:
CUndoWorksheetCommand(QTableWidget *table, QTableWidgetItem* item, const QString &ocontent, QUndoCommand *parent = 0) : QUndoCommand("Insert characters in cells", parent), m_table(table), m_item(item), m_ocontent(ocontent) CUndoWorksheetCommand(QTableWidget *table, QTableWidgetItem *item, const QString &ocontent, QUndoCommand *parent = 0) : QUndoCommand("Insert characters in cells", parent), m_table(table), m_item(item), m_ocontent(ocontent)
{ {
m_ccontent = m_ocontent; m_ccontent = m_ocontent;
} }
@ -106,8 +111,8 @@ public:
m_item->setText(m_ocontent); m_item->setText(m_ocontent);
} }
private: private:
QTableWidget* m_table; QTableWidget *m_table;
QTableWidgetItem* m_item; QTableWidgetItem *m_item;
QString m_ocontent; QString m_ocontent;
QString m_ccontent; QString m_ccontent;
}; };
@ -123,7 +128,7 @@ public:
m_table->setRowCount(m_rowID + 1); m_table->setRowCount(m_rowID + 1);
for(int j = 0; j < m_table->columnCount(); j++) for(int j = 0; j < m_table->columnCount(); j++)
{ {
QTableWidgetItem* item = new QTableWidgetItem(); QTableWidgetItem *item = new QTableWidgetItem();
m_table->setItem(m_rowID, j, item); m_table->setItem(m_rowID, j, item);
m_table->scrollToBottom(); m_table->scrollToBottom();
} }
@ -133,10 +138,10 @@ public:
{ {
m_table->removeRow(m_rowID); m_table->removeRow(m_rowID);
} }
private:
QTableWidget* m_table;
int m_rowID;
private:
QTableWidget *m_table;
int m_rowID;
}; };
class CUndoWorksheetExtraction : public QUndoCommand class CUndoWorksheetExtraction : public QUndoCommand
@ -153,7 +158,6 @@ public:
{ {
m_table->setItem(is.m_row, is.m_column, is.m_item); m_table->setItem(is.m_row, is.m_column, is.m_item);
} }
} }
void undo() void undo()
@ -163,12 +167,11 @@ public:
m_table->setItem(is.m_row, is.m_column, is.m_item); m_table->setItem(is.m_row, is.m_column, is.m_item);
m_table->takeItem(is.m_row, is.m_column); m_table->takeItem(is.m_row, is.m_column);
} }
} }
private: private:
QList<CTableWidgetItemStore> m_items; QList<CTableWidgetItemStore> m_items;
QTableWidget* m_table; QTableWidget *m_table;
}; };
class CUndoWorksheetDeleteCommand : public QUndoCommand class CUndoWorksheetDeleteCommand : public QUndoCommand
@ -181,8 +184,8 @@ public:
{ {
for(int i = 0; i < m_table->columnCount(); i++) for(int i = 0; i < m_table->columnCount(); i++)
{ {
QTableWidgetItem* item = new QTableWidgetItem(); QTableWidgetItem *item = new QTableWidgetItem();
QTableWidgetItem* table_item = m_table->item(m_rowID, i); QTableWidgetItem *table_item = m_table->item(m_rowID, i);
item->setText(table_item->text()); item->setText(table_item->text());
m_deletedItems.push_back(item); m_deletedItems.push_back(item);
} }
@ -203,8 +206,8 @@ public:
} }
private: private:
QList<QTableWidgetItem*> m_deletedItems; QList<QTableWidgetItem *> m_deletedItems;
QTableWidget* m_table; QTableWidget *m_table;
int m_rowID; int m_rowID;
}; };

View file

@ -17,18 +17,14 @@
#include "extract_bot_names.h" #include "extract_bot_names.h"
static bool RemoveOlds = false; static bool RemoveOlds = false;
namespace TranslationManager namespace TranslationManager
{ {
TCreatureInfo *ExtractBotNames::getCreature(const std::string &sheetName) TCreatureInfo *ExtractBotNames::getCreature(const std::string &sheetName)
{ {
CSheetId id(sheetName+".creature"); NLMISC::CSheetId id(sheetName+".creature");
if (Creatures.find(id) != Creatures.end()) if (Creatures.find(id) != Creatures.end())
return &(Creatures.find(id)->second); return &(Creatures.find(id)->second);
@ -36,18 +32,17 @@ TCreatureInfo *ExtractBotNames::getCreature(const std::string &sheetName)
return NULL; return NULL;
} }
string ExtractBotNames::cleanupName(const std::string &name) std::string ExtractBotNames::cleanupName(const std::string &name)
{ {
string ret; std::string ret;
for (uint i=0; i<name.size(); ++i) for (size_t i = 0; i < name.size(); ++i)
{ {
if (name[i] != ' ') if (name[i] != ' ')
ret += name[i]; ret += name[i];
else else
ret += '_'; ret += '_';
} }
return ret; return ret;
} }
@ -55,14 +50,13 @@ ucstring ExtractBotNames::cleanupUcName(const ucstring &name)
{ {
ucstring ret; ucstring ret;
for (uint i=0; i<name.size(); ++i) for (size_t i = 0; i < name.size(); ++i)
{ {
if (name[i] != ' ') if (name[i] != ' ')
ret += name[i]; ret += name[i];
else else
ret += '_'; ret += '_';
} }
return ret; return ret;
} }
@ -70,76 +64,72 @@ ucstring ExtractBotNames::cleanupUcName(const ucstring &name)
/* /*
Removes first and last '$' Removes first and last '$'
*/ */
ucstring ExtractBotNames::makeGroupName(const ucstring & translationName) ucstring ExtractBotNames::makeGroupName(const ucstring &translationName)
{ {
ucstring ret = translationName; ucstring ret = translationName;
if (ret.size() >= 2) if (ret.size() >= 2)
{ {
if ( *ret.begin() == ucchar('$')) if (*ret.begin() == ucchar('$'))
{ {
ret=ret.substr(1); ret=ret.substr(1);
} }
if ( *ret.rbegin() == ucchar('$')) if (*ret.rbegin() == ucchar('$'))
{ {
ret = ret.substr(0, ret.size()-1); ret = ret.substr(0, ret.size() - 1);
} }
} }
ret = cleanupUcName(ret); ret = cleanupUcName(ret);
return ret; return ret;
} }
std::set<std::string> ExtractBotNames::getGenericNames()
set<string> ExtractBotNames::getGenericNames()
{ {
return GenericNames; return GenericNames;
} }
map<string, TEntryInfo> ExtractBotNames::getSimpleNames() std::map<std::string, TEntryInfo> ExtractBotNames::getSimpleNames()
{ {
return SimpleNames; return SimpleNames;
} }
void ExtractBotNames::cleanSimpleNames() void ExtractBotNames::cleanSimpleNames()
{ {
SimpleNames.clear(); SimpleNames.clear();
} }
void ExtractBotNames::cleanGenericNames() void ExtractBotNames::cleanGenericNames()
{ {
GenericNames.clear(); GenericNames.clear();
} }
string ExtractBotNames::removeAndStoreFunction(const std::string &fullName) std::string ExtractBotNames::removeAndStoreFunction(const std::string &fullName)
{ {
string::size_type pos = fullName.find("$"); std::string::size_type pos = fullName.find("$");
if (pos == string::npos) if (pos == std::string::npos)
{
return fullName; return fullName;
}
else else
{ {
// extract and store the function name // extract and store the function name
string ret; std::string ret;
ret = fullName.substr(0, pos); ret = fullName.substr(0, pos);
string::size_type pos2 = fullName.find("$", pos+1); std::string::size_type pos2 = fullName.find("$", pos+1);
string fct = fullName.substr(pos+1, pos2-(pos+1)); std::string fct = fullName.substr(pos + 1, pos2 - (pos + 1));
ret += fullName.substr(pos2+1); ret += fullName.substr(pos2 + 1);
if (Functions.find(fct) == Functions.end()) if (Functions.find(fct) == Functions.end())
{ {
nldebug("Adding function '%s'", fct.c_str()); nldebug("Adding function '%s'", fct.c_str());
Functions.insert(fct); Functions.insert(fct);
} }
return ret; return ret;
} }
} }
void ExtractBotNames::addGenericName(const std::string &name, const std::string &sheetName) void ExtractBotNames::addGenericName(const std::string &name, const std::string &sheetName)
{ {
TCreatureInfo *c = getCreature(sheetName); TCreatureInfo *c = getCreature(sheetName);
@ -185,75 +175,72 @@ void ExtractBotNames::addSimpleName(const std::string &name, const std::string &
} }
} }
void ExtractBotNames::setRequiredSettings(list<string> filters, string level_design_path) void ExtractBotNames::setRequiredSettings(std::list<std::string> filters, std::string level_design_path)
{ {
for (std::list<string>::iterator it = filters.begin(); it != filters.end(); ++it) for (std::list<std::string>::iterator it = filters.begin(); it != filters.end(); ++it)
{ {
Filters.push_back(*it); Filters.push_back(*it);
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// init the sheets // init the sheets
CSheetId::init(false); NLMISC::CSheetId::init(false);
const string PACKED_SHEETS_NAME = "bin/translation_tools_creature.packed_sheets"; const std::string PACKED_SHEETS_NAME = "bin/translation_tools_creature.packed_sheets";
loadForm("creature", PACKED_SHEETS_NAME, Creatures, false, false); loadForm("creature", PACKED_SHEETS_NAME, Creatures, false, false);
if (Creatures.empty()) if (Creatures.empty())
{ {
loadForm("creature", PACKED_SHEETS_NAME, Creatures, true); loadForm("creature", PACKED_SHEETS_NAME, Creatures, true);
} }
} }
void ExtractBotNames::extractBotNamesFromPrimitives(CLigoConfig ligoConfig) void ExtractBotNames::extractBotNamesFromPrimitives(NLLIGO::CLigoConfig ligoConfig)
{ {
//------------------------------------------------------------------- //-------------------------------------------------------------------
// ok, ready for the real work, // ok, ready for the real work,
// first, read the primitives files and parse the primitives // first, read the primitives files and parse the primitives
vector<string> files; std::vector<std::string> files;
CPath::getFileList("primitive", files); NLMISC::CPath::getFileList("primitive", files);
for (uint i=0; i<files.size(); ++i) for (uint i=0; i<files.size(); ++i)
{ {
string pathName = files[i]; std::string pathName = files[i];
pathName = CPath::lookup(pathName); pathName = NLMISC::CPath::lookup(pathName);
/*
// dnk-88: what is it?
// check filters
uint j = 0;
for (size_t j = 0; j < Filters.size(); ++j)
{
if (pathName.find(Filters[j]) != std::string::npos)
break;
}
if (j != Filters.size())
// skip this file
continue;
*/
nlinfo("Loading file '%s'...", NLMISC::CFile::getFilename(pathName).c_str());
NLLIGO::CPrimitives primDoc;
// check filters NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
uint j=0;
for (j=0; j<Filters.size(); ++j)
{
if (pathName.find(Filters[j]) != string::npos)
break;
}
if (j != Filters.size())
// skip this file
continue;
nlinfo("Loading file '%s'...", CFile::getFilename(pathName).c_str());
CPrimitives primDoc;
CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
loadXmlPrimitiveFile(primDoc, pathName, ligoConfig); loadXmlPrimitiveFile(primDoc, pathName, ligoConfig);
// now parse the file // now parse the file
// look for group template // look for group template
{ {
TPrimitiveClassPredicate pred("group_template_npc"); NLLIGO::TPrimitiveClassPredicate pred("group_template_npc");
TPrimitiveSet result; NLLIGO::TPrimitiveSet result;
CPrimitiveSet<TPrimitiveClassPredicate> ps; NLLIGO::CPrimitiveSet<NLLIGO::TPrimitiveClassPredicate> ps;
ps.buildSet(primDoc.RootNode, pred, result); ps.buildSet(primDoc.RootNode, pred, result);
for (uint i=0; i<result.size(); ++i) for (uint i = 0; i < result.size(); ++i)
{ {
string name; std::string name;
string countStr; std::string countStr;
string sheetStr; std::string sheetStr;
result[i]->getPropertyByName("name", name); result[i]->getPropertyByName("name", name);
result[i]->getPropertyByName("count", countStr); result[i]->getPropertyByName("count", countStr);
result[i]->getPropertyByName("bot_sheet_look", sheetStr); result[i]->getPropertyByName("bot_sheet_look", sheetStr);
@ -276,16 +263,16 @@ void ExtractBotNames::extractBotNamesFromPrimitives(CLigoConfig ligoConfig)
} }
// look for bot template // look for bot template
{ {
TPrimitiveClassPredicate pred("bot_template_npc"); NLLIGO::TPrimitiveClassPredicate pred("bot_template_npc");
TPrimitiveSet result; NLLIGO::TPrimitiveSet result;
CPrimitiveSet<TPrimitiveClassPredicate> ps; NLLIGO::CPrimitiveSet<NLLIGO::TPrimitiveClassPredicate> ps;
ps.buildSet(primDoc.RootNode, pred, result); ps.buildSet(primDoc.RootNode, pred, result);
for (uint i=0; i<result.size(); ++i) for (size_t i = 0; i < result.size(); ++i)
{ {
string name; std::string name;
string sheetStr; std::string sheetStr;
result[i]->getPropertyByName("name", name); result[i]->getPropertyByName("name", name);
result[i]->getPropertyByName("sheet_look", sheetStr); result[i]->getPropertyByName("sheet_look", sheetStr);
@ -307,17 +294,17 @@ void ExtractBotNames::extractBotNamesFromPrimitives(CLigoConfig ligoConfig)
} }
// look for npc_group // look for npc_group
{ {
TPrimitiveClassPredicate pred("npc_group"); NLLIGO::TPrimitiveClassPredicate pred("npc_group");
TPrimitiveSet result; NLLIGO::TPrimitiveSet result;
CPrimitiveSet<TPrimitiveClassPredicate> ps; NLLIGO::CPrimitiveSet<NLLIGO::TPrimitiveClassPredicate> ps;
ps.buildSet(primDoc.RootNode, pred, result); ps.buildSet(primDoc.RootNode, pred, result);
for (uint i=0; i<result.size(); ++i) for (size_t i = 0; i < result.size(); ++i)
{ {
string name; std::string name;
string countStr; std::string countStr;
string sheetStr; std::string sheetStr;
result[i]->getPropertyByName("name", name); result[i]->getPropertyByName("name", name);
result[i]->getPropertyByName("count", countStr); result[i]->getPropertyByName("count", countStr);
result[i]->getPropertyByName("bot_sheet_client", sheetStr); result[i]->getPropertyByName("bot_sheet_client", sheetStr);
@ -344,16 +331,16 @@ void ExtractBotNames::extractBotNamesFromPrimitives(CLigoConfig ligoConfig)
} }
// look for bot // look for bot
{ {
TPrimitiveClassPredicate pred("npc_bot"); NLLIGO::TPrimitiveClassPredicate pred("npc_bot");
TPrimitiveSet result; NLLIGO::TPrimitiveSet result;
CPrimitiveSet<TPrimitiveClassPredicate> ps; NLLIGO::CPrimitiveSet<NLLIGO::TPrimitiveClassPredicate> ps;
ps.buildSet(primDoc.RootNode, pred, result); ps.buildSet(primDoc.RootNode, pred, result);
for (uint i=0; i<result.size(); ++i) for (size_t i = 0; i < result.size(); ++i)
{ {
string name; std::string name;
string sheetStr; std::string sheetStr;
result[i]->getPropertyByName("name", name); result[i]->getPropertyByName("name", name);
result[i]->getPropertyByName("sheet_client", sheetStr); result[i]->getPropertyByName("sheet_client", sheetStr);

View file

@ -30,22 +30,16 @@
#include "nel/ligo/primitive.h" #include "nel/ligo/primitive.h"
#include "nel/ligo/primitive_utils.h" #include "nel/ligo/primitive_utils.h"
using namespace std;
using namespace NLMISC;
using namespace NLLIGO;
using namespace STRING_MANAGER;
namespace TranslationManager namespace TranslationManager
{ {
struct TCreatureInfo struct TCreatureInfo
{ {
CSheetId SheetId; NLMISC::CSheetId SheetId;
bool ForceSheetName; bool ForceSheetName;
bool DisplayName; bool DisplayName;
void readGeorges(const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &sheetId)
void readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &sheetId)
{ {
const NLGEORGES::UFormElm &item=form->getRootNode(); const NLGEORGES::UFormElm &item=form->getRootNode();
@ -61,7 +55,6 @@ struct TCreatureInfo
f.serial(DisplayName); f.serial(DisplayName);
} }
static uint getVersion () static uint getVersion ()
{ {
return 1; return 1;
@ -70,42 +63,37 @@ struct TCreatureInfo
void removed() void removed()
{ {
} }
}; };
struct TEntryInfo struct TEntryInfo
{ {
string SheetName; std::string SheetName;
}; };
struct ExtractBotNames struct ExtractBotNames
{ {
private: private:
vector<string> Filters; std::vector<std::string> Filters;
std::map<CSheetId, TCreatureInfo> Creatures; std::map<NLMISC::CSheetId, TCreatureInfo> Creatures;
set<string> GenericNames; std::set<std::string> GenericNames;
map<string, TEntryInfo> SimpleNames; std::map<std::string, TEntryInfo> SimpleNames;
set<string> Functions; std::set<std::string> Functions;
private: private:
TCreatureInfo *getCreature(const std::string &sheetName); TCreatureInfo *getCreature(const std::string &sheetName);
ucstring makeGroupName(const ucstring & translationName); ucstring makeGroupName(const ucstring &translationName);
string removeAndStoreFunction(const std::string &fullName); std::string removeAndStoreFunction(const std::string &fullName);
void addGenericName(const std::string &name, const std::string &sheetName); void addGenericName(const std::string &name, const std::string &sheetName);
void addSimpleName(const std::string &name, const std::string &sheetName); void addSimpleName(const std::string &name, const std::string &sheetName);
public: public:
void extractBotNamesFromPrimitives(CLigoConfig ligoConfig); void extractBotNamesFromPrimitives(NLLIGO::CLigoConfig ligoConfig);
void setRequiredSettings(list<string> filters, string level_design_path); void setRequiredSettings(std::list<std::string> filters, std::string level_design_path);
set<string> getGenericNames(); std::set<std::string> getGenericNames();
map<string, TEntryInfo> getSimpleNames(); std::map<std::string, TEntryInfo> getSimpleNames();
string cleanupName(const std::string &name); std::string cleanupName(const std::string &name);
ucstring cleanupUcName(const ucstring &name); ucstring cleanupUcName(const ucstring &name);
void cleanSimpleNames(); void cleanSimpleNames();
void cleanGenericNames(); void cleanGenericNames();
}; };
} }
#endif /* EXTRACT_BOT_NAMES_H */ #endif /* EXTRACT_BOT_NAMES_H */

View file

@ -16,139 +16,135 @@
#include "extract_new_sheet_names.h" #include "extract_new_sheet_names.h"
using namespace std;
using namespace NLMISC;
using namespace NLLIGO;
using namespace STRING_MANAGER;
namespace TranslationManager namespace TranslationManager
{ {
// *************************************************************************** // ***************************************************************************
/* /*
* Specialisation of IWordListBuilder to list sheets in a directory * Specialisation of IWordListBuilder to list sheets in a directory
*/ */
bool CSheetWordListBuilder::buildWordList(std::vector<std::string> &allWords, std::string workSheetFileName)
bool CSheetWordListBuilder::buildWordList(std::vector<string> &allWords, string workSheetFileName) {
SheetExt = NLMISC::toLower(SheetExt);
// verify the directory is correct
if(!NLMISC::CFile::isDirectory(SheetPath))
{ {
SheetExt= toLower(SheetExt); nlwarning("Error: Directory '%s' not found. '%s' Aborted", SheetPath.c_str(), workSheetFileName.c_str());
// verify the directory is correct return false;
if(!CFile::isDirectory(SheetPath))
{
nlwarning("Error: Directory '%s' not found. '%s' Aborted", SheetPath.c_str(), workSheetFileName.c_str());
return false;
}
// list all files.
std::vector<string> allFiles;
allFiles.reserve(100000);
CPath::getPathContent(SheetPath, true, false, true, allFiles, NULL);
// Keep only the extension we want, and remove "_" (parent)
allWords.clear();
allWords.reserve(allFiles.size());
for(uint i=0;i<allFiles.size();i++)
{
string fileNameWithoutExt= CFile::getFilenameWithoutExtension(allFiles[i]);
string extension= toLower(CFile::getExtension(allFiles[i]));
// bad extension?
if(extension!=SheetExt)
continue;
// parent?
if(fileNameWithoutExt.empty()||fileNameWithoutExt[0]=='_')
continue;
// ok, add
allWords.push_back(toLower(fileNameWithoutExt));
}
return true;
} }
// list all files.
std::vector<std::string> allFiles;
allFiles.reserve(100000);
NLMISC::CPath::getPathContent(SheetPath, true, false, true, allFiles, NULL);
// Keep only the extension we want, and remove "_" (parent)
allWords.clear();
allWords.reserve(allFiles.size());
for(size_t i = 0; i < allFiles.size(); i++)
{
std::string fileNameWithoutExt = NLMISC::CFile::getFilenameWithoutExtension(allFiles[i]);
std::string extension = NLMISC::toLower(NLMISC::CFile::getExtension(allFiles[i]));
// bad extension?
if(extension!=SheetExt)
continue;
// parent?
if(fileNameWithoutExt.empty() || fileNameWithoutExt[0] == '_')
continue;
// ok, add
allWords.push_back(NLMISC::toLower(fileNameWithoutExt));
}
return true;
}
// *************************************************************************** // ***************************************************************************
/* /*
* Specialisation of IWordListBuilder to list new region/place name from .primitive * Specialisation of IWordListBuilder to list new region/place name from .primitive
*/ */
bool CRegionPrimWordListBuilder::buildWordList(std::vector<string> &allWords, string workSheetFileName) bool CRegionPrimWordListBuilder::buildWordList(std::vector<std::string> &allWords, std::string workSheetFileName)
{
// verify the directory is correct
if(!NLMISC::CFile::isDirectory(PrimPath))
{ {
// verify the directory is correct nlwarning("Error: Directory '%s' not found. '%s' Aborted", PrimPath.c_str(), workSheetFileName.c_str());
if(!CFile::isDirectory(PrimPath)) return false;
}
// list all files.
std::vector<std::string> allFiles;
allFiles.reserve(100000);
NLMISC::CPath::getPathContent(PrimPath, true, false, true, allFiles, NULL);
// parse all primitive that match the filter
allWords.clear();
allWords.reserve(100000);
// to avoid duplicate
std::set<std::string> allWordSet;
for(size_t i = 0; i < allFiles.size(); i++)
{
std::string fileName = NLMISC::CFile::getFilename(allFiles[i]);
// filter don't match?
bool oneMatch= false;
for(size_t filter = 0; filter < PrimFilter.size(); filter++)
{ {
nlwarning("Error: Directory '%s' not found. '%s' Aborted", PrimPath.c_str(), workSheetFileName.c_str()); if(NLMISC::testWildCard(fileName, PrimFilter[filter]))
oneMatch= true;
}
if(!oneMatch)
continue;
// ok, read the file
NLLIGO::CPrimitives PrimDoc;
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = &PrimDoc;
if (!NLLIGO::loadXmlPrimitiveFile(PrimDoc, allFiles[i], LigoConfig))
{
nlwarning("Error: cannot open file '%s'. '%s' Aborted", allFiles[i].c_str(), workSheetFileName.c_str());
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL;
return false; return false;
} }
NLLIGO::CPrimitiveContext::instance().CurrentPrimitive = NULL;
// list all files. // For all primitives of interest
std::vector<string> allFiles; const char *listClass[] = {"continent", "region", "place", "stable",
allFiles.reserve(100000); "teleport_destination", "room_template"
CPath::getPathContent(PrimPath, true, false, true, allFiles, NULL); };
// parse all primitive that match the filter const char *listProp[] = {"name", "name", "name", "name",
allWords.clear(); "place_name", "place_name"
allWords.reserve(100000); };
// to avoid duplicate
set<string> allWordSet; const uint numListClass= sizeof(listClass)/sizeof(listClass[0]);
for(uint i=0;i<allFiles.size();i++) const uint numListProp= sizeof(listProp)/sizeof(listProp[0]);
nlctassert(numListProp == numListClass);
for(uint cid = 0; cid < numListClass; cid++)
{ {
string fileName= CFile::getFilename(allFiles[i]); // parse the whole hierarchy
// filter don't match? NLLIGO::TPrimitiveClassPredicate predCont(listClass[cid]);
bool oneMatch= false; NLLIGO::CPrimitiveSet<NLLIGO::TPrimitiveClassPredicate> setPlace;
for(uint filter=0;filter<PrimFilter.size();filter++) NLLIGO::TPrimitiveSet placeRes;
{ setPlace.buildSet(PrimDoc.RootNode, predCont, placeRes);
if(testWildCard(fileName, PrimFilter[filter]))
oneMatch= true;
}
if(!oneMatch)
continue;
// ok, read the file // for all found
CPrimitives PrimDoc; for (size_t placeId = 0; placeId < placeRes.size(); ++placeId)
CPrimitiveContext::instance().CurrentPrimitive = &PrimDoc;
if (!loadXmlPrimitiveFile(PrimDoc, allFiles[i], LigoConfig))
{ {
nlwarning("Error: cannot open file '%s'. '%s' Aborted", allFiles[i].c_str(), workSheetFileName.c_str()); std::string primName;
CPrimitiveContext::instance().CurrentPrimitive = NULL; if(placeRes[placeId]->getPropertyByName(listProp[cid], primName) && !primName.empty())
return false;
}
CPrimitiveContext::instance().CurrentPrimitive = NULL;
// For all primitives of interest
const char *listClass[]= {"continent", "region", "place", "stable",
"teleport_destination", "room_template"};
const char *listProp[]= {"name", "name", "name", "name",
"place_name", "place_name"};
const uint numListClass= sizeof(listClass)/sizeof(listClass[0]);
const uint numListProp= sizeof(listProp)/sizeof(listProp[0]);
nlctassert(numListProp==numListClass);
for(uint cid=0;cid<numListClass;cid++)
{
// parse the whole hierarchy
TPrimitiveClassPredicate predCont(listClass[cid]);
CPrimitiveSet<TPrimitiveClassPredicate> setPlace;
TPrimitiveSet placeRes;
setPlace.buildSet(PrimDoc.RootNode, predCont, placeRes);
// for all found
for (uint placeId= 0; placeId < placeRes.size(); ++placeId)
{ {
string primName; primName = NLMISC::toLower(primName);
if(placeRes[placeId]->getPropertyByName(listProp[cid], primName) && !primName.empty()) // avoid duplicate
if(allWordSet.insert(primName).second)
{ {
primName= toLower(primName); allWords.push_back(primName);
// avoid duplicate
if(allWordSet.insert(primName).second)
{
allWords.push_back(primName);
}
} }
} }
} }
} }
return true;
} }
return true;
}
} }

View file

@ -30,43 +30,34 @@
#include "nel/ligo/primitive.h" #include "nel/ligo/primitive.h"
#include "nel/ligo/primitive_utils.h" #include "nel/ligo/primitive_utils.h"
using namespace std;
using namespace NLMISC;
using namespace NLLIGO;
using namespace STRING_MANAGER;
namespace TranslationManager namespace TranslationManager
{ {
// *************************************************************************** // ***************************************************************************
/* /*
* Interface to build the whole list of words (key id) for a specific worksheet * Interface to build the whole list of words (key id) for a specific worksheet
*/ */
struct IWordListBuilder struct IWordListBuilder
{ {
virtual bool buildWordList(std::vector<string> &allWords, string workSheetFileName) =0; virtual bool buildWordList(std::vector<std::string> &allWords, std::string workSheetFileName) =0;
}; };
struct CSheetWordListBuilder : public IWordListBuilder struct CSheetWordListBuilder : public IWordListBuilder
{ {
string SheetExt; std::string SheetExt;
string SheetPath; std::string SheetPath;
virtual bool buildWordList(std::vector<string> &allWords, string workSheetFileName); virtual bool buildWordList(std::vector<std::string> &allWords, std::string workSheetFileName);
}; };
struct CRegionPrimWordListBuilder : public IWordListBuilder struct CRegionPrimWordListBuilder : public IWordListBuilder
{ {
string PrimPath; std::string PrimPath;
vector<string> PrimFilter; std::vector<std::string> PrimFilter;
NLLIGO::CLigoConfig LigoConfig; NLLIGO::CLigoConfig LigoConfig;
virtual bool buildWordList(std::vector<string> &allWords, string workSheetFileName); virtual bool buildWordList(std::vector<std::string> &allWords, std::string workSheetFileName);
}; };
} }
#endif /* EXTRACT_NEW_SHEET_NAMES_H */ #endif /* EXTRACT_NEW_SHEET_NAMES_H */

View file

@ -1,191 +1,216 @@
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "ftp_selection.h" #include "ftp_selection.h"
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtNetwork/QFtp> #include <QtNetwork/QFtp>
namespace TranslationManager namespace TranslationManager
{ {
CFtpSelection::CFtpSelection(QWidget *parent): QDialog(parent) CFtpSelection::CFtpSelection(QWidget *parent): QDialog(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
connect(_ui.connectButton, SIGNAL(clicked()), this, SLOT(ConnectButtonClicked())); connect(_ui.connectButton, SIGNAL(clicked()), this, SLOT(ConnectButtonClicked()));
connect(_ui.doneButton, SIGNAL(clicked()), this, SLOT(DoneButtonClicked())); connect(_ui.doneButton, SIGNAL(clicked()), this, SLOT(DoneButtonClicked()));
connect(_ui.cdToParrent, SIGNAL(clicked()), this, SLOT(cdToParent())); connect(_ui.cdToParrent, SIGNAL(clicked()), this, SLOT(cdToParent()));
connect(_ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); connect(_ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
// file list // file list
connect(_ui.fileList, SIGNAL(itemActivated(QTreeWidgetItem*,int)),this, SLOT(processItem(QTreeWidgetItem*,int))); connect(_ui.fileList, SIGNAL(itemActivated(QTreeWidgetItem *,int)),this, SLOT(processItem(QTreeWidgetItem *,int)));
_ui.fileList->setEnabled(false); _ui.fileList->setEnabled(false);
_ui.fileList->setRootIsDecorated(false); _ui.fileList->setRootIsDecorated(false);
_ui.fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time")); _ui.fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time"));
_ui.fileList->header()->setStretchLastSection(false); _ui.fileList->header()->setStretchLastSection(false);
// buttons // buttons
_ui.cdToParrent->setEnabled(false); _ui.cdToParrent->setEnabled(false);
_ui.doneButton->setEnabled(false); _ui.doneButton->setEnabled(false);
status = false; status = false;
} }
// Connection with the FTP Server. We retrieve the file list. // Connection with the FTP Server. We retrieve the file list.
void CFtpSelection::ConnectButtonClicked() void CFtpSelection::ConnectButtonClicked()
{ {
conn = new QFtp(this); conn = new QFtp(this);
connect(conn, SIGNAL(commandFinished(int,bool)), this, SLOT(FtpCommandFinished(int,bool))); connect(conn, SIGNAL(commandFinished(int,bool)), this, SLOT(FtpCommandFinished(int,bool)));
connect(conn, SIGNAL(listInfo(QUrlInfo)), this, SLOT(AddToList(QUrlInfo))); connect(conn, SIGNAL(listInfo(QUrlInfo)), this, SLOT(AddToList(QUrlInfo)));
#ifndef QT_NO_CURSOR
setCursor(Qt::WaitCursor);
#endif
QUrl url(_ui.url->text());
if (!url.isValid() || url.scheme().toLower() != QLatin1String("ftp")) {
conn->connectToHost(_ui.url->text(), 21);
conn->login();
} else {
conn->connectToHost(url.host(), url.port(21));
if (!url.userName().isEmpty()) setCursor(Qt::WaitCursor);
conn->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password());
else
conn->login();
if (!url.path().isEmpty())
conn->cd(url.path());
}
}
// Get the user action. QUrl url(_ui.url->text());
void CFtpSelection::FtpCommandFinished(int, bool error) if (!url.isValid() || url.scheme().toLower() != QLatin1String("ftp"))
{
#ifndef QT_NO_CURSOR
setCursor(Qt::ArrowCursor);
#endif
if (conn->currentCommand() == QFtp::ConnectToHost)
{
if (error)
{
QMessageBox::information(this, tr("FTP"),
tr("Unable to connect to the FTP server "
"at %1. Please check that the host "
"name is correct.")
.arg(_ui.url->text()));
return;
}
return;
}
if (conn->currentCommand() == QFtp::Login)
{
conn->list();
}
if (conn->currentCommand() == QFtp::Get)
{
if(error)
{
status = false;
file->close();
file->remove();
} else {
file->close();
status = true;
}
_ui.cancelButton->setEnabled(true);
}
if (conn->currentCommand() == QFtp::List)
{
if (isDirectory.isEmpty()) {
_ui.fileList->addTopLevelItem(new QTreeWidgetItem(QStringList() << tr("<empty>")));
_ui.fileList->setEnabled(false);
}
}
}
// Make the file list with directories and files
void CFtpSelection::AddToList(const QUrlInfo &urlInfo)
{
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, urlInfo.name());
item->setText(1, QString::number(urlInfo.size()));
item->setText(2, urlInfo.owner());
item->setText(3, urlInfo.group());
item->setText(4, urlInfo.lastModified().toString("MMM dd yyyy"));
QPixmap pixmap(urlInfo.isDir() ? ":/translationManager/images/dir.png" : ":/translationManager/images/file.png");
item->setIcon(0, pixmap);
isDirectory[urlInfo.name()] = urlInfo.isDir();
_ui.fileList->addTopLevelItem(item);
if (!_ui.fileList->currentItem()) {
_ui.fileList->setCurrentItem(_ui.fileList->topLevelItem(0));
_ui.fileList->setEnabled(true);
}
}
void CFtpSelection::processItem(QTreeWidgetItem* item, int)
{
QString name = item->text(0);
if (isDirectory.value(name))
{
_ui.fileList->clear();
isDirectory.clear();
currentPath += '/';
currentPath += name;
conn->cd(name);
conn->list();
#ifndef QT_NO_CURSOR
setCursor(Qt::WaitCursor);
#endif
return;
}
_ui.doneButton->setEnabled(true);
}
// Exit from a directory
void CFtpSelection::cdToParent()
{ {
#ifndef QT_NO_CURSOR conn->connectToHost(_ui.url->text(), 21);
setCursor(Qt::WaitCursor); conn->login();
#endif }
_ui.fileList->clear(); else
isDirectory.clear(); {
currentPath = currentPath.left(currentPath.lastIndexOf('/')); conn->connectToHost(url.host(), url.port(21));
if (currentPath.isEmpty()) {
_ui.cdToParrent->setEnabled(false); if (!url.userName().isEmpty())
conn->cd("/"); conn->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password());
} else { else
conn->cd(currentPath); conn->login();
} if (!url.path().isEmpty())
conn->list(); conn->cd(url.path());
}
}
// Get the user action.
void CFtpSelection::FtpCommandFinished(int, bool error)
{
setCursor(Qt::ArrowCursor);
if (conn->currentCommand() == QFtp::ConnectToHost)
{
if (error)
{
QMessageBox::information(this, tr("FTP"),
tr("Unable to connect to the FTP server "
"at %1. Please check that the host "
"name is correct.")
.arg(_ui.url->text()));
return;
}
return;
} }
// Done action if (conn->currentCommand() == QFtp::Login)
void CFtpSelection::DoneButtonClicked() {
{ conn->list();
QString fileName = _ui.fileList->currentItem()->text(0); }
if (QFile::exists(fileName)) { if (conn->currentCommand() == QFtp::Get)
QMessageBox::information(this, tr("FTP"), {
tr("There already exists a file called %1 in " if(error)
"the current directory.") {
.arg(fileName)); status = false;
return; file->close();
} file->remove();
}
else
{
file->close();
status = true;
}
_ui.cancelButton->setEnabled(true);
}
file = new QFile(fileName); if (conn->currentCommand() == QFtp::List)
#ifndef QT_NO_CURSOR {
setCursor(Qt::WaitCursor); if (isDirectory.isEmpty())
#endif {
if (!file->open(QIODevice::WriteOnly)) { _ui.fileList->addTopLevelItem(new QTreeWidgetItem(QStringList() << tr("<empty>")));
QMessageBox::information(this, tr("FTP"), _ui.fileList->setEnabled(false);
tr("Unable to save the file %1: %2.") }
.arg(fileName).arg(file->errorString())); }
delete file; }
return; // Make the file list with directories and files
} void CFtpSelection::AddToList(const QUrlInfo &urlInfo)
_ui.cancelButton->setEnabled(false); {
conn->get(_ui.fileList->currentItem()->text(0), file); QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, urlInfo.name());
item->setText(1, QString::number(urlInfo.size()));
item->setText(2, urlInfo.owner());
item->setText(3, urlInfo.group());
item->setText(4, urlInfo.lastModified().toString("MMM dd yyyy"));
reject(); QPixmap pixmap(urlInfo.isDir() ? ":/translationManager/images/dir.png" : ":/translationManager/images/file.png");
} item->setIcon(0, pixmap);
isDirectory[urlInfo.name()] = urlInfo.isDir();
_ui.fileList->addTopLevelItem(item);
if (!_ui.fileList->currentItem())
{
_ui.fileList->setCurrentItem(_ui.fileList->topLevelItem(0));
_ui.fileList->setEnabled(true);
}
}
void CFtpSelection::processItem(QTreeWidgetItem *item, int)
{
QString name = item->text(0);
if (isDirectory.value(name))
{
_ui.fileList->clear();
isDirectory.clear();
currentPath += '/';
currentPath += name;
conn->cd(name);
conn->list();
setCursor(Qt::WaitCursor);
return;
}
_ui.doneButton->setEnabled(true);
}
// Exit from a directory
void CFtpSelection::cdToParent()
{
setCursor(Qt::WaitCursor);
_ui.fileList->clear();
isDirectory.clear();
currentPath = currentPath.left(currentPath.lastIndexOf('/'));
if (currentPath.isEmpty())
{
_ui.cdToParrent->setEnabled(false);
conn->cd("/");
}
else
{
conn->cd(currentPath);
}
conn->list();
}
// Done action
void CFtpSelection::DoneButtonClicked()
{
QString fileName = _ui.fileList->currentItem()->text(0);
if (QFile::exists(fileName))
{
QMessageBox::information(this, tr("FTP"),
tr("There already exists a file called %1 in "
"the current directory.")
.arg(fileName));
return;
}
file = new QFile(fileName);
setCursor(Qt::WaitCursor);
if (!file->open(QIODevice::WriteOnly))
{
QMessageBox::information(this, tr("FTP"),
tr("Unable to save the file %1: %2.")
.arg(fileName).arg(file->errorString()));
delete file;
return;
}
_ui.cancelButton->setEnabled(false);
conn->get(_ui.fileList->currentItem()->text(0), file);
reject();
}
} }

View file

@ -8,6 +8,8 @@
#ifndef FTP_SELECTION_H #ifndef FTP_SELECTION_H
#define FTP_SELECTION_H #define FTP_SELECTION_H
#include "ui_ftp_selection.h"
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QUrl> #include <QtCore/QUrl>
#include <QtGui/QDialog> #include <QtGui/QDialog>
@ -16,34 +18,33 @@
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtNetwork> #include <QtNetwork>
#include "ui_ftp_selection.h" namespace TranslationManager
{
using namespace std; class CFtpSelection : public QDialog
{
Q_OBJECT
namespace TranslationManager { public:
CFtpSelection(QWidget *parent = 0);
~CFtpSelection() {}
bool status;
QFile *file;
class CFtpSelection : public QDialog private Q_SLOTS:
{ void cdToParent();
Q_OBJECT void processItem(QTreeWidgetItem *,int);
private: void ConnectButtonClicked();
Ui::FtpSelectionDialog _ui; void DoneButtonClicked();
QFtp *conn; void FtpCommandFinished(int, bool error);
QHash<QString, bool> isDirectory; void AddToList(const QUrlInfo &urlInfo);
QString currentPath;
private Q_SLOTS: private:
void cdToParent(); Ui::FtpSelectionDialog _ui;
void processItem(QTreeWidgetItem*,int); QFtp *conn;
void ConnectButtonClicked(); QHash<QString, bool> isDirectory;
void DoneButtonClicked(); QString currentPath;
void FtpCommandFinished(int, bool error); };
void AddToList(const QUrlInfo &urlInfo);
public:
bool status;
QFile *file;
CFtpSelection(QWidget* parent = 0);
~CFtpSelection() {}
};
} }
#endif /* FTP_SELECTION_H */ #endif /* FTP_SELECTION_H */

View file

@ -1,39 +1,54 @@
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
#include <QtGui/qlistwidget.h> // Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "source_selection.h" #include "source_selection.h"
#include <QtGui/QListWidget>
namespace TranslationManager namespace TranslationManager
{ {
CSourceDialog::CSourceDialog(QWidget *parent): QDialog(parent) CSourceDialog::CSourceDialog(QWidget *parent): QDialog(parent)
{ {
_ui.setupUi(this); _ui.setupUi(this);
// Set signal and slot for "OK Button"
connect(_ui.ok_button, SIGNAL(clicked()), this, SLOT(OkButtonClicked())); connect(_ui.ok_button, SIGNAL(clicked()), this, SLOT(OkButtonClicked()));
// Set signal and slot for "Cancel Button" connect(_ui.cancel_button, SIGNAL(clicked()), this, SLOT(reject()));
connect(_ui.cancel_button, SIGNAL(clicked()), this, SLOT(reject()));
_ui.sourceSelectionListWidget->setSortingEnabled(false); _ui.sourceSelectionListWidget->setSortingEnabled(false);
connect(_ui.sourceSelectionListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), connect(_ui.sourceSelectionListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
this, SLOT(itemDoubleClicked(QListWidgetItem *))); this, SLOT(itemDoubleClicked(QListWidgetItem *)));
} }
// Insert options in the source dialog. Options like: from FTP Server, from Local directory etc. // Insert options in the source dialog. Options like: from FTP Server, from Local directory etc.
void CSourceDialog::setSourceOptions(map<QListWidgetItem*,int> options) void CSourceDialog::setSourceOptions(std::map<QListWidgetItem *, int> &options)
{ {
map<QListWidgetItem*,int>::iterator it; std::map<QListWidgetItem *,int>::iterator it;
for(it = options.begin(); it != options.end(); ++it) for(it = options.begin(); it != options.end(); ++it)
{ {
_ui.sourceSelectionListWidget->addItem((*it).first); _ui.sourceSelectionListWidget->addItem((*it).first);
} }
} }
void CSourceDialog::OkButtonClicked() void CSourceDialog::OkButtonClicked()
{ {
selected_item = _ui.sourceSelectionListWidget->currentItem(); selected_item = _ui.sourceSelectionListWidget->currentItem();
accept(); accept();
} }
void CSourceDialog::itemDoubleClicked(QListWidgetItem *item) void CSourceDialog::itemDoubleClicked(QListWidgetItem *item)

View file

@ -1,16 +1,30 @@
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SOURCE_SELECTION_H #ifndef SOURCE_SELECTION_H
#define SOURCE_SELECTION_H #define SOURCE_SELECTION_H
#include "ui_source_selection.h"
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtGui/QDialog> #include <QtGui/QDialog>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtGui/QListWidgetItem> #include <QtGui/QListWidgetItem>
#include "ui_source_selection.h"
#include <map>
using namespace std; #include <map>
namespace TranslationManager namespace TranslationManager
{ {
@ -18,16 +32,19 @@ namespace TranslationManager
class CSourceDialog : public QDialog class CSourceDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
private:
Ui::SourceSelectionDialog _ui; public:
CSourceDialog(QWidget *parent = 0);
~CSourceDialog() {}
void setSourceOptions(std::map<QListWidgetItem *, int> &options);
QListWidgetItem *selected_item;
private Q_SLOTS: private Q_SLOTS:
void OkButtonClicked(); void OkButtonClicked();
void itemDoubleClicked(QListWidgetItem *item); void itemDoubleClicked(QListWidgetItem *item);
public:
CSourceDialog(QWidget *parent = 0); private:
~CSourceDialog(){} Ui::SourceSelectionDialog _ui;
void setSourceOptions(map<QListWidgetItem*, int> options);
QListWidgetItem *selected_item;
}; };
} }

View file

@ -1,29 +1,38 @@
/* // Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
* File: translation_manager_constants.h // Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
* Author: cemycc //
* // This program is free software: you can redistribute it and/or modify
* Created on July 5, 2011, 9:15 PM // it under the terms of the GNU Affero General Public License as
*/ // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef TRANSLATION_MANAGER_CONSTANTS_H #ifndef TRANSLATION_MANAGER_CONSTANTS_H
#define TRANSLATION_MANAGER_CONSTANTS_H #define TRANSLATION_MANAGER_CONSTANTS_H
namespace TranslationManager namespace TranslationManager
{ {
namespace Constants namespace Constants
{ {
const int ED_SHEET = 1; const int ED_SHEET = 1;
const int ED_PHRASE = 2; const int ED_PHRASE = 2;
const char * const WK_BOTNAMES = "bot_names_wk.txt"; const char *const WK_BOTNAMES = "bot_names_wk.txt";
const char * const WK_ITEM = "item_words_wk.txt"; const char *const WK_ITEM = "item_words_wk.txt";
const char * const WK_CREATURE = "creature_words_wk.txt"; const char *const WK_CREATURE = "creature_words_wk.txt";
const char * const WK_SBRICK = "sbrick_words_wk.txt"; const char *const WK_SBRICK = "sbrick_words_wk.txt";
const char * const WK_SPHRASE = "sphrase_words_wk.txt"; const char *const WK_SPHRASE = "sphrase_words_wk.txt";
const char * const WK_PLACE = "place_words_wk.txt"; const char *const WK_PLACE = "place_words_wk.txt";
const char * const WK_CONTINENT = "place_words_wk.txt"; const char *const WK_CONTINENT = "place_words_wk.txt";
const char * const WK_STABLE = "place_words_wk.txt"; const char *const WK_STABLE = "place_words_wk.txt";
} }
} }
#endif /* TRANSLATION_MANAGER_CONSTANTS_H */ #endif /* TRANSLATION_MANAGER_CONSTANTS_H */

View file

@ -1,5 +1,4 @@
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/> // Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com> // Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
@ -25,31 +24,30 @@
#include <QtGui/QUndoStack> #include <QtGui/QUndoStack>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
namespace TranslationManager { namespace TranslationManager
{
class CEditor : public QMdiSubWindow
{
Q_OBJECT
class CEditor : public QMdiSubWindow {
Q_OBJECT
protected:
QUndoStack* current_stack;
QString current_file;
int editor_type;
public:
CEditor(QMdiArea* parent) : QMdiSubWindow(parent) {}
CEditor() : QMdiSubWindow() {}
virtual void open(QString filename) =0;
virtual void save() =0;
virtual void saveAs(QString filename) =0;
virtual void activateWindow() =0;
public: public:
CEditor(QMdiArea *parent) : QMdiSubWindow(parent) {}
CEditor() : QMdiSubWindow() {}
virtual void open(QString filename) =0;
virtual void save() =0;
virtual void saveAs(QString filename) =0;
virtual void activateWindow() =0;
int eType() int eType()
{ {
return editor_type; return editor_type;
} }
QString subWindowFilePath() QString subWindowFilePath()
{ {
return current_file; return current_file;
} }
void setUndoStack(QUndoStack* stack) void setUndoStack(QUndoStack *stack)
{ {
current_stack = stack; current_stack = stack;
} }
@ -62,10 +60,12 @@ public:
setWindowFilePath(current_file); setWindowFilePath(current_file);
} }
protected:
QUndoStack *current_stack;
QString current_file;
int editor_type;
}; };
} }
#endif /* TRANSLATION_MANAGER_EDITOR_H */ #endif /* TRANSLATION_MANAGER_EDITOR_H */

View file

@ -1,5 +1,4 @@
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/> // Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com> // Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
@ -15,20 +14,19 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef MAIN_WINDOW_H #ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H #define MAIN_WINDOW_H
// Project includes
#include "ui_translation_manager_main_window.h"
#include "translation_manager_editor.h"
#include "source_selection.h"
#include "editor_worksheet.h"
#include "editor_phrase.h"
// Project system includes // Project system includes
#include "../core/icore_listener.h" #include "../core/icore_listener.h"
// Nel includes
#include "nel/misc/types_nl.h"
#include "nel/misc/sheet_id.h"
#include "nel/misc/path.h"
#include "nel/misc/diff_tool.h"
#include "nel/ligo/ligo_config.h"
// Qt includes // Qt includes
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtGui/QUndoStack> #include <QtGui/QUndoStack>
@ -39,16 +37,15 @@
#include <QtCore/QSignalMapper> #include <QtCore/QSignalMapper>
#include <QtGui/QDialog> #include <QtGui/QDialog>
// Plugin includes // STL includes
#include "translation_manager_editor.h"
#include "source_selection.h"
#include "ui_translation_manager_main_window.h"
#include <set> #include <set>
#include "editor_worksheet.h"
#include "editor_phrase.h"
class QWidget;
// Nel includes
#include "nel/misc/types_nl.h"
#include "nel/misc/sheet_id.h"
#include "nel/misc/path.h"
#include "nel/misc/diff_tool.h"
#include "nel/ligo/ligo_config.h"
using namespace std; using namespace std;
@ -58,61 +55,64 @@ namespace TranslationManager
class CMainWindow : public QMainWindow class CMainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
CMainWindow(QWidget *parent = 0); CMainWindow(QWidget *parent = 0);
virtual ~CMainWindow() {} virtual ~CMainWindow() {}
QUndoStack *m_undoStack; QUndoStack *m_undoStack;
public: public:
Ui::CMainWindow _ui; Ui::CMainWindow _ui;
private: private:
// actions // actions
QAction *openAct; QAction *openAct;
QAction *saveAct; QAction *saveAct;
QAction *saveAsAct; QAction *saveAsAct;
QMenu *windowMenu; QMenu *windowMenu;
QSignalMapper *windowMapper; QSignalMapper *windowMapper;
// config // config
QMap<string,bool> initialize_settings; QMap<string,bool> initialize_settings;
QList<QString> filters; QList<QString> filters;
QList<QString> languages; QList<QString> languages;
QString level_design_path; QString level_design_path;
QString primitives_path; QString primitives_path;
QString translation_path; QString translation_path;
QString work_path; QString work_path;
NLLIGO::CLigoConfig ligoConfig; NLLIGO::CLigoConfig ligoConfig;
private Q_SLOTS: private Q_SLOTS:
void extractBotNames(); void extractBotNames();
void extractWords(QString typeq); void extractWords(QString typeq);
void open(); void open();
void save(); void save();
void saveAs(); void saveAs();
void setActiveSubWindow(QWidget *window); void setActiveSubWindow(QWidget *window);
void updateWindowsList(); void updateWindowsList();
void mergeSingleFile(); void mergeSingleFile();
private: private:
void openWorkFile(QString file); void openWorkFile(QString file);
void updateToolbar(QMdiSubWindow *window); void updateToolbar(QMdiSubWindow *window);
bool verifySettings(); bool verifySettings();
void readSettings(); void readSettings();
void createMenus(); void createMenus();
void createToolbar(); void createToolbar();
void initializeSettings(bool georges); void initializeSettings(bool georges);
list<string> convertQStringList(QStringList listq); std::list<std::string> convertQStringList(QStringList listq);
CEditor* getEditorByWindowFilePath(const QString &fileName); CEditor *getEditorByWindowFilePath(const QString &fileName);
// Worksheet specific functions // Worksheet specific functions
CEditorWorksheet* getEditorByWorksheetType(const QString &type); CEditorWorksheet *getEditorByWorksheetType(const QString &type);
bool isWorksheetEditor(QString filename); bool isWorksheetEditor(QString filename);
bool isPhraseEditor(QString filename); bool isPhraseEditor(QString filename);
}; };
class CCoreListener : public Core::ICoreListener class CCoreListener : public Core::ICoreListener
{ {
Q_OBJECT Q_OBJECT
public: public:
CCoreListener(CMainWindow* mainWindow, QObject *parent = 0): ICoreListener(parent) CCoreListener(CMainWindow *mainWindow, QObject *parent = 0): ICoreListener(parent)
{ {
m_MainWindow = mainWindow; m_MainWindow = mainWindow;
} }
@ -124,10 +124,6 @@ public:
CMainWindow *m_MainWindow; CMainWindow *m_MainWindow;
}; };
} // namespace TranslationManager } // namespace TranslationManager
#endif
#endif // SIMPLE_VIEWER_H

View file

@ -19,7 +19,8 @@
#include "translation_manager_plugin.h" #include "translation_manager_plugin.h"
#include "translation_manager_settings_page.h" #include "translation_manager_settings_page.h"
#include "translation_manager_main_window.h" #include "translation_manager_main_window.h"
// Project system includes
// Core includes
#include "../core/icore.h" #include "../core/icore.h"
#include "../core/core_constants.h" #include "../core/core_constants.h"
#include "../core/menu_manager.h" #include "../core/menu_manager.h"
@ -65,11 +66,8 @@ bool TranslationManagerPlugin::initialize(ExtensionSystem::IPluginManager *plugi
void TranslationManagerPlugin::extensionsInitialized() void TranslationManagerPlugin::extensionsInitialized()
{ {
} }
void TranslationManagerPlugin::setNelContext(NLMISC::INelContext *nelContext) void TranslationManagerPlugin::setNelContext(NLMISC::INelContext *nelContext)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
@ -86,23 +84,6 @@ void TranslationManagerPlugin::addAutoReleasedObject(QObject *obj)
_autoReleaseObjects.prepend(obj); _autoReleaseObjects.prepend(obj);
} }
QObject* TranslationManagerPlugin::objectByName(const QString &name) const
{
Q_FOREACH (QObject *qobj, _plugMan->allObjects())
if (qobj->objectName() == name)
return qobj;
return 0;
}
ExtensionSystem::IPluginSpec *TranslationManagerPlugin::pluginByName(const QString &name) const
{
Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins())
if (spec->name() == name)
return spec;
return 0;
}
} }
Q_EXPORT_PLUGIN(TranslationManager::TranslationManagerPlugin) Q_EXPORT_PLUGIN(TranslationManager::TranslationManagerPlugin)

View file

@ -45,7 +45,7 @@ class IPluginSpec;
namespace TranslationManager namespace TranslationManager
{ {
class CTranslationManagerContext; class CTranslationManagerContext;
class TranslationManagerPlugin : public QObject, public ExtensionSystem::IPlugin class TranslationManagerPlugin : public QObject, public ExtensionSystem::IPlugin
{ {
@ -58,12 +58,8 @@ public:
void extensionsInitialized(); void extensionsInitialized();
void setNelContext(NLMISC::INelContext *nelContext); void setNelContext(NLMISC::INelContext *nelContext);
void addAutoReleasedObject(QObject *obj); void addAutoReleasedObject(QObject *obj);
QObject *objectByName(const QString &name) const;
ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const;
protected: protected:
NLMISC::CLibraryContext *_LibContext; NLMISC::CLibraryContext *_LibContext;
@ -75,8 +71,9 @@ private:
class CTranslationManagerContext: public Core::IContext class CTranslationManagerContext: public Core::IContext
{ {
Q_OBJECT Q_OBJECT
public: public:
CTranslationManagerContext(CMainWindow* mainWindow, QObject *parent = 0): IContext(parent) CTranslationManagerContext(CMainWindow *mainWindow, QObject *parent = 0): IContext(parent)
{ {
m_MainWindow = mainWindow; m_MainWindow = mainWindow;
} }
@ -109,9 +106,8 @@ public:
} }
CMainWindow *m_MainWindow; CMainWindow *m_MainWindow;
}; };
} // namespace Plugin }
#endif // TRANSLATION_MANAGER_PLUGIN_H #endif // TRANSLATION_MANAGER_PLUGIN_H

View file

@ -1,5 +1,4 @@
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/> // Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com> // Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
@ -17,17 +16,15 @@
#include "translation_manager_settings_page.h" #include "translation_manager_settings_page.h"
// Core includes
#include "../core/icore.h"
// Qt includes // Qt includes
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtGui/QListWidgetItem> #include <QtGui/QListWidgetItem>
// NeL includes
// Project includes
#include "../core/icore.h"
namespace TranslationManager namespace TranslationManager
{ {
@ -68,20 +65,20 @@ QWidget *CTranslationManagerSettingsPage::createPage(QWidget *parent)
{ {
_currentPage = new QWidget(parent); _currentPage = new QWidget(parent);
_ui.setupUi(_currentPage); _ui.setupUi(_currentPage);
readSettings(); readSettings();
connect(_ui.filter_add, SIGNAL(clicked()), this, SLOT(filterAdd())); connect(_ui.filter_add, SIGNAL(clicked()), this, SLOT(filterAdd()));
connect(_ui.filter_del, SIGNAL(clicked()), this, SLOT(filterDel())); connect(_ui.filter_del, SIGNAL(clicked()), this, SLOT(filterDel()));
connect(_ui.lang_add, SIGNAL(clicked()), this, SLOT(languageAdd())); connect(_ui.lang_add, SIGNAL(clicked()), this, SLOT(languageAdd()));
connect(_ui.lang_del, SIGNAL(clicked()), this, SLOT(languageDel())); connect(_ui.lang_del, SIGNAL(clicked()), this, SLOT(languageDel()));
connect(_ui.translation_add, SIGNAL(clicked()), this, SLOT(translationAdd())); connect(_ui.translation_add, SIGNAL(clicked()), this, SLOT(translationAdd()));
connect(_ui.work_add, SIGNAL(clicked()), this, SLOT(workAdd())); connect(_ui.work_add, SIGNAL(clicked()), this, SLOT(workAdd()));
return _currentPage; return _currentPage;
} }
void CTranslationManagerSettingsPage::filterAdd() void CTranslationManagerSettingsPage::filterAdd()
{ {
QString newValue = _ui.filter_edit->text(); QString newValue = _ui.filter_edit->text();
if (!newValue.isEmpty()) if (!newValue.isEmpty())
{ {
QListWidgetItem *newItem = new QListWidgetItem; QListWidgetItem *newItem = new QListWidgetItem;
@ -100,7 +97,7 @@ void CTranslationManagerSettingsPage::filterDel()
void CTranslationManagerSettingsPage::languageAdd() void CTranslationManagerSettingsPage::languageAdd()
{ {
QString newValue = _ui.lang_edit->text(); QString newValue = _ui.lang_edit->text();
if (!newValue.isEmpty()) if (!newValue.isEmpty())
{ {
QListWidgetItem *newItem = new QListWidgetItem; QListWidgetItem *newItem = new QListWidgetItem;
@ -119,43 +116,43 @@ void CTranslationManagerSettingsPage::languageDel()
void CTranslationManagerSettingsPage::translationAdd() void CTranslationManagerSettingsPage::translationAdd()
{ {
QString newPath = QFileDialog::getExistingDirectory(_currentPage, ""); QString newPath = QFileDialog::getExistingDirectory(_currentPage, "");
if (!newPath.isEmpty()) if (!newPath.isEmpty())
{ {
_ui.translation_edit->setText(newPath); _ui.translation_edit->setText(newPath);
} }
} }
void CTranslationManagerSettingsPage::workAdd() void CTranslationManagerSettingsPage::workAdd()
{ {
QString newPath = QFileDialog::getExistingDirectory(_currentPage, ""); QString newPath = QFileDialog::getExistingDirectory(_currentPage, "");
if (!newPath.isEmpty()) if (!newPath.isEmpty())
{ {
_ui.work_edit->setText(newPath); _ui.work_edit->setText(newPath);
} }
} }
void CTranslationManagerSettingsPage::apply() void CTranslationManagerSettingsPage::apply()
{ {
writeSettings(); writeSettings();
} }
void CTranslationManagerSettingsPage::readSettings() void CTranslationManagerSettingsPage::readSettings()
{ {
QStringList filters, languages; QStringList filters, languages;
QString ligo, translation, work; QString ligo, translation, work;
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("translationmanager"); settings->beginGroup("translationmanager");
filters = settings->value("filters").toStringList(); /* filters */ filters = settings->value("filters").toStringList(); /* filters */
languages = settings->value("trlanguages").toStringList(); /* languages */ languages = settings->value("trlanguages").toStringList(); /* languages */
ligo = settings->value("ligo").toString(); ligo = settings->value("ligo").toString();
translation = settings->value("translation").toString(); translation = settings->value("translation").toString();
work = settings->value("work").toString(); work = settings->value("work").toString();
settings->endGroup(); settings->endGroup();
// filter // filter
Q_FOREACH(QString filter, filters) Q_FOREACH(QString filter, filters)
{ {
QListWidgetItem *newItem = new QListWidgetItem; QListWidgetItem *newItem = new QListWidgetItem;
@ -163,7 +160,7 @@ void CTranslationManagerSettingsPage::readSettings()
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
_ui.filter_list->addItem(newItem); _ui.filter_list->addItem(newItem);
} }
// languages // languages
Q_FOREACH(QString lang, languages) Q_FOREACH(QString lang, languages)
{ {
QListWidgetItem *newItem = new QListWidgetItem; QListWidgetItem *newItem = new QListWidgetItem;
@ -171,37 +168,36 @@ void CTranslationManagerSettingsPage::readSettings()
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
_ui.lang_list->addItem(newItem); _ui.lang_list->addItem(newItem);
} }
// translation // translation
_ui.translation_edit->setText(translation); _ui.translation_edit->setText(translation);
// work // work
_ui.work_edit->setText(work); _ui.work_edit->setText(work);
} }
void CTranslationManagerSettingsPage::writeSettings() void CTranslationManagerSettingsPage::writeSettings()
{ {
QStringList filters, languages; QStringList filters, languages;
QString ligo, translation, work; QString ligo, translation, work;
// filters // filters
for (int i = 0; i < _ui.filter_list->count(); ++i) for (int i = 0; i < _ui.filter_list->count(); ++i)
filters << _ui.filter_list->item(i)->text(); filters << _ui.filter_list->item(i)->text();
// languages // languages
for (int i = 0; i < _ui.lang_list->count(); ++i) for (int i = 0; i < _ui.lang_list->count(); ++i)
languages << _ui.lang_list->item(i)->text(); languages << _ui.lang_list->item(i)->text();
// translations path // translations path
translation = _ui.translation_edit->text(); translation = _ui.translation_edit->text();
// work path // work path
work = _ui.work_edit->text(); work = _ui.work_edit->text();
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("translationmanager"); settings->beginGroup("translationmanager");
settings->setValue("filters", filters); settings->setValue("filters", filters);
settings->setValue("trlanguages", languages); settings->setValue("trlanguages", languages);
settings->setValue("translation", translation); settings->setValue("translation", translation);
settings->setValue("work", work); settings->setValue("work", work);
settings->endGroup(); settings->endGroup();
settings->sync(); settings->sync();
} }
}
} /* namespace Plugin */

View file

@ -24,13 +24,9 @@
#include "ui_translation_manager_settings_page.h" #include "ui_translation_manager_settings_page.h"
class QWidget;
namespace TranslationManager namespace TranslationManager
{ {
/**
@class CTranslationManagerSettingsPage
*/
class CTranslationManagerSettingsPage : public Core::IOptionsPage class CTranslationManagerSettingsPage : public Core::IOptionsPage
{ {
Q_OBJECT Q_OBJECT
@ -48,19 +44,19 @@ public:
virtual void apply(); virtual void apply();
virtual void finish() {} virtual void finish() {}
private Q_SLOTS: private Q_SLOTS:
void filterAdd(); void filterAdd();
void filterDel(); void filterDel();
void languageAdd(); void languageAdd();
void languageDel(); void languageDel();
void translationAdd(); void translationAdd();
void workAdd(); void workAdd();
private: private:
QWidget *_currentPage; QWidget *_currentPage;
Ui::CTranslationManagerSettingsPage _ui; Ui::CTranslationManagerSettingsPage _ui;
void writeSettings(); void writeSettings();
void readSettings(); void readSettings();
}; };
} // namespace Plugin }
#endif // TRANSLATION_MANAGER_SETTINGS_H #endif // TRANSLATION_MANAGER_SETTINGS_H

View file

@ -6,178 +6,152 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>533</width> <width>589</width>
<height>478</height> <height>490</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<widget class="QGroupBox" name="groupBox"> <layout class="QGridLayout" name="gridLayout_5">
<property name="geometry"> <item row="0" column="0">
<rect> <widget class="QGroupBox" name="groupBox">
<x>0</x> <property name="title">
<y>10</y> <string>Translation Manager Plugin</string>
<width>531</width> </property>
<height>421</height> <layout class="QGridLayout" name="gridLayout_4">
</rect> <item row="0" column="0">
</property> <layout class="QGridLayout" name="gridLayout">
<property name="title"> <item row="0" column="0">
<string>Translation Manager Plugin</string> <widget class="QLabel" name="label_5">
</property> <property name="text">
<widget class="QWidget" name=""> <string>Filters</string>
<property name="geometry"> </property>
<rect> </widget>
<x>0</x> </item>
<y>30</y> <item row="0" column="1">
<width>521</width> <widget class="QLineEdit" name="filter_edit"/>
<height>232</height> </item>
</rect> <item row="0" column="2">
</property> <widget class="QToolButton" name="filter_add">
<layout class="QGridLayout" name="gridLayout"> <property name="text">
<item row="0" column="0"> <string/>
<widget class="QLabel" name="label_5"> </property>
<property name="text"> <property name="icon">
<string>Filters</string> <iconset resource="../core/core.qrc">
</property> <normaloff>:/core/icons/ic_nel_add_item.png</normaloff>:/core/icons/ic_nel_add_item.png</iconset>
</widget> </property>
</item> <property name="autoRaise">
<item row="0" column="1"> <bool>true</bool>
<widget class="QLineEdit" name="filter_edit"/> </property>
</item> </widget>
<item row="0" column="2"> </item>
<widget class="QToolButton" name="filter_add"> <item row="0" column="3">
<property name="text"> <widget class="QToolButton" name="filter_del">
<string/> <property name="text">
</property> <string/>
<property name="icon"> </property>
<iconset resource="../core/core.qrc"> <property name="icon">
<normaloff>:/core/icons/ic_nel_add_item.png</normaloff>:/core/icons/ic_nel_add_item.png</iconset> <iconset resource="../core/core.qrc">
</property> <normaloff>:/core/icons/ic_nel_delete_item.png</normaloff>:/core/icons/ic_nel_delete_item.png</iconset>
<property name="autoRaise"> </property>
<bool>true</bool> <property name="autoRaise">
</property> <bool>true</bool>
</widget> </property>
</item> </widget>
<item row="0" column="3"> </item>
<widget class="QToolButton" name="filter_del"> <item row="0" column="4">
<property name="text"> <widget class="QLabel" name="label_7">
<string/> <property name="text">
</property> <string>Languages</string>
<property name="icon"> </property>
<iconset resource="../core/core.qrc"> </widget>
<normaloff>:/core/icons/ic_nel_delete_item.png</normaloff>:/core/icons/ic_nel_delete_item.png</iconset> </item>
</property> <item row="0" column="5">
<property name="autoRaise"> <widget class="QLineEdit" name="lang_edit"/>
<bool>true</bool> </item>
</property> <item row="0" column="6">
</widget> <widget class="QToolButton" name="lang_add">
</item> <property name="text">
<item row="0" column="4"> <string/>
<widget class="QLabel" name="label_7"> </property>
<property name="text"> <property name="icon">
<string>Languages</string> <iconset resource="../core/core.qrc">
</property> <normaloff>:/core/icons/ic_nel_add_item.png</normaloff>:/core/icons/ic_nel_add_item.png</iconset>
</widget> </property>
</item> <property name="autoRaise">
<item row="0" column="5"> <bool>true</bool>
<widget class="QLineEdit" name="lang_edit"/> </property>
</item> </widget>
<item row="0" column="6"> </item>
<widget class="QToolButton" name="lang_add"> <item row="0" column="7">
<property name="text"> <widget class="QToolButton" name="lang_del">
<string/> <property name="text">
</property> <string/>
<property name="icon"> </property>
<iconset resource="../core/core.qrc"> <property name="icon">
<normaloff>:/core/icons/ic_nel_add_item.png</normaloff>:/core/icons/ic_nel_add_item.png</iconset> <iconset resource="../core/core.qrc">
</property> <normaloff>:/core/icons/ic_nel_delete_item.png</normaloff>:/core/icons/ic_nel_delete_item.png</iconset>
<property name="autoRaise"> </property>
<bool>true</bool> <property name="autoRaise">
</property> <bool>true</bool>
</widget> </property>
</item> </widget>
<item row="0" column="7"> </item>
<widget class="QToolButton" name="lang_del"> <item row="1" column="0" colspan="4">
<property name="text"> <widget class="QListWidget" name="filter_list"/>
<string/> </item>
</property> <item row="1" column="4" colspan="4">
<property name="icon"> <widget class="QListWidget" name="lang_list"/>
<iconset resource="../core/core.qrc"> </item>
<normaloff>:/core/icons/ic_nel_delete_item.png</normaloff>:/core/icons/ic_nel_delete_item.png</iconset> </layout>
</property> </item>
<property name="autoRaise"> <item row="1" column="0">
<bool>true</bool> <layout class="QGridLayout" name="gridLayout_3">
</property> <item row="0" column="0">
</widget> <widget class="QLabel" name="label_8">
</item> <property name="text">
<item row="1" column="0" colspan="4"> <string>Work directory</string>
<widget class="QListWidget" name="filter_list"/> </property>
</item> </widget>
<item row="1" column="4" colspan="4"> </item>
<widget class="QListWidget" name="lang_list"/> <item row="1" column="0">
</item> <widget class="QLineEdit" name="work_edit"/>
</layout> </item>
</widget> <item row="1" column="1">
<widget class="QWidget" name=""> <widget class="QToolButton" name="work_add">
<property name="geometry"> <property name="text">
<rect> <string>...</string>
<x>0</x> </property>
<y>340</y> </widget>
<width>521</width> </item>
<height>60</height> </layout>
</rect> </item>
</property> <item row="2" 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="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>Translation directory</string> <string>Translation directory</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLineEdit" name="translation_edit"/> <widget class="QLineEdit" name="translation_edit"/>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QToolButton" name="translation_add"> <widget class="QToolButton" name="translation_add">
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </item>
<widget class="QWidget" name=""> </layout>
<property name="geometry"> </widget>
<rect> </item>
<x>0</x> </layout>
<y>270</y>
<width>521</width>
<height>60</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Work directory</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="work_edit"/>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="work_add">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget> </widget>
<resources> <resources>
<include location="../core/core.qrc"/> <include location="../core/core.qrc"/>