Changed: #1307 Added extract_bot_names

This commit is contained in:
cemycc 2011-06-21 01:03:54 +03:00
parent d025085442
commit 7fa052e11c
11 changed files with 302 additions and 529 deletions

View file

@ -10,11 +10,11 @@ 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
qnel_widget.h
simple_viewer.h
translation_manager_main_window.h
translation_manager_settings_page.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)
SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE)

View file

@ -145,6 +145,15 @@ set<string> GenericNames;
map<string, TEntryInfo> SimpleNames;
set<string> Functions;
set<string> getGenericNames()
{
return GenericNames;
}
map<string, TEntryInfo> getSimpleNames()
{
return SimpleNames;
}
string removeAndStoreFunction(const std::string &fullName)
{
@ -221,40 +230,6 @@ void addSimpleName(const std::string &name, const std::string &sheetName)
int extractBotNamesAll(map<string,list<string> > config_paths, string ligo_class_file, string trans_path, string work_path)
{
//-------------------------------------------------------------------
// read the parameters
/*for (int i=2; i<argc; ++i)
{
string s = argv[i];
if (s == "-r")
{
// active remove mode
RemoveOlds = true;
}
else
{
nlwarning("Unknow option '%s'", argv[i]);
return -1;
}
} */
//-------------------------------------------------------------------
// read the configuration file
//CConfigFile cf;
//cf.load("bin/translation_tools.cfg");
//-------------------------------------------------------------------
// read the vars
//CConfigFile::CVar &paths = cf.getVar("Paths");
//CConfigFile::CVar &filtersVar = cf.getVar("Filters");
//CConfigFile::CVar &ligoClassFile= cf.getVar("LigoClassFile");
//CConfigFile::CVar &georgesPaths= cf.getVar("GeorgesPaths");
//CConfigFile::CVar &pathNoRecurse= cf.getVar("PathsNoRecurse");
//CConfigFile::CVar &workBotNamesFile= cf.getVar("WorkBotNamesFile");
//CConfigFile::CVar &transBotNamesFile= cf.getVar("TransBotNamesFile");
//CConfigFile::CVar &workTitleFile= cf.getVar("WorkTitleFile");
for (std::list<string>::iterator it = config_paths["paths"].begin(); it != config_paths["paths"].end(); ++it)
{
CPath::addSearchPath(*it, true, false);
@ -269,7 +244,6 @@ int extractBotNamesAll(map<string,list<string> > config_paths, string ligo_class
Filters.push_back(*it);
}
//-------------------------------------------------------------------
// init the sheets
CSheetId::init(false);
@ -451,26 +425,62 @@ int extractBotNamesAll(map<string,list<string> > config_paths, string ligo_class
}
else
{
TEntryInfo ei;
addSimpleName(removeAndStoreFunction(name), sheetStr);
}
}
}
}
}
//-------------------------------------------------------------------
// step 2 : load the reference file
nlinfo("Looking for missing translation:");
string work_path_file = work_path + "/bot_names.txt";
string trans_path_file = trans_path + "/bot_names.txt";
string title_path_file = work_path + "/title_words_wk.txt";
TWorksheet botNames;
if (!CFile::fileExists(work_path_file) || !loadExcelSheet(work_path_file, botNames))
{
botNames.resize(botNames.size() + 1);
botNames.insertColumn(botNames.ColCount);
botNames.setData(0,botNames.ColCount - 1,ucstring("bot name"));
botNames.insertColumn(botNames.ColCount);
botNames.setData(0,botNames.ColCount - 1,ucstring("translated name"));
botNames.insertColumn(botNames.ColCount);
botNames.setData(0,botNames.ColCount - 1,ucstring("sheet_name"));
}
TWorksheet botNames;
loadExcelSheet(work_path, botNames, true);
TWorksheet transBotNames;
loadExcelSheet(trans_path, transBotNames, true);
TWorksheet transBotNames;
if (!CFile::fileExists(trans_path_file) || !loadExcelSheet(trans_path_file, transBotNames))
{
transBotNames.resize(transBotNames.size() + 1);
transBotNames.insertColumn(transBotNames.ColCount);
transBotNames.setData(0,transBotNames.ColCount - 1,ucstring("*HASH_VALUE"));
transBotNames.insertColumn(transBotNames.ColCount);
transBotNames.setData(0,transBotNames.ColCount - 1,ucstring("bot name"));
transBotNames.insertColumn(transBotNames.ColCount);
transBotNames.setData(0,transBotNames.ColCount - 1,ucstring("translated name"));
transBotNames.insertColumn(transBotNames.ColCount);
transBotNames.setData(0,transBotNames.ColCount - 1,ucstring("sheet_name"));
}
TWorksheet fcts;
loadExcelSheet(work_path, fcts, true);
TWorksheet fcts;
if (!CFile::fileExists(title_path_file) || !loadExcelSheet(title_path_file, fcts))
{
fcts.resize(fcts.size() + 1);
fcts.insertColumn(fcts.ColCount);
fcts.setData(0,fcts.ColCount - 1,ucstring("title_id"));
fcts.insertColumn(fcts.ColCount);
fcts.setData(0,fcts.ColCount - 1,ucstring("name"));
fcts.insertColumn(fcts.ColCount);
fcts.setData(0,fcts.ColCount - 1,ucstring("women_name"));
}
loadExcelSheet(work_path_file, botNames, true);
loadExcelSheet(trans_path_file, transBotNames, true);
loadExcelSheet(title_path_file, fcts, true);
// add missing element
@ -482,9 +492,9 @@ int extractBotNamesAll(map<string,list<string> > config_paths, string ligo_class
nlverify(botNames.findId(botIdCol));
uint transIdCol;
nlverify(transBotNames.findId(transIdCol));
uint fctsIdCol;
uint fctsIdCol;
nlverify(fcts.findId(fctsIdCol));
// special treatment to add the sheet_name col
{
uint sheetCol;
@ -743,14 +753,13 @@ int extractBotNamesAll(map<string,list<string> > config_paths, string ligo_class
nlinfo("Adding %u new generic name", nbAddGenericName);
nlinfo("Adding %u new function name", nbAddFunction);
// saving the modified files
// saving the modified files
ucstring s = prepareExcelSheet(botNames);
CI18N::writeTextFile(work_path, s, false);
CI18N::writeTextFile(work_path_file, s, false);
s = prepareExcelSheet(transBotNames);
CI18N::writeTextFile(trans_path, s, false);
CI18N::writeTextFile(trans_path_file, s, false);
s = prepareExcelSheet(fcts);
CI18N::writeTextFile(work_path, s, false);
CI18N::writeTextFile(title_path_file, s, false);
return 0;
}

View file

@ -1,197 +0,0 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 "qnel_widget.h"
// STL includes
// Qt includes
#include <QtCore/QTimer>
#include <QtGui/QResizeEvent>
// NeL includes
#include <nel/misc/event_server.h>
#include <nel/misc/debug.h>
#include <nel/3d/u_driver.h>
#include <nel/3d/driver_user.h>
namespace NLQT
{
QNLWidget::QNLWidget(QWidget *parent)
: QNeLWidget(parent),
m_driver(NULL),
m_initialized(false),
m_interval(25)
{
setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);
init();
#ifdef Q_OS_LINUX
makeCurrent();
#endif
m_mainTimer = new QTimer(this);
connect(m_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
}
QNLWidget::~QNLWidget()
{
release();
}
void QNLWidget::init()
{
// create the driver
m_driver = NL3D::UDriver::createDriver(NULL, false, NULL);
nlassert(m_driver);
// initialize the nel 3d viewport
m_driver->setDisplay((nlWindow)winId(), NL3D::UDriver::CMode(width(), height(), 32));
// set the cache size for the font manager(in bytes)
m_driver->setFontManagerMaxMemory(2097152);
m_initialized = true;
}
void QNLWidget::release()
{
m_mainTimer->stop();
delete m_mainTimer;
if (m_initialized)
{
m_driver->release();
delete m_driver;
m_driver = NULL;
}
}
void QNLWidget::setInterval(int msec)
{
m_interval = msec;
m_mainTimer->setInterval(msec);
}
void QNLWidget::setBackgroundColor(NLMISC::CRGBA backgroundColor)
{
m_backgroundColor = backgroundColor;
}
void QNLWidget::updateRender()
{
if (isVisible())
{
if (m_initialized)
m_driver->EventServer.pump();
Q_EMIT updateData();
// Calc FPS
static sint64 lastTime = NLMISC::CTime::getPerformanceTime ();
sint64 newTime = NLMISC::CTime::getPerformanceTime ();
m_fps = float(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime));
lastTime = newTime;
if (m_initialized && !m_driver->isLost())
{
//_driver->activate();
m_driver->clearBuffers(m_backgroundColor);
Q_EMIT updatePreRender();
Q_EMIT updatePostRender();
// swap 3d buffers
m_driver->swapBuffers();
}
}
}
void QNLWidget::showEvent(QShowEvent *showEvent)
{
QWidget::showEvent(showEvent);
m_driver->activate();
m_mainTimer->start(m_interval);
}
void QNLWidget::hideEvent(QHideEvent *hideEvent)
{
m_mainTimer->stop();
QWidget::hideEvent(hideEvent);
}
#if defined(NL_OS_WINDOWS)
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
bool QNLWidget::winEvent(MSG *message, long *result)
{
if (m_driver && m_driver->isActive())
{
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(m_driver)->getDriver();
if (driver)
{
winProc proc = (winProc)driver->getWindowProc();
return proc(driver, message->hwnd, message->message, message->wParam, message->lParam);
}
}
return false;
}
#elif defined(NL_OS_MAC)
typedef bool (*cocoaProc)(NL3D::IDriver *, const void *e);
bool QNLWidget::macEvent(EventHandlerCallRef caller, EventRef event)
{
if(caller)
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");
if (m_driver && m_driver->isActive())
{
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(m_driver)->getDriver();
if (driver)
{
cocoaProc proc = (cocoaProc)driver->getWindowProc();
return proc(driver, event);
}
}
return false;
}
#elif defined(NL_OS_UNIX)
typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
bool QNLWidget::x11Event(XEvent *event)
{
if (m_driver && m_driver->isActive())
{
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(m_driver)->getDriver();
if (driver)
{
x11Proc proc = (x11Proc)driver->getWindowProc();
return proc(driver, event);
}
}
return false;
}
#endif
} /* namespace NLQT */

View file

@ -1,130 +0,0 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 QNEL_WIDGET_H
#define QNEL_WIDGET_H
// NeL includes
#include <nel/misc/types_nl.h>
#include <nel/misc/rgba.h>
#include <nel/misc/event_emitter.h>
// Qt includes
#include <QtOpenGL/QGLWidget>
#include <QtGui/QWidget>
class QAction;
/* TODO every platform should use QWidget */
#if defined(NL_OS_WINDOWS)
typedef QWidget QNeLWidget;
#elif defined(NL_OS_MAC)
typedef QWidget QNeLWidget;
#elif defined(NL_OS_UNIX)
typedef QGLWidget QNeLWidget;
#endif // NL_OS_UNIX
namespace NL3D
{
class UDriver;
class UScene;
}
namespace NLQT
{
/**
@class QNLWidget
@brief Responsible for interaction between Qt and NeL.
@details Automatically begins to update the render if the widget is visible
or suspends the updating of render if the widget is hidden.
*/
class QNLWidget : public QNeLWidget
{
Q_OBJECT
public:
QNLWidget(QWidget *parent);
virtual ~QNLWidget();
/// Set the update interval renderer
void setInterval(int msec);
/// Set the background color.
void setBackgroundColor(NLMISC::CRGBA backgroundColor);
float fps() const
{
return m_fps;
}
inline NLMISC::CRGBA backgroundColor() const
{
return m_backgroundColor;
}
NL3D::UDriver *driver() const
{
return m_driver;
}
virtual QPaintEngine* paintEngine() const
{
return NULL;
}
Q_SIGNALS:
void updateData();
void updatePreRender();
void updatePostRender();
private Q_SLOTS:
void updateRender();
protected:
virtual void showEvent(QShowEvent *showEvent);
virtual void hideEvent(QHideEvent *hideEvent);
#if defined(NL_OS_WINDOWS)
virtual bool winEvent(MSG *message, long *result);
#elif defined(NL_OS_MAC)
virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
#elif defined(NL_OS_UNIX)
virtual bool x11Event(XEvent *event);
#endif
private:
void init();
void release();
QNLWidget(const QNLWidget &);
QNLWidget &operator=(const QNLWidget &);
NL3D::UDriver *m_driver;
NLMISC::CRGBA m_backgroundColor;
QTimer *m_mainTimer;
bool m_initialized;
int m_interval;
float m_fps;
}; /* class QNLWidget */
} /* namespace NLQT */
#endif // QNEL_WIDGET_H

View file

@ -1,56 +0,0 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 "simple_viewer.h"
// Qt includes
#include <QtGui/QWidget>
#include <QtGui/QGridLayout>
#include <QtGui/QMessageBox>
// NeL includes
// Project includes
namespace Plugin
{
CSimpleViewer::CSimpleViewer(QWidget *parent)
: QWidget(parent)
{
QGridLayout *gridLayout = new QGridLayout(this);
gridLayout->setObjectName(QString::fromUtf8("gridLayoutSimpleViewer"));
gridLayout->setContentsMargins(0, 0, 0, 0);
NLQT::QNLWidget *_nelWidget = new NLQT::QNLWidget(this);
gridLayout->addWidget(_nelWidget, 0, 0, 1, 1);
m_undoStack = new QUndoStack(this);
}
bool CCoreListener::closeMainWindow() const
{
int ret = QMessageBox::question(0, tr("Example close event hook"),
tr("Do you want to close window?"),
QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes)
return true;
else
return false;
}
} /* namespace Plugin */

View file

@ -0,0 +1,169 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 "translation_manager_main_window.h"
// Project system includes
#include "../core/icore.h"
// Qt includes
#include <QtGui/QWidget>
#include <QtGui/QMessageBox>
#include <QtGui/QLabel>
#include <QtGui/QTextEdit>
#include <QtCore/QSettings>
#include <QtGui/QErrorMessage>
#include <QtCore/QSignalMapper>
#include <QtGui/QTableWidget>
#include <QtGui/QListWidget>
#include <QtGui/QDockWidget>
#include <QtCore/QSize>
#include <QtGui/QGridLayout>
struct TEntryInfo
{
string SheetName;
};
set<string> getGenericNames();
map<string, TEntryInfo> getSimpleNames();
int extractBotNamesAll(map<string,list<string> > config_paths, string ligo_class_file, string trans_path, string work_path);
namespace Plugin
{
CMainWindow::CMainWindow(QWidget *parent)
: QMainWindow(parent)
{
_ui.setupUi(this);
_toolMenu = new QMenu(tr("Primitives"), _ui.toolBar);
_ui.toolBar->addAction(_toolMenu->menuAction());
QAction *extractBotNames = _toolMenu->addAction(tr("Extract bot names"));
extractBotNames->setStatusTip(tr("Extract bot names from primitives"));
connect(extractBotNames, SIGNAL(triggered()), this, SLOT(extractBotNames()));
readSettings();
m_undoStack = new QUndoStack(this);
}
void CMainWindow::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("translationmanager");
list<string> paths = convertQStringList(settings->value("paths").toStringList()); /* paths */
config_paths["paths"] = paths;
list<string> pathsR = convertQStringList(settings->value("pathsR").toStringList()); /* pathsR */
config_paths["pathsR"] = pathsR;
list<string> georges = convertQStringList(settings->value("georges").toStringList()); /* georges */
config_paths["georges"] = georges;
list<string> filters = convertQStringList(settings->value("filters").toStringList()); /* filters */
config_paths["filters"] = filters;
languages = convertQStringList(settings->value("trlanguages").toStringList()); /* languages */
ligo_path = settings->value("ligo").toString().toStdString();
translation_path = settings->value("translation").toString().toStdString();
work_path = settings->value("work").toString().toStdString();
settings->endGroup();
}
void CMainWindow::extractBotNames()
{
if(verifySettings() == true)
{
// int extract_bot_names = extractBotNamesAll(config_paths, ligo_path, translation_path, work_path);
QGridLayout* mainLayout = new QGridLayout();
//contentsWindow->setAllowedAreas(Qt::LeftDockWidgetArea);
QListWidget *listWidget = new QListWidget(this);
mainLayout->addWidget(QListWidget);
QTableWidget *tableWidget = new QTableWidget(this);
tableWidget->setRowCount(10);
tableWidget->setColumnCount(5);
mainLayout->addWidget(QTableWidget);
setCentralWidget(tableWidget);
}
}
bool CMainWindow::verifySettings()
{
bool count_errors = false;
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("translationmanager");
if(settings->value("paths").toList().count() == 0
|| settings->value("pathsR").toList().count() == 0
|| settings->value("georges").toList().count() == 0
|| settings->value("filters").toList().count() == 0)
{
QErrorMessage error_settings;
error_settings.showMessage("Please write all the paths on the settings dialog.");
error_settings.exec();
count_errors = true;
}
if((settings->value("ligo").toString().isEmpty()
|| settings->value("translation").toString().isEmpty()
|| settings->value("work").toString().isEmpty()
|| settings->value("trlanguages").toList().count() == 0)
&& count_errors == false)
{
QErrorMessage error_settings;
error_settings.showMessage("Please write the paths for ligo, translation and work files and the languages on the settings dialog." + settings->value("trlanguages").toString());
error_settings.exec();
count_errors = true;
}
settings->endGroup();
return !count_errors;
}
list<string> CMainWindow::convertQStringList(QStringList listq)
{
std::list<std::string> stdlist;
Q_FOREACH(QString text, listq)
{
stdlist.push_back(text.toStdString());
}
return stdlist;
}
bool CCoreListener::closeMainWindow() const
{
return true;
}
} /* namespace Plugin */

