Misc: Replace dynamic_cast with qobject_cast

This commit is contained in:
Kacper Donat
2025-04-07 20:00:08 +02:00
committed by Benjamin Nauck
parent f2cd99c50a
commit b14d3a224b
10 changed files with 20 additions and 20 deletions

View File

@@ -270,7 +270,7 @@ void DlgSettingsWorkbenchesImp::saveSettings()
};
for (int i = 0; i < ui->wbList->count(); i++) {
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
if (!wbItem)
continue;
std::string wbName = wbItem->objectName().toStdString();
@@ -546,7 +546,7 @@ void DlgSettingsWorkbenchesImp::wbToggled(const QString& wbName, bool enabled)
//reorder the list of items.
int wbIndex = 0;
for (int i = 0; i < ui->wbList->count(); i++) {
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
if (wbItem && wbItem->objectName() == wbName) {
wbIndex = i;
}
@@ -555,7 +555,7 @@ void DlgSettingsWorkbenchesImp::wbToggled(const QString& wbName, bool enabled)
int destinationIndex = ui->wbList->count();
for (int i = 0; i < ui->wbList->count(); i++) {
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
if (wbItem && !wbItem->isEnabled() && (enabled || ((wbItem->objectName()).toStdString() > wbName.toStdString()))) {
//If the wb was enabled, then it was in the disabled wbs. So it moves to the row of the currently first disabled wb
//If the wb was disabled. Then it goes to the disabled wb where it belongs alphabetically.
@@ -574,7 +574,7 @@ void DlgSettingsWorkbenchesImp::setStartWorkbenchComboItems()
// fills the combo box with activated workbenches.
QStringList enabledWbs;
for (int i = 0; i < ui->wbList->count(); i++) {
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
if (wbItem && wbItem->isEnabled()) {
enabledWbs << wbItem->objectName();
}
@@ -614,7 +614,7 @@ void DlgSettingsWorkbenchesImp::setStartWorkbenchComboItems()
void DlgSettingsWorkbenchesImp::wbItemMoved()
{
for (int i = 0; i < ui->wbList->count(); i++) {
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
if (wbItem) {
wbItem->setShortcutLabel(i);
}
@@ -630,7 +630,7 @@ void DlgSettingsWorkbenchesImp::onStartWbChanged(int index)
//Change wb that user can't deactivate.
for (int i = 0; i < ui->wbList->count(); i++) {
wbListItem* wbItem = dynamic_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
wbListItem* wbItem = qobject_cast<wbListItem*>(ui->wbList->itemWidget(ui->wbList->item(i)));
if (wbItem) {
wbItem->setStartupWb(wbItem->objectName() == wbName);
}