From 05216897f0e96e63feea777c1cc8ac5b0e5bd9b0 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 18 Jul 2014 00:50:40 +0200 Subject: [PATCH] Implemented saving. --HG-- branch : gsoc2014-dfighter --- .../translation_manager_main_window.cpp | 4 ++- .../translation_manager/uxt_editor.cpp | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) 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 f3e882739..59e8d5ebe 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 @@ -553,7 +553,9 @@ void CMainWindow::mergeSingleFile() void CMainWindow::onUxtClicked() { UXTEditor *e = new UXTEditor(); - e->open( work_path + "/" + QString( Constants::WK_UXT ) ); + QString path = work_path + "/" + QString( Constants::WK_UXT ); + e->open( path ); + e->setCurrentFile( path ); _ui.mdiArea->addSubWindow( e ); e->activateWindow(); } diff --git a/code/studio/src/plugins/translation_manager/uxt_editor.cpp b/code/studio/src/plugins/translation_manager/uxt_editor.cpp index 69cd1a9b6..6147b8de2 100644 --- a/code/studio/src/plugins/translation_manager/uxt_editor.cpp +++ b/code/studio/src/plugins/translation_manager/uxt_editor.cpp @@ -6,6 +6,9 @@ #include #include +#include +#include + #include "nel/misc/diff_tool.h" namespace TranslationManager @@ -89,10 +92,39 @@ void UXTEditor::open( QString filename ) void UXTEditor::save() { + saveAs( current_file ); } void UXTEditor::saveAs( QString filename ) { + QFile f( filename ); + if( !f.open( QIODevice::WriteOnly ) ) + return; + + QTextStream out( &f ); + + std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = d_ptr->infos.begin(); + while( itr != d_ptr->infos.end() ) + { + QString line = ""; + + line += itr->Identifier.c_str(); + line += "\t"; + + line += "["; + line += itr->Text.toUtf8().c_str(); + line += "]"; + + line += "\r\n"; + + out << line; + + ++itr; + } + + f.close(); + + d_ptr->changed = false; } void UXTEditor::activateWindow()