diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,8 +62,7 @@ endif() set(HAVE_X11 ${X11_FOUND}) -# FIXME: Fix code to allow this -#add_definitions(-DQT_NO_FOREACH) +add_definitions(-DQT_NO_FOREACH) # See above includes for defaults add_definitions( diff --git a/src/Application.cpp b/src/Application.cpp --- a/src/Application.cpp +++ b/src/Application.cpp @@ -58,7 +58,7 @@ void Application::populateCommandLineParser(QCommandLineParser *parser) { - auto options = QVector { + QList options { { { QStringLiteral("profile") }, i18nc("@info:shell", "Name of profile to use for new Konsole instance"), QStringLiteral("name") @@ -119,7 +119,7 @@ QStringLiteral("cmd") } }; - foreach(const auto& option, options) { + for(const auto& option: options) { parser->addOption(option); } @@ -188,7 +188,7 @@ MainWindow *window = newMainWindow(); ViewManager *manager = window->viewManager(); - foreach(TerminalDisplay* terminal, splitter->findChildren()) { + for(TerminalDisplay* terminal: splitter->findChildren()) { manager->attachView(terminal, sessionsMap[terminal]); } manager->activeContainer()->addSplitter(splitter); @@ -475,7 +475,7 @@ { QStringList paths = ProfileManager::instance()->availableProfilePaths(); - foreach (const QString &path, paths) { + for (const QString &path: paths) { QFileInfo info(path); printf("%s\n", info.completeBaseName().toLocal8Bit().constData()); } @@ -486,7 +486,7 @@ Profile::Ptr tempProfile = ProfileManager::instance()->defaultProfile(); const QStringList names = tempProfile->propertiesInfoList(); - foreach (const QString &name, names) { + for (const QString &name: names) { printf("%s\n", name.toLocal8Bit().constData()); } } @@ -506,7 +506,7 @@ // temporary changes to profile options specified on the command line const QStringList profileProperties = m_parser->values(QStringLiteral("p")); - foreach (const QString &value, profileProperties) { + for (const QString &value: profileProperties) { ProfileCommandParser parser; QHashIterator iter(parser.parse(value)); diff --git a/src/BookmarkHandler.cpp b/src/BookmarkHandler.cpp --- a/src/BookmarkHandler.cpp +++ b/src/BookmarkHandler.cpp @@ -155,7 +155,7 @@ QList list; list.reserve(_views.size()); - foreach (ViewProperties *view, _views) { + for (ViewProperties *view: _views) { list << KBookmarkOwner::FutureBookmark(titleForView(view), urlForView(view), iconForView(view)); } diff --git a/src/ColorSchemeManager.cpp b/src/ColorSchemeManager.cpp --- a/src/ColorSchemeManager.cpp +++ b/src/ColorSchemeManager.cpp @@ -60,7 +60,7 @@ int failed = 0; QStringList nativeColorSchemes = listColorSchemes(); - foreach (const QString &colorScheme, nativeColorSchemes) { + for (const QString &colorScheme: nativeColorSchemes) { if (loadColorScheme(colorScheme)) { success++; } else { diff --git a/src/CopyInputDialog.cpp b/src/CopyInputDialog.cpp --- a/src/CopyInputDialog.cpp +++ b/src/CopyInputDialog.cpp @@ -124,7 +124,7 @@ QModelIndexList selected = _ui->sessionList->selectionModel()->selectedIndexes(); if (selected.count() > 1) { - foreach (const QModelIndex &index, selected) { + for (const QModelIndex &index: selected) { setRowChecked(index.row(), checked); } } else { diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -315,7 +315,7 @@ const QList existingProfiles = ProfileManager::instance()->allProfiles(); QStringList otherExistingProfileNames; - foreach(auto existingProfile, existingProfiles) { + for(auto existingProfile: existingProfiles) { if (existingProfile->name() != _profile->name()) { otherExistingProfileNames.append(existingProfile->name()); } @@ -876,7 +876,7 @@ QList schemeList = ColorSchemeManager::instance()->allColorSchemes(); - foreach (const ColorScheme *scheme, schemeList) { + for (const ColorScheme *scheme: schemeList) { QStandardItem *item = new QStandardItem(scheme->description()); item->setData(QVariant::fromValue(scheme), Qt::UserRole + 1); item->setData(QVariant::fromValue(_profile->font()), Qt::UserRole + 2); @@ -1333,7 +1333,7 @@ void EditProfileDialog::updateTransparencyWarning() { // zero or one indexes can be selected - foreach (const QModelIndex &index, _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes()) { + for (const QModelIndex &index: _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes()) { bool needTransparency = index.data(Qt::UserRole + 1).value()->opacity() < 1.0; if (!needTransparency) { diff --git a/src/Emulation.cpp b/src/Emulation.cpp --- a/src/Emulation.cpp +++ b/src/Emulation.cpp @@ -109,7 +109,7 @@ Emulation::~Emulation() { - foreach (ScreenWindow *window, _windows) { + for (ScreenWindow *window: _windows) { delete window; } @@ -124,7 +124,7 @@ _currentScreen = _screen[index & 1]; if (_currentScreen != oldScreen) { // tell all windows onto this emulation to switch to the newly active screen - foreach (ScreenWindow *window, _windows) { + for (ScreenWindow *window: _windows) { window->setScreen(_currentScreen); } diff --git a/src/ExtendedCharTable.cpp b/src/ExtendedCharTable.cpp --- a/src/ExtendedCharTable.cpp +++ b/src/ExtendedCharTable.cpp @@ -75,8 +75,8 @@ // This is slow but should happen very rarely QSet usedExtendedChars; const SessionManager *sm = SessionManager::instance(); - foreach (const Session *s, sm->sessions()) { - foreach (const TerminalDisplay *td, s->views()) { + for (const Session *s: sm->sessions()) { + for (const TerminalDisplay *td: s->views()) { usedExtendedChars += td->screenWindow()->screen()->usedExtendedChars(); } } diff --git a/src/Filter.cpp b/src/Filter.cpp --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -262,7 +262,7 @@ { QList hotspots = _hotspots.values(line); - foreach (HotSpot *spot, hotspots) { + for (HotSpot *spot: hotspots) { if (spot->startLine() == line && spot->startColumn() > column) { continue; } diff --git a/src/KeyBindingEditor.cpp b/src/KeyBindingEditor.cpp --- a/src/KeyBindingEditor.cpp +++ b/src/KeyBindingEditor.cpp @@ -124,7 +124,7 @@ { QList uniqueList; - foreach (QTableWidgetItem *item, _ui->keyBindingTable->selectedItems()) { + for (QTableWidgetItem *item: _ui->keyBindingTable->selectedItems()) { if (item->column() == 1) { //Select item at the first column item = _ui->keyBindingTable->item(item->row(), 0); } @@ -134,7 +134,7 @@ } } - foreach (QTableWidgetItem *item, uniqueList) { + for (QTableWidgetItem *item: uniqueList) { // get the first item in the row which has the entry KeyboardTranslator::Entry existing = item->data(Qt::UserRole). diff --git a/src/KeyboardTranslatorManager.cpp b/src/KeyboardTranslatorManager.cpp --- a/src/KeyboardTranslatorManager.cpp +++ b/src/KeyboardTranslatorManager.cpp @@ -112,7 +112,7 @@ // add the name of each translator to the list and associated // the name with a null pointer to indicate that the translator // has not yet been loaded from disk - foreach (const QString &translatorPath, list) { + for (const QString &translatorPath: list) { QString name = QFileInfo(translatorPath).completeBaseName(); if (!_translators.contains(name)) { @@ -164,7 +164,7 @@ KeyboardTranslatorWriter writer(&destination); writer.writeHeader(translator->description()); - foreach (const KeyboardTranslator::Entry &entry, translator->entries()) { + for (const KeyboardTranslator::Entry &entry: translator->entries()) { writer.writeEntry(entry); } } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -157,7 +157,7 @@ void MainWindow::rememberMenuAccelerators() { - foreach (QAction *menuItem, menuBar()->actions()) { + for (QAction *menuItem: menuBar()->actions()) { QString itemText = menuItem->text(); menuItem->setData(itemText); } @@ -173,14 +173,14 @@ // can then be redefined there to exclude the standard accelerators void MainWindow::removeMenuAccelerators() { - foreach (QAction *menuItem, menuBar()->actions()) { + for (QAction *menuItem: menuBar()->actions()) { menuItem->setText(menuItem->text().replace(QLatin1Char('&'), QString())); } } void MainWindow::restoreMenuAccelerators() { - foreach (QAction *menuItem, menuBar()->actions()) { + for (QAction *menuItem: menuBar()->actions()) { QString itemText = menuItem->data().toString(); menuItem->setText(itemText); } @@ -409,7 +409,7 @@ } else { _newTabMenuAction->setMenu(new QMenu()); } - foreach (QAction *sessionAction, sessionActions) { + for (QAction *sessionAction: sessionActions) { _newTabMenuAction->menu()->addAction(sessionAction); // NOTE: defaultProfile seems to not work here, sigh. @@ -566,7 +566,7 @@ QStringList processesRunning; const auto uniqueSessions = QSet::fromList(_viewManager->sessions()); - foreach (Session *session, uniqueSessions) { + for (Session *session: uniqueSessions) { if ((session == nullptr) || !session->isForegroundProcessActive()) { continue; } @@ -673,7 +673,7 @@ void MainWindow::syncActiveShortcuts(KActionCollection *dest, const KActionCollection *source) { - foreach (QAction *qAction, source->actions()) { + for (QAction *qAction: source->actions()) { if (QAction *destQAction = dest->action(qAction->objectName())) { destQAction->setShortcut(qAction->shortcut()); } @@ -686,13 +686,13 @@ KShortcutsEditor::LetterShortcutsDisallowed, this); // add actions from this window and the current session controller - foreach (KXMLGUIClient *client, guiFactory()->clients()) { + for (KXMLGUIClient *client: guiFactory()->clients()) { dialog.addCollection(client->actionCollection()); } if (dialog.configure()) { // sync shortcuts for non-session actions (defined in "konsoleui.rc") in other main windows - foreach (QWidget *mainWindowWidget, QApplication::topLevelWidgets()) { + for (QWidget *mainWindowWidget: QApplication::topLevelWidgets()) { auto *mainWindow = qobject_cast(mainWindowWidget); if ((mainWindow != nullptr) && mainWindow != this) { syncActiveShortcuts(mainWindow->actionCollection(), actionCollection()); @@ -702,7 +702,7 @@ // Controllers which are currently plugged in (ie. their actions are part of the current menu) // must be updated immediately via syncActiveShortcuts(). Other controllers will be updated // when they are plugged into a main window. - foreach (SessionController *controller, SessionController::allControllers()) { + for (SessionController *controller: SessionController::allControllers()) { controller->reloadXML(); if ((controller->factory() != nullptr) && controller != _pluggedController) { syncActiveShortcuts(controller->actionCollection(), _pluggedController->actionCollection()); diff --git a/src/Part.cpp b/src/Part.cpp --- a/src/Part.cpp +++ b/src/Part.cpp @@ -71,7 +71,7 @@ setWidget(_viewManager->widget()); actionCollection()->addAssociatedWidget(_viewManager->widget()); - foreach (QAction *action, actionCollection()->actions()) { + for (QAction *action: actionCollection()->actions()) { action->setShortcutContext(Qt::WidgetWithChildrenShortcut); } diff --git a/src/ProcessInfo.cpp b/src/ProcessInfo.cpp --- a/src/ProcessInfo.cpp +++ b/src/ProcessInfo.cpp @@ -583,7 +583,7 @@ const QStringList &argList = data.split(QLatin1Char('\0')); - foreach (const QString &entry, argList) { + for (const QString &entry: argList) { if (!entry.isEmpty()) { addArgument(entry); } @@ -711,7 +711,7 @@ // len holds the length of the string QString qargs = QString::fromLocal8Bit(args, len); - foreach (const QString &value, qargs.split(QLatin1Char('\u0000'))) { + for (const QString &value: qargs.split(QLatin1Char('\u0000'))) { if (!value.isEmpty()) { addArgument(value); } diff --git a/src/Profile.cpp b/src/Profile.cpp --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -388,7 +388,7 @@ } Profile::setProperty(p, value); - foreach(Profile::Ptr profile, _profiles) { + for(Profile::Ptr profile: _profiles) { profile->setProperty(p, value); } } diff --git a/src/ProfileList.cpp b/src/ProfileList.cpp --- a/src/ProfileList.cpp +++ b/src/ProfileList.cpp @@ -51,7 +51,7 @@ ProfileManager* manager = ProfileManager::instance(); QList favoriteProfiles = manager->sortedFavorites(); - foreach(const Profile::Ptr& profile, favoriteProfiles) { + for(const Profile::Ptr& profile: favoriteProfiles) { favoriteChanged(profile, true); } @@ -76,7 +76,7 @@ } QAction* ProfileList::actionForProfile(const Profile::Ptr &profile) const { - foreach(QAction* action, _group->actions()) { + for(QAction* action: _group->actions()) { if (action->data().value() == profile) { return action; } @@ -122,7 +122,7 @@ _registeredWidgets.insert(widget); const QList currentActions = widget->actions(); - foreach(QAction * currentAction, currentActions) { + for(QAction * currentAction: currentActions) { widget->removeAction(currentAction); } @@ -142,7 +142,7 @@ updateAction(action, profile); - foreach(QWidget * widget, _registeredWidgets) { + for(QWidget * widget: _registeredWidgets) { widget->addAction(action); } emit actionsChanged(_group->actions()); @@ -156,7 +156,7 @@ if (action != nullptr) { _group->removeAction(action); - foreach(QWidget * widget, _registeredWidgets) { + for(QWidget * widget: _registeredWidgets) { widget->removeAction(action); } emit actionsChanged(_group->actions()); diff --git a/src/ProfileManager.cpp b/src/ProfileManager.cpp --- a/src/ProfileManager.cpp +++ b/src/ProfileManager.cpp @@ -162,7 +162,7 @@ } // check that we have not already loaded this profile - foreach(const Profile::Ptr& profile, _profiles) { + for(const Profile::Ptr& profile: _profiles) { if (profile->path() == path) { return profile; } @@ -222,7 +222,7 @@ { QStringList names; - foreach(Profile::Ptr profile, ProfileManager::instance()->allProfiles()) { + for(Profile::Ptr profile: ProfileManager::instance()->allProfiles()) { if (!profile->isHidden()) { names.push_back(profile->name()); } @@ -240,7 +240,7 @@ } const QStringList& paths = availableProfilePaths(); - foreach(const QString& path, paths) { + for(const QString& path: paths) { loadProfile(path); } @@ -372,7 +372,7 @@ // in the profile manager QList existingProfiles = allProfiles(); QStringList existingProfileNames; - foreach(Profile::Ptr existingProfile, existingProfiles) { + for(Profile::Ptr existingProfile: existingProfiles) { existingProfileNames.append(existingProfile->name()); } @@ -416,7 +416,7 @@ // is saved to disk ProfileGroup::Ptr group = newProfile->asGroup(); if (group) { - foreach(const Profile::Ptr & groupProfile, group->profiles()) { + for(const Profile::Ptr & groupProfile: group->profiles()) { changeProfile(groupProfile, propertyMap, persistent); } return; @@ -436,7 +436,7 @@ // this is needed to include the old profile too _loadedAllProfiles = false; const QList availableProfiles = ProfileManager::instance()->allProfiles(); - foreach(auto oldProfile, availableProfiles) { + for(auto oldProfile: availableProfiles) { if (oldProfile->path() == origPath) { // assign the same shortcut of the old profile to // the newly renamed profile @@ -600,7 +600,7 @@ KConfigGroup favoriteGroup = appConfig->group("Favorite Profiles"); QStringList paths; - foreach(const Profile::Ptr& profile, _favorites) { + for(const Profile::Ptr& profile: _favorites) { Q_ASSERT(_profiles.contains(profile) && profile); paths << normalizePath(profile->path()); } @@ -644,15 +644,15 @@ } // look for favorites among those already loaded - foreach(const Profile::Ptr& profile, _profiles) { + for(const Profile::Ptr& profile: _profiles) { const QString& path = profile->path(); if (favoriteSet.contains(path)) { _favorites.insert(profile); favoriteSet.remove(path); } } // load any remaining favorites - foreach(const QString& favorite, favoriteSet) { + for(const QString& favorite: favoriteSet) { Profile::Ptr profile = loadProfile(favorite); if (profile) { _favorites.insert(profile); diff --git a/src/Pty.cpp b/src/Pty.cpp --- a/src/Pty.cpp +++ b/src/Pty.cpp @@ -211,7 +211,7 @@ { bool isTermEnvAdded = false; - foreach (const QString &pair, environmentVariables) { + for (const QString &pair: environmentVariables) { // split on the first '=' character const int separator = pair.indexOf(QLatin1Char('=')); diff --git a/src/SaveHistoryTask.cpp b/src/SaveHistoryTask.cpp --- a/src/SaveHistoryTask.cpp +++ b/src/SaveHistoryTask.cpp @@ -76,7 +76,7 @@ // iterate over each session in the task and display a dialog to allow the user to choose where // to save that session's history. // then start a KIO job to transfer the data from the history to the chosen URL - foreach(const auto& session, sessions()) { + for(const auto& session: sessions()) { dialog->setWindowTitle(i18n("Save Output From %1", session->title(Session::NameRole))); int result = dialog->exec(); diff --git a/src/Session.cpp b/src/Session.cpp --- a/src/Session.cpp +++ b/src/Session.cpp @@ -621,7 +621,7 @@ } bool hasFocus = false; - foreach(TerminalDisplay *display, _views) { + for(TerminalDisplay *display: _views) { if (display->hasFocus()) { hasFocus = true; break; @@ -644,14 +644,14 @@ { if (suspended) { if (flowControlEnabled()) { - foreach(TerminalDisplay * display, _views) { + for(TerminalDisplay * display: _views) { if (display->flowControlWarningEnabled()) { display->outputSuspended(true); } } } } else { - foreach(TerminalDisplay * display, _views) { + for(TerminalDisplay * display: _views) { display->outputSuspended(false); } } @@ -693,7 +693,7 @@ } else if (state == NOTIFYACTIVITY) { // Don't notify if the terminal is active bool hasFocus = false; - foreach(TerminalDisplay *display, _views) { + for(TerminalDisplay *display: _views) { if (display->hasFocus()) { hasFocus = true; break; @@ -744,7 +744,7 @@ const int VIEW_COLUMNS_THRESHOLD = 2; //select largest number of lines and columns that will fit in all visible views - foreach(TerminalDisplay* view, _views) { + for(TerminalDisplay* view: _views) { if (!view->isHidden() && view->lines() >= VIEW_LINES_THRESHOLD && view->columns() >= VIEW_COLUMNS_THRESHOLD) { @@ -1585,7 +1585,7 @@ void Session::setProfile(const QString &profileName) { const QList profiles = ProfileManager::instance()->allProfiles(); - foreach (const Profile::Ptr &profile, profiles) { + for (const Profile::Ptr &profile: profiles) { if (profile->name() == profileName) { SessionManager::instance()->setSessionProfile(this, profile); } @@ -1766,7 +1766,7 @@ _inForwardData = true; const QList sessionsKeys = _sessions.keys(); - foreach(Session* other, sessionsKeys) { + for(Session* other: sessionsKeys) { if (!_sessions[other]) { other->emulation()->sendString(data); } diff --git a/src/SessionController.cpp b/src/SessionController.cpp --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -138,7 +138,7 @@ } actionCollection()->addAssociatedWidget(view); - foreach(QAction * action, actionCollection()->actions()) { + for(QAction * action: actionCollection()->actions()) { action->setShortcutContext(Qt::WidgetWithChildrenShortcut); } @@ -413,7 +413,7 @@ QAction* action = nullptr; - foreach(const QString& searchProvider, searchProviders) { + for(const QString& searchProvider: searchProviders) { action = new QAction(searchProvider, _webSearchMenu); action->setIcon(QIcon::fromTheme(filterData.iconNameForPreferredSearchProvider(searchProvider))); action->setData(filterData.queryForPreferredSearchProvider(searchProvider)); @@ -812,7 +812,7 @@ { // Searching for Edit profile dialog opened with the same profile const QList allSessionsControllers = _allControllers.values(); - foreach (SessionController* session, allSessionsControllers) { + for (SessionController* session: allSessionsControllers) { if ((session->profileDialogPointer() != nullptr) && session->profileDialogPointer()->isVisible() && session->profileDialogPointer()->lookupProfile() == SessionManager::instance()->sessionProfile(_session)) { @@ -996,7 +996,7 @@ static bool hasTerminalDisplayInSameWindow(const Session* session, const KXmlGuiWindow* window) { // Iterate all TerminalDisplays of this Session ... - foreach(const TerminalDisplay* terminalDisplay, session->views()) { + for(const TerminalDisplay* terminalDisplay: session->views()) { // ... and check whether a TerminalDisplay has the same // window as given in the parameter if (window == findWindow(terminalDisplay)) { @@ -1080,7 +1080,7 @@ newGroup.remove(_session); QSet completeGroup = newGroup | currentGroup; - foreach(Session * session, completeGroup) { + for(Session * session: completeGroup) { if (newGroup.contains(session) && !currentGroup.contains(session)) { _copyToGroup->addSession(session); } else if (!newGroup.contains(session) && currentGroup.contains(session)) { @@ -1623,7 +1623,7 @@ updateReadOnlyActionStates(); // Update all views - foreach (TerminalDisplay* view, session()->views()) { + for (TerminalDisplay* view: session()->views()) { if (view != _view.data()) { view->updateReadOnlyState(isReadOnly()); } @@ -1679,7 +1679,7 @@ // If the close action was chosen, the popup menu will be partially // destroyed at this point, and the rest will be destroyed later by // 'chosen->trigger()' - foreach(QAction * action, contentActions) { + for(QAction * action: contentActions) { popup->removeAction(action); } diff --git a/src/SessionListModel.cpp b/src/SessionListModel.cpp --- a/src/SessionListModel.cpp +++ b/src/SessionListModel.cpp @@ -44,7 +44,7 @@ beginResetModel(); _sessions = sessions; - foreach (Session *session, sessions) { + for (Session *session: sessions) { connect(session, &Konsole::Session::finished, this, &Konsole::SessionListModel::sessionFinished); } diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp --- a/src/SessionManager.cpp +++ b/src/SessionManager.cpp @@ -61,7 +61,7 @@ <<"session(s) still alive"; // ensure that the Session doesn't later try to call back and do things to the // SessionManager - foreach (Session *session, _sessions) { + for (Session *session: _sessions) { disconnect(session, nullptr, this, nullptr); } } @@ -81,7 +81,7 @@ void SessionManager::closeAllSessions() { _isClosingAllSessions = true; - foreach (Session *session, _sessions) { + for (Session *session: _sessions) { session->close(); } _sessions.clear(); @@ -142,7 +142,7 @@ void SessionManager::applyProfile(const Profile::Ptr &profile, bool modifiedPropertiesOnly) { - foreach (Session *session, _sessions) { + for (Session *session: _sessions) { if (_sessionProfiles[session] == profile) { applyProfile(session, profile, modifiedPropertiesOnly); } @@ -298,7 +298,7 @@ // be restored after applying the new profile QHash zoomFontSizes; - foreach (TerminalDisplay *view, session->views()) { + for (TerminalDisplay *view: session->views()) { const QFont &viewCurFont = view->getVTFont(); if (viewCurFont != _sessionProfiles[session]->font()) { zoomFontSizes.insert(view, viewCurFont); @@ -342,7 +342,7 @@ int n = 1; _restoreMapping.clear(); - foreach (Session *session, _sessions) { + for (Session *session: _sessions) { QString name = QLatin1String("Session") + QString::number(n); KConfigGroup group(config, name); @@ -384,7 +384,7 @@ Session *SessionManager::idToSession(int id) { - foreach (Session *session, _sessions) { + for (Session *session: _sessions) { if (session->sessionId() == id) { return session; } diff --git a/src/ShellCommand.cpp b/src/ShellCommand.cpp --- a/src/ShellCommand.cpp +++ b/src/ShellCommand.cpp @@ -76,7 +76,7 @@ QStringList result; result.reserve(items.size()); - foreach (const QString &item, items) { + for (const QString &item: items) { result << expand(item); } diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -1255,23 +1255,23 @@ // Determine which characters should be repainted (1 region unit = 1 character) QRegion dirtyImageRegion; - foreach(const QRect & rect, (pe->region() & contentsRect()).rects()) { + for(const QRect & rect: (pe->region() & contentsRect()).rects()) { dirtyImageRegion += widgetToImage(rect); drawBackground(paint, rect, getBackgroundColor(), true /* use opacity setting */); } paint.setRenderHint(QPainter::Antialiasing, _antialiasText); - foreach(const QRect & rect, dirtyImageRegion.rects()) { + for(const QRect & rect: dirtyImageRegion.rects()) { drawContents(paint, rect); } drawCurrentResultRect(paint); drawInputMethodPreeditString(paint, preeditRect()); paintFilters(paint); const bool drawDimmed = _dimWhenInactive && !hasFocus(); const QColor dimColor(0, 0, 0, 128); - foreach(const QRect & rect, (pe->region() & contentsRect()).rects()) { + for(const QRect & rect: (pe->region() & contentsRect()).rects()) { if (drawDimmed) { paint.fillRect(rect, dimColor); } @@ -1348,7 +1348,7 @@ urlNumber = 0; urlNumInc = 1; } - foreach(Filter::HotSpot* spot, spots) { + for(Filter::HotSpot* spot: spots) { urlNumber += urlNumInc; QRegion region; diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -166,7 +166,7 @@ QHash sessionsMap = _connectedViewManager->forgetAll(splitter); - foreach(TerminalDisplay* terminal, splitter->findChildren()) { + for(TerminalDisplay* terminal: splitter->findChildren()) { manager->attachView(terminal, sessionsMap[terminal]); } auto container = manager->activeContainer(); @@ -275,7 +275,7 @@ } connect(viewSplitter, &ViewSplitter::destroyed, this, &TabbedViewContainer::viewDestroyed); auto terminalDisplays = viewSplitter->findChildren(); - foreach(TerminalDisplay* terminal, terminalDisplays) { + for(TerminalDisplay* terminal: terminalDisplays) { connectTerminalDisplay(terminal); } if (terminalDisplays.count() > 0) { diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -272,7 +272,7 @@ void ViewManager::toggleActionsBasedOnState() { const int count = _viewContainer->count(); - foreach(QAction *tabOnlyAction, _multiTabOnlyActions) { + for(QAction *tabOnlyAction: _multiTabOnlyActions) { tabOnlyAction->setEnabled(count > 1); } @@ -283,7 +283,7 @@ ->findChildren() .count(); - foreach (QAction *action, _multiSplitterOnlyActions) { + for (QAction *action: _multiSplitterOnlyActions) { action->setEnabled(splitCount > 1); } } @@ -433,7 +433,7 @@ QHash ViewManager::forgetAll(ViewSplitter* splitter) { splitter->setParent(nullptr); QHash detachedSessions; - foreach(TerminalDisplay* terminal, splitter->findChildren()) { + for(TerminalDisplay* terminal: splitter->findChildren()) { Session* session = forgetTerminal(terminal); detachedSessions[terminal] = session; } @@ -742,6 +742,7 @@ void ViewManager::containerViewsChanged(TabbedViewContainer *container) { + Q_UNUSED(container) // TODO: Verify that this is right. emit viewPropertiesChanged(viewProperties()); } @@ -810,7 +811,7 @@ const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); const QList sessionMapKeys = _sessionMap.keys(session); - foreach (TerminalDisplay *view, sessionMapKeys) { + for (TerminalDisplay *view: sessionMapKeys) { applyProfileToView(view, profile); } } diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -176,7 +176,7 @@ } QStringList fileNames = sourceDir.entryList( QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks); - foreach (const QString &fileName, fileNames) { + for (const QString &fileName: fileNames) { targetFilePath = targetBasePath + fileName; if (!QFile::exists(targetFilePath)) { QFile::copy(sourceBasePath + fileName, targetFilePath); @@ -241,7 +241,7 @@ qtProblematicOptions << QStringLiteral("--display") << QStringLiteral("--visual"); #endif - foreach (const QString &option, qtProblematicOptions) { + for (const QString &option: qtProblematicOptions) { if (arguments.contains(option)) { return true; } @@ -255,7 +255,7 @@ kdeProblematicOptions << QStringLiteral("--waitforwm"); #endif - foreach (const QString &option, kdeProblematicOptions) { + for (const QString &option: kdeProblematicOptions) { if (arguments.contains(option)) { return true; } diff --git a/src/settings/ProfileSettings.cpp b/src/settings/ProfileSettings.cpp --- a/src/settings/ProfileSettings.cpp +++ b/src/settings/ProfileSettings.cpp @@ -195,7 +195,7 @@ QList profiles = ProfileManager::instance()->allProfiles(); ProfileManager::instance()->sortProfiles(profiles); - foreach(const Profile::Ptr& profile, profiles) { + for(const Profile::Ptr & profile: profiles) { addItems(profile); } updateDefaultItem(); @@ -255,7 +255,7 @@ } void ProfileSettings::deleteSelected() { - foreach(const Profile::Ptr & profile, selectedProfiles()) { + for(const Profile::Ptr & profile: selectedProfiles()) { if (profile != ProfileManager::instance()->defaultProfile()) { ProfileManager::instance()->deleteProfile(profile); } @@ -322,11 +322,11 @@ { QList profiles(selectedProfiles()); - foreach (Session* session, SessionManager::instance()->sessions()) { - foreach (TerminalDisplay* terminal, session->views()) { + for (Session* session: SessionManager::instance()->sessions()) { + for (TerminalDisplay* terminal: session->views()) { // Searching for opened profiles if (terminal->sessionController()->profileDialogPointer() != nullptr) { - foreach (const Profile::Ptr & profile, profiles) { + for (const Profile::Ptr & profile: profiles) { if (profile->name() == terminal->sessionController()->profileDialogPointer()->lookupProfile()->name() && terminal->sessionController()->profileDialogPointer()->isVisible()) { // close opened edit dialog @@ -340,7 +340,7 @@ EditProfileDialog dialog(this); // the dialog will delete the profile group when it is destroyed ProfileGroup* group = new ProfileGroup; - foreach (const Profile::Ptr & profile, profiles) { + for (const Profile::Ptr & profile: profiles) { group->addProfile(profile); } group->updateValues(); @@ -356,7 +356,7 @@ return list; } - foreach(const QModelIndex & index, selection->selectedIndexes()) { + for(const QModelIndex & index: selection->selectedIndexes()) { if (index.column() == ProfileNameColumn) { list << index.data(ProfileKeyRole).value(); }