Commit 744e1f09 authored by Rolf Eike Beer's avatar Rolf Eike Beer
Browse files

modernize for loops

parent 109005e4
......@@ -55,8 +55,8 @@ bool ClearThumbnailsAction::action()
QDir thumbnailDir( QDir::homePath() + QLatin1String( "/.cache/thumbnails/normal" ));
thumbnailDir.setFilter( QDir::Files );
const QStringList entries = thumbnailDir.entryList();
for( QStringList::const_iterator it = entries.begin() ; it != entries.end() ; ++it) {
if(!thumbnailDir.remove(*it)) {
for(const QString &entry: entries) {
if(!thumbnailDir.remove(entry)) {
errMsg = i18n("A thumbnail could not be removed.");
return false;
}
......@@ -64,8 +64,8 @@ bool ClearThumbnailsAction::action()
thumbnailDir.setPath(QDir::homePath() + QLatin1String( "/.cache/thumbnails/large" ));
const QStringList entries2 = thumbnailDir.entryList();
for( QStringList::const_iterator it = entries2.begin() ; it != entries2.end() ; ++it) {
if(!thumbnailDir.remove(*it)) {
for(const QString &entry: entries2) {
if(!thumbnailDir.remove(entry)) {
errMsg = i18n("A thumbnail could not be removed.");
return false;
}
......@@ -73,8 +73,8 @@ bool ClearThumbnailsAction::action()
thumbnailDir.setPath(QDir::homePath() + QLatin1String( "/.cache/thumbnails/fail" ));
const QStringList entries3 = thumbnailDir.entryList();
for( QStringList::const_iterator it = entries3.begin() ; it != entries3.end() ; ++it) {
if(!thumbnailDir.remove(*it)) {
for(const QString &entry: entries3) {
if(!thumbnailDir.remove(entry)) {
errMsg = i18n("A thumbnail could not be removed.");
return false;
}
......@@ -227,11 +227,11 @@ bool ClearFaviconsAction::action()
const QStringList entries = favIconDir.entryList();
// erase all files in favicon directory...
for( QStringList::const_iterator it = entries.begin() ; it != entries.end() ; ++it) {
for(const QString &entry: entries) {
// ...if we're not supposed to save them, of course
if (!saveTheseFavicons.contains(*it)) {
qDebug() << "removing " << *it ;
if(!favIconDir.remove(*it)) {
if (!saveTheseFavicons.contains(entry)) {
qDebug() << "removing " << entry ;
if(!favIconDir.remove(entry)) {
errMsg = i18n("A favicon could not be removed.");
return false;
}
......
......@@ -81,19 +81,15 @@ Sweeper::~Sweeper()
void Sweeper::load()
{
QVector<PrivacyAction*>::iterator itr;
for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
(*itr)->setCheckState(0, m_privacyConfGroup.readEntry((*itr)->configKey(), true) ? Qt::Checked : Qt::Unchecked);
for (auto &&act: checklist) {
act->setCheckState(0, m_privacyConfGroup.readEntry(act->configKey(), true) ? Qt::Checked : Qt::Unchecked);
}
}
void Sweeper::save()
{
QVector<PrivacyAction*>::iterator itr;
for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
m_privacyConfGroup.writeEntry((*itr)->configKey(), (*itr)->checkState(0) == Qt::Checked);
for (auto &&act: checklist) {
m_privacyConfGroup.writeEntry(act->configKey(), act->checkState(0) == Qt::Checked);
}
m_privacyConfGroup.sync();
......@@ -101,25 +97,18 @@ void Sweeper::save()
void Sweeper::selectAll()
{
QVector<PrivacyAction*>::iterator itr;
for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
(*itr)->setCheckState(0, Qt::Checked);
for (auto &&act: checklist) {
act->setCheckState(0, Qt::Checked);
}
}
void Sweeper::selectNone()
{
QVector<PrivacyAction*>::iterator itr;
for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
(*itr)->setCheckState(0, Qt::Unchecked);
for (auto &&act: checklist) {
act->setCheckState(0, Qt::Unchecked);
}
}
void Sweeper::cleanup()
{
if (!m_automatic) {
......@@ -131,16 +120,14 @@ void Sweeper::cleanup()
ui.statusTextEdit->clear();
ui.statusTextEdit->setText(i18n("Starting cleanup..."));
QVector<PrivacyAction*>::iterator itr;
for (itr = checklist.begin(); itr != checklist.end(); ++itr) {
if((*itr)->checkState(0) == Qt::Checked) {
QString statusText = i18n("Clearing %1...", (*itr)->text(0));
for (auto &&act: checklist) {
if(act->checkState(0) == Qt::Checked) {
QString statusText = i18n("Clearing %1...", act->text(0));
ui.statusTextEdit->append(statusText);
// actions return whether they were successful
if(!(*itr)->action()) {
QString errorText = i18n("Clearing of %1 failed: %2", (*itr)->text(0), (*itr)->getErrMsg());
if(!act->action()) {
QString errorText = i18n("Clearing of %1 failed: %2", act->text(0), act->getErrMsg());
ui.statusTextEdit->append(errorText);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment