use C++11 foreach loop consistently (instead of Qt foreach macro)

This commit is contained in:
Martchus 2016-03-05 17:12:51 +01:00
parent 74b76e83a3
commit 152df3a2f6
4 changed files with 17 additions and 17 deletions

View File

@ -29,7 +29,7 @@ OptionCategory::~OptionCategory()
*/
bool OptionCategory::applyAllPages()
{
foreach(OptionPage *page, m_pages) {
for(OptionPage *page : m_pages) {
if(!page->apply()) {
return false;
}
@ -43,7 +43,7 @@ bool OptionCategory::applyAllPages()
*/
void OptionCategory::resetAllPages()
{
foreach(OptionPage *page, m_pages) {
for(OptionPage *page : m_pages) {
page->reset();
}
}
@ -53,7 +53,7 @@ void OptionCategory::resetAllPages()
*/
bool OptionCategory::matches(const QString &searchKeyWord) const
{
foreach(OptionPage *page, m_pages) {
for(OptionPage *page : m_pages) {
if(page->matches(searchKeyWord)) {
return true;
}

View File

@ -29,7 +29,7 @@ OptionCategoryModel::OptionCategoryModel(const QList<Dialogs::OptionCategory *>
QAbstractListModel(parent),
m_categories(categories)
{
foreach(OptionCategory *category, m_categories) {
for(OptionCategory *category : m_categories) {
category->setParent(this);
}
}
@ -50,7 +50,7 @@ void OptionCategoryModel::setCategories(const QList<OptionCategory *> categories
beginResetModel();
qDeleteAll(m_categories);
m_categories = categories;
foreach(OptionCategory *category, m_categories) {
for(OptionCategory *category : m_categories) {
category->setParent(this);
connect(category, &OptionCategory::displayNameChanged, this, &OptionCategoryModel::categoryChangedName);
connect(category, &OptionCategory::iconChanged, this, &OptionCategoryModel::categoryChangedIcon);

View File

@ -68,19 +68,19 @@ bool OptionPage::matches(const QString &searchKeyWord)
m_widget.reset(setupWidget()); // ensure widget has been created
}
// find common subwidgets
foreach (const QLabel *label, m_widget->findChildren<QLabel *>())
for(const QLabel *label : m_widget->findChildren<QLabel *>())
m_keywords << label->text();
foreach (const QCheckBox *checkbox, m_widget->findChildren<QCheckBox *>())
for(const QCheckBox *checkbox : m_widget->findChildren<QCheckBox *>())
m_keywords << checkbox->text();
foreach (const QRadioButton *checkbox, m_widget->findChildren<QRadioButton *>())
for(const QRadioButton *checkbox : m_widget->findChildren<QRadioButton *>())
m_keywords << checkbox->text();
foreach (const QPushButton *pushButton, m_widget->findChildren<QPushButton *>())
for(const QPushButton *pushButton : m_widget->findChildren<QPushButton *>())
m_keywords << pushButton->text();
foreach (const QGroupBox *groupBox, m_widget->findChildren<QGroupBox *>())
for(const QGroupBox *groupBox : m_widget->findChildren<QGroupBox *>())
m_keywords << groupBox->title();
m_keywordsInitialized = true;
}
foreach (const QString &keyword, m_keywords)
for(const QString &keyword : m_keywords)
if (keyword.contains(searchKeyWord, Qt::CaseInsensitive))
return true;
return false;

View File

@ -105,8 +105,8 @@ OptionPage *SettingsDialog::page(int categoryIndex, int pageIndex) const
void SettingsDialog::showEvent(QShowEvent *event)
{
if(!event->spontaneous()) {
foreach(OptionCategory *category, m_categoryModel->categories()) {
foreach(OptionPage *page, category->pages()) {
for(OptionCategory *category : m_categoryModel->categories()) {
for(OptionPage *page : category->pages()) {
page->reset();
}
}
@ -149,7 +149,7 @@ void SettingsDialog::updateTabWidget()
m_ui->pagesTabWidget->setUpdatesEnabled(false);
QString searchKeyWord = m_ui->filterLineEdit->text();
int index = 0;
foreach(OptionPage *page, m_currentCategory->pages()) {
for(OptionPage *page : m_currentCategory->pages()) {
if(page->matches(searchKeyWord)) {
QScrollArea *scrollArea;
if(index < m_ui->pagesTabWidget->count()) {
@ -189,8 +189,8 @@ void SettingsDialog::updateTabWidget()
*/
bool SettingsDialog::apply()
{
foreach(OptionCategory *category, m_categoryModel->categories()) {
foreach(OptionPage *page, category->pages()) {
for(OptionCategory *category : m_categoryModel->categories()) {
for(OptionPage *page : category->pages()) {
if(!page->apply()) {
return false;
}
@ -205,7 +205,7 @@ bool SettingsDialog::apply()
*/
void SettingsDialog::reset()
{
foreach(OptionCategory *category, m_categoryModel->categories()) {
for(OptionCategory *category : m_categoryModel->categories()) {
category->resetAllPages();
}
emit resetted();