mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-22 17:08:43 +00:00
Changed: #1307 Minor fix on QMainWindow reported here: http://ryzomcore.etherpad.opennel.org/12
This commit is contained in:
parent
5b234330aa
commit
6d9feeccac
6 changed files with 220 additions and 260 deletions
|
@ -91,7 +91,7 @@ const char * const DATA_PATH_SECTION = "DataPath";
|
||||||
const char * const SEARCH_PATHS = "SearchPaths";
|
const char * const SEARCH_PATHS = "SearchPaths";
|
||||||
const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes";
|
const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes";
|
||||||
const char * const LEVELDESIGN_PATH = "LevelDesignPath";
|
const char * const LEVELDESIGN_PATH = "LevelDesignPath";
|
||||||
const char * const PRIMITIVES_PATH = "/home/cemycc/Ryzom/work/ryzom/code/ryzom/common/data_leveldesign/primitives";
|
const char * const PRIMITIVES_PATH = "D:/Ryzom/ryzom/code/ryzom/common/data_leveldesign/primitives";
|
||||||
const char * const ASSETS_PATH = "AssetsPath";
|
const char * const ASSETS_PATH = "AssetsPath";
|
||||||
const char * const REMAP_EXTENSIONS = "RemapExtensions";
|
const char * const REMAP_EXTENSIONS = "RemapExtensions";
|
||||||
|
|
||||||
|
|
|
@ -243,8 +243,7 @@ void CEditorWorksheet::worksheetEditorChanged(QTableWidgetItem * item)
|
||||||
{
|
{
|
||||||
if(temp_content != item->text())
|
if(temp_content != item->text())
|
||||||
{
|
{
|
||||||
QString i_text = item->text();
|
current_stack->push(new CUndoWorksheetCommand(table_editor, item, temp_content));
|
||||||
current_stack->push(new CUndoWorksheetCommand(item, temp_content, i_text));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isWindowModified())
|
if(!isWindowModified())
|
||||||
|
|
|
@ -1,97 +1,100 @@
|
||||||
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
|
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
|
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#ifndef EDITOR_WORKSHEET_H
|
#ifndef EDITOR_WORKSHEET_H
|
||||||
#define EDITOR_WORKSHEET_H
|
#define EDITOR_WORKSHEET_H
|
||||||
|
|
||||||
// Nel includes
|
// Nel includes
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
#include "nel/misc/sheet_id.h"
|
#include "nel/misc/sheet_id.h"
|
||||||
#include "nel/misc/path.h"
|
#include "nel/misc/path.h"
|
||||||
#include "nel/misc/diff_tool.h"
|
#include "nel/misc/diff_tool.h"
|
||||||
#include "nel/ligo/ligo_config.h"
|
#include "nel/ligo/ligo_config.h"
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QMdiArea>
|
#include <QtGui/QMdiArea>
|
||||||
#include <QtGui/QTableWidget>
|
#include <QtGui/QTableWidget>
|
||||||
#include <QtGui/QMdiSubWindow>
|
#include <QtGui/QMdiSubWindow>
|
||||||
#include <QtGui/QUndoCommand>
|
#include <QtGui/QUndoCommand>
|
||||||
#include <QtGui/qundostack.h>
|
#include <QtGui/qundostack.h>
|
||||||
|
|
||||||
|
|
||||||
#include "translation_manager_editor.h"
|
#include "translation_manager_editor.h"
|
||||||
#include "extract_new_sheet_names.h"
|
#include "extract_new_sheet_names.h"
|
||||||
|
|
||||||
namespace Plugin {
|
namespace Plugin {
|
||||||
|
|
||||||
class CEditorWorksheet : public CEditor
|
class CEditorWorksheet : public CEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QString temp_content;
|
QString temp_content;
|
||||||
public:
|
public:
|
||||||
CEditorWorksheet(QMdiArea* parent) : CEditor(parent) {}
|
CEditorWorksheet(QMdiArea* parent) : CEditor(parent) {}
|
||||||
CEditorWorksheet() : CEditor() {}
|
CEditorWorksheet() : CEditor() {}
|
||||||
QTableWidget* table_editor;
|
QTableWidget* table_editor;
|
||||||
void open(QString filename);
|
void open(QString filename);
|
||||||
void save();
|
void save();
|
||||||
void saveAs(QString filename);
|
void saveAs(QString filename);
|
||||||
void activateWindow();
|
void activateWindow();
|
||||||
void mergeWorksheetFile(QString filename);
|
void mergeWorksheetFile(QString filename);
|
||||||
bool compareWorksheetFile(QString filename);
|
bool compareWorksheetFile(QString filename);
|
||||||
void extractBotNames(list<string> filters, string level_design_path, NLLIGO::CLigoConfig ligoConfig);
|
void extractBotNames(list<string> filters, string level_design_path, NLLIGO::CLigoConfig ligoConfig);
|
||||||
void extractWords(QString filename, QString columnId, IWordListBuilder &wordListBuilder);
|
void extractWords(QString filename, QString columnId, IWordListBuilder &wordListBuilder);
|
||||||
bool isBotNamesTable();
|
bool isBotNamesTable();
|
||||||
bool isSheetTable(QString type);
|
bool isSheetTable(QString type);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void worksheetEditorCellEntered(QTableWidgetItem * item);
|
void worksheetEditorCellEntered(QTableWidgetItem * item);
|
||||||
void worksheetEditorChanged(QTableWidgetItem * item);
|
void worksheetEditorChanged(QTableWidgetItem * item);
|
||||||
void insertRow();
|
void insertRow();
|
||||||
void deleteRow();
|
void deleteRow();
|
||||||
private:
|
private:
|
||||||
void setCurrentFile(QString filename);
|
void setCurrentFile(QString filename);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CUndoWorksheetCommand : public QUndoCommand
|
class CUndoWorksheetCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CUndoWorksheetCommand(QTableWidgetItem* item, const QString &ocontent, QString ccontent) : QUndoCommand("Insert characters in cells"), m_item(item), m_ocontent(ocontent), m_ccontent(ccontent) { }
|
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_item->text();
|
||||||
|
}
|
||||||
|
|
||||||
virtual void redo()
|
void redo()
|
||||||
{
|
{
|
||||||
|
m_item->setText(m_ccontent);
|
||||||
//m_ccontent = m_item->text();
|
|
||||||
m_item->setText(m_ccontent);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
virtual void undo()
|
void undo()
|
||||||
{
|
{
|
||||||
m_item->setText(m_ocontent);
|
m_item->setText(m_ocontent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QTableWidget* m_table;
|
||||||
QTableWidgetItem* m_item;
|
QTableWidgetItem* m_item;
|
||||||
QString m_ocontent;
|
|
||||||
QString m_ccontent;
|
QString m_ccontent;
|
||||||
};
|
QString m_ocontent;
|
||||||
|
};
|
||||||
}
|
|
||||||
#endif /* EDITOR_WORKSHEET_H */
|
}
|
||||||
|
#endif /* EDITOR_WORKSHEET_H */
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include "translation_manager_main_window.h"
|
#include "translation_manager_main_window.h"
|
||||||
#include "translation_manager_constants.h"
|
#include "translation_manager_constants.h"
|
||||||
#include "editor_worksheet.h"
|
|
||||||
#include "ftp_selection.h"
|
#include "ftp_selection.h"
|
||||||
|
|
||||||
// Project system includes
|
// Project system includes
|
||||||
|
@ -63,11 +62,12 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||||
|
|
||||||
initialize_settings["georges"] = false;
|
initialize_settings["georges"] = false;
|
||||||
initialize_settings["ligo"] = false;
|
initialize_settings["ligo"] = false;
|
||||||
|
|
||||||
|
connect(Core::ICore::instance(), SIGNAL(changeSettings()), this, SLOT(readSettings()));
|
||||||
readSettings();
|
readSettings();
|
||||||
createToolbar();
|
createToolbar();
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
_ui.toolBar->addAction(m_undoStack->createUndoAction(this));
|
|
||||||
_ui.toolBar->addAction(m_undoStack->createRedoAction(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::createToolbar()
|
void CMainWindow::createToolbar()
|
||||||
|
@ -132,6 +132,18 @@ void CMainWindow::createToolbar()
|
||||||
updateWindowsList();
|
updateWindowsList();
|
||||||
_ui.toolBar->addAction(windowMenu->menuAction());
|
_ui.toolBar->addAction(windowMenu->menuAction());
|
||||||
connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(updateWindowsList()));
|
connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(updateWindowsList()));
|
||||||
|
|
||||||
|
// Undo, Redo actions
|
||||||
|
// -----------------------------
|
||||||
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
Core::IMenuManager *menuManager = core->menuManager();
|
||||||
|
QAction* undoAction = menuManager->action(Core::Constants::UNDO);
|
||||||
|
if (undoAction != 0)
|
||||||
|
_ui.toolBar->addAction(undoAction);
|
||||||
|
|
||||||
|
QAction* redoAction = menuManager->action(Core::Constants::REDO);
|
||||||
|
if (redoAction != 0)
|
||||||
|
_ui.toolBar->addAction(redoAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::updateToolbar(QMdiSubWindow *window)
|
void CMainWindow::updateToolbar(QMdiSubWindow *window)
|
||||||
|
@ -159,7 +171,7 @@ void CMainWindow::setActiveSubWindow(QWidget* window)
|
||||||
|
|
||||||
void CMainWindow::activeSubWindowChanged()
|
void CMainWindow::activeSubWindowChanged()
|
||||||
{
|
{
|
||||||
|
//TODO: nothing to be done here atm
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::updateWindowsList()
|
void CMainWindow::updateWindowsList()
|
||||||
|
@ -192,35 +204,26 @@ void CMainWindow::open()
|
||||||
QString file_name = QFileDialog::getOpenFileName(this);
|
QString file_name = QFileDialog::getOpenFileName(this);
|
||||||
if(!file_name.isEmpty())
|
if(!file_name.isEmpty())
|
||||||
{
|
{
|
||||||
list<CEditor*> subWindows = convertSubWindowList(_ui.mdiArea->subWindowList());
|
CEditor *editor = getEditorByWindowFilePath(file_name);
|
||||||
list<CEditor*>::iterator it = subWindows.begin();
|
if(editor != NULL)
|
||||||
CEditor* current_window = qobject_cast<CEditor*>(_ui.mdiArea->currentSubWindow());
|
{
|
||||||
for(; it != subWindows.end(); ++it)
|
editor->activateWindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(isWorksheetEditor(file_name))
|
||||||
{
|
{
|
||||||
QString sw_file = (*it)->subWindowFilePath();
|
|
||||||
if(file_name == sw_file)
|
|
||||||
{
|
|
||||||
if((*it) != current_window)
|
|
||||||
{
|
|
||||||
(*it)->activateWindow();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(isWorksheetEditor(file_name))
|
|
||||||
{
|
|
||||||
CEditorWorksheet *new_window = new CEditorWorksheet(_ui.mdiArea);
|
CEditorWorksheet *new_window = new CEditorWorksheet(_ui.mdiArea);
|
||||||
new_window->setUndoStack(m_undoStack);
|
new_window->setUndoStack(m_undoStack);
|
||||||
new_window->open(file_name);
|
new_window->open(file_name);
|
||||||
new_window->activateWindow();
|
new_window->activateWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::openWorkFile(QString file)
|
void CMainWindow::openWorkFile(QString file)
|
||||||
{
|
{
|
||||||
QFileInfo* file_path = new QFileInfo(QString("%1/%2").arg(QString(work_path.c_str())).arg(file));
|
QFileInfo* file_path = new QFileInfo(QString("%1/%2").arg(work_path).arg(file));
|
||||||
if(file_path->exists())
|
if(file_path->exists())
|
||||||
{
|
{
|
||||||
if(isWorksheetEditor(file_path->filePath()))
|
if(isWorksheetEditor(file_path->filePath()))
|
||||||
|
@ -273,8 +276,8 @@ void CMainWindow::initializeSettings(bool georges = false)
|
||||||
{
|
{
|
||||||
if(georges == true && initialize_settings["georges"] == false)
|
if(georges == true && initialize_settings["georges"] == false)
|
||||||
{
|
{
|
||||||
CPath::addSearchPath(level_design_path + "/DFN", true, false);
|
CPath::addSearchPath(level_design_path.toStdString() + "/DFN", true, false);
|
||||||
CPath::addSearchPath(level_design_path + "/Game_elem/Creature", true, false);
|
CPath::addSearchPath(level_design_path.toStdString() + "/Game_elem/Creature", true, false);
|
||||||
initialize_settings["georges"] = true;
|
initialize_settings["georges"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,54 +297,21 @@ void CMainWindow::extractWords(QString typeq)
|
||||||
{
|
{
|
||||||
if(verifySettings() == true)
|
if(verifySettings() == true)
|
||||||
{
|
{
|
||||||
CEditorWorksheet* current_window;
|
CEditorWorksheet* editor_window = getEditorByWorksheetType(typeq);
|
||||||
if(_ui.mdiArea->subWindowList().size() > 0)
|
if(editor_window != NULL)
|
||||||
{
|
{
|
||||||
CEditor* editor_window = qobject_cast<CEditor*>(_ui.mdiArea->currentSubWindow());
|
editor_window->activateWindow();
|
||||||
if(QString(editor_window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor
|
QString file_path = editor_window->windowFilePath();
|
||||||
{
|
} else {
|
||||||
current_window = qobject_cast<CEditorWorksheet*>(editor_window);
|
openWorkFile(typeq);
|
||||||
QString file_path = current_window->subWindowFilePath();
|
editor_window = getEditorByWorksheetType(typeq);
|
||||||
if(!current_window->isSheetTable(typeq))
|
if(editor_window != NULL)
|
||||||
{
|
{
|
||||||
list<CEditor*> subWindows = convertSubWindowList(_ui.mdiArea->subWindowList());
|
editor_window->activateWindow();
|
||||||
list<CEditor*>::iterator it = subWindows.begin();
|
QString file_path = editor_window->windowFilePath();
|
||||||
bool finded = false;
|
} else return;
|
||||||
|
}
|
||||||
for(; it != subWindows.end(); ++it)
|
|
||||||
{
|
|
||||||
current_window = qobject_cast<CEditorWorksheet*>((*it));
|
|
||||||
file_path = current_window->subWindowFilePath();
|
|
||||||
if(current_window->isSheetTable(typeq))
|
|
||||||
{
|
|
||||||
finded = true;
|
|
||||||
current_window->activateWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!finded)
|
|
||||||
{
|
|
||||||
openWorkFile(typeq);
|
|
||||||
if(_ui.mdiArea->subWindowList().size() > 0)
|
|
||||||
{
|
|
||||||
current_window = qobject_cast<CEditorWorksheet*>(_ui.mdiArea->currentSubWindow());
|
|
||||||
QString file_path = current_window->windowFilePath();
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
openWorkFile(typeq);
|
|
||||||
if(_ui.mdiArea->subWindowList().size() > 0)
|
|
||||||
{
|
|
||||||
current_window = qobject_cast<CEditorWorksheet*>(_ui.mdiArea->currentSubWindow());
|
|
||||||
QString file_path = current_window->windowFilePath();
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
QString column_name;
|
QString column_name;
|
||||||
// Sheet extraction
|
// Sheet extraction
|
||||||
CSheetWordListBuilder builderS;
|
CSheetWordListBuilder builderS;
|
||||||
|
@ -351,26 +321,26 @@ void CMainWindow::extractWords(QString typeq)
|
||||||
if(typeq.toAscii() == Constants::WK_ITEM) {
|
if(typeq.toAscii() == Constants::WK_ITEM) {
|
||||||
column_name = "item ID";
|
column_name = "item ID";
|
||||||
builderS.SheetExt = "sitem";
|
builderS.SheetExt = "sitem";
|
||||||
builderS.SheetPath = level_design_path + "/game_element/sitem";
|
builderS.SheetPath = level_design_path.append("/game_element/sitem").toStdString();
|
||||||
isSheet = true;
|
isSheet = true;
|
||||||
} else if(typeq.toAscii() == Constants::WK_CREATURE) {
|
} else if(typeq.toAscii() == Constants::WK_CREATURE) {
|
||||||
column_name = "creature ID";
|
column_name = "creature ID";
|
||||||
builderS.SheetExt = "creature";
|
builderS.SheetExt = "creature";
|
||||||
builderS.SheetPath = level_design_path + "/Game_elem/Creature/fauna";
|
builderS.SheetPath = level_design_path.append("/Game_elem/Creature/fauna").toStdString();
|
||||||
isSheet = true;
|
isSheet = true;
|
||||||
} else if(typeq.toAscii() == Constants::WK_SBRICK) {
|
} else if(typeq.toAscii() == Constants::WK_SBRICK) {
|
||||||
column_name = "sbrick ID";
|
column_name = "sbrick ID";
|
||||||
builderS.SheetExt = "sbrick";
|
builderS.SheetExt = "sbrick";
|
||||||
builderS.SheetPath = level_design_path + "/game_element/sbrick";
|
builderS.SheetPath = level_design_path.append("/game_element/sbrick").toStdString();
|
||||||
isSheet = true;
|
isSheet = true;
|
||||||
} else if(typeq.toAscii() == Constants::WK_SPHRASE) {
|
} else if(typeq.toAscii() == Constants::WK_SPHRASE) {
|
||||||
column_name = "sphrase ID";
|
column_name = "sphrase ID";
|
||||||
builderS.SheetExt = "sphrase";
|
builderS.SheetExt = "sphrase";
|
||||||
builderS.SheetPath = level_design_path + "/game_element/sphrase";
|
builderS.SheetPath = level_design_path.append("/game_element/sphrase").toStdString();
|
||||||
isSheet = true;
|
isSheet = true;
|
||||||
} else if(typeq.toAscii() == Constants::WK_PLACE) {
|
} else if(typeq.toAscii() == Constants::WK_PLACE) {
|
||||||
column_name = "placeId";
|
column_name = "placeId";
|
||||||
builderP.PrimPath = primitives_path;
|
builderP.PrimPath = primitives_path.toStdString();
|
||||||
builderP.PrimFilter.push_back("region_*.primitive");
|
builderP.PrimFilter.push_back("region_*.primitive");
|
||||||
builderP.PrimFilter.push_back("indoors_*.primitive");
|
builderP.PrimFilter.push_back("indoors_*.primitive");
|
||||||
isSheet = false;
|
isSheet = false;
|
||||||
|
@ -378,12 +348,12 @@ void CMainWindow::extractWords(QString typeq)
|
||||||
|
|
||||||
if(isSheet)
|
if(isSheet)
|
||||||
{
|
{
|
||||||
current_window->extractWords(current_window->windowFilePath(), column_name, builderS);
|
editor_window->extractWords(editor_window->windowFilePath(), column_name, builderS);
|
||||||
} else {
|
} else {
|
||||||
initializeSettings(false);
|
initializeSettings(false);
|
||||||
current_window->extractWords(current_window->windowFilePath(), column_name, builderP);
|
editor_window->extractWords(editor_window->windowFilePath(), column_name, builderP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,55 +361,22 @@ void CMainWindow::extractBotNames()
|
||||||
{
|
{
|
||||||
if(verifySettings() == true)
|
if(verifySettings() == true)
|
||||||
{
|
{
|
||||||
CEditorWorksheet* current_window;
|
CEditorWorksheet* editor_window = getEditorByWorksheetType(NULL);
|
||||||
if(_ui.mdiArea->subWindowList().size() > 0)
|
if(editor_window != NULL)
|
||||||
{
|
{
|
||||||
CEditor* editor_window = qobject_cast<CEditor*>(_ui.mdiArea->currentSubWindow());
|
editor_window->activateWindow();
|
||||||
if(QString(editor_window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor
|
QString file_path = editor_window->windowFilePath();
|
||||||
{
|
} else {
|
||||||
current_window = qobject_cast<CEditorWorksheet*>(editor_window);
|
openWorkFile(Constants::WK_BOTNAMES);
|
||||||
QString file_path = current_window->subWindowFilePath();
|
editor_window = getEditorByWorksheetType(NULL);
|
||||||
if(!current_window->isBotNamesTable())
|
if(editor_window != NULL)
|
||||||
{
|
{
|
||||||
list<CEditor*> subWindows = convertSubWindowList(_ui.mdiArea->subWindowList());
|
editor_window->activateWindow();
|
||||||
list<CEditor*>::iterator it = subWindows.begin();
|
QString file_path = editor_window->windowFilePath();
|
||||||
bool finded = false;
|
} else return;
|
||||||
|
}
|
||||||
for(; it != subWindows.end(); ++it)
|
|
||||||
{
|
|
||||||
current_window = qobject_cast<CEditorWorksheet*>((*it));
|
|
||||||
file_path = current_window->subWindowFilePath();
|
|
||||||
if(current_window->isBotNamesTable())
|
|
||||||
{
|
|
||||||
finded = true;
|
|
||||||
current_window->activateWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!finded)
|
|
||||||
{
|
|
||||||
openWorkFile(tr(Constants::WK_BOTNAMES));
|
|
||||||
if(_ui.mdiArea->subWindowList().size() > 0)
|
|
||||||
{
|
|
||||||
current_window = qobject_cast<CEditorWorksheet*>(_ui.mdiArea->currentSubWindow());
|
|
||||||
QString file_path = current_window->windowFilePath();
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
openWorkFile(tr(Constants::WK_BOTNAMES));
|
|
||||||
if(_ui.mdiArea->subWindowList().size() > 0)
|
|
||||||
{
|
|
||||||
current_window = qobject_cast<CEditorWorksheet*>(_ui.mdiArea->currentSubWindow());
|
|
||||||
QString file_path = current_window->windowFilePath();
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
initializeSettings(true);
|
initializeSettings(true);
|
||||||
current_window->extractBotNames(filters, level_design_path, ligoConfig);
|
editor_window->extractBotNames(convertQStringList(filters), level_design_path.toStdString(), ligoConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,15 +435,17 @@ void CMainWindow::mergeSingleFile()
|
||||||
void CMainWindow::readSettings()
|
void CMainWindow::readSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
// translation manager settings
|
||||||
settings->beginGroup("translationmanager");
|
settings->beginGroup("translationmanager");
|
||||||
filters = convertQStringList(settings->value("filters").toStringList()); /* filters */
|
filters = settings->value("filters").toStringList();
|
||||||
languages = convertQStringList(settings->value("trlanguages").toStringList()); /* languages */
|
languages = settings->value("trlanguages").toStringList();
|
||||||
translation_path = settings->value("translation").toString().toStdString();
|
translation_path = settings->value("translation").toString();
|
||||||
work_path = settings->value("work").toString().toStdString();
|
work_path = settings->value("work").toString();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
// core settings
|
||||||
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
|
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
|
||||||
level_design_path = settings->value(Core::Constants::LEVELDESIGN_PATH).toString().toStdString();
|
level_design_path = settings->value(Core::Constants::LEVELDESIGN_PATH).toString();
|
||||||
primitives_path = QString(Core::Constants::PRIMITIVES_PATH).toStdString();
|
primitives_path = QString(Core::Constants::PRIMITIVES_PATH); //TODO
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,23 +460,53 @@ bool CMainWindow::verifySettings()
|
||||||
{
|
{
|
||||||
bool count_errors = false;
|
bool count_errors = false;
|
||||||
|
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
if(level_design_path.isNull() || primitives_path.isNull() || work_path.isNull())
|
||||||
settings->beginGroup("translationmanager");
|
|
||||||
|
|
||||||
if(settings->value("filters").toList().count() == 0)
|
|
||||||
{
|
{
|
||||||
QErrorMessage error_settings;
|
QErrorMessage error_settings;
|
||||||
error_settings.showMessage("Please write all the paths on the settings dialog.");
|
error_settings.showMessage("Please write all the paths on the settings dialog.");
|
||||||
error_settings.exec();
|
error_settings.exec();
|
||||||
count_errors = true;
|
count_errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings->endGroup();
|
|
||||||
|
|
||||||
return !count_errors;
|
return !count_errors;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CEditor *CMainWindow::getEditorByWindowFilePath(const QString &fileName)
|
||||||
|
{
|
||||||
|
Q_FOREACH(QMdiSubWindow *subWindow, _ui.mdiArea->subWindowList())
|
||||||
|
{
|
||||||
|
CEditor *currentEditor = qobject_cast<CEditor *>(subWindow);
|
||||||
|
if(currentEditor->subWindowFilePath() == fileName)
|
||||||
|
return currentEditor;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CEditorWorksheet *CMainWindow::getEditorByWorksheetType(const QString &type = NULL)
|
||||||
|
{
|
||||||
|
Q_FOREACH(QMdiSubWindow *subWindow, _ui.mdiArea->subWindowList())
|
||||||
|
{
|
||||||
|
CEditor *currentEditor = qobject_cast<CEditor*>(subWindow);
|
||||||
|
if(QString(currentEditor->widget()->metaObject()->className()) == "QTableWidget")
|
||||||
|
{
|
||||||
|
CEditorWorksheet *editor = qobject_cast<CEditorWorksheet *>(currentEditor);
|
||||||
|
if(!type.isNull())
|
||||||
|
if(editor->isSheetTable(type))
|
||||||
|
{
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(editor->isBotNamesTable())
|
||||||
|
{
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
list<string> CMainWindow::convertQStringList(QStringList listq)
|
list<string> CMainWindow::convertQStringList(QStringList listq)
|
||||||
{
|
{
|
||||||
std::list<std::string> stdlist;
|
std::list<std::string> stdlist;
|
||||||
|
@ -550,20 +519,6 @@ list<string> CMainWindow::convertQStringList(QStringList listq)
|
||||||
return stdlist;
|
return stdlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<CEditor*> CMainWindow::convertSubWindowList(QList<QMdiSubWindow*> listq)
|
|
||||||
{
|
|
||||||
list<CEditor*> subwindows;
|
|
||||||
QList<QMdiSubWindow*>::iterator it = listq.begin();
|
|
||||||
|
|
||||||
for(; it != listq.end(); ++it)
|
|
||||||
{
|
|
||||||
CEditor* current_window = qobject_cast<CEditor*>((*it));
|
|
||||||
subwindows.push_back(current_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
return subwindows;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMainWindow::isWorksheetEditor(QString filename)
|
bool CMainWindow::isWorksheetEditor(QString filename)
|
||||||
{
|
{
|
||||||
STRING_MANAGER::TWorksheet wk_file;
|
STRING_MANAGER::TWorksheet wk_file;
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "source_selection.h"
|
#include "source_selection.h"
|
||||||
#include "ui_translation_manager_main_window.h"
|
#include "ui_translation_manager_main_window.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include "editor_worksheet.h"
|
||||||
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
|
@ -72,12 +73,12 @@ private:
|
||||||
QSignalMapper *windowMapper;
|
QSignalMapper *windowMapper;
|
||||||
// config
|
// config
|
||||||
map<string,bool> initialize_settings;
|
map<string,bool> initialize_settings;
|
||||||
list<string> filters;
|
QList<QString> filters;
|
||||||
list<string> languages;
|
QList<QString> languages;
|
||||||
string level_design_path;
|
QString level_design_path;
|
||||||
string primitives_path;
|
QString primitives_path;
|
||||||
string translation_path;
|
QString translation_path;
|
||||||
string work_path;
|
QString work_path;
|
||||||
NLLIGO::CLigoConfig ligoConfig;
|
NLLIGO::CLigoConfig ligoConfig;
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void extractBotNames();
|
void extractBotNames();
|
||||||
|
@ -99,7 +100,9 @@ private:
|
||||||
void createToolbar();
|
void createToolbar();
|
||||||
void initializeSettings(bool georges);
|
void initializeSettings(bool georges);
|
||||||
list<string> convertQStringList(QStringList listq);
|
list<string> convertQStringList(QStringList listq);
|
||||||
list<CEditor*> convertSubWindowList(QList<QMdiSubWindow*> listq);
|
CEditor* getEditorByWindowFilePath(const QString &fileName);
|
||||||
|
// Worksheet specific functions
|
||||||
|
CEditorWorksheet* getEditorByWorksheetType(const QString &type);
|
||||||
bool isWorksheetEditor(QString filename);
|
bool isWorksheetEditor(QString filename);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,17 +46,17 @@ QString CTranslationManagerSettingsPage::id() const
|
||||||
|
|
||||||
QString CTranslationManagerSettingsPage::trName() const
|
QString CTranslationManagerSettingsPage::trName() const
|
||||||
{
|
{
|
||||||
return tr("Translation Manager page");
|
return tr("Translation Manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CTranslationManagerSettingsPage::category() const
|
QString CTranslationManagerSettingsPage::category() const
|
||||||
{
|
{
|
||||||
return QLatin1String("General");
|
return QLatin1String("Translation Manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CTranslationManagerSettingsPage::trCategory() const
|
QString CTranslationManagerSettingsPage::trCategory() const
|
||||||
{
|
{
|
||||||
return tr("General");
|
return tr("Translation Manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon CTranslationManagerSettingsPage::categoryIcon() const
|
QIcon CTranslationManagerSettingsPage::categoryIcon() const
|
||||||
|
@ -195,12 +195,12 @@ void CTranslationManagerSettingsPage::writeSettings()
|
||||||
|
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup("translationmanager");
|
settings->beginGroup("translationmanager");
|
||||||
settings->setValue("filters", filters);
|
settings->setValue("filters", filters);
|
||||||
settings->setValue("trlanguages", languages);
|
settings->setValue("trlanguages", languages);
|
||||||
settings->setValue("translation", translation);
|
settings->setValue("translation", translation);
|
||||||
settings->setValue("work", work);
|
settings->setValue("work", work);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue