FIXED: #1471 LinkList should update the edited item's display when the editor is finished.

This commit is contained in:
dfighter1985 2012-07-25 22:10:23 +02:00
parent f608e3a780
commit 0bd53bf1b6
4 changed files with 30 additions and 1 deletions

View file

@ -76,6 +76,8 @@ namespace GUIEditor
data.cond = condEdit->text().toStdString(); data.cond = condEdit->text().toStdString();
parser->updateLinkData( data.id, data ); parser->updateLinkData( data.id, data );
Q_EMIT okClicked();
hide(); hide();
} }
} }

View file

@ -32,6 +32,9 @@ namespace GUIEditor
void setup(); void setup();
void setLinkId( uint32 linkId ); void setLinkId( uint32 linkId );
Q_SIGNALS:
void okClicked();
private Q_SLOTS: private Q_SLOTS:
void onOKButtonClicked(); void onOKButtonClicked();

View file

@ -41,6 +41,8 @@ namespace GUIEditor
connect( linkTree, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), connect( linkTree, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ),
this, SLOT( onItemDblClicked( QTreeWidgetItem* ) ) ); this, SLOT( onItemDblClicked( QTreeWidgetItem* ) ) );
connect( linkEditor, SIGNAL( okClicked() ), this, SLOT( onEditorFinished() ) );
} }
LinkList::~LinkList() LinkList::~LinkList()
@ -50,6 +52,8 @@ namespace GUIEditor
void LinkList::onGUILoaded() void LinkList::onGUILoaded()
{ {
linkTree->clear();
const std::map< uint32, SLinkData > &linkMap = const std::map< uint32, SLinkData > &linkMap =
CWidgetManager::getInstance()->getParser()->getLinkMap(); CWidgetManager::getInstance()->getParser()->getLinkMap();
@ -125,7 +129,6 @@ namespace GUIEditor
void LinkList::onEditButtonClicked() void LinkList::onEditButtonClicked()
{ {
QTreeWidgetItem *item = QTreeWidgetItem *item =
linkTree->currentItem(); linkTree->currentItem();
if( item == NULL ) if( item == NULL )
@ -150,5 +153,25 @@ namespace GUIEditor
linkEditor->setLinkId( id ); linkEditor->setLinkId( id );
linkEditor->show(); linkEditor->show();
} }
void LinkList::onEditorFinished()
{
QTreeWidgetItem *item =
linkTree->currentItem();
if( item == NULL )
return;
bool ok;
uint32 id = item->data( 3, Qt::UserRole ).toUInt( &ok );
if( !ok )
return;
SLinkData data;
if( !CWidgetManager::getInstance()->getParser()->getLinkData( id, data ) )
return;
item->setText( 1, data.target.c_str() );
item->setText( 2, data.action.c_str() );
}
} }

View file

@ -39,6 +39,7 @@ namespace GUIEditor
void onRemoveButtonClicked(); void onRemoveButtonClicked();
void onEditButtonClicked(); void onEditButtonClicked();
void onItemDblClicked( QTreeWidgetItem *item ); void onItemDblClicked( QTreeWidgetItem *item );
void onEditorFinished();
private: private:
LinkEditor *linkEditor; LinkEditor *linkEditor;