forked from qt-creator/qt-creator
TextEditor: Modernize
modernize-* Change-Id: Ic497fea1942a77cf017be3b0033f92e3807066f1 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -40,8 +40,7 @@ AutoCompleter::AutoCompleter() :
|
||||
m_surroundWithQuotes(true)
|
||||
{}
|
||||
|
||||
AutoCompleter::~AutoCompleter()
|
||||
{}
|
||||
AutoCompleter::~AutoCompleter() = default;
|
||||
|
||||
static void countBracket(QChar open, QChar close, QChar c, int *errors, int *stillopen)
|
||||
{
|
||||
|
@@ -32,8 +32,7 @@
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
BaseHoverHandler::~BaseHoverHandler()
|
||||
{}
|
||||
BaseHoverHandler::~BaseHoverHandler() = default;
|
||||
|
||||
void BaseHoverHandler::showToolTip(TextEditorWidget *widget, const QPoint &point, bool decorate)
|
||||
{
|
||||
|
@@ -29,13 +29,9 @@ using namespace TextEditor::Internal;
|
||||
|
||||
static const int kMaxSize = 10;
|
||||
|
||||
CircularClipboard::CircularClipboard()
|
||||
: m_current(-1)
|
||||
{}
|
||||
CircularClipboard::CircularClipboard() = default;
|
||||
|
||||
CircularClipboard::~CircularClipboard()
|
||||
{
|
||||
}
|
||||
CircularClipboard::~CircularClipboard() = default;
|
||||
|
||||
CircularClipboard *CircularClipboard::instance()
|
||||
{
|
||||
|
@@ -48,7 +48,7 @@ private:
|
||||
~CircularClipboard();
|
||||
CircularClipboard &operator=(const CircularClipboard &);
|
||||
|
||||
mutable int m_current;
|
||||
mutable int m_current = -1;
|
||||
QList< QSharedPointer<const QMimeData> > m_items;
|
||||
};
|
||||
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
setText(text);
|
||||
}
|
||||
|
||||
~ClipboardProposalItem() noexcept override {}
|
||||
~ClipboardProposalItem() noexcept override = default;
|
||||
|
||||
void apply(TextDocumentManipulatorInterface &manipulator, int /*basePosition*/) const override
|
||||
{
|
||||
|
@@ -39,7 +39,7 @@ namespace TextEditor {
|
||||
class TEXTEDITOR_EXPORT AssistProposalItem : public AssistProposalItemInterface
|
||||
{
|
||||
public:
|
||||
~AssistProposalItem() noexcept override {}
|
||||
~AssistProposalItem() noexcept override = default;
|
||||
QString text() const override;
|
||||
bool implicitlyApplies() const override;
|
||||
bool prematurelyApplies(const QChar &c) const override;
|
||||
|
@@ -33,8 +33,7 @@ CompletionAssistProvider::CompletionAssistProvider(QObject *parent)
|
||||
: IAssistProvider(parent)
|
||||
{}
|
||||
|
||||
CompletionAssistProvider::~CompletionAssistProvider()
|
||||
{}
|
||||
CompletionAssistProvider::~CompletionAssistProvider() = default;
|
||||
|
||||
IAssistProvider::RunType CompletionAssistProvider::runType() const
|
||||
{
|
||||
|
@@ -36,8 +36,7 @@ FunctionHintProposal::FunctionHintProposal(int cursorPos, FunctionHintProposalMo
|
||||
setFragile(true);
|
||||
}
|
||||
|
||||
FunctionHintProposal::~FunctionHintProposal()
|
||||
{}
|
||||
FunctionHintProposal::~FunctionHintProposal() = default;
|
||||
|
||||
ProposalModelPtr FunctionHintProposal::model() const
|
||||
{
|
||||
|
@@ -43,8 +43,7 @@ GenericProposal::GenericProposal(int cursorPos, const QList<AssistProposalItemIn
|
||||
m_model->loadContent(items);
|
||||
}
|
||||
|
||||
GenericProposal::~GenericProposal()
|
||||
{}
|
||||
GenericProposal::~GenericProposal() = default;
|
||||
|
||||
GenericProposal *GenericProposal::createProposal(const AssistInterface *interface, const QuickFixOperations &quickFixes)
|
||||
{
|
||||
|
@@ -38,10 +38,12 @@
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
uint qHash(const AssistProposalItem &item)
|
||||
{
|
||||
return qHash(item.text());
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -129,8 +131,7 @@ private:
|
||||
|
||||
} // Anonymous
|
||||
|
||||
GenericProposalModel::GenericProposalModel()
|
||||
{}
|
||||
GenericProposalModel::GenericProposalModel() = default;
|
||||
|
||||
GenericProposalModel::~GenericProposalModel()
|
||||
{
|
||||
|
@@ -36,11 +36,9 @@ using namespace TextEditor;
|
||||
\sa IAssistProposal, IAssistProvider
|
||||
*/
|
||||
|
||||
IAssistProcessor::IAssistProcessor()
|
||||
{}
|
||||
IAssistProcessor::IAssistProcessor() = default;
|
||||
|
||||
IAssistProcessor::~IAssistProcessor()
|
||||
{}
|
||||
IAssistProcessor::~IAssistProcessor() = default;
|
||||
|
||||
void IAssistProcessor::setAsyncProposalAvailable(IAssistProposal *proposal)
|
||||
{
|
||||
|
@@ -63,8 +63,7 @@ IAssistProposal::IAssistProposal(int basePosition)
|
||||
: m_basePosition(basePosition)
|
||||
{}
|
||||
|
||||
IAssistProposal::~IAssistProposal()
|
||||
{}
|
||||
IAssistProposal::~IAssistProposal() = default;
|
||||
|
||||
/*!
|
||||
\fn bool TextEditor::IAssistProposal::isFragile() const
|
||||
|
@@ -41,8 +41,6 @@ using namespace TextEditor;
|
||||
This is class is part of the CodeAssist API.
|
||||
*/
|
||||
|
||||
IAssistProposalModel::IAssistProposalModel()
|
||||
{}
|
||||
IAssistProposalModel::IAssistProposalModel() = default;
|
||||
|
||||
IAssistProposalModel::~IAssistProposalModel()
|
||||
{}
|
||||
IAssistProposalModel::~IAssistProposalModel() = default;
|
||||
|
@@ -52,8 +52,7 @@ IAssistProposalWidget::IAssistProposalWidget()
|
||||
: QFrame(nullptr, Qt::Popup)
|
||||
{}
|
||||
|
||||
IAssistProposalWidget::~IAssistProposalWidget()
|
||||
{}
|
||||
IAssistProposalWidget::~IAssistProposalWidget() = default;
|
||||
|
||||
int IAssistProposalWidget::basePosition() const
|
||||
{
|
||||
|
@@ -29,11 +29,9 @@
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
IFunctionHintProposalModel::IFunctionHintProposalModel()
|
||||
{}
|
||||
IFunctionHintProposalModel::IFunctionHintProposalModel() = default;
|
||||
|
||||
IFunctionHintProposalModel::~IFunctionHintProposalModel()
|
||||
{}
|
||||
IFunctionHintProposalModel::~IFunctionHintProposalModel() = default;
|
||||
|
||||
QString IFunctionHintProposalModel::id(int /*index*/) const
|
||||
{
|
||||
|
@@ -160,7 +160,7 @@ int KeywordsFunctionHintModel::activeArgument(const QString &prefix) const
|
||||
// ---------------------------------
|
||||
// KeywordsCompletionAssistProcessor
|
||||
// ---------------------------------
|
||||
KeywordsCompletionAssistProcessor::KeywordsCompletionAssistProcessor(Keywords keywords)
|
||||
KeywordsCompletionAssistProcessor::KeywordsCompletionAssistProcessor(const Keywords &keywords)
|
||||
: m_snippetCollector(QString(), QIcon(":/texteditor/images/snippet.png"))
|
||||
, m_variableIcon(QLatin1String(":/codemodel/images/keyword.png"))
|
||||
, m_functionIcon(QLatin1String(":/codemodel/images/member.png"))
|
||||
@@ -222,7 +222,7 @@ void KeywordsCompletionAssistProcessor::setSnippetGroup(const QString &id)
|
||||
m_snippetCollector.setGroupId(id);
|
||||
}
|
||||
|
||||
void KeywordsCompletionAssistProcessor::setKeywords(Keywords keywords)
|
||||
void KeywordsCompletionAssistProcessor::setKeywords(const Keywords &keywords)
|
||||
{
|
||||
m_keywords = keywords;
|
||||
}
|
||||
|
@@ -100,7 +100,7 @@ private:
|
||||
class TEXTEDITOR_EXPORT KeywordsCompletionAssistProcessor : public IAssistProcessor
|
||||
{
|
||||
public:
|
||||
KeywordsCompletionAssistProcessor(Keywords keywords);
|
||||
KeywordsCompletionAssistProcessor(const Keywords &keywords);
|
||||
~KeywordsCompletionAssistProcessor() override = default;
|
||||
|
||||
IAssistProposal *perform(const AssistInterface *interface) override;
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
void setSnippetGroup(const QString &id);
|
||||
|
||||
protected:
|
||||
void setKeywords (Keywords keywords);
|
||||
void setKeywords (const Keywords &keywords);
|
||||
|
||||
private:
|
||||
bool isInComment(const AssistInterface *interface) const;
|
||||
|
@@ -32,8 +32,7 @@
|
||||
using namespace TextEditor;
|
||||
using namespace Internal;
|
||||
|
||||
ProcessorRunner::ProcessorRunner()
|
||||
{}
|
||||
ProcessorRunner::ProcessorRunner() = default;
|
||||
|
||||
ProcessorRunner::~ProcessorRunner()
|
||||
{
|
||||
|
@@ -134,9 +134,7 @@ CodecSelector::CodecSelector(QWidget *parent, TextDocument *doc)
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
CodecSelector::~CodecSelector()
|
||||
{
|
||||
}
|
||||
CodecSelector::~CodecSelector() = default;
|
||||
|
||||
void CodecSelector::updateButtons()
|
||||
{
|
||||
|
@@ -50,14 +50,12 @@ namespace Internal {
|
||||
class CodeStylePoolPrivate
|
||||
{
|
||||
public:
|
||||
CodeStylePoolPrivate()
|
||||
: m_factory(nullptr)
|
||||
{}
|
||||
CodeStylePoolPrivate() = default;
|
||||
~CodeStylePoolPrivate();
|
||||
|
||||
QByteArray generateUniqueId(const QByteArray &id) const;
|
||||
|
||||
ICodeStylePreferencesFactory *m_factory;
|
||||
ICodeStylePreferencesFactory *m_factory = nullptr;
|
||||
QList<ICodeStylePreferences *> m_pool;
|
||||
QList<ICodeStylePreferences *> m_builtInPool;
|
||||
QList<ICodeStylePreferences *> m_customPool;
|
||||
|
@@ -109,9 +109,9 @@ static QColor fromEnumString(const QString &s)
|
||||
{QLatin1String("transparent"), QColor(Qt::transparent)}
|
||||
};
|
||||
|
||||
for (uint ii = 0; ii < sizeof(table) / sizeof(table[0]); ++ii) {
|
||||
if (s == table[ii].name)
|
||||
return table[ii].color;
|
||||
for (const auto &enumColor : table) {
|
||||
if (s == enumColor.name)
|
||||
return enumColor.color;
|
||||
}
|
||||
|
||||
return QColor();
|
||||
@@ -189,11 +189,9 @@ static QString removeWhitespace(const QString &s)
|
||||
{
|
||||
QString ret;
|
||||
ret.reserve(s.size());
|
||||
for (int ii = 0; ii < s.length(); ++ii) {
|
||||
const QChar c = s[ii];
|
||||
for (QChar c : s) {
|
||||
if (!c.isSpace())
|
||||
ret += c;
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@@ -428,7 +428,7 @@ void ColorSchemeEdit::changeForeColor()
|
||||
m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor));
|
||||
m_ui->eraseForegroundToolButton->setEnabled(true);
|
||||
|
||||
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
const TextStyle category = m_descriptions[index.row()].id();
|
||||
m_scheme.formatFor(category).setForeground(newColor);
|
||||
m_formatsModel->emitDataChanged(index);
|
||||
@@ -448,7 +448,7 @@ void ColorSchemeEdit::changeBackColor()
|
||||
m_ui->backgroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor));
|
||||
m_ui->eraseBackgroundToolButton->setEnabled(true);
|
||||
|
||||
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
const TextStyle category = m_descriptions[index.row()].id();
|
||||
m_scheme.formatFor(category).setBackground(newColor);
|
||||
m_formatsModel->emitDataChanged(index);
|
||||
@@ -485,7 +485,7 @@ void ColorSchemeEdit::eraseForeColor()
|
||||
m_ui->foregroundToolButton->setStyleSheet(colorButtonStyleSheet(newColor));
|
||||
m_ui->eraseForegroundToolButton->setEnabled(false);
|
||||
|
||||
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
const TextStyle category = m_descriptions[index.row()].id();
|
||||
m_scheme.formatFor(category).setForeground(newColor);
|
||||
m_formatsModel->emitDataChanged(index);
|
||||
@@ -534,7 +534,7 @@ void ColorSchemeEdit::eraseRelativeForeColor()
|
||||
m_ui->foregroundSaturationSpinBox->setValue(0.0);
|
||||
m_ui->foregroundLightnessSpinBox->setValue(0.0);
|
||||
|
||||
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
const TextStyle category = m_descriptions[index.row()].id();
|
||||
m_scheme.formatFor(category).setRelativeForegroundSaturation(0.0);
|
||||
m_scheme.formatFor(category).setRelativeForegroundLightness(0.0);
|
||||
@@ -563,7 +563,7 @@ void ColorSchemeEdit::checkCheckBoxes()
|
||||
if (m_curItem == -1)
|
||||
return;
|
||||
|
||||
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
const TextStyle category = m_descriptions[index.row()].id();
|
||||
m_scheme.formatFor(category).setBold(m_ui->boldCheckBox->isChecked());
|
||||
m_scheme.formatFor(category).setItalic(m_ui->italicCheckBox->isChecked());
|
||||
@@ -582,7 +582,7 @@ void ColorSchemeEdit::changeUnderlineColor()
|
||||
m_ui->underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(newColor));
|
||||
m_ui->eraseUnderlineColorToolButton->setEnabled(true);
|
||||
|
||||
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
const TextStyle category = m_descriptions[index.row()].id();
|
||||
m_scheme.formatFor(category).setUnderlineColor(newColor);
|
||||
m_formatsModel->emitDataChanged(index);
|
||||
@@ -597,7 +597,7 @@ void ColorSchemeEdit::eraseUnderlineColor()
|
||||
m_ui->underlineColorToolButton->setStyleSheet(colorButtonStyleSheet(newColor));
|
||||
m_ui->eraseUnderlineColorToolButton->setEnabled(false);
|
||||
|
||||
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
const TextStyle category = m_descriptions[index.row()].id();
|
||||
m_scheme.formatFor(category).setUnderlineColor(newColor);
|
||||
m_formatsModel->emitDataChanged(index);
|
||||
@@ -609,7 +609,7 @@ void ColorSchemeEdit::changeUnderlineStyle(int comboBoxIndex)
|
||||
if (m_curItem == -1)
|
||||
return;
|
||||
|
||||
foreach (const QModelIndex &index, m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex &index : m_ui->itemList->selectionModel()->selectedRows()) {
|
||||
const TextStyle category = m_descriptions[index.row()].id();
|
||||
auto value = m_ui->underlineComboBox->itemData(comboBoxIndex);
|
||||
auto enumeratorIndex = static_cast<QTextCharFormat::UnderlineStyle>(value.toInt());
|
||||
|
@@ -39,8 +39,7 @@ using namespace TextEditor;
|
||||
ExtraEncodingSettings::ExtraEncodingSettings() : m_utf8BomSetting(OnlyKeep)
|
||||
{}
|
||||
|
||||
ExtraEncodingSettings::~ExtraEncodingSettings()
|
||||
{}
|
||||
ExtraEncodingSettings::~ExtraEncodingSettings() = default;
|
||||
|
||||
void ExtraEncodingSettings::toSettings(const QString &category, QSettings *s) const
|
||||
{
|
||||
|
@@ -58,9 +58,7 @@ FindInFiles::FindInFiles()
|
||||
this, &FindInFiles::findOnFileSystem);
|
||||
}
|
||||
|
||||
FindInFiles::~FindInFiles()
|
||||
{
|
||||
}
|
||||
FindInFiles::~FindInFiles() = default;
|
||||
|
||||
bool FindInFiles::isValid() const
|
||||
{
|
||||
|
@@ -51,7 +51,7 @@ class FormatDescription;
|
||||
class TEXTEDITOR_EXPORT FontSettings
|
||||
{
|
||||
public:
|
||||
typedef std::vector<FormatDescription> FormatDescriptions;
|
||||
using FormatDescriptions = std::vector<FormatDescription>;
|
||||
|
||||
FontSettings();
|
||||
void clear();
|
||||
|
@@ -117,7 +117,7 @@ private:
|
||||
ShowControls m_showControls = ShowAllAbsoluteControls;
|
||||
};
|
||||
|
||||
typedef std::vector<FormatDescription> FormatDescriptions;
|
||||
using FormatDescriptions = std::vector<FormatDescription>;
|
||||
|
||||
class TEXTEDITOR_EXPORT FontSettingsPage : public TextEditorOptionsPage
|
||||
{
|
||||
|
@@ -270,7 +270,7 @@ static void updateEditorText(QPlainTextEdit *editor, const QString &text)
|
||||
+ absoluteVerticalCursorOffset / fontHeight);
|
||||
// Restore folded blocks
|
||||
const QTextDocument *doc = editor->document();
|
||||
for (int blockId : foldedBlocks) {
|
||||
for (int blockId : qAsConst(foldedBlocks)) {
|
||||
const QTextBlock block = doc->findBlockByNumber(qMax(0, blockId));
|
||||
if (block.isValid())
|
||||
TextDocumentLayout::doFoldOrUnfold(block, false);
|
||||
|
@@ -54,8 +54,7 @@ const Context &Context::operator=(Context copy)
|
||||
return *this;
|
||||
}
|
||||
|
||||
Context::~Context()
|
||||
{}
|
||||
Context::~Context() = default;
|
||||
|
||||
void Context::swap(Context &context)
|
||||
{
|
||||
|
@@ -32,8 +32,7 @@ using namespace Internal;
|
||||
DynamicRule::DynamicRule() : m_active(false)
|
||||
{}
|
||||
|
||||
DynamicRule::~DynamicRule()
|
||||
{}
|
||||
DynamicRule::~DynamicRule() = default;
|
||||
|
||||
void DynamicRule::setActive(const QString &active)
|
||||
{ m_active = toBool(active); }
|
||||
|
@@ -76,13 +76,12 @@ HighlightDefinition::HighlightDefinition() :
|
||||
m_singleLineCommentAfterWhiteSpaces(false),
|
||||
m_indentationBasedFolding(false)
|
||||
{
|
||||
QString s(QLatin1String(".():!+,-<=>%&/;?[]^{|}~\\*, \t"));
|
||||
foreach (const QChar &c, s)
|
||||
const QString s(QLatin1String(".():!+,-<=>%&/;?[]^{|}~\\*, \t"));
|
||||
for (auto &c : s)
|
||||
m_delimiters.insert(c);
|
||||
}
|
||||
|
||||
HighlightDefinition::~HighlightDefinition()
|
||||
{}
|
||||
HighlightDefinition::~HighlightDefinition() = default;
|
||||
|
||||
bool HighlightDefinition::isValid() const
|
||||
{
|
||||
@@ -169,15 +168,15 @@ const QString &HighlightDefinition::multiLineCommentRegion() const
|
||||
|
||||
void HighlightDefinition::removeDelimiters(const QString &characters)
|
||||
{
|
||||
for (int i = 0; i < characters.length(); ++i)
|
||||
m_delimiters.remove(characters.at(i));
|
||||
for (QChar character : characters)
|
||||
m_delimiters.remove(character);
|
||||
}
|
||||
|
||||
void HighlightDefinition::addDelimiters(const QString &characters)
|
||||
{
|
||||
for (int i = 0; i < characters.length(); ++i) {
|
||||
if (!m_delimiters.contains(characters.at(i)))
|
||||
m_delimiters.insert(characters.at(i));
|
||||
for (QChar character : characters) {
|
||||
if (!m_delimiters.contains(character))
|
||||
m_delimiters.insert(character);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -113,8 +113,7 @@ HighlightDefinitionHandler(const QSharedPointer<HighlightDefinition> &definition
|
||||
m_initialContext(true)
|
||||
{}
|
||||
|
||||
HighlightDefinitionHandler::~HighlightDefinitionHandler()
|
||||
{}
|
||||
HighlightDefinitionHandler::~HighlightDefinitionHandler() = default;
|
||||
|
||||
bool HighlightDefinitionHandler::startDocument()
|
||||
{
|
||||
|
@@ -35,10 +35,10 @@ namespace Internal {
|
||||
class HighlightDefinitionMetaData
|
||||
{
|
||||
public:
|
||||
HighlightDefinitionMetaData() : priority(0) {}
|
||||
HighlightDefinitionMetaData() = default;
|
||||
|
||||
public:
|
||||
int priority;
|
||||
int priority = 0;
|
||||
QString id;
|
||||
QString name;
|
||||
QString version;
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
QUrl url;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<HighlightDefinitionMetaData> DefinitionMetaDataPtr;
|
||||
using DefinitionMetaDataPtr = QSharedPointer<HighlightDefinitionMetaData>;
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace TextEditor
|
||||
|
@@ -56,17 +56,11 @@ namespace {
|
||||
class HighlighterCodeFormatterData : public CodeFormatterData
|
||||
{
|
||||
public:
|
||||
HighlighterCodeFormatterData() :
|
||||
m_foldingIndentDelta(0),
|
||||
m_originalObservableState(-1),
|
||||
m_continueObservableState(-1)
|
||||
{}
|
||||
|
||||
~HighlighterCodeFormatterData() override {}
|
||||
int m_foldingIndentDelta;
|
||||
int m_originalObservableState;
|
||||
~HighlighterCodeFormatterData() override = default;
|
||||
int m_foldingIndentDelta = 0;
|
||||
int m_originalObservableState = -1;
|
||||
QStack<QString> m_foldingRegions;
|
||||
int m_continueObservableState;
|
||||
int m_continueObservableState = -1;
|
||||
};
|
||||
|
||||
HighlighterCodeFormatterData *formatterData(const QTextBlock &block)
|
||||
@@ -132,8 +126,7 @@ Highlighter::Highlighter(QTextDocument *parent) :
|
||||
setTextFormatCategories(TextFormatIdCount, styleForFormat);
|
||||
}
|
||||
|
||||
Highlighter::~Highlighter()
|
||||
{}
|
||||
Highlighter::~Highlighter() = default;
|
||||
|
||||
// Mapping from Kate format strings to format ids.
|
||||
struct KateFormatMap
|
||||
@@ -344,7 +337,7 @@ void Highlighter::iterateThroughRules(const QString &text,
|
||||
}
|
||||
}
|
||||
|
||||
typedef QList<QSharedPointer<Rule> >::const_iterator RuleIterator;
|
||||
using RuleIterator = QList<QSharedPointer<Rule> >::const_iterator;
|
||||
|
||||
bool contextChanged = false;
|
||||
bool atLeastOneMatch = false;
|
||||
@@ -639,8 +632,8 @@ void Highlighter::mapLeadingSequence(const QString &contextSequence)
|
||||
void Highlighter::pushContextSequence(int state)
|
||||
{
|
||||
const QVector<QSharedPointer<Context> > &contexts = m_persistentContexts.value(state);
|
||||
for (int i = 0; i < contexts.size(); ++i)
|
||||
m_contexts.push_back(contexts.at(i));
|
||||
for (const auto &context : contexts)
|
||||
m_contexts.push_back(context);
|
||||
}
|
||||
|
||||
QString Highlighter::currentContextSequence() const
|
||||
|
@@ -45,20 +45,19 @@ QString findFallbackDefinitionsLocation()
|
||||
dir.setNameFilters(QStringList(QLatin1String("*.xml")));
|
||||
|
||||
if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost()) {
|
||||
static const QLatin1String kateSyntax[] = {
|
||||
static const QLatin1String kateSyntaxPaths[] = {
|
||||
QLatin1String("/share/apps/katepart/syntax"),
|
||||
QLatin1String("/share/kde4/apps/katepart/syntax")
|
||||
};
|
||||
static const int kateSyntaxCount =
|
||||
sizeof(kateSyntax) / sizeof(kateSyntax[0]);
|
||||
|
||||
// Some wild guesses.
|
||||
for (int i = 0; i < kateSyntaxCount; ++i) {
|
||||
QStringList paths;
|
||||
paths << QLatin1String("/usr") + kateSyntax[i]
|
||||
<< QLatin1String("/usr/local") + kateSyntax[i]
|
||||
<< QLatin1String("/opt") + kateSyntax[i];
|
||||
foreach (const QString &path, paths) {
|
||||
for (const auto &kateSyntaxPath : kateSyntaxPaths) {
|
||||
const QStringList paths = {
|
||||
QLatin1String("/usr") + kateSyntaxPath,
|
||||
QLatin1String("/usr/local") + kateSyntaxPath,
|
||||
QLatin1String("/opt") + kateSyntaxPath
|
||||
};
|
||||
for (const auto &path : paths) {
|
||||
dir.setPath(path);
|
||||
if (dir.exists() && !dir.entryInfoList().isEmpty())
|
||||
return dir.path();
|
||||
@@ -66,9 +65,8 @@ QString findFallbackDefinitionsLocation()
|
||||
}
|
||||
|
||||
// Try kde-config.
|
||||
QStringList programs;
|
||||
programs << QLatin1String("kde-config") << QLatin1String("kde4-config");
|
||||
foreach (const QString &program, programs) {
|
||||
const QStringList programs = {QLatin1String("kde-config"), QLatin1String("kde4-config")};
|
||||
for (auto &program : programs) {
|
||||
Utils::SynchronousProcess process;
|
||||
process.setTimeoutS(5);
|
||||
Utils::SynchronousProcessResponse response
|
||||
@@ -76,8 +74,8 @@ QString findFallbackDefinitionsLocation()
|
||||
if (response.result == Utils::SynchronousProcessResponse::Finished) {
|
||||
QString output = response.stdOut();
|
||||
output.remove(QLatin1Char('\n'));
|
||||
for (int i = 0; i < kateSyntaxCount; ++i) {
|
||||
dir.setPath(output + kateSyntax[i]);
|
||||
for (auto &kateSyntaxPath : kateSyntaxPaths) {
|
||||
dir.setPath(output + kateSyntaxPath);
|
||||
if (dir.exists() && !dir.entryInfoList().isEmpty())
|
||||
return dir.path();
|
||||
}
|
||||
@@ -189,7 +187,7 @@ void HighlighterSettings::assignDefaultDefinitionsPath()
|
||||
|
||||
bool HighlighterSettings::isIgnoredFilePattern(const QString &fileName) const
|
||||
{
|
||||
foreach (QRegExp regExp, m_ignoredFiles)
|
||||
for (auto ®Exp : m_ignoredFiles)
|
||||
if (regExp.indexIn(fileName) != -1)
|
||||
return true;
|
||||
|
||||
@@ -210,8 +208,8 @@ void HighlighterSettings::setExpressionsFromList(const QStringList &patterns)
|
||||
QRegExp regExp;
|
||||
regExp.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
regExp.setPatternSyntax(QRegExp::Wildcard);
|
||||
foreach (const QString &s, patterns) {
|
||||
regExp.setPattern(s);
|
||||
for (auto &pattern : patterns) {
|
||||
regExp.setPattern(pattern);
|
||||
m_ignoredFiles.append(regExp);
|
||||
}
|
||||
}
|
||||
|
@@ -58,8 +58,7 @@ Rule::Rule(bool consumesNonSpace) :
|
||||
m_lookAhead(false), m_firstNonSpace(false), m_column(-1), m_consumesNonSpace(consumesNonSpace)
|
||||
{}
|
||||
|
||||
Rule::~Rule()
|
||||
{}
|
||||
Rule::~Rule() = default;
|
||||
|
||||
void Rule::setContext(const QString &context)
|
||||
{ m_context = context; }
|
||||
|
@@ -278,8 +278,7 @@ KeywordRule::KeywordRule(const QSharedPointer<HighlightDefinition> &definition)
|
||||
setDefinition(definition);
|
||||
}
|
||||
|
||||
KeywordRule::~KeywordRule()
|
||||
{}
|
||||
KeywordRule::~KeywordRule() = default;
|
||||
|
||||
void KeywordRule::setInsensitive(const QString &insensitive)
|
||||
{
|
||||
|
@@ -42,7 +42,7 @@ class HighlightDefinition;
|
||||
class DetectCharRule : public DynamicRule
|
||||
{
|
||||
public:
|
||||
~DetectCharRule() override {}
|
||||
~DetectCharRule() override = default;
|
||||
|
||||
void setChar(const QString &character);
|
||||
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
class Detect2CharsRule : public DynamicRule
|
||||
{
|
||||
public:
|
||||
~Detect2CharsRule() override {}
|
||||
~Detect2CharsRule() override = default;
|
||||
|
||||
void setChar(const QString &character);
|
||||
void setChar1(const QString &character);
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
class AnyCharRule : public Rule
|
||||
{
|
||||
public:
|
||||
~AnyCharRule() override {}
|
||||
~AnyCharRule() override = default;
|
||||
|
||||
void setCharacterSet(const QString &s);
|
||||
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
class StringDetectRule : public DynamicRule
|
||||
{
|
||||
public:
|
||||
~StringDetectRule() override {}
|
||||
~StringDetectRule() override = default;
|
||||
|
||||
void setString(const QString &s);
|
||||
void setInsensitive(const QString &insensitive);
|
||||
@@ -157,7 +157,7 @@ private:
|
||||
class IntRule : public Rule
|
||||
{
|
||||
public:
|
||||
~IntRule() override {}
|
||||
~IntRule() override = default;
|
||||
|
||||
private:
|
||||
bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override;
|
||||
@@ -167,7 +167,7 @@ private:
|
||||
class FloatRule : public Rule
|
||||
{
|
||||
public:
|
||||
~FloatRule() override {}
|
||||
~FloatRule() override = default;
|
||||
|
||||
private:
|
||||
bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override;
|
||||
@@ -177,7 +177,7 @@ private:
|
||||
class HlCOctRule : public Rule
|
||||
{
|
||||
public:
|
||||
~HlCOctRule() override {}
|
||||
~HlCOctRule() override = default;
|
||||
|
||||
private:
|
||||
bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override;
|
||||
@@ -187,7 +187,7 @@ private:
|
||||
class HlCHexRule : public Rule
|
||||
{
|
||||
public:
|
||||
~HlCHexRule() override {}
|
||||
~HlCHexRule() override = default;
|
||||
|
||||
private:
|
||||
bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override;
|
||||
@@ -197,7 +197,7 @@ private:
|
||||
class HlCStringCharRule : public Rule
|
||||
{
|
||||
public:
|
||||
~HlCStringCharRule() override {}
|
||||
~HlCStringCharRule() override = default;
|
||||
|
||||
private:
|
||||
bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override;
|
||||
@@ -207,7 +207,7 @@ private:
|
||||
class HlCCharRule : public Rule
|
||||
{
|
||||
public:
|
||||
~HlCCharRule() override {}
|
||||
~HlCCharRule() override = default;
|
||||
|
||||
private:
|
||||
bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override;
|
||||
@@ -217,7 +217,7 @@ private:
|
||||
class RangeDetectRule : public Rule
|
||||
{
|
||||
public:
|
||||
~RangeDetectRule() override {}
|
||||
~RangeDetectRule() override = default;
|
||||
|
||||
void setChar(const QString &character);
|
||||
void setChar1(const QString &character);
|
||||
@@ -233,7 +233,7 @@ private:
|
||||
class LineContinueRule : public Rule
|
||||
{
|
||||
public:
|
||||
~LineContinueRule() override {}
|
||||
~LineContinueRule() override = default;
|
||||
|
||||
private:
|
||||
bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override;
|
||||
@@ -244,7 +244,7 @@ class DetectSpacesRule : public Rule
|
||||
{
|
||||
public:
|
||||
DetectSpacesRule();
|
||||
~DetectSpacesRule() override {}
|
||||
~DetectSpacesRule() override = default;
|
||||
|
||||
private:
|
||||
bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override;
|
||||
@@ -254,7 +254,7 @@ private:
|
||||
class DetectIdentifierRule : public Rule
|
||||
{
|
||||
public:
|
||||
~DetectIdentifierRule() override {}
|
||||
~DetectIdentifierRule() override = default;
|
||||
|
||||
private:
|
||||
bool doMatchSucceed(const QString &text, const int length, ProgressData *progress) override;
|
||||
|
@@ -30,8 +30,7 @@
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
HelpItem::HelpItem()
|
||||
{}
|
||||
HelpItem::HelpItem() = default;
|
||||
|
||||
HelpItem::HelpItem(const QString &helpId, Category category) :
|
||||
m_helpId(helpId), m_docMark(helpId), m_category(category)
|
||||
|
@@ -32,11 +32,9 @@
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
Indenter::Indenter()
|
||||
{}
|
||||
Indenter::Indenter() = default;
|
||||
|
||||
Indenter::~Indenter()
|
||||
{}
|
||||
Indenter::~Indenter() = default;
|
||||
|
||||
bool Indenter::isElectricCharacter(const QChar &) const
|
||||
{
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include <QPair>
|
||||
#include <QVariant>
|
||||
|
||||
typedef QPair<int,int> LineColumn;
|
||||
using LineColumn = QPair<int, int>;
|
||||
Q_DECLARE_METATYPE(LineColumn)
|
||||
|
||||
using namespace Core;
|
||||
|
@@ -32,8 +32,8 @@ namespace TextEditor {
|
||||
class TEXTEDITOR_EXPORT NormalIndenter : public Indenter
|
||||
{
|
||||
public:
|
||||
NormalIndenter() {}
|
||||
~NormalIndenter() override {}
|
||||
NormalIndenter() = default;
|
||||
~NormalIndenter() override = default;
|
||||
|
||||
int indentFor(const QTextBlock &block, const TabSettings &tabSettings) override;
|
||||
};
|
||||
|
@@ -92,9 +92,7 @@ OutlineWidgetStack::OutlineWidgetStack(OutlineFactory *factory) :
|
||||
updateCurrentEditor(Core::EditorManager::currentEditor());
|
||||
}
|
||||
|
||||
OutlineWidgetStack::~OutlineWidgetStack()
|
||||
{
|
||||
}
|
||||
OutlineWidgetStack::~OutlineWidgetStack() = default;
|
||||
|
||||
QToolButton *OutlineWidgetStack::toggleSyncButton()
|
||||
{
|
||||
@@ -166,7 +164,7 @@ void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor)
|
||||
IOutlineWidget *newWidget = nullptr;
|
||||
|
||||
if (editor) {
|
||||
for (IOutlineWidgetFactory *widgetFactory : g_outlineWidgetFactories) {
|
||||
for (IOutlineWidgetFactory *widgetFactory : qAsConst(g_outlineWidgetFactories)) {
|
||||
if (widgetFactory->supportsEditor(editor)) {
|
||||
newWidget = widgetFactory->createWidget(editor);
|
||||
break;
|
||||
|
@@ -46,7 +46,7 @@ static PlainTextEditorFactory *m_instance = nullptr;
|
||||
class PlainTextEditorWidget : public TextEditorWidget
|
||||
{
|
||||
public:
|
||||
PlainTextEditorWidget() {}
|
||||
PlainTextEditorWidget() = default;
|
||||
void finalizeInitialization() override
|
||||
{
|
||||
textDocument()->setMimeType(QLatin1String(Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
|
||||
|
@@ -32,9 +32,7 @@ QuickFixOperation::QuickFixOperation(int priority)
|
||||
setPriority(priority);
|
||||
}
|
||||
|
||||
QuickFixOperation::~QuickFixOperation()
|
||||
{
|
||||
}
|
||||
QuickFixOperation::~QuickFixOperation() = default;
|
||||
|
||||
int QuickFixOperation::priority() const
|
||||
{
|
||||
|
@@ -49,7 +49,7 @@ class TEXTEDITOR_EXPORT QuickFixOperation
|
||||
Q_DISABLE_COPY(QuickFixOperation)
|
||||
|
||||
public:
|
||||
typedef QSharedPointer<QuickFixOperation> Ptr;
|
||||
using Ptr = QSharedPointer<QuickFixOperation>;
|
||||
|
||||
public:
|
||||
QuickFixOperation(int priority = -1);
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
QString _description;
|
||||
};
|
||||
|
||||
typedef QList<QuickFixOperation::Ptr> QuickFixOperations;
|
||||
using QuickFixOperations = QList<QuickFixOperation::Ptr>;
|
||||
|
||||
inline QuickFixOperations &operator<<(QuickFixOperations &list, QuickFixOperation *op)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ inline QuickFixOperations &operator<<(QuickFixOperations &list, QuickFixOperatio
|
||||
return list;
|
||||
}
|
||||
|
||||
typedef QSharedPointer<const AssistInterface> QuickFixInterface;
|
||||
using QuickFixInterface = QSharedPointer<const AssistInterface>;
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
|
@@ -55,8 +55,7 @@ RefactoringChanges::RefactoringChanges(RefactoringChangesData *data)
|
||||
: m_data(data)
|
||||
{}
|
||||
|
||||
RefactoringChanges::~RefactoringChanges()
|
||||
{}
|
||||
RefactoringChanges::~RefactoringChanges() = default;
|
||||
|
||||
RefactoringSelections RefactoringChanges::rangesToSelections(QTextDocument *document,
|
||||
const QList<Range> &ranges)
|
||||
@@ -387,7 +386,7 @@ void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const
|
||||
const TextDocument *) const,
|
||||
const RefactoringSelections &ranges)
|
||||
{
|
||||
typedef QPair<QTextCursor, QTextCursor> CursorPair;
|
||||
using CursorPair = QPair<QTextCursor, QTextCursor>;
|
||||
|
||||
foreach (const CursorPair &p, ranges) {
|
||||
QTextCursor selection(p.first.document());
|
||||
@@ -403,8 +402,7 @@ void RefactoringFile::fileChanged()
|
||||
m_data->fileChanged(m_fileName);
|
||||
}
|
||||
|
||||
RefactoringChangesData::~RefactoringChangesData()
|
||||
{}
|
||||
RefactoringChangesData::~RefactoringChangesData() = default;
|
||||
|
||||
void RefactoringChangesData::indentSelection(const QTextCursor &, const QString &, const TextDocument *) const
|
||||
{
|
||||
|
@@ -44,15 +44,15 @@ class TextEditorWidget;
|
||||
class RefactoringChanges;
|
||||
class RefactoringFile;
|
||||
class RefactoringChangesData;
|
||||
typedef QSharedPointer<RefactoringFile> RefactoringFilePtr;
|
||||
typedef QVector<QPair<QTextCursor, QTextCursor> > RefactoringSelections;
|
||||
using RefactoringFilePtr = QSharedPointer<RefactoringFile>;
|
||||
using RefactoringSelections = QVector<QPair<QTextCursor, QTextCursor>>;
|
||||
|
||||
// ### listen to the m_editor::destroyed signal?
|
||||
class TEXTEDITOR_EXPORT RefactoringFile
|
||||
{
|
||||
Q_DISABLE_COPY(RefactoringFile)
|
||||
public:
|
||||
typedef Utils::ChangeSet::Range Range;
|
||||
using Range = Utils::ChangeSet::Range;
|
||||
|
||||
public:
|
||||
virtual ~RefactoringFile();
|
||||
@@ -122,7 +122,7 @@ protected:
|
||||
class TEXTEDITOR_EXPORT RefactoringChanges
|
||||
{
|
||||
public:
|
||||
typedef Utils::ChangeSet::Range Range;
|
||||
using Range = Utils::ChangeSet::Range;
|
||||
|
||||
public:
|
||||
RefactoringChanges();
|
||||
@@ -150,7 +150,7 @@ class TEXTEDITOR_EXPORT RefactoringChangesData
|
||||
Q_DISABLE_COPY(RefactoringChangesData)
|
||||
|
||||
public:
|
||||
RefactoringChangesData() {}
|
||||
RefactoringChangesData() = default;
|
||||
virtual ~RefactoringChangesData();
|
||||
|
||||
virtual void indentSelection(const QTextCursor &selection,
|
||||
|
@@ -46,8 +46,8 @@ RefactorOverlay::RefactorOverlay(TextEditor::TextEditorWidget *editor) :
|
||||
void RefactorOverlay::paint(QPainter *painter, const QRect &clip)
|
||||
{
|
||||
m_maxWidth = 0;
|
||||
for (int i = 0; i < m_markers.size(); ++i) {
|
||||
paintMarker(m_markers.at(i), painter, clip);
|
||||
for (auto &marker : qAsConst(m_markers)) {
|
||||
paintMarker(marker, painter, clip);
|
||||
}
|
||||
|
||||
if (auto documentLayout = qobject_cast<TextDocumentLayout*>(m_editor->document()->documentLayout()))
|
||||
@@ -57,7 +57,7 @@ void RefactorOverlay::paint(QPainter *painter, const QRect &clip)
|
||||
|
||||
RefactorMarker RefactorOverlay::markerAt(const QPoint &pos) const
|
||||
{
|
||||
foreach (const RefactorMarker &marker, m_markers) {
|
||||
for (const auto &marker : m_markers) {
|
||||
if (marker.rect.contains(pos))
|
||||
return marker;
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ struct TEXTEDITOR_EXPORT RefactorMarker {
|
||||
QVariant data;
|
||||
};
|
||||
|
||||
typedef QList<RefactorMarker> RefactorMarkers;
|
||||
using RefactorMarkers = QList<RefactorMarker>;
|
||||
|
||||
class TEXTEDITOR_EXPORT RefactorOverlay : public QObject
|
||||
{
|
||||
|
@@ -82,8 +82,7 @@ const QChar Snippet::kEscapeChar(QLatin1Char('\\'));
|
||||
Snippet::Snippet(const QString &groupId, const QString &id) : m_groupId(groupId), m_id(id)
|
||||
{}
|
||||
|
||||
Snippet::~Snippet()
|
||||
{}
|
||||
Snippet::~Snippet() = default;
|
||||
|
||||
const QString &Snippet::id() const
|
||||
{
|
||||
|
@@ -107,8 +107,7 @@ SnippetsCollection::SnippetsCollection() :
|
||||
this, &SnippetsCollection::identifyGroups);
|
||||
}
|
||||
|
||||
SnippetsCollection::~SnippetsCollection()
|
||||
{}
|
||||
SnippetsCollection::~SnippetsCollection() = default;
|
||||
|
||||
void SnippetsCollection::insertSnippet(const Snippet &snippet)
|
||||
{
|
||||
@@ -309,7 +308,7 @@ bool SnippetsCollection::synchronize(QString *errorString)
|
||||
}
|
||||
Utils::FileSaver saver(m_userSnippetsPath + m_userSnippetsFile);
|
||||
if (!saver.hasError()) {
|
||||
typedef QHash<QString, int>::ConstIterator GroupIndexByIdConstIt;
|
||||
using GroupIndexByIdConstIt = QHash<QString, int>::ConstIterator;
|
||||
|
||||
QXmlStreamWriter writer(saver.file());
|
||||
writer.setAutoFormatting(true);
|
||||
|
@@ -54,7 +54,7 @@ class SnippetsTableModel : public QAbstractTableModel
|
||||
Q_OBJECT
|
||||
public:
|
||||
SnippetsTableModel(QObject *parent);
|
||||
~SnippetsTableModel() override {}
|
||||
~SnippetsTableModel() override = default;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
@@ -36,8 +36,6 @@
|
||||
#include <QPointer>
|
||||
#include <qtimer.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
class SyntaxHighlighterPrivate
|
||||
@@ -690,8 +688,8 @@ void SyntaxHighlighter::setExtraFormats(const QTextBlock &block,
|
||||
previousSemanticFormats.reserve(all.size());
|
||||
formatsToApply.reserve(all.size() + formats.size());
|
||||
|
||||
for (int i = 0, ei = formats.size(); i < ei; ++i)
|
||||
formats[i].format.setProperty(QTextFormat::UserProperty, true);
|
||||
for (auto &format : formats)
|
||||
format.format.setProperty(QTextFormat::UserProperty, true);
|
||||
|
||||
foreach (const QTextLayout::FormatRange &r, all) {
|
||||
if (r.format.hasProperty(QTextFormat::UserProperty))
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include <QTextLayout>
|
||||
|
||||
#include <functional>
|
||||
#include <limits.h>
|
||||
#include <climits>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTextDocument;
|
||||
|
@@ -224,8 +224,8 @@ int TabSettings::positionAtColumn(const QString &text, int column, int *offset,
|
||||
int TabSettings::columnCountForText(const QString &text, int startColumn) const
|
||||
{
|
||||
int column = startColumn;
|
||||
for (int i = 0; i < text.size(); ++i) {
|
||||
if (text.at(i) == QLatin1Char('\t'))
|
||||
for (auto c : text) {
|
||||
if (c == QLatin1Char('\t'))
|
||||
column = column - (column % m_tabSize) + m_tabSize;
|
||||
else
|
||||
++column;
|
||||
|
@@ -57,7 +57,7 @@ class TextDocumentPrivate;
|
||||
class TextMark;
|
||||
class TypingSettings;
|
||||
|
||||
typedef QList<TextMark *> TextMarks;
|
||||
using TextMarks = QList<TextMark *>;
|
||||
|
||||
class TEXTEDITOR_EXPORT TextDocument : public Core::BaseTextDocument
|
||||
{
|
||||
@@ -169,6 +169,6 @@ private:
|
||||
TextDocumentPrivate *d;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<TextDocument> TextDocumentPtr;
|
||||
using TextDocumentPtr = QSharedPointer<TextDocument>;
|
||||
|
||||
} // namespace TextEditor
|
||||
|
@@ -30,9 +30,7 @@
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
CodeFormatterData::~CodeFormatterData()
|
||||
{
|
||||
}
|
||||
CodeFormatterData::~CodeFormatterData() = default;
|
||||
|
||||
TextBlockUserData::~TextBlockUserData()
|
||||
{
|
||||
@@ -48,8 +46,8 @@ TextBlockUserData::~TextBlockUserData()
|
||||
int TextBlockUserData::braceDepthDelta() const
|
||||
{
|
||||
int delta = 0;
|
||||
for (int i = 0; i < m_parentheses.size(); ++i) {
|
||||
switch (m_parentheses.at(i).chr.unicode()) {
|
||||
for (auto &parenthesis : m_parentheses) {
|
||||
switch (parenthesis.chr.unicode()) {
|
||||
case '{': case '+': case '[': ++delta; break;
|
||||
case '}': case '-': case ']': --delta; break;
|
||||
default: break;
|
||||
|
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace TextEditor {
|
||||
struct Parenthesis;
|
||||
typedef QVector<Parenthesis> Parentheses;
|
||||
using Parentheses = QVector<Parenthesis>;
|
||||
|
||||
struct TEXTEDITOR_EXPORT Parenthesis
|
||||
{
|
||||
|
@@ -3852,8 +3852,8 @@ void TextEditorWidgetPrivate::insertIntoBlockSelection(const QString &text)
|
||||
const QStringList::const_iterator endLine = textLines.constEnd();
|
||||
for (QStringList::const_iterator textLine = textLines.constBegin(); textLine != endLine; ++textLine)
|
||||
textLength += qMax(0, ts.columnCountForText(*textLine, column) - textLength);
|
||||
for (QStringList::iterator textLine = textLines.begin(); textLine != textLines.end(); ++textLine)
|
||||
textLine->append(QString(qMax(0, textLength - ts.columnCountForText(*textLine, column)), QLatin1Char(' ')));
|
||||
for (auto &textLine : textLines)
|
||||
textLine.append(QString(qMax(0, textLength - ts.columnCountForText(textLine, column)), QLatin1Char(' ')));
|
||||
|
||||
// insert Text
|
||||
for (;;) {
|
||||
@@ -4156,7 +4156,7 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data,
|
||||
}
|
||||
}
|
||||
|
||||
for (const TextMark *mark : marks) {
|
||||
for (const TextMark *mark : qAsConst(marks)) {
|
||||
boundingRect = QRectF(x, boundingRect.top(), q->viewport()->width() - x, boundingRect.height());
|
||||
if (boundingRect.isEmpty())
|
||||
break;
|
||||
@@ -4617,7 +4617,7 @@ void TextEditorWidgetPrivate::paintReplacement(PaintEventData &data, QPainter &p
|
||||
|
||||
if (TextBlockUserData *nextBlockUserData = TextDocumentLayout::testUserData(nextBlock)) {
|
||||
if (nextBlockUserData->foldingStartIncluded())
|
||||
replacement.prepend(nextBlock.text().trimmed().left(1));
|
||||
replacement.prepend(nextBlock.text().trimmed().at(0));
|
||||
}
|
||||
|
||||
QTextBlock nextVisibleBlock = TextEditor::nextVisibleBlock(data.block, data.doc);
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include "texteditor_global.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QTextCursor>
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
@@ -39,9 +40,7 @@ namespace Internal {
|
||||
class TEXTEDITOR_EXPORT TextBlockSelection
|
||||
{
|
||||
public:
|
||||
TextBlockSelection()
|
||||
: positionBlock(0), positionColumn(0)
|
||||
, anchorBlock(0) , anchorColumn(0){}
|
||||
TextBlockSelection() = default;
|
||||
TextBlockSelection(const TextBlockSelection &other);
|
||||
|
||||
void clear();
|
||||
@@ -60,10 +59,10 @@ public:
|
||||
inline int lastVisualColumn() const { return qMax(positionColumn, anchorColumn); }
|
||||
|
||||
public:
|
||||
int positionBlock;
|
||||
int positionColumn;
|
||||
int anchorBlock;
|
||||
int anchorColumn;
|
||||
int positionBlock = 0;
|
||||
int positionColumn = 0;
|
||||
int anchorBlock = 0;
|
||||
int anchorColumn = 0;
|
||||
|
||||
private:
|
||||
QTextCursor cursor(const TextDocument *baseTextDocument, bool fullSelection) const;
|
||||
|
@@ -51,7 +51,7 @@ struct TestBlockSelection
|
||||
TestBlockSelection(int positionBlock, int positionColumn, int anchorBlock, int anchorColumn)
|
||||
: positionBlock(positionBlock), positionColumn(positionColumn)
|
||||
, anchorBlock(anchorBlock), anchorColumn(anchorColumn) {}
|
||||
TestBlockSelection() {}
|
||||
TestBlockSelection() = default;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(TransFormationType)
|
||||
@@ -529,23 +529,25 @@ struct TabSettingsFlags{
|
||||
TabSettings::ContinuationAlignBehavior behavior;
|
||||
};
|
||||
|
||||
typedef std::function<bool(TabSettingsFlags)> IsClean;
|
||||
void generateTestRows(QLatin1String name, QString text, IsClean isClean)
|
||||
using IsClean = std::function<bool (TabSettingsFlags)>;
|
||||
void generateTestRows(const QLatin1String &name, const QString &text, IsClean isClean)
|
||||
{
|
||||
QList<TabSettings::TabPolicy> allPolicys;
|
||||
allPolicys << TabSettings::SpacesOnlyTabPolicy
|
||||
<< TabSettings::TabsOnlyTabPolicy
|
||||
<< TabSettings::MixedTabPolicy;
|
||||
QList<TabSettings::ContinuationAlignBehavior> allbehavior;
|
||||
allbehavior << TabSettings::NoContinuationAlign
|
||||
<< TabSettings::ContinuationAlignWithSpaces
|
||||
<< TabSettings::ContinuationAlignWithIndent;
|
||||
const QVector<TabSettings::TabPolicy> allPolicies = {
|
||||
TabSettings::SpacesOnlyTabPolicy,
|
||||
TabSettings::TabsOnlyTabPolicy,
|
||||
TabSettings::MixedTabPolicy
|
||||
};
|
||||
const QVector<TabSettings::ContinuationAlignBehavior> allbehaviors = {
|
||||
TabSettings::NoContinuationAlign,
|
||||
TabSettings::ContinuationAlignWithSpaces,
|
||||
TabSettings::ContinuationAlignWithIndent
|
||||
};
|
||||
|
||||
const QLatin1Char splitter('_');
|
||||
const int indentSize = 3;
|
||||
|
||||
foreach (TabSettings::TabPolicy policy, allPolicys) {
|
||||
foreach (TabSettings::ContinuationAlignBehavior behavior, allbehavior) {
|
||||
for (auto policy : allPolicies) {
|
||||
for (auto behavior : allbehaviors) {
|
||||
const QString tag = tabPolicyToString(policy) + splitter
|
||||
+ continuationAlignBehaviorToString(behavior) + splitter
|
||||
+ name;
|
||||
|
@@ -41,14 +41,14 @@ namespace Internal {
|
||||
|
||||
struct OverlaySelection
|
||||
{
|
||||
OverlaySelection():m_fixedLength(-1), m_dropShadow(false){}
|
||||
OverlaySelection() = default;
|
||||
|
||||
QTextCursor m_cursor_begin;
|
||||
QTextCursor m_cursor_end;
|
||||
QColor m_fg;
|
||||
QColor m_bg;
|
||||
int m_fixedLength;
|
||||
bool m_dropShadow;
|
||||
int m_fixedLength = -1;
|
||||
bool m_dropShadow = false;
|
||||
};
|
||||
|
||||
class TextEditorOverlay : public QObject
|
||||
|
Reference in New Issue
Block a user