perf: Fix all clazy qstring-allocation warnings (#903)
This commit is contained in:
@@ -55,7 +55,7 @@ bool MouseWheelOverScrollbarFilter::eventFilter(QObject* obj, QEvent* event)
|
||||
|
||||
QtLineNumberArea::QtLineNumberArea(QtCodeArea* codeArea): QWidget(codeArea), m_codeArea(codeArea)
|
||||
{
|
||||
setObjectName("line_number_area");
|
||||
setObjectName(QStringLiteral("line_number_area"));
|
||||
}
|
||||
|
||||
QtLineNumberArea::~QtLineNumberArea() {}
|
||||
|
||||
@@ -40,7 +40,7 @@ QtCodeField::QtCodeField(
|
||||
{
|
||||
TRACE();
|
||||
|
||||
setObjectName("code_area");
|
||||
setObjectName(QStringLiteral("code_area"));
|
||||
setReadOnly(true);
|
||||
setFrameStyle(QFrame::NoFrame);
|
||||
setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
@@ -96,9 +96,9 @@ QtCodeField::QtCodeField(
|
||||
setFont(font);
|
||||
setTabStopWidth(appSettings->getCodeTabWidth() * fontMetrics().width('9'));
|
||||
|
||||
m_openInTabAction = new QAction("Open in New Tab", this);
|
||||
m_openInTabAction->setStatusTip("Opens the node in a new tab");
|
||||
m_openInTabAction->setToolTip("Opens the node in a new tab");
|
||||
m_openInTabAction = new QAction(QStringLiteral("Open in New Tab"), this);
|
||||
m_openInTabAction->setStatusTip(QStringLiteral("Opens the node in a new tab"));
|
||||
m_openInTabAction->setToolTip(QStringLiteral("Opens the node in a new tab"));
|
||||
m_openInTabAction->setEnabled(false);
|
||||
connect(m_openInTabAction, &QAction::triggered, this, &QtCodeField::openInTab);
|
||||
}
|
||||
@@ -771,7 +771,7 @@ void QtCodeField::createMultibyteCharacterLocationCache(const QString& code)
|
||||
QTextCodec* codec = QTextCodec::codecForName(
|
||||
ApplicationSettings::getInstance()->getTextEncoding().c_str());
|
||||
|
||||
for (const QString& line: code.split("\n"))
|
||||
for (const QString& line: code.split(QStringLiteral("\n")))
|
||||
{
|
||||
std::vector<std::pair<int, int>> columnsToOffsets;
|
||||
for (int i = 0; i < line.size(); i++)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeNavigator* navigator, bool isFirst)
|
||||
: QFrame(), m_navigator(navigator), m_filePath(filePath), m_isWholeFile(false)
|
||||
{
|
||||
setObjectName("code_file");
|
||||
setObjectName(QStringLiteral("code_file"));
|
||||
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
@@ -25,11 +25,11 @@ QtCodeFileList::QtCodeFileList(QtCodeNavigator* navigator)
|
||||
{
|
||||
m_scrollArea = new QScrollArea();
|
||||
|
||||
m_scrollArea->setObjectName("code_container");
|
||||
m_scrollArea->setObjectName(QStringLiteral("code_container"));
|
||||
m_scrollArea->setWidgetResizable(true);
|
||||
|
||||
m_filesArea = new QFrame();
|
||||
m_filesArea->setObjectName("code_file_list");
|
||||
m_filesArea->setObjectName(QStringLiteral("code_file_list"));
|
||||
|
||||
QVBoxLayout* innerLayout = new QVBoxLayout();
|
||||
innerLayout->setSpacing(0);
|
||||
@@ -53,7 +53,7 @@ QtCodeFileList::QtCodeFileList(QtCodeNavigator* navigator)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lastSnippetScrollBar->setObjectName("last_scroll_bar");
|
||||
m_lastSnippetScrollBar->setObjectName(QStringLiteral("last_scroll_bar"));
|
||||
}
|
||||
|
||||
m_lastSnippetScrollBar->hide();
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
QtCodeFileSingle::QtCodeFileSingle(QtCodeNavigator* navigator, QWidget* parent)
|
||||
: m_navigator(navigator), m_area(nullptr)
|
||||
{
|
||||
setObjectName("code_container");
|
||||
setObjectName(QStringLiteral("code_container"));
|
||||
|
||||
setLayout(new QVBoxLayout(this));
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
layout()->setSpacing(0);
|
||||
|
||||
m_titleBar = new QtCodeFileTitleBar(this, false, true);
|
||||
m_titleBar->setObjectName("title_bar_single");
|
||||
m_titleBar->setObjectName(QStringLiteral("title_bar_single"));
|
||||
layout()->addWidget(m_titleBar);
|
||||
|
||||
connect(m_titleBar, &QtCodeFileTitleBar::snippet, this, &QtCodeFileSingle::clickedSnippetButton);
|
||||
|
||||
m_areaWrapper = new QWidget();
|
||||
m_areaWrapper->setObjectName("code_file_single");
|
||||
m_areaWrapper->setObjectName(QStringLiteral("code_file_single"));
|
||||
m_areaWrapper->setSizePolicy(
|
||||
m_areaWrapper->sizePolicy().horizontalPolicy(), QSizePolicy::Expanding);
|
||||
m_areaWrapper->setLayout(new QVBoxLayout());
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool isSingle)
|
||||
: QtHoverButton(parent)
|
||||
{
|
||||
setObjectName("title_bar");
|
||||
setObjectName(QStringLiteral("title_bar"));
|
||||
setProperty("hovering", isHovering);
|
||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
|
||||
@@ -32,17 +32,17 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool is
|
||||
FilePath imageDir = ResourcePaths::getGuiPath().concatenate(L"code_view/images/");
|
||||
|
||||
m_expandButton = new QtSelfRefreshIconButton(
|
||||
"", imageDir.getConcatenated(L"snippet_arrow_right.png"), "code/file/title", this);
|
||||
QLatin1String(""), imageDir.getConcatenated(L"snippet_arrow_right.png"), "code/file/title", this);
|
||||
m_collapseButton = new QtSelfRefreshIconButton(
|
||||
"", imageDir.getConcatenated(L"snippet_arrow_down.png"), "code/file/title", this);
|
||||
QLatin1String(""), imageDir.getConcatenated(L"snippet_arrow_down.png"), "code/file/title", this);
|
||||
|
||||
m_expandButton->setToolTip("expand");
|
||||
m_collapseButton->setToolTip("collapse");
|
||||
m_expandButton->setToolTip(QStringLiteral("expand"));
|
||||
m_collapseButton->setToolTip(QStringLiteral("collapse"));
|
||||
|
||||
for (QtSelfRefreshIconButton* button: {m_expandButton, m_collapseButton})
|
||||
{
|
||||
button->setIconSize(QSize(9, 9));
|
||||
button->setObjectName("expand_button");
|
||||
button->setObjectName(QStringLiteral("expand_button"));
|
||||
titleLayout->addWidget(button);
|
||||
}
|
||||
|
||||
@@ -66,15 +66,15 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool is
|
||||
setMinimumHeight(m_titleButton->height() + 4);
|
||||
|
||||
m_referenceCount = new QLabel(this);
|
||||
m_referenceCount->setObjectName("references_label");
|
||||
m_referenceCount->setObjectName(QStringLiteral("references_label"));
|
||||
m_referenceCount->hide();
|
||||
titleLayout->addWidget(m_referenceCount);
|
||||
|
||||
titleLayout->addStretch(3);
|
||||
|
||||
m_showErrorsButton = new QPushButton("show errors");
|
||||
m_showErrorsButton->setObjectName("screen_button");
|
||||
m_showErrorsButton->setToolTip("Show all errors causing this file to be incomplete");
|
||||
m_showErrorsButton = new QPushButton(QStringLiteral("show errors"));
|
||||
m_showErrorsButton->setObjectName(QStringLiteral("screen_button"));
|
||||
m_showErrorsButton->setToolTip(QStringLiteral("Show all errors causing this file to be incomplete"));
|
||||
m_showErrorsButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_showErrorsButton->hide();
|
||||
titleLayout->addWidget(m_showErrorsButton);
|
||||
@@ -94,7 +94,7 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool is
|
||||
inactiveColor);
|
||||
m_snippetButton->addState(
|
||||
QtIconStateButton::STATE_DISABLED, imageDir.getConcatenated(L"snippet_inactive.png"));
|
||||
m_snippetButton->setToolTip("show snippets");
|
||||
m_snippetButton->setToolTip(QStringLiteral("show snippets"));
|
||||
|
||||
m_maximizeButton = new QtIconStateButton(this);
|
||||
m_maximizeButton->addState(
|
||||
@@ -105,12 +105,12 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool is
|
||||
inactiveColor);
|
||||
m_maximizeButton->addState(
|
||||
QtIconStateButton::STATE_DISABLED, imageDir.getConcatenated(L"maximize_inactive.png"));
|
||||
m_maximizeButton->setToolTip("maximize");
|
||||
m_maximizeButton->setToolTip(QStringLiteral("maximize"));
|
||||
|
||||
for (QtIconStateButton* button: {m_snippetButton, m_maximizeButton})
|
||||
{
|
||||
button->setIconSize(QSize(16, 16));
|
||||
button->setObjectName("file_button");
|
||||
button->setObjectName(QStringLiteral("file_button"));
|
||||
button->setEnabled(false);
|
||||
titleLayout->addWidget(button);
|
||||
}
|
||||
@@ -160,18 +160,18 @@ void QtCodeFileTitleBar::updateRefCount(int refCount, bool hasErrors, size_t fat
|
||||
{
|
||||
if (refCount > 0)
|
||||
{
|
||||
QString label = hasErrors ? "error" : "reference";
|
||||
QString label = hasErrors ? QStringLiteral("error") : QStringLiteral("reference");
|
||||
if (refCount > 1)
|
||||
{
|
||||
label += "s";
|
||||
label += QChar('s');
|
||||
}
|
||||
|
||||
if (fatalErrorCount > 0)
|
||||
{
|
||||
label += " (" + QString::number(fatalErrorCount) + " fatal)";
|
||||
label += QStringLiteral(" (") + QString::number(fatalErrorCount) + QStringLiteral(" fatal)");
|
||||
}
|
||||
|
||||
QString text = QString::number(refCount) + " " + label;
|
||||
QString text = QString::number(refCount) + QChar(' ') + label;
|
||||
if (text != m_referenceCount->text())
|
||||
{
|
||||
m_referenceCount->setText(text);
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
#include "QtContextMenu.h"
|
||||
|
||||
QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent)
|
||||
: QtSelfRefreshIconButton("", FilePath(), "code/file/title", parent)
|
||||
: QtSelfRefreshIconButton(QLatin1String(""), FilePath(), "code/file/title", parent)
|
||||
, m_isComplete(true)
|
||||
, m_isIndexed(true)
|
||||
{
|
||||
setObjectName("title_button");
|
||||
setObjectName(QStringLiteral("title_button"));
|
||||
minimumSizeHint(); // force font loading
|
||||
|
||||
setFixedHeight(std::max(fontMetrics().height() * 1.2, 28.0));
|
||||
@@ -31,9 +31,9 @@ QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent)
|
||||
|
||||
connect(this, &QtCodeFileTitleButton::clicked, this, &QtCodeFileTitleButton::clickedTitle);
|
||||
|
||||
m_openInTabAction = new QAction("Open in New Tab", this);
|
||||
m_openInTabAction->setStatusTip("Opens the file in a new tab");
|
||||
m_openInTabAction->setToolTip("Opens the file in a new tab");
|
||||
m_openInTabAction = new QAction(QStringLiteral("Open in New Tab"), this);
|
||||
m_openInTabAction->setStatusTip(QStringLiteral("Opens the file in a new tab"));
|
||||
m_openInTabAction->setToolTip(QStringLiteral("Opens the file in a new tab"));
|
||||
m_openInTabAction->setEnabled(false);
|
||||
connect(m_openInTabAction, &QAction::triggered, this, &QtCodeFileTitleButton::openInTab);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ void QtCodeFileTitleButton::setProject(const std::wstring& name)
|
||||
m_filePath = FilePath();
|
||||
|
||||
setText(QString::fromStdWString(name));
|
||||
setToolTip("edit project");
|
||||
setToolTip(QStringLiteral("edit project"));
|
||||
|
||||
updateIcon();
|
||||
}
|
||||
@@ -273,6 +273,6 @@ void QtCodeFileTitleButton::updateHatching()
|
||||
}
|
||||
else
|
||||
{
|
||||
setStyleSheet("");
|
||||
setStyleSheet(QLatin1String(""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
|
||||
{
|
||||
QWidget* navigation = new QWidget();
|
||||
navigation->setObjectName("code_navigation");
|
||||
navigation->setObjectName(QStringLiteral("code_navigation"));
|
||||
|
||||
QHBoxLayout* navLayout = new QHBoxLayout();
|
||||
navLayout->setSpacing(2);
|
||||
@@ -47,11 +47,11 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
m_nextReferenceButton = new QtSearchBarButton(
|
||||
ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_down.png"), true);
|
||||
|
||||
m_prevReferenceButton->setObjectName("reference_button_previous");
|
||||
m_nextReferenceButton->setObjectName("reference_button_next");
|
||||
m_prevReferenceButton->setObjectName(QStringLiteral("reference_button_previous"));
|
||||
m_nextReferenceButton->setObjectName(QStringLiteral("reference_button_next"));
|
||||
|
||||
m_prevReferenceButton->setToolTip("previous reference");
|
||||
m_nextReferenceButton->setToolTip("next reference");
|
||||
m_prevReferenceButton->setToolTip(QStringLiteral("previous reference"));
|
||||
m_nextReferenceButton->setToolTip(QStringLiteral("next reference"));
|
||||
|
||||
m_prevReferenceButton->setIconSize(QSize(12, 12));
|
||||
m_nextReferenceButton->setIconSize(QSize(12, 12));
|
||||
@@ -65,8 +65,8 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
m_nextReferenceButton, &QPushButton::clicked, this, &QtCodeNavigator::nextReference);
|
||||
|
||||
// m_refLabel = new QLabel("0 files | 0 references");
|
||||
m_refLabel = new QLabel("0 references");
|
||||
m_refLabel->setObjectName("references_label");
|
||||
m_refLabel = new QLabel(QStringLiteral("0 references"));
|
||||
m_refLabel->setObjectName(QStringLiteral("references_label"));
|
||||
navLayout->addWidget(m_refLabel);
|
||||
|
||||
navLayout->addStretch();
|
||||
@@ -78,11 +78,11 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
m_nextLocalReferenceButton = new QtSearchBarButton(
|
||||
ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_down.png"), true);
|
||||
|
||||
m_prevLocalReferenceButton->setObjectName("local_reference_button_previous");
|
||||
m_nextLocalReferenceButton->setObjectName("local_reference_button_next");
|
||||
m_prevLocalReferenceButton->setObjectName(QStringLiteral("local_reference_button_previous"));
|
||||
m_nextLocalReferenceButton->setObjectName(QStringLiteral("local_reference_button_next"));
|
||||
|
||||
m_prevLocalReferenceButton->setToolTip("previous local reference");
|
||||
m_nextLocalReferenceButton->setToolTip("next local reference");
|
||||
m_prevLocalReferenceButton->setToolTip(QStringLiteral("previous local reference"));
|
||||
m_nextLocalReferenceButton->setToolTip(QStringLiteral("next local reference"));
|
||||
|
||||
m_prevLocalReferenceButton->setIconSize(QSize(12, 12));
|
||||
m_nextLocalReferenceButton->setIconSize(QSize(12, 12));
|
||||
@@ -101,8 +101,8 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
this,
|
||||
&QtCodeNavigator::nextLocalReference);
|
||||
|
||||
m_localRefLabel = new QLabel("0/0 local references");
|
||||
m_localRefLabel->setObjectName("references_label");
|
||||
m_localRefLabel = new QLabel(QStringLiteral("0/0 local references"));
|
||||
m_localRefLabel->setObjectName(QStringLiteral("references_label"));
|
||||
navLayout->addWidget(m_localRefLabel);
|
||||
|
||||
navLayout->addStretch();
|
||||
@@ -121,11 +121,11 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
m_fileButton = new QtSearchBarButton(
|
||||
ResourcePaths::getGuiPath().concatenate(L"code_view/images/file.png"), true);
|
||||
|
||||
m_listButton->setObjectName("mode_button_list");
|
||||
m_fileButton->setObjectName("mode_button_single");
|
||||
m_listButton->setObjectName(QStringLiteral("mode_button_list"));
|
||||
m_fileButton->setObjectName(QStringLiteral("mode_button_single"));
|
||||
|
||||
m_listButton->setToolTip("snippet list mode");
|
||||
m_fileButton->setToolTip("single file mode");
|
||||
m_listButton->setToolTip(QStringLiteral("snippet list mode"));
|
||||
m_fileButton->setToolTip(QStringLiteral("single file mode"));
|
||||
|
||||
m_listButton->setCheckable(true);
|
||||
m_fileButton->setCheckable(true);
|
||||
@@ -149,7 +149,7 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
m_separatorLine = new QFrame();
|
||||
m_separatorLine->setFrameShape(QFrame::HLine);
|
||||
m_separatorLine->setFrameShadow(QFrame::Plain);
|
||||
m_separatorLine->setObjectName("separator_line");
|
||||
m_separatorLine->setObjectName(QStringLiteral("separator_line"));
|
||||
m_separatorLine->setFixedHeight(1);
|
||||
m_separatorLine->hide();
|
||||
layout->addWidget(m_separatorLine);
|
||||
|
||||
@@ -22,7 +22,7 @@ QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* n
|
||||
, m_footer(nullptr)
|
||||
, m_codeArea(nullptr)
|
||||
{
|
||||
setObjectName("code_snippet");
|
||||
setObjectName(QStringLiteral("code_snippet"));
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
@@ -189,13 +189,13 @@ QPushButton* QtCodeSnippet::createScopeLine(QBoxLayout* layout)
|
||||
layout->addLayout(lineLayout);
|
||||
|
||||
QPushButton* dots = new QPushButton(this);
|
||||
dots->setObjectName("dots");
|
||||
dots->setObjectName(QStringLiteral("dots"));
|
||||
dots->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
lineLayout->addWidget(dots);
|
||||
m_dots.push_back(dots);
|
||||
|
||||
QPushButton* line = new QPushButton(this);
|
||||
line->setObjectName("scope_name");
|
||||
line->setObjectName(QStringLiteral("scope_name"));
|
||||
line->minimumSizeHint(); // force font loading
|
||||
line->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
Reference in New Issue
Block a user