From e5fd9ca07bb22804adf3e59b2386176f98f2d9ce Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 17 Jul 2014 19:08:29 +0200 Subject: [PATCH] UXT Editor widget --- .../translation_manager/CMakeLists.txt | 1 + .../translation_manager_constants.h | 4 +- .../translation_manager_main_window.cpp | 14 +++ .../translation_manager_main_window.h | 1 + .../translation_manager/uxt_editor.cpp | 96 +++++++++++++++++++ .../plugins/translation_manager/uxt_editor.h | 33 +++++++ 6 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 code/studio/src/plugins/translation_manager/uxt_editor.cpp create mode 100644 code/studio/src/plugins/translation_manager/uxt_editor.h diff --git a/code/studio/src/plugins/translation_manager/CMakeLists.txt b/code/studio/src/plugins/translation_manager/CMakeLists.txt index 6f0f7a1c2..b35c64735 100644 --- a/code/studio/src/plugins/translation_manager/CMakeLists.txt +++ b/code/studio/src/plugins/translation_manager/CMakeLists.txt @@ -17,6 +17,7 @@ SET(OVQT_PLUG_TRANSLATION_MANAGER_HDR translation_manager_plugin.h ftp_selection.h editor_worksheet.h editor_phrase.h + uxt_editor.h ) SET(OVQT_PLUG_TRANSLATION_MANAGER_UIS translation_manager_settings_page.ui diff --git a/code/studio/src/plugins/translation_manager/translation_manager_constants.h b/code/studio/src/plugins/translation_manager/translation_manager_constants.h index d72a2b223..7ff813d40 100644 --- a/code/studio/src/plugins/translation_manager/translation_manager_constants.h +++ b/code/studio/src/plugins/translation_manager/translation_manager_constants.h @@ -21,8 +21,9 @@ namespace TranslationManager { namespace Constants { -const int ED_SHEET = 1; +const int ED_SHEET = 1; const int ED_PHRASE = 2; +const int ED_UXT = 3; const char *const WK_BOTNAMES = "bot_names_wk.txt"; const char *const WK_ITEM = "item_words_wk.txt"; @@ -32,6 +33,7 @@ const char *const WK_SPHRASE = "sphrase_words_wk.txt"; const char *const WK_PLACE = "place_words_wk.txt"; const char *const WK_CONTINENT = "place_words_wk.txt"; const char *const WK_STABLE = "place_words_wk.txt"; +const char *const WK_UXT = "wk.uxt"; } } diff --git a/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp b/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp index dcade72ef..f3e882739 100644 --- a/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp +++ b/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp @@ -41,6 +41,8 @@ #include #include +#include "uxt_editor.h" + namespace TranslationManager { @@ -84,6 +86,10 @@ void CMainWindow::createMenus() if( m != NULL ) { windowMenu = m->addMenu("Window"); + + QAction *a = m->addAction( "Uxt" ); + connect( a, SIGNAL( triggered() ), this, SLOT( onUxtClicked() ) ); + menu = m; } @@ -544,6 +550,14 @@ void CMainWindow::mergeSingleFile() } } +void CMainWindow::onUxtClicked() +{ + UXTEditor *e = new UXTEditor(); + e->open( work_path + "/" + QString( Constants::WK_UXT ) ); + _ui.mdiArea->addSubWindow( e ); + e->activateWindow(); +} + // Read the settings from QSettings void CMainWindow::readSettings() { diff --git a/code/studio/src/plugins/translation_manager/translation_manager_main_window.h b/code/studio/src/plugins/translation_manager/translation_manager_main_window.h index 73bccdd8e..ba6ce8746 100644 --- a/code/studio/src/plugins/translation_manager/translation_manager_main_window.h +++ b/code/studio/src/plugins/translation_manager/translation_manager_main_window.h @@ -90,6 +90,7 @@ private Q_SLOTS: void setActiveSubWindow(QWidget *window); void updateWindowsList(); void mergeSingleFile(); + void onUxtClicked(); private: void openWorkFile(QString file); diff --git a/code/studio/src/plugins/translation_manager/uxt_editor.cpp b/code/studio/src/plugins/translation_manager/uxt_editor.cpp new file mode 100644 index 000000000..e13a6300d --- /dev/null +++ b/code/studio/src/plugins/translation_manager/uxt_editor.cpp @@ -0,0 +1,96 @@ +#include "translation_manager_constants.h" +#include "uxt_editor.h" + +#include +#include +#include + +#include "nel/misc/diff_tool.h" + +namespace TranslationManager +{ + +class UXTEditorPvt +{ +public: + + UXTEditorPvt() + { + t = new QTableWidget(); + } + + QTableWidget *t; +}; + + +UXTEditor::UXTEditor( QMdiArea *parent ) : +CEditor( parent ) +{ + editor_type = Constants::ED_UXT; + setAttribute( Qt::WA_DeleteOnClose ); + + d_ptr = new UXTEditorPvt(); +} + +UXTEditor::~UXTEditor() +{ + delete d_ptr; + d_ptr = NULL; +} + +void UXTEditor::open( QString filename ) +{ + std::vector< STRING_MANAGER::TStringInfo > infos; + STRING_MANAGER::loadStringFile( filename.toUtf8().constData(), infos, true ); + + if( infos.size() == 0 ) + return; + + d_ptr->t->clear(); + d_ptr->t->setColumnCount( 2 ); + d_ptr->t->setRowCount( infos.size() ); + + int i = 0; + + std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = infos.begin(); + while( itr != infos.end() ) + { + const STRING_MANAGER::TStringInfo &info = *itr; + + QTableWidgetItem *name = new QTableWidgetItem( info.Identifier.c_str() ); + QTableWidgetItem *text1 = new QTableWidgetItem( info.Text.toUtf8().c_str() ); + + d_ptr->t->setItem( i, 0, name ); + d_ptr->t->setItem( i, 1, text1 ); + + ++itr; + i++; + } + + d_ptr->t->resizeColumnsToContents(); + + setWidget( d_ptr->t ); + setCurrentFile( filename ); +} + +void UXTEditor::save() +{ +} + +void UXTEditor::saveAs( QString filename ) +{ +} + +void UXTEditor::activateWindow() +{ + showMaximized(); +} + + +void UXTEditor::closeEvent( QCloseEvent *e ) +{ + e->accept(); + close(); +} + +} diff --git a/code/studio/src/plugins/translation_manager/uxt_editor.h b/code/studio/src/plugins/translation_manager/uxt_editor.h new file mode 100644 index 000000000..231461bc3 --- /dev/null +++ b/code/studio/src/plugins/translation_manager/uxt_editor.h @@ -0,0 +1,33 @@ +#ifndef UXT_EDITOR_H +#define UXT_EDITOR_H + +#include "translation_manager_editor.h" + +namespace TranslationManager +{ + +class UXTEditorPvt; + +class UXTEditor : public CEditor +{ + Q_OBJECT +public: + UXTEditor( QMdiArea *parent = NULL ); + ~UXTEditor(); + + void open( QString filename ); + void save(); + void saveAs( QString filename ); + void activateWindow(); + +protected: + void closeEvent( QCloseEvent *e ); + +private: + UXTEditorPvt *d_ptr; +}; + +} + +#endif +