diff --git a/src/CopyInputDialog.cpp b/src/CopyInputDialog.cpp index e9f17abb5..49b9e78ee 100644 --- a/src/CopyInputDialog.cpp +++ b/src/CopyInputDialog.cpp @@ -162,7 +162,7 @@ void CheckableSessionModel::setCheckColumn(int column) Qt::ItemFlags CheckableSessionModel::flags(const QModelIndex &index) const { - Session *session = static_cast(index.internalPointer()); + auto *session = static_cast(index.internalPointer()); if (_fixedSessions.contains(session)) { return SessionListModel::flags(index) & ~Qt::ItemIsEnabled; @@ -174,7 +174,7 @@ Qt::ItemFlags CheckableSessionModel::flags(const QModelIndex &index) const QVariant CheckableSessionModel::data(const QModelIndex &index, int role) const { if (role == Qt::CheckStateRole && index.column() == _checkColumn) { - Session *session = static_cast(index.internalPointer()); + auto *session = static_cast(index.internalPointer()); if (_checkedSessions.contains(session)) { return QVariant::fromValue(static_cast(Qt::Checked)); @@ -189,7 +189,7 @@ QVariant CheckableSessionModel::data(const QModelIndex &index, int role) const bool CheckableSessionModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (role == Qt::CheckStateRole && index.column() == _checkColumn) { - Session *session = static_cast(index.internalPointer()); + auto *session = static_cast(index.internalPointer()); if (_fixedSessions.contains(session)) { return false; diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp index 8af8de3cb..34bf4df31 100644 --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -667,7 +667,7 @@ void EditProfileDialog::updateColorSchemeList(const QString &selectedColorScheme const ColorScheme *selectedColorScheme = ColorSchemeManager::instance()->findColorScheme(selectedColorSchemeName); - QStandardItemModel *model = qobject_cast(_ui->colorSchemeList->model()); + auto *model = qobject_cast(_ui->colorSchemeList->model()); Q_ASSERT(model); @@ -710,7 +710,7 @@ void EditProfileDialog::updateKeyBindingsList(const QString &selectKeyBindingsNa _ui->keyBindingList->setModel(new QStandardItemModel(this)); } - QStandardItemModel *model = qobject_cast(_ui->keyBindingList->model()); + auto *model = qobject_cast(_ui->keyBindingList->model()); Q_ASSERT(model); @@ -1032,7 +1032,7 @@ void EditProfileDialog::colorSchemeSelected() if (!selected.isEmpty()) { QAbstractItemModel *model = _ui->colorSchemeList->model(); - const ColorScheme *colors = model->data(selected.first(), Qt::UserRole + 1).value(); + const auto *colors = model->data(selected.first(), Qt::UserRole + 1).value(); if (colors != nullptr) { updateTempProfileProperty(Profile::ColorScheme, colors->name()); previewColorScheme(selected.first()); @@ -1187,7 +1187,7 @@ void EditProfileDialog::keyBindingSelected() if (!selected.isEmpty()) { QAbstractItemModel *model = _ui->keyBindingList->model(); - const KeyboardTranslator *translator = model->data(selected.first(), Qt::UserRole + 1) + const auto *translator = model->data(selected.first(), Qt::UserRole + 1) .value(); if (translator != nullptr) { updateTempProfileProperty(Profile::KeyBindings, translator->name()); @@ -1282,7 +1282,7 @@ void EditProfileDialog::setupRadio(const QVector& possibilities, in void EditProfileDialog::setupScrollingPage(const Profile::Ptr profile) { // setup scrollbar radio - int scrollBarPosition = profile->property(Profile::ScrollBarPosition); + auto scrollBarPosition = profile->property(Profile::ScrollBarPosition); const auto positions = QVector{ {_ui->scrollBarHiddenButton, Enum::ScrollBarHidden, SLOT(hideScrollBar())}, {_ui->scrollBarLeftButton, Enum::ScrollBarLeft, SLOT(showScrollBarLeft())}, @@ -1291,7 +1291,7 @@ void EditProfileDialog::setupScrollingPage(const Profile::Ptr profile) setupRadio(positions, scrollBarPosition); // setup scrollback type radio - int scrollBackType = profile->property(Profile::HistoryMode); + auto scrollBackType = profile->property(Profile::HistoryMode); _ui->historySizeWidget->setMode(Enum::HistoryModeEnum(scrollBackType)); connect(_ui->historySizeWidget, &Konsole::HistorySizeWidget::historyModeChanged, this, &Konsole::EditProfileDialog::historyModeChanged); @@ -1301,7 +1301,7 @@ void EditProfileDialog::setupScrollingPage(const Profile::Ptr profile) _ui->historySizeWidget->setLineCount(historySize); // setup scrollpageamount type radio - int scrollFullPage = profile->property(Profile::ScrollFullPage); + auto scrollFullPage = profile->property(Profile::ScrollFullPage); const auto pageamounts = QVector{ {_ui->scrollHalfPage, Enum::ScrollPageHalf, SLOT(scrollHalfPage())}, @@ -1397,7 +1397,7 @@ void EditProfileDialog::setupMousePage(const Profile::Ptr profile) setupCheckBoxes(options, profile); // setup middle click paste mode - const int middleClickPasteMode = profile->property(Profile::MiddleClickPasteMode); + const auto middleClickPasteMode = profile->property(Profile::MiddleClickPasteMode); const auto pasteModes = QVector { {_ui->pasteFromX11SelectionButton, Enum::PasteFromX11Selection, SLOT(pasteFromX11Selection())}, {_ui->pasteFromClipboardButton, Enum::PasteFromClipboard, SLOT(pasteFromClipboard())} }; @@ -1408,7 +1408,7 @@ void EditProfileDialog::setupMousePage(const Profile::Ptr profile) connect(_ui->wordCharacterEdit, &QLineEdit::textChanged, this, &Konsole::EditProfileDialog::wordCharactersChanged); - int tripleClickMode = profile->property(Profile::TripleClickMode); + auto tripleClickMode = profile->property(Profile::TripleClickMode); _ui->tripleClickModeCombo->setCurrentIndex(tripleClickMode); connect(_ui->tripleClickModeCombo, static_cast(&KComboBox::activated), this, &Konsole::EditProfileDialog::TripleClickModeChanged); @@ -1447,7 +1447,7 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile) // Setup the URL hints modifier checkboxes { - int modifiers = profile->property(Profile::UrlHintsModifiers); + auto modifiers = profile->property(Profile::UrlHintsModifiers); _ui->urlHintsModifierShift->setChecked((modifiers &Qt::ShiftModifier) != 0u); _ui->urlHintsModifierCtrl->setChecked((modifiers &Qt::ControlModifier) != 0u); _ui->urlHintsModifierAlt->setChecked((modifiers &Qt::AltModifier) != 0u); @@ -1476,7 +1476,7 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile) connect(_ui->autoCursorColorButton, &QRadioButton::clicked, this, &Konsole::EditProfileDialog::autoCursorColor); connect(_ui->customColorSelectButton, &KColorButton::changed, this, &Konsole::EditProfileDialog::customCursorColorChanged); - int shape = profile->property(Profile::CursorShape); + auto shape = profile->property(Profile::CursorShape); _ui->cursorShapeCombo->setCurrentIndex(shape); connect(_ui->cursorShapeCombo, static_cast(&KComboBox::activated), this, &Konsole::EditProfileDialog::setCursorShape); @@ -1694,7 +1694,7 @@ ColorSchemeViewDelegate::ColorSchemeViewDelegate(QObject *aParent) : void ColorSchemeViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - const ColorScheme *scheme = index.data(Qt::UserRole + 1).value(); + const auto *scheme = index.data(Qt::UserRole + 1).value(); QFont profileFont = index.data(Qt::UserRole + 2).value(); Q_ASSERT(scheme); if (scheme == nullptr) { diff --git a/src/ProcessInfo.cpp b/src/ProcessInfo.cpp index a284c2a10..34dfd5e6d 100644 --- a/src/ProcessInfo.cpp +++ b/src/ProcessInfo.cpp @@ -430,7 +430,7 @@ protected: char path_buffer[MAXPATHLEN + 1]; path_buffer[MAXPATHLEN] = 0; QByteArray procCwd = QFile::encodeName(QStringLiteral("/proc/%1/cwd").arg(pid)); - const int length = static_cast(readlink(procCwd.constData(), path_buffer, MAXPATHLEN)); + const auto length = static_cast(readlink(procCwd.constData(), path_buffer, MAXPATHLEN)); if (length == -1) { setError(UnknownError); return false; diff --git a/src/Session.cpp b/src/Session.cpp index c1161ebe8..300f10808 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -334,7 +334,7 @@ void Session::addView(TerminalDisplay* widget) void Session::viewDestroyed(QObject* view) { - TerminalDisplay* display = reinterpret_cast(view); + auto* display = reinterpret_cast(view); Q_ASSERT(_views.contains(display)); @@ -1722,7 +1722,7 @@ void SessionGroup::removeSession(Session* session) } void SessionGroup::sessionFinished() { - Session* session = qobject_cast(sender()); + auto* session = qobject_cast(sender()); Q_ASSERT(session); removeSession(session); } diff --git a/src/SessionController.cpp b/src/SessionController.cpp index 0e381c86f..66c03fcda 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -436,7 +436,7 @@ void SessionController::updateWebSearchMenu() void SessionController::handleWebShortcutAction() { - QAction * action = qobject_cast(sender()); + auto * action = qobject_cast(sender()); if (action == nullptr) { return; } @@ -456,7 +456,7 @@ void SessionController::configureWebShortcuts() void SessionController::sendSignal(QAction* action) { - const int signal = action->data().value(); + const auto signal = action->data().value(); _session->sendSignal(signal); } @@ -468,7 +468,7 @@ void SessionController::sendBackgroundColor() void SessionController::toggleReadOnly() { - QAction *action = qobject_cast(sender()); + auto *action = qobject_cast(sender()); if (action != nullptr) { bool readonly = !isReadOnly(); _session->setReadOnly(readonly); @@ -660,20 +660,20 @@ void SessionController::setupExtraActions() collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::ALT + Qt::Key_S); // Copy input to ==> all tabs - KToggleAction* copyInputToAllTabsAction = collection->add(QStringLiteral("copy-input-to-all-tabs")); + auto* copyInputToAllTabsAction = collection->add(QStringLiteral("copy-input-to-all-tabs")); copyInputToAllTabsAction->setText(i18n("&All Tabs in Current Window")); copyInputToAllTabsAction->setData(CopyInputToAllTabsMode); // this action is also used in other place, so remember it _copyInputToAllTabsAction = copyInputToAllTabsAction; // Copy input to ==> selected tabs - KToggleAction* copyInputToSelectedTabsAction = collection->add(QStringLiteral("copy-input-to-selected-tabs")); + auto* copyInputToSelectedTabsAction = collection->add(QStringLiteral("copy-input-to-selected-tabs")); copyInputToSelectedTabsAction->setText(i18n("&Select Tabs...")); collection->setDefaultShortcut(copyInputToSelectedTabsAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_Period); copyInputToSelectedTabsAction->setData(CopyInputToSelectedTabsMode); // Copy input to ==> none - KToggleAction* copyInputToNoneAction = collection->add(QStringLiteral("copy-input-to-none")); + auto* copyInputToNoneAction = collection->add(QStringLiteral("copy-input-to-none")); copyInputToNoneAction->setText(i18nc("@action:inmenu Do not select any tabs", "&None")); collection->setDefaultShortcut(copyInputToNoneAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_Slash); copyInputToNoneAction->setData(CopyInputToNoneMode); @@ -681,7 +681,7 @@ void SessionController::setupExtraActions() // The "Copy Input To" submenu // The above three choices are represented as combo boxes - KSelectAction* copyInputActions = collection->add(QStringLiteral("copy-input-to")); + auto* copyInputActions = collection->add(QStringLiteral("copy-input-to")); copyInputActions->setText(i18n("Copy Input To")); copyInputActions->addAction(copyInputToAllTabsAction); copyInputActions->addAction(copyInputToSelectedTabsAction); @@ -723,7 +723,7 @@ void SessionController::setupExtraActions() collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::ALT + Qt::Key_0); // Send signal - KSelectAction* sendSignalActions = collection->add(QStringLiteral("send-signal")); + auto* sendSignalActions = collection->add(QStringLiteral("send-signal")); sendSignalActions->setText(i18n("Send Signal")); connect(sendSignalActions, static_cast(&KSelectAction::triggered), this, &Konsole::SessionController::sendSignal); @@ -985,7 +985,7 @@ static const KXmlGuiWindow* findWindow(const QObject* object) { // Walk up the QObject hierarchy to find a KXmlGuiWindow. while (object != nullptr) { - const KXmlGuiWindow* window = qobject_cast(object); + const auto* window = qobject_cast(object); if (window != nullptr) { return(window); } @@ -1009,7 +1009,7 @@ static bool hasTerminalDisplayInSameWindow(const Session* session, const KXmlGui void SessionController::copyInputActionsTriggered(QAction* action) { - const int mode = action->data().value(); + const auto mode = action->data().value(); switch (mode) { case CopyInputToAllTabsMode: diff --git a/src/SessionListModel.cpp b/src/SessionListModel.cpp index e361f7116..b4dfdcd6d 100644 --- a/src/SessionListModel.cpp +++ b/src/SessionListModel.cpp @@ -127,7 +127,7 @@ QModelIndex SessionListModel::parent(const QModelIndex &) const void SessionListModel::sessionFinished() { - Session *session = qobject_cast(sender()); + auto *session = qobject_cast(sender()); int row = _sessions.indexOf(session); if (row != -1) { diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp index 9b3ec86c6..da8f153df 100644 --- a/src/SessionManager.cpp +++ b/src/SessionManager.cpp @@ -215,8 +215,8 @@ void SessionManager::applyProfile(Session *session, const Profile::Ptr profile, if (apply.shouldApply(Profile::TerminalColumns) || apply.shouldApply(Profile::TerminalRows)) { - const int columns = profile->property(Profile::TerminalColumns); - const int rows = profile->property(Profile::TerminalRows); + const auto columns = profile->property(Profile::TerminalColumns); + const auto rows = profile->property(Profile::TerminalRows); session->setPreferredSize(QSize(columns, rows)); } @@ -243,7 +243,7 @@ void SessionManager::applyProfile(Session *session, const Profile::Ptr profile, // History if (apply.shouldApply(Profile::HistoryMode) || apply.shouldApply(Profile::HistorySize)) { - const int mode = profile->property(Profile::HistoryMode); + const auto mode = profile->property(Profile::HistoryMode); switch (mode) { case Enum::NoHistory: session->setHistoryType(HistoryTypeNone()); @@ -281,7 +281,7 @@ void SessionManager::applyProfile(Session *session, const Profile::Ptr profile, void SessionManager::sessionProfileCommandReceived(const QString &text) { - Session *session = qobject_cast(sender()); + auto *session = qobject_cast(sender()); Q_ASSERT(session); // store the font for each view if zoom was applied so that they can diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index dcf42a04c..b6a854e29 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -382,7 +382,7 @@ namespace Konsole QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object) { Q_UNUSED(key) - if (TerminalDisplay *display = qobject_cast(object)) { + if (auto *display = qobject_cast(object)) { return new TerminalDisplayAccessible(display); } return nullptr; @@ -845,7 +845,7 @@ void TerminalDisplay::resetCursorStyle() Profile::Ptr currentProfile = SessionManager::instance()->sessionProfile(_sessionController->session()); if (currentProfile != nullptr) { - Enum::CursorShapeEnum shape = static_cast(currentProfile->property(Profile::CursorShape)); + auto shape = static_cast(currentProfile->property(Profile::CursorShape)); setKeyboardCursorShape(shape); setBlinkingCursorEnabled(currentProfile->blinkingCursorEnabled()); @@ -2301,7 +2301,7 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev) if (ev->button() == Qt::LeftButton) { // request the software keyboard, if any if (qApp->autoSipEnabled()) { - QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( + auto behavior = QStyle::RequestSoftwareInputPanel( style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); if (hasFocus() || behavior == QStyle::RSIP_OnMouseClick) { QEvent event(QEvent::RequestSoftwareInputPanel); @@ -3872,7 +3872,7 @@ void TerminalDisplay::dropEvent(QDropEvent* event) void TerminalDisplay::dropMenuPasteActionTriggered() { if (sender() != nullptr) { - const QAction* action = qobject_cast(sender()); + const auto* action = qobject_cast(sender()); if (action != nullptr) { emit sendStringToEmu(action->data().toString().toLocal8Bit()); } @@ -3882,7 +3882,7 @@ void TerminalDisplay::dropMenuPasteActionTriggered() void TerminalDisplay::dropMenuCdActionTriggered() { if (sender() != nullptr) { - const QAction* action = qobject_cast(sender()); + const auto* action = qobject_cast(sender()); if (action != nullptr) { emit sendStringToEmu(action->data().toString().toLocal8Bit()); } @@ -3946,7 +3946,7 @@ bool AutoScrollHandler::eventFilter(QObject* watched, QEvent* event) switch (event->type()) { case QEvent::MouseMove: { - QMouseEvent* mouseEvent = static_cast(event); + auto* mouseEvent = static_cast(event); bool mouseInWidget = widget()->rect().contains(mouseEvent->pos()); if (mouseInWidget) { if (_timerId != 0) { @@ -3963,7 +3963,7 @@ bool AutoScrollHandler::eventFilter(QObject* watched, QEvent* event) break; } case QEvent::MouseButtonRelease: { - QMouseEvent* mouseEvent = static_cast(event); + auto* mouseEvent = static_cast(event); if ((_timerId != 0) && ((mouseEvent->buttons() & ~Qt::LeftButton) != 0u)) { killTimer(_timerId); _timerId = 0; diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 2ff5cfd8c..e3aa09592 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -354,7 +354,7 @@ void ViewManager::detachView(TabbedViewContainer *container, QWidget *view) return; #endif - TerminalDisplay *viewToDetach = qobject_cast(view); + auto *viewToDetach = qobject_cast(view); if (viewToDetach == nullptr) { return; @@ -390,7 +390,7 @@ void ViewManager::sessionFinished() return; } - Session *session = qobject_cast(sender()); + auto *session = qobject_cast(sender()); Q_ASSERT(session); // close attached views @@ -473,7 +473,7 @@ void ViewManager::removeContainer(TabbedViewContainer *container) // remove session map entries for views in this container for(int i = 0, end = container->count(); i < end; i++) { auto view = container->widget(i); - TerminalDisplay *display = qobject_cast(view); + auto *display = qobject_cast(view); Q_ASSERT(display); _sessionMap.remove(display); } @@ -657,8 +657,8 @@ TabbedViewContainer *ViewManager::createContainer() void ViewManager::containerMoveViewRequest(int index, int id, TabbedViewContainer *sourceTabbedContainer) { - TabbedViewContainer *container = qobject_cast(sender()); - SessionController *controller = qobject_cast(ViewProperties::propertiesById(id)); + auto *container = qobject_cast(sender()); + auto *controller = qobject_cast(ViewProperties::propertiesById(id)); if (controller == nullptr) { return; @@ -737,7 +737,7 @@ void ViewManager::viewDestroyed(QWidget *view) // Note: the received QWidget has already been destroyed, so // using dynamic_cast<> or qobject_cast<> does not work here // We only need the pointer address to look it up below - TerminalDisplay *display = reinterpret_cast(view); + auto *display = reinterpret_cast(view); // 1. detach view from session // 2. if the session has no views left, close it @@ -916,9 +916,9 @@ void ViewManager::saveSessions(KConfigGroup &group) } ids.reserve(container->count()); - TerminalDisplay *activeview = qobject_cast(container->currentWidget()); + auto *activeview = qobject_cast(container->currentWidget()); for (int i = 0, end = container->count(); i < end; i++) { - TerminalDisplay *view = qobject_cast(container->widget(i)); + auto *view = qobject_cast(container->widget(i)); Q_ASSERT(view); Session *session = _sessionMap[view]; diff --git a/src/ViewSplitter.cpp b/src/ViewSplitter.cpp index 43cbe9231..c6774518b 100644 --- a/src/ViewSplitter.cpp +++ b/src/ViewSplitter.cpp @@ -56,7 +56,7 @@ void ViewSplitter::adjustContainerSize(TabbedViewContainer *container, int perce QList containerSizes = sizes(); const int oldSize = containerSizes[containerIndex]; - const int newSize = static_cast(oldSize * (1.0 + percentage / 100.0)); + const auto newSize = static_cast(oldSize * (1.0 + percentage / 100.0)); const int perContainerDelta = (count() == 1) ? 0 : ((newSize - oldSize) / (count() - 1)) * (-1); diff --git a/src/settings/ProfileSettings.cpp b/src/settings/ProfileSettings.cpp index f80f10695..12b4dab4e 100644 --- a/src/settings/ProfileSettings.cpp +++ b/src/settings/ProfileSettings.cpp @@ -405,7 +405,7 @@ void ProfileSettings::setShortcutEditorVisible(bool visible) void StyledBackgroundPainter::drawBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex&) { - const QStyleOptionViewItemV3* v3option = qstyleoption_cast(&option); + const auto* v3option = qstyleoption_cast(&option); const QWidget* widget = v3option != nullptr ? v3option->widget : nullptr; QStyle* style = widget != nullptr ? widget->style() : QApplication::style(); @@ -459,7 +459,7 @@ void ShortcutItemDelegate::editorModified(const QKeySequence& keys) { Q_UNUSED(keys); - KKeySequenceWidget* editor = qobject_cast(sender()); + auto* editor = qobject_cast(sender()); Q_ASSERT(editor); _modifiedEditors.insert(editor); emit commitData(editor); diff --git a/src/tests/PartManualTest.cpp b/src/tests/PartManualTest.cpp index 1062b8780..ab380f0af 100644 --- a/src/tests/PartManualTest.cpp +++ b/src/tests/PartManualTest.cpp @@ -125,7 +125,7 @@ KParts::Part* PartManualTest::createPart() KPluginFactory* factory = KPluginLoader(service->library()).factory(); Q_ASSERT(factory); - KParts::Part* terminalPart = factory->create(this); + auto* terminalPart = factory->create(this); return terminalPart; } diff --git a/src/tests/demo_konsolepart/src/demo_konsolepart.cpp b/src/tests/demo_konsolepart/src/demo_konsolepart.cpp index 08e75c1e8..f634cc056 100644 --- a/src/tests/demo_konsolepart/src/demo_konsolepart.cpp +++ b/src/tests/demo_konsolepart/src/demo_konsolepart.cpp @@ -91,7 +91,7 @@ KParts::ReadOnlyPart* demo_konsolepart::createPart() KPluginFactory* factory = KPluginLoader(service->library()).factory(); Q_ASSERT(factory); - KParts::ReadOnlyPart* terminalPart = factory->create(this); + auto* terminalPart = factory->create(this); return terminalPart; }