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