|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
#include <QTableWidget>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
|
|
#include "nel/misc/diff_tool.h"
|
|
|
|
|
|
|
|
|
@ -17,9 +18,12 @@ public:
|
|
|
|
|
UXTEditorPvt()
|
|
|
|
|
{
|
|
|
|
|
t = new QTableWidget();
|
|
|
|
|
changed = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTableWidget *t;
|
|
|
|
|
std::vector< STRING_MANAGER::TStringInfo > infos;
|
|
|
|
|
bool changed;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -30,6 +34,8 @@ CEditor( parent )
|
|
|
|
|
setAttribute( Qt::WA_DeleteOnClose );
|
|
|
|
|
|
|
|
|
|
d_ptr = new UXTEditorPvt();
|
|
|
|
|
|
|
|
|
|
blockTableSignals( false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UXTEditor::~UXTEditor()
|
|
|
|
@ -40,12 +46,16 @@ UXTEditor::~UXTEditor()
|
|
|
|
|
|
|
|
|
|
void UXTEditor::open( QString filename )
|
|
|
|
|
{
|
|
|
|
|
std::vector< STRING_MANAGER::TStringInfo > infos;
|
|
|
|
|
std::vector< STRING_MANAGER::TStringInfo > &infos = d_ptr->infos;
|
|
|
|
|
|
|
|
|
|
infos.clear();
|
|
|
|
|
STRING_MANAGER::loadStringFile( filename.toUtf8().constData(), infos, true );
|
|
|
|
|
|
|
|
|
|
if( infos.size() == 0 )
|
|
|
|
|
if( d_ptr->infos.size() == 0 )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
blockTableSignals( true );
|
|
|
|
|
|
|
|
|
|
d_ptr->t->clear();
|
|
|
|
|
d_ptr->t->setColumnCount( 2 );
|
|
|
|
|
d_ptr->t->setRowCount( infos.size() );
|
|
|
|
@ -71,6 +81,8 @@ void UXTEditor::open( QString filename )
|
|
|
|
|
|
|
|
|
|
d_ptr->t->resizeColumnsToContents();
|
|
|
|
|
|
|
|
|
|
blockTableSignals( false );
|
|
|
|
|
|
|
|
|
|
setWidget( d_ptr->t );
|
|
|
|
|
setCurrentFile( filename );
|
|
|
|
|
}
|
|
|
|
@ -91,10 +103,38 @@ void UXTEditor::activateWindow()
|
|
|
|
|
|
|
|
|
|
void UXTEditor::closeEvent( QCloseEvent *e )
|
|
|
|
|
{
|
|
|
|
|
if( d_ptr->changed )
|
|
|
|
|
{
|
|
|
|
|
int reply = QMessageBox::question( this,
|
|
|
|
|
tr( "Table changed" ),
|
|
|
|
|
tr( "The table has changed. Would you like to save your changes?" ),
|
|
|
|
|
QMessageBox::Yes,
|
|
|
|
|
QMessageBox::No
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if( reply == QMessageBox::Yes )
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e->accept();
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UXTEditor::onCellChanged( int row, int column )
|
|
|
|
|
{
|
|
|
|
|
QTableWidgetItem *item = d_ptr->t->item( row, column );
|
|
|
|
|
STRING_MANAGER::TStringInfo &info = d_ptr->infos[ row ];
|
|
|
|
|
|
|
|
|
|
if( column == 0 )
|
|
|
|
|
info.Identifier = item->text().toUtf8().constData();
|
|
|
|
|
else
|
|
|
|
|
if( column == 1 )
|
|
|
|
|
info.Text = item->text().toUtf8().constData();
|
|
|
|
|
|
|
|
|
|
d_ptr->changed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UXTEditor::setHeaderText( const QString &id, const QString &text )
|
|
|
|
|
{
|
|
|
|
|
QTableWidgetItem *h1 = new QTableWidgetItem( id );
|
|
|
|
@ -105,4 +145,12 @@ void UXTEditor::setHeaderText( const QString &id, const QString &text )
|
|
|
|
|
d_ptr->t->setHorizontalHeaderItem( 1, h2 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UXTEditor::blockTableSignals( bool block )
|
|
|
|
|
{
|
|
|
|
|
if( block )
|
|
|
|
|
disconnect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) );
|
|
|
|
|
else
|
|
|
|
|
connect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|