diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/CMakeLists.txt
index 0f520c9d8..272c7b962 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/CMakeLists.txt
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/CMakeLists.txt
@@ -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)
SET(OVQT_PLUG_TRANSLATION_MANAGER_HDR translation_manager_plugin.h
- translation_manager_main_window.h
- translation_manager_settings_page.h
- translation_manager_editor.h
- source_selection.h
- ftp_selection.h
- editor_worksheet.h
- editor_phrase.h
- extract_new_sheet_names.h
- extract_bot_names.h)
+ translation_manager_main_window.h
+ translation_manager_settings_page.h
+ translation_manager_editor.h
+ source_selection.h
+ ftp_selection.h
+ editor_worksheet.h
+ editor_phrase.h
+)
SET(OVQT_PLUG_TRANSLATION_MANAGER_UIS translation_manager_settings_page.ui
- translation_manager_main_window.ui
- source_selection.ui
- ftp_selection.ui)
+ translation_manager_main_window.ui
+ source_selection.ui
+ ftp_selection.ui)
SET(OVQT_PLUG_TRANSLATION_MANAGER_RCS ftp_selection.qrc)
SET(QT_USE_QTGUI TRUE)
-SET(QT_USE_QTOPENGL TRUE)
SET(QT_USE_QTNETWORK TRUE)
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})
-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_ADD_RUNTIME_FLAGS(ovqt_plugin_translation_manager)
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_phrase.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_phrase.cpp
index c1633c3be..a1c59a11f 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_phrase.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_phrase.cpp
@@ -1,5 +1,4 @@
// Translation Manager Plugin - OVQT Plugin
-// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Emanuel Costea
//
// 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
// along with this program. If not, see .
+// Project includes
+#include "editor_phrase.h"
+#include "translation_manager_constants.h"
+
// Nel includes
#include "nel/misc/path.h"
#include "nel/misc/diff_tool.h"
// Qt includes
+#include
+#include
+#include
+#include
+#include
#include
-#include
#include
#include
-#include
-#include
-#include
-#include
-#include
-
-// Project includes
-#include "editor_phrase.h"
-#include "translation_manager_constants.h"
using namespace std;
-namespace TranslationManager {
+namespace TranslationManager
+{
void CEditorPhrase::open(QString filename)
{
- vector phrases;
+ std::vector phrases;
if(readPhraseFile(filename.toStdString(), phrases, false))
{
text_edit = new CTextEdit(this);
@@ -53,26 +52,28 @@ void CEditorPhrase::open(QString filename)
QFile file(filename);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream in(&file);
- // set the file content to the text edit
+ // set the file content to the text edit
QString data = in.readAll();
text_edit->append(data);
// window settings
setCurrentFile(filename);
- setAttribute(Qt::WA_DeleteOnClose);
+ setAttribute(Qt::WA_DeleteOnClose);
editor_type = Constants::ED_PHRASE;
current_file = filename;
connect(text_edit->document(), SIGNAL(contentsChanged()), this, SLOT(docContentsChanged()));
connect(text_edit->document(), SIGNAL(undoCommandAdded()), this, SLOT(newUndoCommandAdded()));
- } else {
- QErrorMessage error;
- error.showMessage("This file is not a phrase file.");
- error.exec();
- }
+ }
+ else
+ {
+ QErrorMessage error;
+ error.showMessage("This file is not a phrase file.");
+ error.exec();
+ }
}
void CEditorPhrase::newUndoCommandAdded()
{
- current_stack->push(new CUndoPhraseNewCommand(text_edit));
+ current_stack->push(new CUndoPhraseNewCommand(text_edit));
}
void CEditorPhrase::docContentsChanged()
@@ -97,44 +98,37 @@ void CEditorPhrase::saveAs(QString filename)
QTextStream out(&file);
out.setCodec("UTF-8");
out.setGenerateByteOrderMark(true);
- out<toPlainText();
+ out << text_edit->toPlainText();
current_file = filename;
setCurrentFile(current_file);
}
-
-
void CEditorPhrase::closeEvent(QCloseEvent *event)
{
- if(isWindowModified())
- {
- QMessageBox msgBox;
- msgBox.setText("The document has been modified.");
- msgBox.setInformativeText("Do you want to save your changes?");
- msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
- msgBox.setDefaultButton(QMessageBox::Save);
- int ret = msgBox.exec();
- switch (ret)
- {
- case QMessageBox::Save:
- save();
- event->accept();
- close();
- break;
- case QMessageBox::Discard:
- event->accept();
- close();
- break;
- case QMessageBox::Cancel:
- event->ignore();
- break;
- default:
- break;
- }
- } else {
- event->accept();
- close();
- }
+ if(isWindowModified())
+ {
+ QMessageBox msgBox;
+ msgBox.setIcon(QMessageBox::Question);
+ msgBox.setText(tr("The document has been modified."));
+ msgBox.setInformativeText(tr("Do you want to save your changes?"));
+ msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+ msgBox.setDefaultButton(QMessageBox::Save);
+
+ int ret = msgBox.exec();
+ switch (ret)
+ {
+ case QMessageBox::Save:
+ save();
+ break;
+ case QMessageBox::Discard:
+ break;
+ case QMessageBox::Cancel:
+ event->ignore();
+ return;
+ }
+ }
+ event->accept();
+ close();
}
}
\ No newline at end of file
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_phrase.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_phrase.h
index f26dec73e..b9955fa48 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_phrase.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_phrase.h
@@ -18,6 +18,9 @@
#ifndef EDITOR_PHRASE_H
#define EDITOR_PHRASE_H
+// Project includes
+#include "translation_manager_editor.h"
+
// Qt includes
#include
#include
@@ -32,23 +35,23 @@
#include
#include
-// Project includes
-#include "translation_manager_editor.h"
-
-namespace TranslationManager {
+namespace TranslationManager
+{
class CTextEdit : public QTextEdit
{
Q_OBJECT
+
private:
- QUndoStack* m_undoStack;
+ QUndoStack *m_undoStack;
+
public:
- CTextEdit(QWidget* parent = 0) : QTextEdit(parent)
- {
+ CTextEdit(QWidget *parent = 0) : QTextEdit(parent)
+ {
setUndoRedoEnabled(true);
}
//void keyPressEvent(QKeyEvent *event);
- void setUndoStack(QUndoStack* undoStack)
+ void setUndoStack(QUndoStack *undoStack)
{
m_undoStack = undoStack;
}
@@ -57,20 +60,22 @@ public:
class CEditorPhrase : public CEditor
{
Q_OBJECT
+
public:
- CTextEdit *text_edit;
-public:
- CEditorPhrase(QMdiArea* parent) : CEditor(parent) {}
- CEditorPhrase() : CEditor() {}
- void open(QString filename);
- void save();
- void saveAs(QString filename);
- void activateWindow();
+ CEditorPhrase(QMdiArea *parent) : CEditor(parent) {}
+ CEditorPhrase() : CEditor() {}
+ void open(QString filename);
+ void save();
+ void saveAs(QString filename);
+ void activateWindow();
void closeEvent(QCloseEvent *event);
+
public Q_SLOTS:
void docContentsChanged();
void newUndoCommandAdded();
+private:
+ CTextEdit *text_edit;
};
class CUndoPhraseNewCommand : public QUndoCommand
@@ -79,7 +84,7 @@ public:
CUndoPhraseNewCommand(CTextEdit *textEdit, QUndoCommand *parent = 0)
: QUndoCommand("Inserting/Removing characters", parent),
m_textEdit(textEdit)
- { }
+ {}
~CUndoPhraseNewCommand() {}
@@ -92,96 +97,102 @@ public:
{
m_textEdit->redo();
}
+
private:
- CTextEdit* m_textEdit;
+ CTextEdit *m_textEdit;
};
class SyntaxHighlighter : public QSyntaxHighlighter
{
public:
SyntaxHighlighter(QTextEdit *parent) : QSyntaxHighlighter(parent)
- {
- HighlightingRule rule;
+ {
+ HighlightingRule rule;
- translateStringFormat.setFontWeight(QFont::Bold);
- translateStringFormat.setForeground(Qt::darkMagenta);
- rule.pattern = QRegExp("\\[.+\\]");
- rule.format = translateStringFormat;
- highlightingRules.append(rule);
+ translateStringFormat.setFontWeight(QFont::Bold);
+ translateStringFormat.setForeground(Qt::darkMagenta);
+ rule.pattern = QRegExp("\\[.+\\]");
+ rule.format = translateStringFormat;
+ highlightingRules.append(rule);
+ singleLineCommentFormat.setForeground(Qt::red);
+ rule.pattern = QRegExp("//[^\n]*");
+ rule.format = singleLineCommentFormat;
+ highlightingRules.append(rule);
- singleLineCommentFormat.setForeground(Qt::red);
- rule.pattern = QRegExp("//[^\n]*");
- rule.format = singleLineCommentFormat;
- highlightingRules.append(rule);
+ multiLineCommentFormat.setForeground(Qt::red);
- multiLineCommentFormat.setForeground(Qt::red);
+ quotationFormat.setForeground(Qt::darkGreen);
+ rule.pattern = QRegExp("\".*\"");
+ rule.format = quotationFormat;
+ highlightingRules.append(rule);
- quotationFormat.setForeground(Qt::darkGreen);
- rule.pattern = QRegExp("\".*\"");
- rule.format = quotationFormat;
- highlightingRules.append(rule);
+ functionFormat.setFontItalic(true);
+ functionFormat.setForeground(Qt::blue);
+ rule.pattern = QRegExp("\\(.+\\)");
+ rule.format = functionFormat;
+ highlightingRules.append(rule);
- functionFormat.setFontItalic(true);
- functionFormat.setForeground(Qt::blue);
- rule.pattern = QRegExp("\\(.+\\)");
- rule.format = functionFormat;
- highlightingRules.append(rule);
-
- commentStartExpression = QRegExp("/\\*");
- commentEndExpression = QRegExp("\\*/");
+ commentStartExpression = QRegExp("/\\*");
+ commentEndExpression = QRegExp("\\*/");
}
- void highlightBlock(const QString &text)
- {
- Q_FOREACH(const HighlightingRule &rule, highlightingRules) {
- QRegExp expression(rule.pattern);
- int index = expression.indexIn(text);
- while (index >= 0) {
- int length = expression.matchedLength();
- setFormat(index, length, rule.format);
- index = expression.indexIn(text, index + length);
- }
- }
- setCurrentBlockState(0);
+ void highlightBlock(const QString &text)
+ {
+ Q_FOREACH(const HighlightingRule &rule, highlightingRules)
+ {
+ QRegExp expression(rule.pattern);
+ int index = expression.indexIn(text);
+ while (index >= 0)
+ {
+ int length = expression.matchedLength();
+ setFormat(index, length, rule.format);
+ index = expression.indexIn(text, index + length);
+ }
+ }
+ setCurrentBlockState(0);
- int startIndex = 0;
- if (previousBlockState() != 1)
- startIndex = commentStartExpression.indexIn(text);
+ int startIndex = 0;
+ if (previousBlockState() != 1)
+ startIndex = commentStartExpression.indexIn(text);
- while (startIndex >= 0) {
- int endIndex = commentEndExpression.indexIn(text, startIndex);
- int commentLength;
- if (endIndex == -1) {
- setCurrentBlockState(1);
- commentLength = text.length() - startIndex;
- } else {
- commentLength = endIndex - startIndex
- + commentEndExpression.matchedLength();
- }
- setFormat(startIndex, commentLength, multiLineCommentFormat);
- startIndex = commentStartExpression.indexIn(text, startIndex + commentLength);
- }
- }
+ while (startIndex >= 0)
+ {
+ int endIndex = commentEndExpression.indexIn(text, startIndex);
+ int commentLength;
+ if (endIndex == -1)
+ {
+ setCurrentBlockState(1);
+ commentLength = text.length() - startIndex;
+ }
+ else
+ {
+ commentLength = endIndex - startIndex
+ + commentEndExpression.matchedLength();
+ }
+ setFormat(startIndex, commentLength, multiLineCommentFormat);
+ startIndex = commentStartExpression.indexIn(text, startIndex + commentLength);
+ }
+ }
- private:
- struct HighlightingRule
- {
- QRegExp pattern;
- QTextCharFormat format;
- };
- QVector highlightingRules;
+private:
+ struct HighlightingRule
+ {
+ QRegExp pattern;
+ QTextCharFormat format;
+ };
+ QVector highlightingRules;
- QRegExp commentStartExpression;
- QRegExp commentEndExpression;
+ QRegExp commentStartExpression;
+ QRegExp commentEndExpression;
- QTextCharFormat keywordFormat;
- QTextCharFormat classFormat;
- QTextCharFormat singleLineCommentFormat;
- QTextCharFormat multiLineCommentFormat;
- QTextCharFormat quotationFormat;
- QTextCharFormat functionFormat;
- QTextCharFormat translateStringFormat;
+ QTextCharFormat keywordFormat;
+ QTextCharFormat classFormat;
+ QTextCharFormat singleLineCommentFormat;
+ QTextCharFormat multiLineCommentFormat;
+ QTextCharFormat quotationFormat;
+ QTextCharFormat functionFormat;
+ QTextCharFormat translateStringFormat;
};
}
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.cpp
index c8a101e0f..7041a5178 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.cpp
@@ -15,6 +15,11 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
+// Project includes
+#include "editor_worksheet.h"
+#include "extract_bot_names.h"
+#include "translation_manager_constants.h"
+
// Qt includes
#include
#include
@@ -24,97 +29,103 @@
#include
#include
-// Project includes
-#include "editor_worksheet.h"
-#include "extract_bot_names.h"
-#include "translation_manager_constants.h"
-#include
-
using namespace std;
-namespace TranslationManager {
+namespace TranslationManager
+{
void CEditorWorksheet::open(QString filename)
{
- STRING_MANAGER::TWorksheet wk_file;
- if(loadExcelSheet(filename.toStdString(), wk_file, true) == true)
- {
- bool hasHashValue = false;
- table_editor = new QTableWidget();
- if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
- {
- table_editor->setColumnCount(wk_file.ColCount - 1);
- hasHashValue = true;
- } else {
- table_editor->setColumnCount(wk_file.ColCount);
- }
- table_editor->setRowCount(wk_file.size() - 1);
-
- // read columns name
- for(unsigned int i = 0; i < wk_file.ColCount; i++)
- {
- if(hasHashValue && i == 0)
- {
- // we don't show the column with hash value
- } else {
- QTableWidgetItem *col = new QTableWidgetItem();
- ucstring col_name = wk_file.getData(0, i);
- col->setText(QString(col_name.toString().c_str()));
- if(hasHashValue)
- {
- 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();
- }
-
+ STRING_MANAGER::TWorksheet wk_file;
+ if(loadExcelSheet(filename.toStdString(), wk_file, true) == true)
+ {
+ bool hasHashValue = false;
+ table_editor = new QTableWidget();
+ if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
+ {
+ table_editor->setColumnCount(wk_file.ColCount - 1);
+ hasHashValue = true;
+ }
+ else
+ {
+ table_editor->setColumnCount(wk_file.ColCount);
+ }
+ table_editor->setRowCount(wk_file.size() - 1);
+
+ // read columns name
+ for(uint i = 0; i < wk_file.ColCount; i++)
+ {
+ if(hasHashValue && i == 0)
+ {
+ // we don't show the column with hash value
+ }
+ else
+ {
+ QTableWidgetItem *col = new QTableWidgetItem();
+ ucstring col_name = wk_file.getData(0, i);
+ col->setText(QString(col_name.toString().c_str()));
+ if(hasHashValue)
+ {
+ 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(tr("This file is not a worksheet file."));
+ error.exec();
+ }
}
void CEditorWorksheet::contextMenuEvent(QContextMenuEvent *e)
{
- QAction *insertRowAct = new QAction("Insert new row", this);
- connect(insertRowAct, SIGNAL(triggered()), this, SLOT(insertRow()));
- QAction *deleteRowAct = new QAction("Delete row", this);
- connect(deleteRowAct, SIGNAL(triggered()), this, SLOT(deleteRow()));
+ QAction *insertRowAct = new QAction(tr("Insert new row"), this);
+ connect(insertRowAct, SIGNAL(triggered()), this, SLOT(insertRow()));
+ QAction *deleteRowAct = new QAction(tr("Delete row"), this);
+ connect(deleteRowAct, SIGNAL(triggered()), this, SLOT(deleteRow()));
QMenu *contextMenu = new QMenu(this);
contextMenu->addAction(insertRowAct);
@@ -127,7 +138,7 @@ void CEditorWorksheet::contextMenuEvent(QContextMenuEvent *e)
void CEditorWorksheet::activateWindow()
{
- showMaximized();
+ showMaximized();
}
void CEditorWorksheet::save()
@@ -137,372 +148,377 @@ void CEditorWorksheet::save()
void CEditorWorksheet::saveAs(QString filename)
{
- STRING_MANAGER::TWorksheet new_file, wk_file;
- loadExcelSheet(current_file.toStdString(), wk_file, true);
- // set columns
- new_file.resize(new_file.size() + 1);
- for(unsigned int i = 0; i < wk_file.ColCount; i++)
- {
- ucstring col_name = wk_file.getData(0, i);
- new_file.insertColumn(new_file.ColCount);
- new_file.setData(0, new_file.ColCount - 1, col_name);
- }
- // read all the rows from table
- uint rowIdx;
- uint colIdx = 0;
- bool hasHashValue = false;
- if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
- {
- hasHashValue = true;
- colIdx = 1;
- }
- for(int i = 0; i < table_editor->rowCount(); i++)
- {
- rowIdx = new_file.size();
- new_file.resize(new_file.size() + 1);
- ucstring tvalue;
- for(int j = 0; j < table_editor->columnCount(); j++)
- {
- QTableWidgetItem* item = table_editor->item(i, j);
- tvalue.fromUtf8(std::string(item->text().toUtf8()));
- new_file.setData(rowIdx, j + colIdx, tvalue);
- }
- }
- if(hasHashValue)
- {
- // rewrite the hash codes
- makeHashCode(wk_file, true);
- }
- ucstring s = prepareExcelSheet(new_file);
- NLMISC::CI18N::writeTextFile(filename.toStdString(), s, false);
- current_file = filename;
- setCurrentFile(filename);
+ STRING_MANAGER::TWorksheet new_file, wk_file;
+ loadExcelSheet(current_file.toStdString(), wk_file, true);
+ // set columns
+ new_file.resize(new_file.size() + 1);
+ for(unsigned int i = 0; i < wk_file.ColCount; i++)
+ {
+ ucstring col_name = wk_file.getData(0, i);
+ new_file.insertColumn(new_file.ColCount);
+ new_file.setData(0, new_file.ColCount - 1, col_name);
+ }
+ // read all the rows from table
+ uint rowIdx;
+ uint colIdx = 0;
+ bool hasHashValue = false;
+ if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
+ {
+ hasHashValue = true;
+ colIdx = 1;
+ }
+ for(int i = 0; i < table_editor->rowCount(); i++)
+ {
+ rowIdx = new_file.size();
+ new_file.resize(new_file.size() + 1);
+ ucstring tvalue;
+ for(int j = 0; j < table_editor->columnCount(); j++)
+ {
+ QTableWidgetItem *item = table_editor->item(i, j);
+ tvalue.fromUtf8(std::string(item->text().toUtf8()));
+ new_file.setData(rowIdx, j + colIdx, tvalue);
+ }
+ }
+ if(hasHashValue)
+ {
+ // rewrite the hash codes
+ makeHashCode(wk_file, true);
+ }
+ ucstring s = prepareExcelSheet(new_file);
+ NLMISC::CI18N::writeTextFile(filename.toStdString(), s, false);
+ current_file = filename;
+ setCurrentFile(filename);
}
void CEditorWorksheet::insertRow()
{
- int last_row = table_editor->rowCount();
+ int last_row = table_editor->rowCount();
current_stack->push(new CUndoWorksheetNewCommand(table_editor, last_row));
}
void CEditorWorksheet::deleteRow()
{
- int selected_row = table_editor->currentRow();
- QMessageBox msgBox;
- msgBox.setText(tr("The row will be deleted."));
- msgBox.setInformativeText(tr("Do you want to delete the selected row ?"));
- msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
- msgBox.setDefaultButton(QMessageBox::No);
- int ret = msgBox.exec();
- if(ret == QMessageBox::Yes)
- {
- current_stack->push(new CUndoWorksheetDeleteCommand(table_editor, selected_row));
- }
+ int selected_row = table_editor->currentRow();
+ QMessageBox msgBox;
+ msgBox.setIcon(QMessageBox::Question);
+ msgBox.setText(tr("The row will be deleted."));
+ msgBox.setInformativeText(tr("Do you want to delete the selected row ?"));
+ msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
+ msgBox.setDefaultButton(QMessageBox::No);
- table_editor->clearFocus();
- table_editor->clearSelection();
- return;
+ int ret = msgBox.exec();
+ if(ret == QMessageBox::Yes)
+ {
+ 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();
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())
{
//current_stack->push(new CUndoWorksheetCommand(table_editor, item, temp_content));
}
- if(!isWindowModified())
- setWindowModified(true);
+ if(!isWindowModified())
+ setWindowModified(true);
}
void CEditorWorksheet::extractBotNames(list filters, string level_design_path, NLLIGO::CLigoConfig ligoConfig)
{
- bool modified = false;
+ bool modified = false;
QList new_items;
- ExtractBotNames ebn;
- ebn.setRequiredSettings(filters, level_design_path);
- ebn.extractBotNamesFromPrimitives(ligoConfig);
- // get SimpleNames
- {
- map SimpleNames = ebn.getSimpleNames();
- map::iterator it(SimpleNames.begin()), last(SimpleNames.end());
+ ExtractBotNames ebn;
+ ebn.setRequiredSettings(filters, level_design_path);
+ ebn.extractBotNamesFromPrimitives(ligoConfig);
+ // get SimpleNames
+ {
+ map SimpleNames = ebn.getSimpleNames();
+ map::iterator it(SimpleNames.begin()), last(SimpleNames.end());
+
+ for (; it != last; ++it)
+ {
+ QList search_results = table_editor->findItems(QString(it->first.c_str()), Qt::MatchExactly);
+ if(search_results.size() == 0)
+ {
+ QList records;
+ 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()));
+ insertTableRecords(records, new_items);
+ if(!modified) modified = true;
+ }
+ }
+ ebn.cleanSimpleNames();
+ }
+ // get GenericNames
+ {
+ set GenericNames = ebn.getGenericNames();
+ set::iterator it(GenericNames.begin()), last(GenericNames.end());
+ for (; it != last; ++it)
+ {
+ string gnName = "gn_" + ebn.cleanupName(*it);
+ QList search_results = table_editor->findItems(QString((*it).c_str()), Qt::MatchExactly);
+ if(search_results.size() == 0)
+ {
+ QList records;
+ records.push_back(QString((*it).c_str()));
+ records.push_back(QString(gnName.c_str()));
+ records.push_back(" ");
+ insertTableRecords(records, new_items);
+ if(!modified) modified = true;
+ }
+ }
+ ebn.cleanGenericNames();
+ }
+
+ current_stack->push(new CUndoWorksheetExtraction(new_items, table_editor));
+ if(modified)
+ {
+ setWindowModified(true);
+ table_editor->scrollToBottom();
+ }
- for (; it != last; ++it)
- {
- QList search_results = table_editor->findItems(QString(it->first.c_str()), Qt::MatchExactly);
- if(search_results.size() == 0)
- {
- QList records;
- 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()));
- insertTableRecords(records, new_items);
- if(!modified) modified = true;
- }
- }
- ebn.cleanSimpleNames();
- }
- // get GenericNames
- {
- set GenericNames = ebn.getGenericNames();
- set::iterator it(GenericNames.begin()), last(GenericNames.end());
- for (; it != last; ++it)
- {
- string gnName = "gn_" + ebn.cleanupName(*it);
- QList search_results = table_editor->findItems(QString((*it).c_str()), Qt::MatchExactly);
- if(search_results.size() == 0)
- {
- QList records;
- records.push_back(QString((*it).c_str()));
- records.push_back(QString(gnName.c_str()));
- records.push_back(" ");
- insertTableRecords(records, new_items);
- if(!modified) modified = true;
- }
- }
- ebn.cleanGenericNames();
- }
-
- current_stack->push(new CUndoWorksheetExtraction(new_items, table_editor));
- if(modified)
- {
- setWindowModified(true);
- 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
- TWorksheet workSheet;
+ STRING_MANAGER::TWorksheet workSheet;
if(!loadExcelSheet(filename.toStdString(), workSheet, true))
{
nlwarning("Error reading '%s'. Aborted", filename.toStdString().c_str());
return;
}
// get the key column index
- uint keyColIndex = 0;
+ uint keyColIndex = 0;
if(!workSheet.findCol(columnId.toStdString(), keyColIndex))
{
nlwarning("Error: Don't find the column '%s'. '%s' Aborted", columnId.toStdString().c_str(), filename.toStdString().c_str());
return;
}
// get the name column index
- uint nameColIndex;
+ uint nameColIndex;
if(!workSheet.findCol(ucstring("name"), nameColIndex))
{
nlwarning("Error: Don't find the column 'name'. '%s' Aborted", filename.toStdString().c_str());
return;
- }
-
- // **** List all words with the builder given
- std::vector allWords;
- if(!wordListBuilder.buildWordList(allWords, filename.toStdString()))
- {
- return;
- }
- bool modified = false;
- QList new_items;
- for(i = 0; i < allWords.size(); i++)
- {
- string keyName = allWords[i];
- QList search_results = table_editor->findItems(QString(keyName.c_str()), Qt::MatchExactly);
- if(search_results.size() == 0)
- {
- int knPos = 0, nPos = 0;
- if(workSheet.getData(0, 0) == ucstring("*HASH_VALUE"))
- {
- knPos = keyColIndex - 1;
- nPos = nameColIndex - 1;
- } else {
- knPos = keyColIndex;
- nPos = nameColIndex;
- }
+ }
- QList records;
- records.push_back(QString(keyName.c_str()));
- records.push_back(QString("") + QString(keyName.c_str()));
- insertTableRecords(records, new_items);
- if(!modified) modified = true;
- }
- }
- current_stack->push(new CUndoWorksheetExtraction(new_items, table_editor));
- if(modified)
- {
- setWindowModified(true);
- table_editor->scrollToBottom();
- }
+ // **** List all words with the builder given
+ std::vector allWords;
+ if(!wordListBuilder.buildWordList(allWords, filename.toStdString()))
+ {
+ return;
+ }
+ bool modified = false;
+ QList new_items;
+ for(i = 0; i < allWords.size(); i++)
+ {
+ string keyName = allWords[i];
+ QList search_results = table_editor->findItems(QString(keyName.c_str()), Qt::MatchExactly);
+ if(search_results.size() == 0)
+ {
+ int knPos = 0, nPos = 0;
+ if(workSheet.getData(0, 0) == ucstring("*HASH_VALUE"))
+ {
+ knPos = keyColIndex - 1;
+ nPos = nameColIndex - 1;
+ }
+ else
+ {
+ knPos = keyColIndex;
+ nPos = nameColIndex;
+ }
+
+ QList records;
+ records.push_back(QString(keyName.c_str()));
+ records.push_back(QString("") + QString(keyName.c_str()));
+ insertTableRecords(records, new_items);
+ if(!modified) modified = true;
+ }
+ }
+ current_stack->push(new CUndoWorksheetExtraction(new_items, table_editor));
+ if(modified)
+ {
+ setWindowModified(true);
+ table_editor->scrollToBottom();
+ }
}
void CEditorWorksheet::insertTableRecords(QList records, QList new_items)
{
- const int currentRow = table_editor->rowCount();
+ const int currentRow = table_editor->rowCount();
table_editor->setRowCount(currentRow + 1);
int n = 0;
Q_FOREACH(QString record, records)
{
QTableWidgetItem *rec = new QTableWidgetItem();
rec->setBackgroundColor(QColor("#F75D59"));
- table_editor ->setItem(currentRow, n, rec);
+ table_editor ->setItem(currentRow, n, rec);
CTableWidgetItemStore rec_s(rec, currentRow, n);
new_items.push_back(rec_s);
n++;
}
-
}
bool CEditorWorksheet::compareWorksheetFile(QString filename)
{
- STRING_MANAGER::TWorksheet wk_file;
- int colIndex = 0;
- if(loadExcelSheet(filename.toStdString(), wk_file, true) == true)
- {
- if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
- {
- colIndex = 1;
- }
- if(wk_file.ColCount - colIndex != table_editor->columnCount())
- {
- return false;
- }
- for(int i = 0; i < table_editor->columnCount(); i++)
- {
- QString item = table_editor->horizontalHeaderItem(i)->text();
- ucstring itemC = wk_file.getData(0, i+ colIndex);
- if(item.toStdString() != itemC.toString())
- {
- nlwarning(item.toStdString().c_str());
- nlwarning(itemC.toString().c_str());
- return false;
- }
- }
- } else {
- return false;
- }
-
- return true;
+ STRING_MANAGER::TWorksheet wk_file;
+ int colIndex = 0;
+ if(loadExcelSheet(filename.toStdString(), wk_file, true) == true)
+ {
+ if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
+ {
+ colIndex = 1;
+ }
+ if(wk_file.ColCount - colIndex != table_editor->columnCount())
+ {
+ return false;
+ }
+ for(int i = 0; i < table_editor->columnCount(); i++)
+ {
+ QString item = table_editor->horizontalHeaderItem(i)->text();
+ ucstring itemC = wk_file.getData(0, i+ colIndex);
+ if(item.toStdString() != itemC.toString())
+ {
+ nlwarning(item.toStdString().c_str());
+ nlwarning(itemC.toString().c_str());
+ return false;
+ }
+ }
+ }
+ else
+ {
+ return false;
+ }
+ return true;
}
void CEditorWorksheet::mergeWorksheetFile(QString filename)
{
- STRING_MANAGER::TWorksheet wk_file;
- if(loadExcelSheet(filename.toStdString(), wk_file, true) == true)
- {
- bool hasHashValue = false;
- int colIndex = 0;
- if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
- {
- hasHashValue = true;
- colIndex = 1;
- }
- // read rows
- for(unsigned int i = 1; i < wk_file.size(); i++)
- {
- // search with the first column
- ucstring rowId = wk_file.getData(i,colIndex);
- QList search_results = table_editor->findItems(QString(rowId.toString().c_str()), Qt::MatchExactly);
- if(search_results.size() == 0)
- {
- const int lastRow = table_editor->rowCount();
- table_editor->setRowCount(lastRow + 1);
- for(unsigned int j = 0; j < table_editor->columnCount(); j++)
- {
- ucstring rowValue = wk_file.getData(i, j + colIndex); // get the value
- QTableWidgetItem *row = new QTableWidgetItem();
- row->setText(QString(rowValue.toString().c_str())); // set the value in table item
- table_editor->setItem(lastRow, j, row);
- }
- }
- }
- } else {
- QErrorMessage error;
- error.showMessage(tr("This file is not a worksheet file."));
- error.exec();
- }
+ STRING_MANAGER::TWorksheet wk_file;
+ if(loadExcelSheet(filename.toStdString(), wk_file, true) == true)
+ {
+ bool hasHashValue = false;
+ int colIndex = 0;
+ if(wk_file.getData(0, 0) == ucstring("*HASH_VALUE"))
+ {
+ hasHashValue = true;
+ colIndex = 1;
+ }
+ // read rows
+ for(unsigned int i = 1; i < wk_file.size(); i++)
+ {
+ // search with the first column
+ ucstring rowId = wk_file.getData(i,colIndex);
+ QList search_results = table_editor->findItems(QString(rowId.toString().c_str()), Qt::MatchExactly);
+ if(search_results.size() == 0)
+ {
+ const int lastRow = table_editor->rowCount();
+ table_editor->setRowCount(lastRow + 1);
+ for(int j = 0; j < table_editor->columnCount(); j++)
+ {
+ ucstring rowValue = wk_file.getData(i, j + colIndex); // get the value
+ QTableWidgetItem *row = new QTableWidgetItem();
+ row->setText(QString(rowValue.toString().c_str())); // set the value in table item
+ table_editor->setItem(lastRow, j, row);
+ }
+ }
+ }
+ }
+ else
+ {
+ QErrorMessage error;
+ error.showMessage(tr("This file is not a worksheet file."));
+ error.exec();
+ }
}
void CEditorWorksheet::closeEvent(QCloseEvent *event)
{
- if(isWindowModified())
- {
- QMessageBox msgBox;
- msgBox.setText(tr("The document has been modified."));
- msgBox.setInformativeText(tr("Do you want to save your changes?"));
- msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
- msgBox.setDefaultButton(QMessageBox::Save);
- int ret = msgBox.exec();
- switch (ret)
- {
- case QMessageBox::Save:
- save();
- event->accept();
- close();
- break;
- case QMessageBox::Discard:
- event->accept();
- close();
- break;
- case QMessageBox::Cancel:
- event->ignore();
- break;
- default:
- break;
- }
- } else {
- event->accept();
- close();
- }
+ if(isWindowModified())
+ {
+ QMessageBox msgBox;
+ msgBox.setIcon(QMessageBox::Question);
+ msgBox.setText(tr("The document has been modified."));
+ msgBox.setInformativeText(tr("Do you want to save your changes?"));
+ msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+ msgBox.setDefaultButton(QMessageBox::Save);
+ int ret = msgBox.exec();
+ switch (ret)
+ {
+ case QMessageBox::Save:
+ save();
+ break;
+ case QMessageBox::Discard:
+ break;
+ case QMessageBox::Cancel:
+ event->ignore();
+ return;
+ }
+ }
+ event->accept();
+ close();
}
bool CEditorWorksheet::isBotNamesTable()
{
- bool status = true;
- if(table_editor->horizontalHeaderItem(0)->text() != "bot name"
- || table_editor->horizontalHeaderItem(1)->text() != "translated name"
- || table_editor->horizontalHeaderItem(2)->text() != "sheet_name")
- {
- status = false;
- }
-
- return status;
+ bool status = true;
+ if(table_editor->horizontalHeaderItem(0)->text() != "bot name"
+ || table_editor->horizontalHeaderItem(1)->text() != "translated name"
+ || table_editor->horizontalHeaderItem(2)->text() != "sheet_name")
+ {
+ status = false;
+ }
+ return status;
}
bool CEditorWorksheet::isSheetTable(QString type)
{
- QString column_name;
- if(type.toAscii() == Constants::WK_ITEM)
- {
- column_name = "item ID";
- } else if(type.toAscii() == Constants::WK_CREATURE) {
- column_name = "creature ID";
- } else if(type.toAscii() == Constants::WK_SBRICK) {
- column_name = "sbrick ID";
- } else if(type.toAscii() == Constants::WK_SPHRASE) {
- column_name = "sphrase ID";
- } else if(type.toAscii() == Constants::WK_PLACE) {
- column_name = "placeId";
- }
- bool status = true;
- if(table_editor->horizontalHeaderItem(0)->text() != column_name
- || table_editor->horizontalHeaderItem(1)->text() != "name")
- {
- status = false;
- }
-
- return status;
+ QString column_name;
+ if(type.toAscii() == Constants::WK_ITEM)
+ {
+ column_name = "item ID";
+ }
+ else if(type.toAscii() == Constants::WK_CREATURE)
+ {
+ column_name = "creature ID";
+ }
+ else if(type.toAscii() == Constants::WK_SBRICK)
+ {
+ column_name = "sbrick ID";
+ }
+ else if(type.toAscii() == Constants::WK_SPHRASE)
+ {
+ column_name = "sphrase ID";
+ }
+ else if(type.toAscii() == Constants::WK_PLACE)
+ {
+ column_name = "placeId";
+ }
+ bool status = true;
+ if(table_editor->horizontalHeaderItem(0)->text() != column_name
+ || table_editor->horizontalHeaderItem(1)->text() != "name")
+ {
+ status = false;
+ }
+ return status;
}
}
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.h
index 487a9eea8..b60c7a534 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.h
@@ -18,6 +18,10 @@
#ifndef EDITOR_WORKSHEET_H
#define EDITOR_WORKSHEET_H
+// Project includes
+#include "translation_manager_editor.h"
+#include "extract_new_sheet_names.h"
+
// Nel includes
#include "nel/misc/types_nl.h"
#include "nel/misc/sheet_id.h"
@@ -34,11 +38,9 @@
#include
#include
-// Project includes
-#include "translation_manager_editor.h"
-#include "extract_new_sheet_names.h"
-namespace TranslationManager {
+namespace TranslationManager
+{
struct CTableWidgetItemStore
{
@@ -47,6 +49,7 @@ public:
m_item(item),
m_row(row),
m_column(column) { }
+
QTableWidgetItem *m_item;
int m_row;
int m_column;
@@ -54,39 +57,41 @@ public:
class CEditorWorksheet : public CEditor
{
- Q_OBJECT
-private:
- QString temp_content;
+ Q_OBJECT
+
public:
- CEditorWorksheet(QMdiArea* parent) : CEditor(parent) {}
- CEditorWorksheet() : CEditor() {}
- QTableWidget* table_editor;
- void open(QString filename);
- void save();
- void saveAs(QString filename);
- void activateWindow();
- void mergeWorksheetFile(QString filename);
- bool compareWorksheetFile(QString filename);
- void extractBotNames(list filters, string level_design_path, NLLIGO::CLigoConfig ligoConfig);
- void extractWords(QString filename, QString columnId, IWordListBuilder &wordListBuilder);
+ CEditorWorksheet(QMdiArea *parent) : CEditor(parent) {}
+ CEditorWorksheet() : CEditor() {}
+ QTableWidget *table_editor;
+ void open(QString filename);
+ void save();
+ void saveAs(QString filename);
+ void activateWindow();
+ void mergeWorksheetFile(QString filename);
+ bool compareWorksheetFile(QString filename);
+ void extractBotNames(std::list filters, std::string level_design_path, NLLIGO::CLigoConfig ligoConfig);
+ void extractWords(QString filename, QString columnId, IWordListBuilder &wordListBuilder);
void insertTableRecords(QList records, QList new_items);
- bool isBotNamesTable();
- bool isSheetTable(QString type);
- void closeEvent(QCloseEvent *event);
+ bool isBotNamesTable();
+ bool isSheetTable(QString type);
+ void closeEvent(QCloseEvent *event);
+
private Q_SLOTS:
- void worksheetEditorCellEntered(QTableWidgetItem * item);
- void worksheetEditorChanged(QTableWidgetItem * item);
- void insertRow();
- void deleteRow();
+ void worksheetEditorCellEntered(QTableWidgetItem *item);
+ void worksheetEditorChanged(QTableWidgetItem *item);
+ void insertRow();
+ void deleteRow();
void contextMenuEvent(QContextMenuEvent *e);
-
+
+private:
+ QString temp_content;
};
class CUndoWorksheetCommand : public QUndoCommand
{
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;
}
@@ -98,16 +103,16 @@ public:
}
}
void undo()
- {
+ {
if(m_item->text() != m_ocontent)
{
m_ccontent = m_item->text();
}
m_item->setText(m_ocontent);
- }
+ }
private:
- QTableWidget* m_table;
- QTableWidgetItem* m_item;
+ QTableWidget *m_table;
+ QTableWidgetItem *m_item;
QString m_ocontent;
QString m_ccontent;
};
@@ -123,7 +128,7 @@ public:
m_table->setRowCount(m_rowID + 1);
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->scrollToBottom();
}
@@ -133,16 +138,16 @@ public:
{
m_table->removeRow(m_rowID);
}
-private:
- QTableWidget* m_table;
- int m_rowID;
+private:
+ QTableWidget *m_table;
+ int m_rowID;
};
class CUndoWorksheetExtraction : public QUndoCommand
{
public:
- CUndoWorksheetExtraction(QList items, QTableWidget *table, QUndoCommand *parent = 0) : QUndoCommand("Word extraction", parent),
+ CUndoWorksheetExtraction(QList items, QTableWidget *table, QUndoCommand *parent = 0) : QUndoCommand("Word extraction", parent),
m_items(items),
m_table(table)
{ }
@@ -153,7 +158,6 @@ public:
{
m_table->setItem(is.m_row, is.m_column, is.m_item);
}
-
}
void undo()
@@ -161,14 +165,13 @@ public:
Q_FOREACH(CTableWidgetItemStore is, m_items)
{
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:
QList m_items;
- QTableWidget* m_table;
+ QTableWidget *m_table;
};
class CUndoWorksheetDeleteCommand : public QUndoCommand
@@ -181,8 +184,8 @@ public:
{
for(int i = 0; i < m_table->columnCount(); i++)
{
- QTableWidgetItem* item = new QTableWidgetItem();
- QTableWidgetItem* table_item = m_table->item(m_rowID, i);
+ QTableWidgetItem *item = new QTableWidgetItem();
+ QTableWidgetItem *table_item = m_table->item(m_rowID, i);
item->setText(table_item->text());
m_deletedItems.push_back(item);
}
@@ -203,8 +206,8 @@ public:
}
private:
- QList m_deletedItems;
- QTableWidget* m_table;
+ QList m_deletedItems;
+ QTableWidget *m_table;
int m_rowID;
};
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.cpp
index e8ed68bbf..ee65ca73c 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.cpp
@@ -17,18 +17,14 @@
#include "extract_bot_names.h"
-
static bool RemoveOlds = false;
-
-
-
namespace TranslationManager
{
TCreatureInfo *ExtractBotNames::getCreature(const std::string &sheetName)
{
- CSheetId id(sheetName+".creature");
+ NLMISC::CSheetId id(sheetName+".creature");
if (Creatures.find(id) != Creatures.end())
return &(Creatures.find(id)->second);
@@ -36,18 +32,17 @@ TCreatureInfo *ExtractBotNames::getCreature(const std::string &sheetName)
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= 2)
{
- if ( *ret.begin() == ucchar('$'))
+ if (*ret.begin() == ucchar('$'))
{
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);
- return ret;
+ return ret;
}
-
-
-
-
-set ExtractBotNames::getGenericNames()
+std::set ExtractBotNames::getGenericNames()
{
- return GenericNames;
+ return GenericNames;
}
-map ExtractBotNames::getSimpleNames()
+std::map ExtractBotNames::getSimpleNames()
{
- return SimpleNames;
+ return SimpleNames;
}
void ExtractBotNames::cleanSimpleNames()
-{
- SimpleNames.clear();
+{
+ SimpleNames.clear();
}
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("$");
- if (pos == string::npos)
+ std::string::size_type pos = fullName.find("$");
+ if (pos == std::string::npos)
+ {
return fullName;
+ }
else
{
// extract and store the function name
- string ret;
+ std::string ret;
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())
{
nldebug("Adding function '%s'", fct.c_str());
Functions.insert(fct);
}
-
return ret;
}
}
-
void ExtractBotNames::addGenericName(const std::string &name, const std::string &sheetName)
{
TCreatureInfo *c = getCreature(sheetName);
if (!c || c->ForceSheetName || !c->DisplayName)
return;
-
+
if (SimpleNames.find(name) != SimpleNames.end())
{
nldebug("Name '%s' is now a generic name", name.c_str());
@@ -177,7 +167,7 @@ void ExtractBotNames::addSimpleName(const std::string &name, const std::string &
else
{
nldebug("Adding simple name '%s'", name.c_str());
-
+
TEntryInfo ei;
ei.SheetName = sheetName;
@@ -185,75 +175,72 @@ void ExtractBotNames::addSimpleName(const std::string &name, const std::string &
}
}
-void ExtractBotNames::setRequiredSettings(list filters, string level_design_path)
+void ExtractBotNames::setRequiredSettings(std::list filters, std::string level_design_path)
{
- for (std::list::iterator it = filters.begin(); it != filters.end(); ++it)
+ for (std::list::iterator it = filters.begin(); it != filters.end(); ++it)
{
Filters.push_back(*it);
}
//-------------------------------------------------------------------
// init the sheets
- CSheetId::init(false);
- const string PACKED_SHEETS_NAME = "bin/translation_tools_creature.packed_sheets";
+ NLMISC::CSheetId::init(false);
+ const std::string PACKED_SHEETS_NAME = "bin/translation_tools_creature.packed_sheets";
loadForm("creature", PACKED_SHEETS_NAME, Creatures, false, false);
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,
// first, read the primitives files and parse the primitives
- vector files;
- CPath::getFileList("primitive", files);
-
+ std::vector files;
+ NLMISC::CPath::getFileList("primitive", files);
for (uint i=0; i ps;
+ NLLIGO::CPrimitiveSet ps;
ps.buildSet(primDoc.RootNode, pred, result);
- for (uint i=0; igetPropertyByName("name", name);
result[i]->getPropertyByName("count", countStr);
result[i]->getPropertyByName("bot_sheet_look", sheetStr);
@@ -276,16 +263,16 @@ void ExtractBotNames::extractBotNamesFromPrimitives(CLigoConfig ligoConfig)
}
// look for bot template
{
- TPrimitiveClassPredicate pred("bot_template_npc");
- TPrimitiveSet result;
+ NLLIGO::TPrimitiveClassPredicate pred("bot_template_npc");
+ NLLIGO::TPrimitiveSet result;
- CPrimitiveSet ps;
+ NLLIGO::CPrimitiveSet ps;
ps.buildSet(primDoc.RootNode, pred, result);
- for (uint i=0; igetPropertyByName("name", name);
result[i]->getPropertyByName("sheet_look", sheetStr);
@@ -305,19 +292,19 @@ void ExtractBotNames::extractBotNamesFromPrimitives(CLigoConfig ligoConfig)
}
}
}
- // look for npc_group
+ // look for npc_group
{
- TPrimitiveClassPredicate pred("npc_group");
- TPrimitiveSet result;
+ NLLIGO::TPrimitiveClassPredicate pred("npc_group");
+ NLLIGO::TPrimitiveSet result;
- CPrimitiveSet ps;
+ NLLIGO::CPrimitiveSet ps;
ps.buildSet(primDoc.RootNode, pred, result);
- for (uint i=0; igetPropertyByName("name", name);
result[i]->getPropertyByName("count", countStr);
result[i]->getPropertyByName("bot_sheet_client", sheetStr);
@@ -342,18 +329,18 @@ void ExtractBotNames::extractBotNamesFromPrimitives(CLigoConfig ligoConfig)
}
}
}
- // look for bot
+ // look for bot
{
- TPrimitiveClassPredicate pred("npc_bot");
- TPrimitiveSet result;
+ NLLIGO::TPrimitiveClassPredicate pred("npc_bot");
+ NLLIGO::TPrimitiveSet result;
- CPrimitiveSet ps;
+ NLLIGO::CPrimitiveSet ps;
ps.buildSet(primDoc.RootNode, pred, result);
- for (uint i=0; igetPropertyByName("name", name);
result[i]->getPropertyByName("sheet_client", sheetStr);
@@ -373,7 +360,7 @@ void ExtractBotNames::extractBotNamesFromPrimitives(CLigoConfig ligoConfig)
}
}
}
- }
+ }
}
-
+
}
\ No newline at end of file
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.h
index df1cb39ca..208b4db5c 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.h
@@ -30,22 +30,16 @@
#include "nel/ligo/primitive.h"
#include "nel/ligo/primitive_utils.h"
-using namespace std;
-using namespace NLMISC;
-using namespace NLLIGO;
-using namespace STRING_MANAGER;
-
namespace TranslationManager
{
struct TCreatureInfo
{
- CSheetId SheetId;
- bool ForceSheetName;
- bool DisplayName;
+ NLMISC::CSheetId SheetId;
+ bool ForceSheetName;
+ bool DisplayName;
-
- void readGeorges (const NLMISC::CSmartPtr &form, const NLMISC::CSheetId &sheetId)
+ void readGeorges(const NLMISC::CSmartPtr &form, const NLMISC::CSheetId &sheetId)
{
const NLGEORGES::UFormElm &item=form->getRootNode();
@@ -61,51 +55,45 @@ struct TCreatureInfo
f.serial(DisplayName);
}
-
- static uint getVersion ()
- {
+ static uint getVersion ()
+ {
return 1;
}
void removed()
{
}
-
};
struct TEntryInfo
{
- string SheetName;
+ std::string SheetName;
};
struct ExtractBotNames
{
private:
- vector Filters;
- std::map Creatures;
- set GenericNames;
- map SimpleNames;
- set Functions;
+ std::vector Filters;
+ std::map Creatures;
+ std::set GenericNames;
+ std::map SimpleNames;
+ std::set Functions;
private:
- TCreatureInfo *getCreature(const std::string &sheetName);
- ucstring makeGroupName(const ucstring & translationName);
- string removeAndStoreFunction(const std::string &fullName);
- void addGenericName(const std::string &name, const std::string &sheetName);
- void addSimpleName(const std::string &name, const std::string &sheetName);
+ TCreatureInfo *getCreature(const std::string &sheetName);
+ ucstring makeGroupName(const ucstring &translationName);
+ std::string removeAndStoreFunction(const std::string &fullName);
+ void addGenericName(const std::string &name, const std::string &sheetName);
+ void addSimpleName(const std::string &name, const std::string &sheetName);
public:
- void extractBotNamesFromPrimitives(CLigoConfig ligoConfig);
- void setRequiredSettings(list filters, string level_design_path);
- set getGenericNames();
- map getSimpleNames();
- string cleanupName(const std::string &name);
- ucstring cleanupUcName(const ucstring &name);
- void cleanSimpleNames();
- void cleanGenericNames();
-
+ void extractBotNamesFromPrimitives(NLLIGO::CLigoConfig ligoConfig);
+ void setRequiredSettings(std::list filters, std::string level_design_path);
+ std::set getGenericNames();
+ std::map getSimpleNames();
+ std::string cleanupName(const std::string &name);
+ ucstring cleanupUcName(const ucstring &name);
+ void cleanSimpleNames();
+ void cleanGenericNames();
};
-
}
-
-#endif /* EXTRACT_BOT_NAMES_H */
-
+#endif /* EXTRACT_BOT_NAMES_H */
\ No newline at end of file
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.cpp
index 5d0b9b455..984f86d17 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.cpp
@@ -16,139 +16,135 @@
#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
*/
-
-bool CSheetWordListBuilder::buildWordList(std::vector &allWords, string workSheetFileName)
+bool CSheetWordListBuilder::buildWordList(std::vector &allWords, std::string workSheetFileName)
+{
+ SheetExt = NLMISC::toLower(SheetExt);
+ // verify the directory is correct
+ if(!NLMISC::CFile::isDirectory(SheetPath))
{
- SheetExt= toLower(SheetExt);
- // verify the directory is correct
- 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 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;
+ 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
*/
-bool CRegionPrimWordListBuilder::buildWordList(std::vector &allWords, string workSheetFileName)
+bool CRegionPrimWordListBuilder::buildWordList(std::vector &allWords, std::string workSheetFileName)
+{
+ // verify the directory is correct
+ if(!NLMISC::CFile::isDirectory(PrimPath))
{
- // verify the directory is correct
- if(!CFile::isDirectory(PrimPath))
+ nlwarning("Error: Directory '%s' not found. '%s' Aborted", PrimPath.c_str(), workSheetFileName.c_str());
+ return false;
+ }
+
+ // list all files.
+ std::vector 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 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;
}
-
- // list all files.
- std::vector allFiles;
- allFiles.reserve(100000);
- CPath::getPathContent(PrimPath, true, false, true, allFiles, NULL);
-
- // parse all primitive that match the filter
- allWords.clear();
- allWords.reserve(100000);
- // to avoid duplicate
- set allWordSet;
- for(uint i=0;i setPlace;
+ NLLIGO::TPrimitiveSet placeRes;
+ setPlace.buildSet(PrimDoc.RootNode, predCont, placeRes);
+
+ // for all found
+ for (size_t placeId = 0; placeId < placeRes.size(); ++placeId)
{
- nlwarning("Error: cannot open file '%s'. '%s' Aborted", allFiles[i].c_str(), workSheetFileName.c_str());
- CPrimitiveContext::instance().CurrentPrimitive = NULL;
- 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 setPlace;
- TPrimitiveSet placeRes;
- setPlace.buildSet(PrimDoc.RootNode, predCont, placeRes);
- // for all found
- for (uint placeId= 0; placeId < placeRes.size(); ++placeId)
+ std::string primName;
+ if(placeRes[placeId]->getPropertyByName(listProp[cid], primName) && !primName.empty())
{
- string primName;
- if(placeRes[placeId]->getPropertyByName(listProp[cid], primName) && !primName.empty())
+ primName = NLMISC::toLower(primName);
+ // avoid duplicate
+ if(allWordSet.insert(primName).second)
{
- primName= toLower(primName);
- // avoid duplicate
- if(allWordSet.insert(primName).second)
- {
- allWords.push_back(primName);
- }
+ allWords.push_back(primName);
}
}
}
}
-
- return true;
}
+ return true;
+}
}
\ No newline at end of file
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.h
index ca7295f91..01d0f1a0a 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.h
@@ -30,43 +30,34 @@
#include "nel/ligo/primitive.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
*/
struct IWordListBuilder
{
- virtual bool buildWordList(std::vector &allWords, string workSheetFileName) =0;
-
+ virtual bool buildWordList(std::vector &allWords, std::string workSheetFileName) =0;
};
struct CSheetWordListBuilder : public IWordListBuilder
{
- string SheetExt;
- string SheetPath;
+ std::string SheetExt;
+ std::string SheetPath;
- virtual bool buildWordList(std::vector &allWords, string workSheetFileName);
+ virtual bool buildWordList(std::vector &allWords, std::string workSheetFileName);
};
struct CRegionPrimWordListBuilder : public IWordListBuilder
{
- string PrimPath;
- vector PrimFilter;
- NLLIGO::CLigoConfig LigoConfig;
- virtual bool buildWordList(std::vector &allWords, string workSheetFileName);
+ std::string PrimPath;
+ std::vector PrimFilter;
+ NLLIGO::CLigoConfig LigoConfig;
+ virtual bool buildWordList(std::vector &allWords, std::string workSheetFileName);
};
}
-
-#endif /* EXTRACT_NEW_SHEET_NAMES_H */
-
+#endif /* EXTRACT_NEW_SHEET_NAMES_H */
\ No newline at end of file
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/ftp_selection.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/ftp_selection.cpp
index 41a8072e2..876599b61 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/ftp_selection.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/ftp_selection.cpp
@@ -1,191 +1,216 @@
+// Translation Manager Plugin - OVQT Plugin
+// Copyright (C) 2011 Emanuel Costea
+//
+// 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 .
#include "ftp_selection.h"
#include
#include
+
namespace TranslationManager
{
- CFtpSelection::CFtpSelection(QWidget *parent): QDialog(parent)
- {
- _ui.setupUi(this);
- connect(_ui.connectButton, SIGNAL(clicked()), this, SLOT(ConnectButtonClicked()));
- connect(_ui.doneButton, SIGNAL(clicked()), this, SLOT(DoneButtonClicked()));
- connect(_ui.cdToParrent, SIGNAL(clicked()), this, SLOT(cdToParent()));
- connect(_ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
-
- // file list
- connect(_ui.fileList, SIGNAL(itemActivated(QTreeWidgetItem*,int)),this, SLOT(processItem(QTreeWidgetItem*,int)));
- _ui.fileList->setEnabled(false);
- _ui.fileList->setRootIsDecorated(false);
- _ui.fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time"));
- _ui.fileList->header()->setStretchLastSection(false);
+CFtpSelection::CFtpSelection(QWidget *parent): QDialog(parent)
+{
+ _ui.setupUi(this);
+ connect(_ui.connectButton, SIGNAL(clicked()), this, SLOT(ConnectButtonClicked()));
+ connect(_ui.doneButton, SIGNAL(clicked()), this, SLOT(DoneButtonClicked()));
+ connect(_ui.cdToParrent, SIGNAL(clicked()), this, SLOT(cdToParent()));
+ connect(_ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
- // buttons
- _ui.cdToParrent->setEnabled(false);
- _ui.doneButton->setEnabled(false);
+ // file list
+ connect(_ui.fileList, SIGNAL(itemActivated(QTreeWidgetItem *,int)),this, SLOT(processItem(QTreeWidgetItem *,int)));
+ _ui.fileList->setEnabled(false);
+ _ui.fileList->setRootIsDecorated(false);
+ _ui.fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time"));
+ _ui.fileList->header()->setStretchLastSection(false);
- status = false;
- }
-
- // Connection with the FTP Server. We retrieve the file list.
- void CFtpSelection::ConnectButtonClicked()
- {
- conn = new QFtp(this);
- connect(conn, SIGNAL(commandFinished(int,bool)), this, SLOT(FtpCommandFinished(int,bool)));
- 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));
+ // buttons
+ _ui.cdToParrent->setEnabled(false);
+ _ui.doneButton->setEnabled(false);
- if (!url.userName().isEmpty())
- conn->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password());
- else
- conn->login();
- if (!url.path().isEmpty())
- conn->cd(url.path());
- }
- }
-
- // Get the user action.
- void CFtpSelection::FtpCommandFinished(int, bool error)
- {
- #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;
- }
+ status = false;
+}
- 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);
- }
+// Connection with the FTP Server. We retrieve the file list.
+void CFtpSelection::ConnectButtonClicked()
+{
+ conn = new QFtp(this);
+ connect(conn, SIGNAL(commandFinished(int,bool)), this, SLOT(FtpCommandFinished(int,bool)));
+ connect(conn, SIGNAL(listInfo(QUrlInfo)), this, SLOT(AddToList(QUrlInfo)));
- if (conn->currentCommand() == QFtp::List)
- {
- if (isDirectory.isEmpty()) {
- _ui.fileList->addTopLevelItem(new QTreeWidgetItem(QStringList() << tr("")));
- _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"));
+ setCursor(Qt::WaitCursor);
- 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()
+ QUrl url(_ui.url->text());
+ if (!url.isValid() || url.scheme().toLower() != QLatin1String("ftp"))
{
- #ifndef QT_NO_CURSOR
- setCursor(Qt::WaitCursor);
- #endif
- _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();
+ conn->connectToHost(_ui.url->text(), 21);
+ conn->login();
+ }
+ else
+ {
+ conn->connectToHost(url.host(), url.port(21));
+
+ if (!url.userName().isEmpty())
+ conn->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password());
+ else
+ conn->login();
+ if (!url.path().isEmpty())
+ 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
- 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);
- #ifndef QT_NO_CURSOR
- setCursor(Qt::WaitCursor);
- #endif
- 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();
- }
-
+ 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("")));
+ _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();
+
+ 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();
+}
+
}
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/ftp_selection.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/ftp_selection.h
index 47dcfdb57..9f8af85dd 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/ftp_selection.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/ftp_selection.h
@@ -1,4 +1,4 @@
-/*
+/*
* File: ftp_selection.h
* Author: cemycc
*
@@ -8,6 +8,8 @@
#ifndef FTP_SELECTION_H
#define FTP_SELECTION_H
+#include "ui_ftp_selection.h"
+
#include
#include
#include
@@ -16,34 +18,33 @@
#include
#include
-#include "ui_ftp_selection.h"
+namespace TranslationManager
+{
-using namespace std;
+class CFtpSelection : public QDialog
+{
+ Q_OBJECT
-namespace TranslationManager {
-
- class CFtpSelection : public QDialog
- {
- Q_OBJECT
- private:
- Ui::FtpSelectionDialog _ui;
- QFtp *conn;
- QHash isDirectory;
- QString currentPath;
- private Q_SLOTS:
- void cdToParent();
- void processItem(QTreeWidgetItem*,int);
- void ConnectButtonClicked();
- void DoneButtonClicked();
- void FtpCommandFinished(int, bool error);
- void AddToList(const QUrlInfo &urlInfo);
- public:
- bool status;
- QFile *file;
- CFtpSelection(QWidget* parent = 0);
- ~CFtpSelection() {}
- };
+public:
+ CFtpSelection(QWidget *parent = 0);
+ ~CFtpSelection() {}
+ bool status;
+ QFile *file;
+
+private Q_SLOTS:
+ void cdToParent();
+ void processItem(QTreeWidgetItem *,int);
+ void ConnectButtonClicked();
+ void DoneButtonClicked();
+ void FtpCommandFinished(int, bool error);
+ void AddToList(const QUrlInfo &urlInfo);
+
+private:
+ Ui::FtpSelectionDialog _ui;
+ QFtp *conn;
+ QHash isDirectory;
+ QString currentPath;
+};
}
-#endif /* FTP_SELECTION_H */
-
+#endif /* FTP_SELECTION_H */
\ No newline at end of file
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/source_selection.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/source_selection.cpp
index 3015b447d..518906db0 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/source_selection.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/source_selection.cpp
@@ -1,39 +1,54 @@
-
-#include
+// Translation Manager Plugin - OVQT Plugin
+// Copyright (C) 2010 Winch Gate Property Limited
+// Copyright (C) 2011 Emanuel Costea
+//
+// 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 .
#include "source_selection.h"
+#include
+
namespace TranslationManager
{
-
CSourceDialog::CSourceDialog(QWidget *parent): QDialog(parent)
{
_ui.setupUi(this);
- // Set signal and slot for "OK Button"
+
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()));
- _ui.sourceSelectionListWidget->setSortingEnabled(false);
+ connect(_ui.cancel_button, SIGNAL(clicked()), this, SLOT(reject()));
+
+ _ui.sourceSelectionListWidget->setSortingEnabled(false);
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.
-void CSourceDialog::setSourceOptions(map options)
+void CSourceDialog::setSourceOptions(std::map &options)
{
- map::iterator it;
-
- for(it = options.begin(); it != options.end(); ++it)
- {
- _ui.sourceSelectionListWidget->addItem((*it).first);
- }
+ std::map::iterator it;
+
+ for(it = options.begin(); it != options.end(); ++it)
+ {
+ _ui.sourceSelectionListWidget->addItem((*it).first);
+ }
}
void CSourceDialog::OkButtonClicked()
{
- selected_item = _ui.sourceSelectionListWidget->currentItem();
- accept();
+ selected_item = _ui.sourceSelectionListWidget->currentItem();
+ accept();
}
void CSourceDialog::itemDoubleClicked(QListWidgetItem *item)
@@ -42,4 +57,4 @@ void CSourceDialog::itemDoubleClicked(QListWidgetItem *item)
accept();
}
-}
+}
\ No newline at end of file
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/source_selection.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/source_selection.h
index d32bfcb02..7b6fc2cb9 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/source_selection.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/source_selection.h
@@ -1,16 +1,30 @@
-
+// Translation Manager Plugin - OVQT Plugin
+// Copyright (C) 2011 Emanuel Costea
+//
+// 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 .
#ifndef SOURCE_SELECTION_H
#define SOURCE_SELECTION_H
+#include "ui_source_selection.h"
+
#include
#include
#include
#include
-#include "ui_source_selection.h"
-#include