View file

@ -16,29 +16,53 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SIMPLE_VIEWER_H
#define SIMPLE_VIEWER_H
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
// Project includes
#include "qnel_widget.h"
#include "../core/icore_listener.h"
// Qt includes
#include <QtCore/QObject>
#include <QtGui/QUndoStack>
#include <QtGui/QMainWindow>
#include <QtGui/QGridLayout>
#include <QtGui/QTabWidget>
#include <QtGui/QMenu>
#include "ui_translation_manager_main_window.h"
#include <set>
class QWidget;
using namespace std;
namespace Plugin
{
class CSimpleViewer : public QWidget
class CMainWindow : public QMainWindow
{
Q_OBJECT
public:
CSimpleViewer(QWidget *parent = 0);
virtual ~CSimpleViewer() {}
QUndoStack *m_undoStack;
CMainWindow(QWidget *parent = 0);
virtual ~CMainWindow() {}
QUndoStack *m_undoStack;
private:
Ui::CMainWindow _ui;
QMenu *_toolMenu;
map<string, list<string> > config_paths;
list<string> languages;
string ligo_path;
string translation_path;
string work_path;
private Q_SLOTS:
void extractBotNames();
private:
void compareBotNames();
bool verifySettings();
void readSettings();
list<string> convertQStringList(QStringList listq);
};
class CCoreListener : public Core::ICoreListener

View file

@ -1,7 +1,7 @@
// Project includes
#include "translation_manager_plugin.h"
#include "translation_manager_settings_page.h"
#include "simple_viewer.h"
#include "translation_manager_main_window.h"
// Project system includes
#include "../core/icore.h"
#include "../core/core_constants.h"
@ -14,13 +14,12 @@
// Qt includes
#include <QtCore/QObject>
#include <QtGui/QMessageBox>
#include <QtGui/QErrorMessage>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QAction>
#include <QtGui/QMenuBar>
int extractBotNamesAll(map<string,list<string> > config_paths, string ligo_class_file, string trans_path, string work_path);
namespace Plugin
{
TranslationManagerPlugin::~TranslationManagerPlugin()
@ -41,6 +40,7 @@ bool TranslationManagerPlugin::initialize(ExtensionSystem::IPluginManager *plugi
addAutoReleasedObject(new CTranslationManagerSettingsPage(this));
addAutoReleasedObject(new CTranslationManagerContext(this));
addAutoReleasedObject(new CCoreListener(this));
return true;
}
@ -56,39 +56,6 @@ void TranslationManagerPlugin::extensionsInitialized()
QAction *aboutQtAction = menuManager->action(Core::Constants::ABOUT_QT);
helpMenu->addSeparator();
helpMenu->insertAction(aboutQtAction, aboutTManPlugin);
QMenu *transMenu = menuManager->menuBar()->addMenu("Translation Manager");
// Words extraction
QAction *botnamesAct = new QAction("Extract bot_names", this);
connect(botnamesAct, SIGNAL(triggered()), this, SLOT(extractBotNames()));
transMenu->addAction(botnamesAct);
}
void TranslationManagerPlugin::extractBotNames()
{
// prepare the config paths
list<string> paths,pathsR, georges, filters, languages;
string ligo, translation, work;
map<string, list<string> > config_paths;
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("translationmanager");
paths = ConvertQStringList(settings->value("paths").toStringList()); /* paths */
config_paths["paths"] = paths;
pathsR = ConvertQStringList(settings->value("pathsR").toStringList()); /* pathsR */
config_paths["pathsR"] = pathsR;
georges = ConvertQStringList(settings->value("georges").toStringList()); /* georges */
config_paths["georges"] = georges;
filters = ConvertQStringList(settings->value("filters").toStringList()); /* filters */
config_paths["filters"] = filters;
languages = ConvertQStringList(settings->value("languages").toStringList()); /* languages */
ligo = settings->value("ligo").toString().toStdString();
translation = settings->value("translation").toString().toStdString();
work = settings->value("work").toString().toStdString();
settings->endGroup();
extractBotNamesAll(config_paths, ligo, translation, work);
}
void TranslationManagerPlugin::setNelContext(NLMISC::INelContext *nelContext)
@ -101,17 +68,6 @@ void TranslationManagerPlugin::setNelContext(NLMISC::INelContext *nelContext)
_LibContext = new NLMISC::CLibraryContext(*nelContext);
}
list<string> TranslationManagerPlugin::ConvertQStringList(QStringList listq)
{
std::list<std::string> stdlist;
Q_FOREACH(QString text, listq)
{
stdlist.push_back(text.toStdString());
}
return stdlist;
}
QString TranslationManagerPlugin::name() const
{
return "Translation Manager";

View file

@ -4,7 +4,7 @@
// Project includes
#include "../../extension_system/iplugin.h"
#include "../core/icontext.h"
#include "simple_viewer.h"
#include "translation_manager_main_window.h"
// NeL includes
#include "nel/misc/app_context.h"
@ -28,12 +28,13 @@ class IPluginSpec;
namespace Plugin
{
class CTranslationManagerContext;
class TranslationManagerPlugin : public QObject, public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_INTERFACES(ExtensionSystem::IPlugin)
public:
virtual ~TranslationManagerPlugin();
bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString);
@ -58,11 +59,6 @@ protected:
private:
ExtensionSystem::IPluginManager *_plugMan;
QList<QObject *> _autoReleaseObjects;
list<string> ConvertQStringList(QStringList list);
private Q_SLOTS:
void extractBotNames();
};
class CTranslationManagerContext: public Core::IContext
@ -71,7 +67,7 @@ class CTranslationManagerContext: public Core::IContext
public:
CTranslationManagerContext(QObject *parent = 0): IContext(parent)
{
m_simpleViewer = new CSimpleViewer();
m_MainWindow = new CMainWindow();
}
virtual ~CTranslationManagerContext() {}
@ -90,18 +86,18 @@ public:
}
virtual QWidget *widget()
{
return m_simpleViewer;
return m_MainWindow;
}
virtual QUndoStack *undoStack()
{
return m_simpleViewer->m_undoStack;
return m_MainWindow->m_undoStack;
}
virtual void open()
{
}
CSimpleViewer *m_simpleViewer;
CMainWindow *m_MainWindow;
};

