Beautifier: Remove dead ends

Detected by Axivion plugin.

Change-Id: If57596124e3bae663918a9a0161164321ea7a525
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-02-06 09:52:33 +01:00
parent 751d352c8e
commit 6e5f649d96
4 changed files with 2 additions and 25 deletions

View File

@@ -114,14 +114,6 @@ void ConfigurationDialog::setSettings(AbstractSettings *settings)
m_editor->setSettings(m_settings); m_editor->setSettings(m_settings);
} }
void ConfigurationDialog::clear()
{
m_name->clear();
m_editor->clear();
m_currentKey.clear();
updateOkButton();
}
QString ConfigurationDialog::key() const QString ConfigurationDialog::key() const
{ {
return m_name->text().simplified(); return m_name->text().simplified();

View File

@@ -24,7 +24,6 @@ public:
~ConfigurationDialog() override; ~ConfigurationDialog() override;
void setSettings(AbstractSettings *settings); void setSettings(AbstractSettings *settings);
void clear();
QString key() const; QString key() const;
void setKey(const QString &key); void setKey(const QString &key);
QString value() const; QString value() const;

View File

@@ -22,8 +22,6 @@ ConfigurationSyntaxHighlighter::ConfigurationSyntaxHighlighter(QTextDocument *pa
const TextEditor::FontSettings fs = TextEditor::TextEditorSettings::fontSettings(); const TextEditor::FontSettings fs = TextEditor::TextEditorSettings::fontSettings();
m_formatKeyword = fs.toTextCharFormat(TextEditor::C_FIELD); m_formatKeyword = fs.toTextCharFormat(TextEditor::C_FIELD);
m_formatComment = fs.toTextCharFormat(TextEditor::C_COMMENT); m_formatComment = fs.toTextCharFormat(TextEditor::C_COMMENT);
m_expressionComment.setPattern("#[^\\n]*");
} }
void ConfigurationSyntaxHighlighter::setKeywords(const QStringList &keywords) void ConfigurationSyntaxHighlighter::setKeywords(const QStringList &keywords)
@@ -41,11 +39,6 @@ void ConfigurationSyntaxHighlighter::setKeywords(const QStringList &keywords)
m_expressionKeyword.setPattern("(?:\\s|^)(" + pattern.join('|') + ")(?=\\s|\\:|\\=|\\,|$)"); m_expressionKeyword.setPattern("(?:\\s|^)(" + pattern.join('|') + ")(?=\\s|\\:|\\=|\\,|$)");
} }
void ConfigurationSyntaxHighlighter::setCommentExpression(const QRegularExpression &rx)
{
m_expressionComment = rx;
}
void ConfigurationSyntaxHighlighter::highlightBlock(const QString &text) void ConfigurationSyntaxHighlighter::highlightBlock(const QString &text)
{ {
QRegularExpressionMatchIterator it = m_expressionKeyword.globalMatch(text); QRegularExpressionMatchIterator it = m_expressionKeyword.globalMatch(text);
@@ -54,7 +47,8 @@ void ConfigurationSyntaxHighlighter::highlightBlock(const QString &text)
setFormat(match.capturedStart(), match.capturedLength(), m_formatKeyword); setFormat(match.capturedStart(), match.capturedLength(), m_formatKeyword);
} }
it = m_expressionComment.globalMatch(text); static const QRegularExpression expressionComment("#[^\\n]*");
it = expressionComment.globalMatch(text);
while (it.hasNext()) { while (it.hasNext()) {
const QRegularExpressionMatch match = it.next(); const QRegularExpressionMatch match = it.next();
setFormat(match.capturedStart(), match.capturedLength(), m_formatComment); setFormat(match.capturedStart(), match.capturedLength(), m_formatComment);
@@ -93,11 +87,6 @@ void ConfigurationEditor::setSettings(AbstractSettings *settings)
m_model->setStringList(keywords); m_model->setStringList(keywords);
} }
void ConfigurationEditor::setCommentExpression(const QRegularExpression &rx)
{
m_highlighter->setCommentExpression(rx);
}
// Workaround for handling "ESC" right when popup is shown. // Workaround for handling "ESC" right when popup is shown.
bool ConfigurationEditor::eventFilter(QObject *object, QEvent *event) bool ConfigurationEditor::eventFilter(QObject *object, QEvent *event)
{ {

View File

@@ -25,14 +25,12 @@ class ConfigurationSyntaxHighlighter : public QSyntaxHighlighter
public: public:
explicit ConfigurationSyntaxHighlighter(QTextDocument *parent); explicit ConfigurationSyntaxHighlighter(QTextDocument *parent);
void setKeywords(const QStringList &keywords); void setKeywords(const QStringList &keywords);
void setCommentExpression(const QRegularExpression &rx);
protected: protected:
void highlightBlock(const QString &text) override; void highlightBlock(const QString &text) override;
private: private:
QRegularExpression m_expressionKeyword; QRegularExpression m_expressionKeyword;
QRegularExpression m_expressionComment;
QTextCharFormat m_formatKeyword; QTextCharFormat m_formatKeyword;
QTextCharFormat m_formatComment; QTextCharFormat m_formatComment;
}; };
@@ -44,7 +42,6 @@ class ConfigurationEditor : public QPlainTextEdit
public: public:
explicit ConfigurationEditor(QWidget *parent = nullptr); explicit ConfigurationEditor(QWidget *parent = nullptr);
void setSettings(AbstractSettings *settings); void setSettings(AbstractSettings *settings);
void setCommentExpression(const QRegularExpression &rx);
protected: protected:
bool eventFilter(QObject *object, QEvent *event) override; bool eventFilter(QObject *object, QEvent *event) override;