Gui: Use auto and range-based for (#7481)

* On lines where the variable type is obvious from inspection, avoid repeating the type using auto. 
* When possible use a ranged for loop instead of begin() and end() iterators
This commit is contained in:
berniev
2022-09-15 04:25:13 +10:00
committed by GitHub
parent f7c84dfd09
commit ae53c9b0a4
175 changed files with 2051 additions and 2057 deletions

View File

@@ -211,9 +211,9 @@ void DlgSettingsNavigation::retranslate()
// add submenu at the end to select navigation style
std::map<Base::Type, std::string> styles = UserNavigationStyle::getUserFriendlyNames();
for (std::map<Base::Type, std::string>::iterator it = styles.begin(); it != styles.end(); ++it) {
QByteArray data(it->first.getName());
QString name = QApplication::translate(it->first.getName(), it->second.c_str());
for (const auto & style : styles) {
QByteArray data(style.first.getName());
QString name = QApplication::translate(style.first.getName(), style.second.c_str());
ui->comboNavigationStyle->addItem(name, data);
}
@@ -256,7 +256,7 @@ CameraDialog::CameraDialog(QWidget* parent)
layout = new QGridLayout(groupBox);
// Q0
QLabel* label0 = new QLabel(groupBox);
auto label0 = new QLabel(groupBox);
label0->setText(tr("Q0"));
layout->addWidget(label0, 0, 0, 1, 1);
@@ -266,7 +266,7 @@ CameraDialog::CameraDialog(QWidget* parent)
layout->addWidget(sb0, 0, 1, 1, 1);
// Q1
QLabel* label1 = new QLabel(groupBox);
auto label1 = new QLabel(groupBox);
label1->setText(tr("Q1"));
layout->addWidget(label1, 1, 0, 1, 1);
@@ -276,7 +276,7 @@ CameraDialog::CameraDialog(QWidget* parent)
layout->addWidget(sb1, 1, 1, 1, 1);
// Q2
QLabel* label2 = new QLabel(groupBox);
auto label2 = new QLabel(groupBox);
label2->setText(tr("Q2"));
layout->addWidget(label2, 2, 0, 1, 1);
@@ -286,7 +286,7 @@ CameraDialog::CameraDialog(QWidget* parent)
layout->addWidget(sb2, 2, 1, 1, 1);
// Q3
QLabel* label3 = new QLabel(groupBox);
auto label3 = new QLabel(groupBox);
label3->setText(tr("Q3"));
layout->addWidget(label3, 3, 0, 1, 1);
@@ -295,8 +295,7 @@ CameraDialog::CameraDialog(QWidget* parent)
sb3->setSingleStep(0.1);
layout->addWidget(sb3, 3, 1, 1, 1);
QPushButton *currentViewButton;
currentViewButton = new QPushButton(this);
auto currentViewButton = new QPushButton(this);
currentViewButton->setText(tr("Current view"));
currentViewButton->setObjectName(QString::fromLatin1("currentView"));
layout->addWidget(currentViewButton, 4, 1, 2, 1);
@@ -328,7 +327,7 @@ void CameraDialog::getValues(double& q0, double& q1, double& q2, double& q3) con
void CameraDialog::on_currentView_clicked()
{
View3DInventor* mdi = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
auto mdi = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
if (mdi) {
SbRotation rot = mdi->getViewer()->getCameraOrientation();
const float* q = rot.getValue();