From 4e0c1690d24eeb8eb4d496a8df1c86a9242d681f Mon Sep 17 00:00:00 2001 From: Simone Gaiarin Date: Sun, 30 Aug 2020 23:49:14 +0200 Subject: [PATCH] Uniform the case of the 'Id' suffix in variable names --- ui/annotationactionhandler.cpp | 36 +++++++++---------- ui/pageviewannotator.cpp | 66 +++++++++++++++++----------------- ui/pageviewannotator.h | 10 +++--- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/ui/annotationactionhandler.cpp b/ui/annotationactionhandler.cpp index d25bb3db5..c09bb07ab 100644 --- a/ui/annotationactionhandler.cpp +++ b/ui/annotationactionhandler.cpp @@ -83,7 +83,7 @@ public: * matches a default stamp, any existing stamp annotation action is removed. */ void maybeUpdateCustomStampAction(const QString &stampIconName); - void parseTool(int toolID); + void parseTool(int toolId); void updateConfigActions(const QString &annotType = QLatin1String("")); void populateQuickAnnotations(); @@ -92,9 +92,9 @@ public: const QIcon widthIcon(double width); const QIcon stampIcon(const QString &stampIconName); - void selectTool(int toolID); + void selectTool(int toolId); void slotStampToolSelected(const QString &stamp); - void slotQuickToolSelected(int favToolID); + void slotQuickToolSelected(int favToolId); void slotSetColor(AnnotationColor colorType, const QColor &color = QColor()); void slotSelectAnnotationFont(); void slotToolBarVisibilityChanged(bool checked); @@ -196,14 +196,14 @@ void AnnotationActionHandlerPrivate::maybeUpdateCustomStampAction(const QString } } -void AnnotationActionHandlerPrivate::parseTool(int toolID) +void AnnotationActionHandlerPrivate::parseTool(int toolId) { - if (toolID == -1) { + if (toolId == -1) { updateConfigActions(); return; } - QDomElement toolElement = annotator->builtinTool(toolID); + QDomElement toolElement = annotator->builtinTool(toolId); const QString annotType = toolElement.attribute(QStringLiteral("type")); QDomElement engineElement = toolElement.firstChildElement(QStringLiteral("engine")); QDomElement annElement = engineElement.firstChildElement(QStringLiteral("annotation")); @@ -421,11 +421,11 @@ const QIcon AnnotationActionHandlerPrivate::stampIcon(const QString &stampIconNa return QIcon::fromTheme(QStringLiteral("tag")); } -void AnnotationActionHandlerPrivate::selectTool(int toolID) +void AnnotationActionHandlerPrivate::selectTool(int toolId) { - selectedTool = toolID; - annotator->selectTool(toolID); - parseTool(toolID); + selectedTool = toolId; + annotator->selectTool(toolId); + parseTool(toolId); } void AnnotationActionHandlerPrivate::slotStampToolSelected(const QString &stamp) @@ -435,17 +435,17 @@ void AnnotationActionHandlerPrivate::slotStampToolSelected(const QString &stamp) annotator->selectStampTool(stamp); // triggers a reparsing thus calling parseTool } -void AnnotationActionHandlerPrivate::slotQuickToolSelected(int favToolID) +void AnnotationActionHandlerPrivate::slotQuickToolSelected(int favToolId) { - int toolID = annotator->setQuickTool(favToolID); // always triggers an unuseful reparsing - if (toolID == -1) { - qWarning("Corrupted configuration for quick annotation tool with id: %d", favToolID); + int toolId = annotator->setQuickTool(favToolId); // always triggers an unuseful reparsing + if (toolId == -1) { + qWarning("Corrupted configuration for quick annotation tool with id: %d", favToolId); return; } - int indexOfActionInGroup = toolID - 1; - if (toolID == PageViewAnnotator::STAMP_TOOL_ID) { + int indexOfActionInGroup = toolId - 1; + if (toolId == PageViewAnnotator::STAMP_TOOL_ID) { // if the quick tool is a stamp we need to find its corresponding built-in tool action and select it - QDomElement favToolElement = annotator->quickTool(favToolID); + QDomElement favToolElement = annotator->quickTool(favToolId); QDomElement engineElement = favToolElement.firstChildElement(QStringLiteral("engine")); QDomElement annotationElement = engineElement.firstChildElement(QStringLiteral("annotation")); QString stampIconName = annotationElement.attribute(QStringLiteral("icon")); @@ -465,7 +465,7 @@ void AnnotationActionHandlerPrivate::slotQuickToolSelected(int favToolID) // when new tool if different from the selected one favToolAction->trigger(); } else { - selectTool(toolID); + selectTool(toolId); } aShowToolBar->setChecked(true); } diff --git a/ui/pageviewannotator.cpp b/ui/pageviewannotator.cpp index 27ad4ff6d..52f690289 100644 --- a/ui/pageviewannotator.cpp +++ b/ui/pageviewannotator.cpp @@ -663,10 +663,10 @@ public: return tools; } - QDomElement tool(int toolID) + QDomElement tool(int toolId) { QDomElement toolElement = m_toolsDefinition.documentElement().firstChildElement(); - while (!toolElement.isNull() && toolElement.attribute(QStringLiteral("id")).toInt() != toolID) { + while (!toolElement.isNull() && toolElement.attribute(QStringLiteral("id")).toInt() != toolId) { toolElement = toolElement.nextSiblingElement(); } return toolElement; // can return a null element @@ -679,20 +679,20 @@ public: m_toolsDefinition.documentElement().appendChild(toolElement); } - bool updateTool(QDomElement newToolElement, int toolID) + bool updateTool(QDomElement newToolElement, int toolId) { - QDomElement toolElement = tool(toolID); + QDomElement toolElement = tool(toolId); if (toolElement.isNull()) return false; newToolElement = newToolElement.cloneNode().toElement(); - newToolElement.setAttribute(QStringLiteral("id"), toolID); + newToolElement.setAttribute(QStringLiteral("id"), toolId); QDomNode oldTool = m_toolsDefinition.documentElement().replaceChild(newToolElement, toolElement); return !oldTool.isNull(); } int findToolId(const QString &type) { - int toolID = -1; + int toolId = -1; if (type.isEmpty()) { return -1; } @@ -704,12 +704,12 @@ public: } if (!toolElement.isNull() && toolElement.hasAttribute(QStringLiteral("id"))) { bool ok; - toolID = toolElement.attribute(QStringLiteral("id")).toInt(&ok); + toolId = toolElement.attribute(QStringLiteral("id")).toInt(&ok); if (!ok) { return -1; } } - return toolID; + return toolId; } private: @@ -730,7 +730,7 @@ PageViewAnnotator::PageViewAnnotator(PageView *parent, Okular::Document *storage , m_quickToolsDefinition(nullptr) , m_continuousMode(true) , m_constrainRatioAndAngle(false) - , m_lastToolID(-1) + , m_lastToolId(-1) , m_lockedItem(nullptr) { reparseConfig(); @@ -848,7 +848,7 @@ QRect PageViewAnnotator::performRouteMouseOrTabletEvent(const AnnotatorEngine::E } if (m_continuousMode) - selectTool(m_lastToolID); + selectTool(m_lastToolId); else detachAnnotation(); } @@ -935,10 +935,10 @@ void PageViewAnnotator::routePaint(QPainter *painter, const QRect paintRect) painter->restore(); } -void PageViewAnnotator::selectTool(int toolID) +void PageViewAnnotator::selectTool(int toolId) { // ask for Author's name if not already set - if (toolID > 0 && Okular::Settings::identityAuthor().isEmpty()) { + if (toolId > 0 && Okular::Settings::identityAuthor().isEmpty()) { // get default username from the kdelibs/kdecore/KUser KUser currentUser; QString userName = currentUser.property(KUser::FullName).toString(); @@ -969,17 +969,17 @@ void PageViewAnnotator::selectTool(int toolID) } // store current tool for later usage - m_lastToolID = toolID; + m_lastToolId = toolId; // handle tool deselection - if (toolID == -1) { + if (toolId == -1) { m_pageView->displayMessage(QString()); m_pageView->updateCursor(); return; } // for the selected tool create the Engine - QDomElement toolElement = m_builtinToolsDefinition->tool(toolID); + QDomElement toolElement = m_builtinToolsDefinition->tool(toolId); if (!toolElement.isNull()) { // parse tool properties QDomElement engineElement = toolElement.firstChildElement(QStringLiteral("engine")); @@ -1040,7 +1040,7 @@ void PageViewAnnotator::selectTool(int toolID) m_pageView->updateCursor(); } - if (toolID > 0) + if (toolId > 0) emit toolSelected(); } @@ -1280,10 +1280,10 @@ void PageViewAnnotator::saveAnnotationTools() Okular::Settings::self()->save(); } -int PageViewAnnotator::setQuickTool(int favToolID) +int PageViewAnnotator::setQuickTool(int favToolId) { int toolId = -1; - QDomElement favToolElement = m_quickToolsDefinition->tool(favToolID); + QDomElement favToolElement = m_quickToolsDefinition->tool(favToolId); if (!favToolElement.isNull()) { toolId = m_builtinToolsDefinition->findToolId(favToolElement.attribute(QStringLiteral("type"))); if (toolId == -1) { @@ -1295,19 +1295,19 @@ int PageViewAnnotator::setQuickTool(int favToolID) return toolId; } -QDomElement PageViewAnnotator::builtinTool(int toolID) +QDomElement PageViewAnnotator::builtinTool(int toolId) { - return m_builtinToolsDefinition->tool(toolID); + return m_builtinToolsDefinition->tool(toolId); } -QDomElement PageViewAnnotator::quickTool(int toolID) +QDomElement PageViewAnnotator::quickTool(int toolId) { - return m_quickToolsDefinition->tool(toolID); + return m_quickToolsDefinition->tool(toolId); } QDomElement PageViewAnnotator::currentEngineElement() { - return m_builtinToolsDefinition->tool(m_lastToolID).firstChildElement(QStringLiteral("engine")); + return m_builtinToolsDefinition->tool(m_lastToolId).firstChildElement(QStringLiteral("engine")); } QDomElement PageViewAnnotator::currentAnnotationElement() @@ -1319,7 +1319,7 @@ void PageViewAnnotator::setAnnotationWidth(double width) { currentAnnotationElement().setAttribute(QStringLiteral("width"), QString::number(width)); saveAnnotationTools(); - selectTool(m_lastToolID); + selectTool(m_lastToolId); } void PageViewAnnotator::setAnnotationColor(const QColor &color) @@ -1333,7 +1333,7 @@ void PageViewAnnotator::setAnnotationColor(const QColor &color) annotationElement.setAttribute(QStringLiteral("color"), color.name(QColor::HexRgb)); } saveAnnotationTools(); - selectTool(m_lastToolID); + selectTool(m_lastToolId); } void PageViewAnnotator::setAnnotationInnerColor(const QColor &color) @@ -1345,26 +1345,26 @@ void PageViewAnnotator::setAnnotationInnerColor(const QColor &color) annotationElement.setAttribute(QStringLiteral("innerColor"), color.name(QColor::HexRgb)); } saveAnnotationTools(); - selectTool(m_lastToolID); + selectTool(m_lastToolId); } void PageViewAnnotator::setAnnotationOpacity(double opacity) { currentAnnotationElement().setAttribute(QStringLiteral("opacity"), QString::number(opacity)); saveAnnotationTools(); - selectTool(m_lastToolID); + selectTool(m_lastToolId); } void PageViewAnnotator::setAnnotationFont(const QFont &font) { currentAnnotationElement().setAttribute(QStringLiteral("font"), font.toString()); saveAnnotationTools(); - selectTool(m_lastToolID); + selectTool(m_lastToolId); } void PageViewAnnotator::addToQuickAnnotations() { - QDomElement sourceToolElement = m_builtinToolsDefinition->tool(m_lastToolID); + QDomElement sourceToolElement = m_builtinToolsDefinition->tool(m_lastToolId); if (sourceToolElement.isNull()) return; @@ -1384,17 +1384,17 @@ void PageViewAnnotator::addToQuickAnnotations() void PageViewAnnotator::slotAdvancedSettings() { - QDomElement toolElement = m_builtinToolsDefinition->tool(m_lastToolID); + QDomElement toolElement = m_builtinToolsDefinition->tool(m_lastToolId); EditAnnotToolDialog t(nullptr, toolElement, true); if (t.exec() != QDialog::Accepted) return; QDomElement toolElementUpdated = t.toolXml().documentElement(); - int toolID = toolElement.attribute(QStringLiteral("id")).toInt(); - m_builtinToolsDefinition->updateTool(toolElementUpdated, toolID); + int toolId = toolElement.attribute(QStringLiteral("id")).toInt(); + m_builtinToolsDefinition->updateTool(toolElementUpdated, toolId); saveAnnotationTools(); - selectTool(m_lastToolID); + selectTool(m_lastToolId); } #include "moc_pageviewannotator.cpp" diff --git a/ui/pageviewannotator.h b/ui/pageviewannotator.h index 63b3e172e..6e3dd432b 100644 --- a/ui/pageviewannotator.h +++ b/ui/pageviewannotator.h @@ -103,18 +103,18 @@ public: void setTextToolsEnabled(bool enabled); // selects the active tool - void selectTool(int toolID); + void selectTool(int toolId); // selects a stamp tool and sets the stamp symbol void selectStampTool(const QString &stampSymbol); // makes a quick annotation the active tool - int setQuickTool(int toolID); + int setQuickTool(int toolId); // deselects the tool and uncheck all the annotation actions void detachAnnotation(); // returns the builtin annotation tool with the given Id - QDomElement builtinTool(int toolID); + QDomElement builtinTool(int toolId); // returns the quick annotation tool with the given Id - QDomElement quickTool(int toolID); + QDomElement quickTool(int toolId); // methods that write the properties void setAnnotationWidth(double width); @@ -155,7 +155,7 @@ private: bool m_constrainRatioAndAngle; // creation related variables - int m_lastToolID; + int m_lastToolId; QRect m_lastDrawnRect; PageViewItem *m_lockedItem; // selected annotation name