Commit 5a15d20d authored by Kurt Hindenburg's avatar Kurt Hindenburg

use auto range loops

parent 2afeb33f
......@@ -221,8 +221,8 @@ void Emulation::receiveData(const char* text, int length)
QString unicodeText = _decoder->toUnicode(text, length);
//send characters to terminal emulator
for (int i = 0; i < unicodeText.length(); i++)
receiveChar(unicodeText[i].unicode());
for (auto && i : unicodeText)
receiveChar(i.unicode());
//look for z-modem indicator
//-- someone who understands more about z-modems that I do may be able to move
......
......@@ -237,15 +237,15 @@ void ProfileManager::sortProfiles(QList<Profile::Ptr>& list)
QList<Profile::Ptr> lackingIndices;
QList<Profile::Ptr> havingIndices;
for (int i = 0; i < list.size(); ++i) {
for (const auto & i : list) {
// dis-regard the fallback profile
if (list.at(i)->path() == _fallbackProfile->path())
if (i->path() == _fallbackProfile->path())
continue;
if (list.at(i)->menuIndexAsInt() == 0)
lackingIndices.append(list.at(i));
if (i->menuIndexAsInt() == 0)
lackingIndices.append(i);
else
havingIndices.append(list.at(i));
havingIndices.append(i);
}
// sort by index
......
......@@ -1007,10 +1007,7 @@ void SessionController::copyInputToAllTabs()
QSet<Session*> group =
QSet<Session*>::fromList(SessionManager::instance()->sessions());
for (QSet<Session*>::iterator iterator = group.begin();
iterator != group.end(); ++iterator) {
Session* session = *iterator;
for (auto session : group) {
// First, ensure that the session is removed
// (necessary to avoid duplicates on addSession()!)
_copyToGroup->removeSession(session);
......@@ -1073,12 +1070,11 @@ void SessionController::copyInputToNone()
QSet<Session*> group =
QSet<Session*>::fromList(SessionManager::instance()->sessions());
for (QSet<Session*>::iterator iterator = group.begin();
iterator != group.end(); ++iterator) {
Session* session = *iterator;
for (auto iterator : group) {
Session* session = iterator;
if (session != _session) {
_copyToGroup->removeSession(*iterator);
_copyToGroup->removeSession(iterator);
}
}
delete _copyToGroup;
......
......@@ -1010,9 +1010,9 @@ int ViewManager::newSession(const QString& profile, const QString& directory)
const QList<Profile::Ptr> profilelist = ProfileManager::instance()->allProfiles();
Profile::Ptr profileptr = ProfileManager::instance()->defaultProfile();
for (int i = 0; i < profilelist.size(); ++i) {
if (profilelist.at(i)->name() == profile) {
profileptr = profilelist.at(i);
for (const auto & i : profilelist) {
if (i->name() == profile) {
profileptr = i;
break;
}
}
......
......@@ -129,9 +129,9 @@ void ProfileTest::testProfileGroup()
{
// create three new profiles
Profile::Ptr profile[3];
for (int i = 0; i < 3; i++) {
profile[i] = new Profile;
QVERIFY(!profile[i]->asGroup());
for (auto & i : profile) {
i = new Profile;
QVERIFY(!i->asGroup());
}
// set properties with different values
......@@ -139,18 +139,18 @@ void ProfileTest::testProfileGroup()
profile[1]->setProperty(Profile::UseCustomCursorColor, false);
// set properties with same values
for (int i = 0; i < 3; i++)
profile[i]->setProperty(Profile::HistorySize, 1234);
for (auto & i : profile)
i->setProperty(Profile::HistorySize, 1234);
// create a group profile
ProfileGroup::Ptr group = ProfileGroup::Ptr(new ProfileGroup);
const ProfileGroup::Ptr group_const = ProfileGroup::Ptr(new ProfileGroup);
QVERIFY(group->asGroup());
QVERIFY(group_const->asGroup());
for (int i = 0; i < 3; i++) {
group->addProfile(profile[i]);
QVERIFY(group->profiles().contains(profile[i]));
QVERIFY(!group_const->profiles().contains(profile[i]));
for (auto & i : profile) {
group->addProfile(i);
QVERIFY(group->profiles().contains(i));
QVERIFY(!group_const->profiles().contains(i));
}
group->updateValues();
......
......@@ -223,8 +223,8 @@ int KONSOLEPRIVATE_EXPORT konsole_wcwidth(quint16 oucs)
int string_width(const QString& text)
{
int w = 0;
for (int i = 0; i < text.length(); ++i)
w += konsole_wcwidth(text[i].unicode());
for (auto i : text)
w += konsole_wcwidth(i.unicode());
return w;
}
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