Changed: #1307 Added the base files for phrase editor and new method to save the editor type

This commit is contained in:
cemycc 2011-07-27 01:01:00 +03:00
parent 907a09526b
commit fb5373284d
7 changed files with 150 additions and 18 deletions

View file

@ -16,6 +16,7 @@ SET(OVQT_PLUG_TRANSLATION_MANAGER_HDR translation_manager_plugin.h
source_selection.h
ftp_selection.h
editor_worksheet.h
editor_phrase.h
extract_new_sheet_names.h
extract_bot_names.h)

View file

@ -0,0 +1,53 @@
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
//
// 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/>.
// Qt includes
#include <QtGui/QErrorMessage>
#include <QtCore/qfileinfo.h>
#include <QtGui/QMessageBox>
#include <QtGui/QCloseEvent>
// Project includes
#include "editor_phrase.h"
#include "translation_manager_constants.h"
using namespace std;
namespace Plugin {
void CEditorPhrase::open(QString filename)
{
}
void CEditorPhrase::activateWindow()
{
}
void CEditorPhrase::save()
{
}
void CEditorPhrase::saveAs(QString filename)
{
}
}

View file

@ -0,0 +1,48 @@
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
//
// 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 EDITOR_PHRASE_H
#define EDITOR_PHRASE_H
// Qt includes
#include <QtCore/QObject>
#include <QtGui/QWidget>
#include <QtGui/QMdiArea>
#include <QtGui/QMdiSubWindow>
#include <QtGui/QUndoCommand>
#include <QtGui/QUndoStack>
// Project includes
#include "translation_manager_editor.h"
namespace Plugin {
class CEditorPhrase : public CEditor
{
Q_OBJECT
public:
CEditorPhrase(QMdiArea* parent) : CEditor(parent) {}
CEditorPhrase() : CEditor() {}
void open(QString filename);
void save();
void saveAs(QString filename);
void activateWindow();
};
}
#endif /* EDITOR_PHRASE_H */

View file

@ -93,6 +93,7 @@ void CEditorWorksheet::open(QString filename)
setCurrentFile(filename);
setAttribute(Qt::WA_DeleteOnClose);
setWidget(table_editor);
editor_type = Constants::ED_SHEET;
table_editor->resizeColumnsToContents();
table_editor->resizeRowsToContents();
// set editor signals

View file

@ -12,6 +12,9 @@ namespace Plugin
{
namespace Constants
{
const int ED_SHEET = 1;
const int ED_PHRASE = 2;
const char * const WK_BOTNAMES = "bot_names_wk.txt";
const char * const WK_ITEM = "item_words_wk.txt";
const char * const WK_CREATURE = "creature_words_wk.txt";

View file

@ -40,6 +40,10 @@ public:
virtual void saveAs(QString filename) =0;
virtual void activateWindow() =0;
public:
int eType()
{
return editor_type;
}
QString subWindowFilePath()
{
return current_file;

View file

@ -206,6 +206,10 @@ void CMainWindow::open()
editor->activateWindow();
return;
}
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
// sheet editor
if(isWorksheetEditor(file_name))
{
CEditorWorksheet *new_window = new CEditorWorksheet(_ui.mdiArea);
@ -213,6 +217,9 @@ void CMainWindow::open()
new_window->open(file_name);
new_window->activateWindow();
}
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
}
@ -241,11 +248,13 @@ void CMainWindow::save()
if(_ui.mdiArea->subWindowList().size() > 0)
{
CEditor* current_window = qobject_cast<CEditor*>(_ui.mdiArea->currentSubWindow());
if(QString(current_window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor
{
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
current_window->save();
}
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
}
@ -260,11 +269,13 @@ void CMainWindow::saveAs()
if (!file_name.isEmpty())
{
CEditor* current_window = qobject_cast<CEditor*>(_ui.mdiArea->currentSubWindow());
if(QString(current_window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor
{
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
current_window->saveAs(file_name);
}
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
}
@ -341,7 +352,9 @@ void CMainWindow::extractWords(QString typeq)
builderP.PrimFilter.push_back("indoors_*.primitive");
isSheet = false;
}
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
if(isSheet)
{
editor_window->extractWords(editor_window->windowFilePath(), column_name, builderS);
@ -349,6 +362,9 @@ void CMainWindow::extractWords(QString typeq)
initializeSettings(false);
editor_window->extractWords(editor_window->windowFilePath(), column_name, builderP);
}
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
}
@ -371,8 +387,14 @@ void CMainWindow::extractBotNames()
QString file_path = editor_window->windowFilePath();
} else return;
}
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
initializeSettings(true);
editor_window->extractBotNames(convertQStringList(filters), level_design_path.toStdString(), ligoConfig);
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
}
@ -392,7 +414,7 @@ void CMainWindow::mergeSingleFile()
return;
}
if(QString(editor_window->widget()->metaObject()->className()) != "QTableWidget") // Sheet Editor
if(editor_window->eType() != Constants::ED_SHEET) // Sheet Editor
{
QErrorMessage error;
error.showMessage(QString("Please open or activate the window with a sheet file."));
@ -500,7 +522,7 @@ CEditorWorksheet *CMainWindow::getEditorByWorksheetType(const QString &type)
Q_FOREACH(QMdiSubWindow *subWindow, _ui.mdiArea->subWindowList())
{
CEditor *currentEditor = qobject_cast<CEditor*>(subWindow);
if(QString(currentEditor->widget()->metaObject()->className()) == "QTableWidget")
if(currentEditor->eType() == Constants::ED_SHEET)
{
CEditorWorksheet *editor = qobject_cast<CEditorWorksheet *>(currentEditor);
if(type != NULL) {