String cooking support

This commit is contained in:
Aruki
2019-01-12 23:43:41 -08:00
parent a1d94cc58f
commit e9e1ccb8d6
12 changed files with 431 additions and 15 deletions

View File

@@ -60,6 +60,21 @@ CStringEditor::~CStringEditor()
delete mpUI;
}
bool CStringEditor::Save()
{
if (!mpStringTable->Entry()->Save())
{
UICommon::ErrorMsg(this, "Failed to save!");
return false;
}
else
{
UndoStack().setClean();
setWindowModified(false);
return true;
}
}
bool CStringEditor::eventFilter(QObject* pWatched, QEvent* pEvent)
{
if (pEvent->type() == QEvent::FocusOut)
@@ -120,6 +135,9 @@ void CStringEditor::InitUI()
connect( mpListModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
this, SLOT(OnRowsMoved(QModelIndex,int,int,QModelIndex,int)) );
connect( mpUI->ActionSave, SIGNAL(triggered(bool)), this, SLOT(Save()) );
connect( mpUI->ActionSaveAndCook, SIGNAL(triggered(bool)), this, SLOT(SaveAndRepack()) );
connect( &UndoStack(), SIGNAL(indexChanged(int)), this, SLOT(UpdateUI()) );
mpUI->ToolBar->addSeparator();
@@ -224,6 +242,7 @@ void CStringEditor::UpdateUI()
pSelectionModel->blockSignals(true);
pSelectionModel->setCurrentIndex(NewStringIndex, QItemSelectionModel::ClearAndSelect);
pSelectionModel->blockSignals(false);
mpUI->StringNameListView->scrollTo(NewStringIndex);
mpUI->StringNameListView->update(OldStringIndex);
}
mpUI->StringNameListView->update(NewStringIndex);

View File

@@ -43,7 +43,8 @@ public:
explicit CStringEditor(CStringTable* pStringTable, QWidget* pParent = 0);
~CStringEditor();
bool eventFilter(QObject* pWatched, QEvent* pEvent);
virtual bool Save() override;
virtual bool eventFilter(QObject* pWatched, QEvent* pEvent) override;
void InitUI();
void UpdateStatusBar();