forked from qt-creator/qt-creator
Beautifier: Add const wherever applicable
Change-Id: Iba3e5793bfd0e4057074e2b04e6353ba09aa4a5f Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
committed by
David Schulz
parent
f06482ca7f
commit
e7789de28c
@@ -82,7 +82,7 @@ bool AbstractSettings::styleExists(const QString &key) const
|
||||
|
||||
bool AbstractSettings::styleIsReadOnly(const QString &key)
|
||||
{
|
||||
QFileInfo fi(m_styleDir.absoluteFilePath(key + m_ending));
|
||||
const QFileInfo fi(m_styleDir.absoluteFilePath(key + m_ending));
|
||||
if (!fi.exists()) {
|
||||
// newly added style which was not saved yet., thus it is not read only.
|
||||
//TODO In a later version when we have predefined styles in Core::ICore::resourcePath()
|
||||
|
||||
@@ -142,7 +142,7 @@ QString BeautifierPlugin::format(const QString &text, const Command &command,
|
||||
switch (command.processing()) {
|
||||
case Command::FileProcessing: {
|
||||
// Save text to temporary file
|
||||
QFileInfo fi(fileName);
|
||||
const QFileInfo fi(fileName);
|
||||
Utils::TempFileSaver sourceFile(QDir::tempPath() + QLatin1String("/qtc_beautifier_XXXXXXXX.")
|
||||
+ fi.suffix());
|
||||
sourceFile.setAutoRemove(true);
|
||||
@@ -396,7 +396,7 @@ void BeautifierPlugin::formatCurrentFileContinue(QObject *watcher)
|
||||
// Restore folded blocks
|
||||
const QTextDocument *doc = textEditor->document();
|
||||
foreach (const int blockId, foldedBlocks) {
|
||||
QTextBlock block = doc->findBlockByNumber(qMax(0, blockId));
|
||||
const QTextBlock block = doc->findBlockByNumber(qMax(0, blockId));
|
||||
if (block.isValid())
|
||||
TextDocumentLayout::doFoldOrUnfold(block, false);
|
||||
}
|
||||
|
||||
@@ -112,11 +112,12 @@ void ClangFormat::formatFile()
|
||||
|
||||
void ClangFormat::formatSelectedText()
|
||||
{
|
||||
TextEditor::TextEditorWidget *widget = TextEditor::TextEditorWidget::currentTextEditorWidget();
|
||||
const TextEditor::TextEditorWidget *widget
|
||||
= TextEditor::TextEditorWidget::currentTextEditorWidget();
|
||||
if (!widget)
|
||||
return;
|
||||
|
||||
QTextCursor tc = widget->textCursor();
|
||||
const QTextCursor tc = widget->textCursor();
|
||||
if (tc.hasSelection()) {
|
||||
const int offset = tc.selectionStart();
|
||||
const int length = tc.selectionEnd() - offset;
|
||||
|
||||
@@ -69,7 +69,7 @@ ClangFormatOptionsPageWidget::~ClangFormatOptionsPageWidget()
|
||||
void ClangFormatOptionsPageWidget::restore()
|
||||
{
|
||||
ui->command->setPath(m_settings->command());
|
||||
int textIndex = ui->predefinedStyle->findText(m_settings->predefinedStyle());
|
||||
const int textIndex = ui->predefinedStyle->findText(m_settings->predefinedStyle());
|
||||
if (textIndex != -1)
|
||||
ui->predefinedStyle->setCurrentIndex(textIndex);
|
||||
ui->formatEntireFileFallback->setChecked(m_settings->formatEntireFileFallback());
|
||||
|
||||
@@ -137,9 +137,7 @@ QString ConfigurationDialog::value() const
|
||||
void ConfigurationDialog::updateOkButton()
|
||||
{
|
||||
const QString key = ui->name->text().simplified();
|
||||
bool exists = false;
|
||||
if (m_settings && key != m_currentKey)
|
||||
exists = m_settings->styleExists(key);
|
||||
const bool exists = m_settings && key != m_currentKey && m_settings->styleExists(key);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!(key.isEmpty() || exists));
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ void ConfigurationEditor::setCommentExpression(const QRegExp &rx)
|
||||
bool ConfigurationEditor::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ShortcutOverride) {
|
||||
QKeyEvent *key = static_cast<QKeyEvent *>(event);
|
||||
const QKeyEvent *key = static_cast<const QKeyEvent *>(event);
|
||||
if (key->key() == Qt::Key_Escape) {
|
||||
event->accept();
|
||||
m_completer->popup()->hide();
|
||||
@@ -176,7 +176,7 @@ void ConfigurationEditor::keyPressEvent(QKeyEvent *event)
|
||||
QPlainTextEdit::keyPressEvent(event);
|
||||
|
||||
const int cursorPosition = textCursor().position();
|
||||
QTextCursor cursor = cursorForTextUnderCursor();
|
||||
const QTextCursor cursor = cursorForTextUnderCursor();
|
||||
const QString prefix = cursor.selectedText();
|
||||
|
||||
if (!isShortcut && (prefix.length() < 2 || cursorPosition != cursor.position())) {
|
||||
|
||||
@@ -65,7 +65,7 @@ void ConfigurationPanel::setSettings(AbstractSettings *settings)
|
||||
|
||||
void ConfigurationPanel::setCurrentConfiguration(const QString &text)
|
||||
{
|
||||
int textIndex = ui->configurations->findText(text);
|
||||
const int textIndex = ui->configurations->findText(text);
|
||||
if (textIndex != -1)
|
||||
ui->configurations->setCurrentIndex(textIndex);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ void ConfigurationPanel::populateConfigurations(const QString &key)
|
||||
const QString currentText = (!key.isEmpty()) ? key : ui->configurations->currentText();
|
||||
ui->configurations->clear();
|
||||
ui->configurations->addItems(m_settings->styles());
|
||||
int textIndex = ui->configurations->findText(currentText);
|
||||
const int textIndex = ui->configurations->findText(currentText);
|
||||
if (textIndex != -1)
|
||||
ui->configurations->setCurrentIndex(textIndex);
|
||||
updateButtons();
|
||||
|
||||
@@ -130,7 +130,8 @@ void Uncrustify::formatSelectedText()
|
||||
return;
|
||||
}
|
||||
|
||||
TextEditor::TextEditorWidget *widget = TextEditor::TextEditorWidget::currentTextEditorWidget();
|
||||
const TextEditor::TextEditorWidget *widget
|
||||
= TextEditor::TextEditorWidget::currentTextEditorWidget();
|
||||
if (!widget)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user