View file

@ -68,7 +68,7 @@ QWidget *CTranslationManagerSettingsPage::createPage(QWidget *parent)
{
_currentPage = new QWidget(parent);
_ui.setupUi(_currentPage);
readSettings();
readSettings();
connect(_ui.paths_add, SIGNAL(clicked()), this, SLOT(pathAdd()));
connect(_ui.paths_del, SIGNAL(clicked()), this, SLOT(pathDel()));
connect(_ui.pathsR_add, SIGNAL(clicked()), this, SLOT(pathRAdd()));
@ -79,8 +79,8 @@ QWidget *CTranslationManagerSettingsPage::createPage(QWidget *parent)
connect(_ui.filter_del, SIGNAL(clicked()), this, SLOT(filterDel()));
connect(_ui.lang_add, SIGNAL(clicked()), this, SLOT(languageAdd()));
connect(_ui.lang_del, SIGNAL(clicked()), this, SLOT(languageDel()));
connect(_ui.translation_add, SIGNAL(clicked()), this, SLOT(translationAdd()));
connect(_ui.work_add, SIGNAL(clicked()), this, SLOT(workAdd()));
connect(_ui.translation_add, SIGNAL(clicked()), this, SLOT(translationAdd()));
connect(_ui.work_add, SIGNAL(clicked()), this, SLOT(workAdd()));
return _currentPage;
}
@ -218,13 +218,13 @@ void CTranslationManagerSettingsPage::readSettings()
pathsR = settings->value("pathsR").toStringList(); /* pathsR */
georges = settings->value("georges").toStringList(); /* georges */
filters = settings->value("filters").toStringList(); /* filters */
languages = settings->value("languages").toStringList(); /* languages */
languages = settings->value("trlanguages").toStringList(); /* languages */
ligo = settings->value("ligo").toString();
translation = settings->value("translation").toString();
work = settings->value("work").toString();
settings->endGroup();
/* paths */
// paths
Q_FOREACH(QString path, paths)
{
QListWidgetItem *newItem = new QListWidgetItem;
@ -232,7 +232,7 @@ void CTranslationManagerSettingsPage::readSettings()
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
_ui.paths_list->addItem(newItem);
}
/* pathsR */
// pathsR
Q_FOREACH(QString pathR, pathsR)
{
QListWidgetItem *newItem = new QListWidgetItem;
@ -240,7 +240,7 @@ void CTranslationManagerSettingsPage::readSettings()
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
_ui.pathsR_list->addItem(newItem);
}
/* georges */
// georges
Q_FOREACH(QString george, georges)
{
QListWidgetItem *newItem = new QListWidgetItem;
@ -248,7 +248,7 @@ void CTranslationManagerSettingsPage::readSettings()
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
_ui.georges_list->addItem(newItem);
}
/* filter */
// filter
Q_FOREACH(QString filter, filters)
{
QListWidgetItem *newItem = new QListWidgetItem;
@ -256,7 +256,7 @@ void CTranslationManagerSettingsPage::readSettings()
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
_ui.filter_list->addItem(newItem);
}
/* languages */
// languages
Q_FOREACH(QString lang, languages)
{
QListWidgetItem *newItem = new QListWidgetItem;
@ -264,11 +264,11 @@ void CTranslationManagerSettingsPage::readSettings()
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
_ui.lang_list->addItem(newItem);
}
/* ligo */
// ligo
_ui.ligo_edit->setText(ligo);
/* translation */
// translation
_ui.translation_edit->setText(translation);
/* work */
// work
_ui.work_edit->setText(work);
}
@ -277,25 +277,26 @@ void CTranslationManagerSettingsPage::writeSettings()
{
QStringList paths, pathsR, georges, filters, languages;
QString ligo, translation, work;
/* paths */
// paths
for (int i = 0; i < _ui.paths_list->count(); ++i)
paths << _ui.paths_list->item(i)->text();
/* pathsR */
// pathsR
for (int i = 0; i < _ui.pathsR_list->count(); ++i)
pathsR << _ui.pathsR_list->item(i)->text();
/* georges */
// georges
for (int i = 0; i < _ui.georges_list->count(); ++i)
georges << _ui.georges_list->item(i)->text();
/* filters */
// filters
for (int i = 0; i < _ui.filter_list->count(); ++i)
filters << _ui.filter_list->item(i)->text();
/* languages */
// languages
for (int i = 0; i < _ui.lang_list->count(); ++i)
languages << _ui.lang_list->item(i)->text();
/* ligo path */
// ligo path
ligo = _ui.ligo_edit->text();
/* translations path*/
// translations path
translation = _ui.translation_edit->text();
// work path
work = _ui.work_edit->text();
QSettings *settings = Core::ICore::instance()->settings();
@ -304,11 +305,12 @@ void CTranslationManagerSettingsPage::writeSettings()
settings->setValue("pathsR", pathsR);
settings->setValue("georges", georges);
settings->setValue("filters", filters);
settings->setValue("languages", languages);
settings->setValue("trlanguages", languages);
settings->setValue("ligo", ligo);
settings->setValue("translation", translation);
settings->setValue("work", work);
settings->endGroup();
settings->sync();
}

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>490</width>
<height>482</height>
<height>496</height>
</rect>
</property>
<property name="windowTitle">
@ -214,9 +214,9 @@
<property name="geometry">
<rect>
<x>9</x>
<y>230</y>
<width>450</width>
<height>201</height>
<y>190</y>
<width>454</width>
<height>161</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@ -280,7 +280,7 @@
<x>9</x>
<y>10</y>
<width>211</width>
<height>221</height>
<height>181</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
@ -333,7 +333,7 @@
<x>240</x>
<y>10</y>
<width>221</width>
<height>221</height>
<height>181</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">