CGeneratePropertyNamesDialog: Eliminate variable shadowing, etc
This commit is contained in:
parent
dbd2912ee5
commit
54f90b3b8f
|
@ -50,9 +50,9 @@ void CGeneratePropertyNamesDialog::AddToIDPool(IProperty* pProperty)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ID = pProperty->ID();
|
const uint32 ID = pProperty->ID();
|
||||||
const char* pkTypeName = pProperty->HashableTypeName();
|
const char* pkTypeName = pProperty->HashableTypeName();
|
||||||
mIdPairs << SPropertyIdTypePair { ID, pkTypeName };
|
mIdPairs.push_back(SPropertyIdTypePair{ID, pkTypeName});
|
||||||
|
|
||||||
const QString ItemText = tr("%1 [%2]").arg(*TString::HexString(pProperty->ID(), 8, false)).arg(pkTypeName);
|
const QString ItemText = tr("%1 [%2]").arg(*TString::HexString(pProperty->ID(), 8, false)).arg(pkTypeName);
|
||||||
mpUI->IdPoolList->addItem(ItemText);
|
mpUI->IdPoolList->addItem(ItemText);
|
||||||
|
@ -115,12 +115,12 @@ void CGeneratePropertyNamesDialog::AddSuffix()
|
||||||
/** Deletes an item from the suffix list */
|
/** Deletes an item from the suffix list */
|
||||||
void CGeneratePropertyNamesDialog::DeleteSuffix()
|
void CGeneratePropertyNamesDialog::DeleteSuffix()
|
||||||
{
|
{
|
||||||
if (mpUI->TypeSuffixesListWidget->selectedItems().size() > 0)
|
if (mpUI->TypeSuffixesListWidget->selectedItems().empty())
|
||||||
{
|
return;
|
||||||
int Row = mpUI->TypeSuffixesListWidget->currentRow();
|
|
||||||
|
const int Row = mpUI->TypeSuffixesListWidget->currentRow();
|
||||||
delete mpUI->TypeSuffixesListWidget->takeItem(Row);
|
delete mpUI->TypeSuffixesListWidget->takeItem(Row);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** Clear the ID pool */
|
/** Clear the ID pool */
|
||||||
void CGeneratePropertyNamesDialog::ClearIdPool()
|
void CGeneratePropertyNamesDialog::ClearIdPool()
|
||||||
|
@ -148,7 +148,7 @@ void CGeneratePropertyNamesDialog::StartGeneration()
|
||||||
|
|
||||||
for (int RowIdx = 0; RowIdx < mpUI->TypeSuffixesListWidget->count(); RowIdx++)
|
for (int RowIdx = 0; RowIdx < mpUI->TypeSuffixesListWidget->count(); RowIdx++)
|
||||||
{
|
{
|
||||||
QString ItemText = mpUI->TypeSuffixesListWidget->item(RowIdx)->text();
|
const QString ItemText = mpUI->TypeSuffixesListWidget->item(RowIdx)->text();
|
||||||
Params.TypeNames.push_back(TO_TSTRING(ItemText));
|
Params.TypeNames.push_back(TO_TSTRING(ItemText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,14 +188,12 @@ void CGeneratePropertyNamesDialog::GenerationComplete()
|
||||||
mNotifier.SetCanceled(false);
|
mNotifier.SetCanceled(false);
|
||||||
mUpdateTimer.stop();
|
mUpdateTimer.stop();
|
||||||
|
|
||||||
mTaskOutput = QList<SGeneratedPropertyName>::fromStdList(
|
mTaskOutput = QList<SGeneratedPropertyName>::fromStdList(mGenerator.GetOutput());
|
||||||
mGenerator.GetOutput()
|
|
||||||
);
|
|
||||||
|
|
||||||
mpUI->ProgressBar->setValue(mpUI->ProgressBar->maximum());
|
mpUI->ProgressBar->setValue(mpUI->ProgressBar->maximum());
|
||||||
|
|
||||||
disconnect( &mFutureWatcher, 0, this, 0 );
|
disconnect(&mFutureWatcher, nullptr, this, nullptr);
|
||||||
disconnect( &mUpdateTimer, 0, this, 0 );
|
disconnect(&mUpdateTimer, nullptr, this, nullptr);
|
||||||
UpdateUI();
|
UpdateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,19 +212,19 @@ void CGeneratePropertyNamesDialog::OnTreeItemChecked(QTreeWidgetItem* pItem)
|
||||||
void CGeneratePropertyNamesDialog::OnTreeItemDoubleClicked(QTreeWidgetItem* pItem)
|
void CGeneratePropertyNamesDialog::OnTreeItemDoubleClicked(QTreeWidgetItem* pItem)
|
||||||
{
|
{
|
||||||
// Check whether this is an XML path
|
// Check whether this is an XML path
|
||||||
if (pItem->parent() != nullptr)
|
if (pItem->parent() == nullptr)
|
||||||
{
|
return;
|
||||||
QString Text = pItem->text(0);
|
|
||||||
|
|
||||||
if (Text.endsWith(".xml"))
|
const QString Text = pItem->text(0);
|
||||||
{
|
|
||||||
TString TStrText = TO_TSTRING(Text);
|
if (!Text.endsWith(".xml"))
|
||||||
TString DirPath = gDataDir + "templates/" + TStrText.GetFileDirectory();
|
return;
|
||||||
TString AbsPath = FileUtil::MakeAbsolute(DirPath) + TStrText.GetFileName();
|
|
||||||
|
const TString TStrText = TO_TSTRING(Text);
|
||||||
|
const TString DirPath = gDataDir + "templates/" + TStrText.GetFileDirectory();
|
||||||
|
const TString AbsPath = FileUtil::MakeAbsolute(DirPath) + TStrText.GetFileName();
|
||||||
UICommon::OpenInExternalApplication( TO_QSTRING(AbsPath) );
|
UICommon::OpenInExternalApplication( TO_QSTRING(AbsPath) );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Check all items in the output tree */
|
/** Check all items in the output tree */
|
||||||
void CGeneratePropertyNamesDialog::CheckAll()
|
void CGeneratePropertyNamesDialog::CheckAll()
|
||||||
|
@ -239,7 +237,7 @@ void CGeneratePropertyNamesDialog::CheckAll()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem* pItem = mpUI->OutputTreeWidget->topLevelItem(RowIdx);
|
QTreeWidgetItem* pItem = mpUI->OutputTreeWidget->topLevelItem(RowIdx);
|
||||||
pItem->setCheckState(0, Qt::Checked);
|
pItem->setCheckState(0, Qt::Checked);
|
||||||
mCheckedItems << pItem;
|
mCheckedItems.push_back(pItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpUI->OutputTreeWidget->blockSignals(false);
|
mpUI->OutputTreeWidget->blockSignals(false);
|
||||||
|
@ -279,12 +277,11 @@ void CGeneratePropertyNamesDialog::ApplyChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform rename operation
|
// Perform rename operation
|
||||||
for (int ItemIdx = 0; ItemIdx < mCheckedItems.size(); ItemIdx++)
|
for (QTreeWidgetItem* pItem : mCheckedItems)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem* pItem = mCheckedItems[ItemIdx];
|
const uint32 ID = TO_TSTRING(pItem->text(2)).ToInt32(16);
|
||||||
uint32 ID = TO_TSTRING( pItem->text(2) ).ToInt32(16);
|
const TString Type = TO_TSTRING(pItem->text(1));
|
||||||
TString Type = TO_TSTRING( pItem->text(1) );
|
const TString NewName = TO_TSTRING(pItem->text(0));
|
||||||
TString NewName = TO_TSTRING( pItem->text(0) );
|
|
||||||
|
|
||||||
NPropertyMap::SetPropertyName(ID, *Type, *NewName);
|
NPropertyMap::SetPropertyName(ID, *Type, *NewName);
|
||||||
pItem->setText(3, TO_QSTRING(NewName));
|
pItem->setText(3, TO_QSTRING(NewName));
|
||||||
|
@ -299,40 +296,41 @@ void CGeneratePropertyNamesDialog::CheckForNewResults()
|
||||||
const std::list<SGeneratedPropertyName>& rkOutput = mGenerator.GetOutput();
|
const std::list<SGeneratedPropertyName>& rkOutput = mGenerator.GetOutput();
|
||||||
|
|
||||||
QTreeWidget* pTreeWidget = mpUI->OutputTreeWidget;
|
QTreeWidget* pTreeWidget = mpUI->OutputTreeWidget;
|
||||||
int CurItemCount = pTreeWidget->topLevelItemCount();
|
const int CurItemCount = pTreeWidget->topLevelItemCount();
|
||||||
|
|
||||||
// Add new items to the tree
|
// Add new items to the tree
|
||||||
if (rkOutput.size() > CurItemCount)
|
if (static_cast<int>(rkOutput.size()) > CurItemCount)
|
||||||
{
|
{
|
||||||
auto Iter = rkOutput.cbegin();
|
auto Iter = rkOutput.cbegin();
|
||||||
auto End = rkOutput.cend();
|
auto End = rkOutput.cend();
|
||||||
std::advance(Iter, CurItemCount);
|
std::advance(Iter, CurItemCount);
|
||||||
|
|
||||||
for (; Iter != End; Iter++)
|
for (; Iter != End; ++Iter)
|
||||||
{
|
{
|
||||||
const SGeneratedPropertyName& rkName = *Iter;
|
const SGeneratedPropertyName& rkName = *Iter;
|
||||||
|
|
||||||
// Add an item to the tree for this name
|
// Add an item to the tree for this name
|
||||||
QStringList ColumnText;
|
QStringList ColumnText{
|
||||||
ColumnText << TO_QSTRING(rkName.Name)
|
TO_QSTRING(rkName.Name),
|
||||||
<< TO_QSTRING(rkName.Type)
|
TO_QSTRING(rkName.Type),
|
||||||
<< TO_QSTRING(TString::HexString(rkName.ID))
|
TO_QSTRING(TString::HexString(rkName.ID)),
|
||||||
<< TO_QSTRING(NPropertyMap::GetPropertyName(rkName.ID, *rkName.Type));
|
TO_QSTRING(NPropertyMap::GetPropertyName(rkName.ID, *rkName.Type)),
|
||||||
|
};
|
||||||
|
|
||||||
QTreeWidgetItem* pItem = new CCheckableTreeWidgetItem(pTreeWidget, ColumnText);
|
auto* pItem = new CCheckableTreeWidgetItem(pTreeWidget, ColumnText);
|
||||||
pItem->setFlags(Qt::ItemIsEnabled |
|
pItem->setFlags(Qt::ItemIsEnabled |
|
||||||
Qt::ItemIsSelectable |
|
Qt::ItemIsSelectable |
|
||||||
Qt::ItemIsUserCheckable);
|
Qt::ItemIsUserCheckable);
|
||||||
pItem->setCheckState(0, Qt::Unchecked);
|
pItem->setCheckState(0, Qt::Unchecked);
|
||||||
|
|
||||||
// Add children items
|
// Add children items
|
||||||
for (auto Iter = rkName.XmlList.begin(); Iter != rkName.XmlList.end(); Iter++)
|
for (const auto& name : rkName.XmlList)
|
||||||
{
|
{
|
||||||
QString XmlName = TO_QSTRING( *Iter );
|
QString XmlName = TO_QSTRING(name);
|
||||||
ColumnText.clear();
|
ColumnText.clear();
|
||||||
ColumnText << XmlName;
|
ColumnText.push_back(XmlName);
|
||||||
|
|
||||||
QTreeWidgetItem* pChild = new QTreeWidgetItem(pItem, ColumnText);
|
auto* pChild = new QTreeWidgetItem(pItem, ColumnText);
|
||||||
pChild->setFlags(Qt::ItemIsEnabled);
|
pChild->setFlags(Qt::ItemIsEnabled);
|
||||||
pChild->setFirstColumnSpanned(true);
|
pChild->setFirstColumnSpanned(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue