Commit f8bbbd02 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Use initializer list with containers and multiple initial elements

parent 074b9376
......@@ -42,8 +42,10 @@ void SessionJob::start()
{
if (operationName() == QLatin1String("open"))
{
QStringList args;
args << QStringLiteral("--open-session") << destination();
const QStringList args{
QStringLiteral("--open-session"),
destination(),
};
KToolInvocation::kdeinitExec(QStringLiteral("kdevelop"), args);
setResult(true);
......
......@@ -78,9 +78,9 @@ Variable::Variable(TreeModel* model, TreeItem* parent,
// FIXME: should not duplicate the data, instead overload 'data'
// and return expression_ directly.
if (display.isEmpty())
setData(QVector<QVariant>() << expression << QString() << QString());
setData(QVector<QVariant>{expression, QString(), QString()});
else
setData(QVector<QVariant>() << display << QString() << QString());
setData(QVector<QVariant>{display, QString(), QString()});
}
QString Variable::expression() const
......@@ -245,7 +245,7 @@ QVariant Variable::data(int column, int role) const
Watches::Watches(TreeModel* model, TreeItem* parent)
: TreeItem(model, parent), finishResult_(nullptr)
{
setData(QVector<QVariant>() << i18n("Auto") << QString());
setData(QVector<QVariant>{i18n("Auto"), QString()});
}
Variable* Watches::add(const QString& expression)
......@@ -323,7 +323,7 @@ void Watches::reinstall()
Locals::Locals(TreeModel* model, TreeItem* parent, const QString &name)
: TreeItem(model, parent)
{
setData(QVector<QVariant>() << name << QString());
setData(QVector<QVariant>{name, QString()});
}
QList<Variable*> Locals::updateLocals(QStringList locals)
......
......@@ -93,8 +93,7 @@ VariableToolTip::VariableToolTip(QWidget* parent, const QPoint& position,
{
setPalette( QApplication::palette() );
m_model = new TreeModel(QVector<QString>() << i18n("Name") << i18n("Value") << i18n("Type"),
this);
m_model = new TreeModel(QVector<QString>{i18n("Name"), i18n("Value"), i18n("Type")}, this);
TooltipRoot* tr = new TooltipRoot(m_model);
m_model->setRootItem(tr);
......
......@@ -185,7 +185,7 @@ void ApplyChangesWidgetPrivate::createEditPart(const IndexedString & file)
m_editParts[m_index]->openUrl(url);
v->addWidget(m_editParts[m_index]->widget());
v->setSizes(QList<int>() << 400 << 100);
v->setSizes(QList<int>{400, 100});
}
void ApplyChangesWidget::indexChanged(int newIndex)
......
......@@ -213,8 +213,13 @@ QString TemplateClassGenerator::identifier() const
void TemplateClassGenerator::setIdentifier(const QString& identifier)
{
d->renderer.addVariable(QStringLiteral("identifier"), identifier);;
QStringList separators;
separators << QStringLiteral("::") << QStringLiteral(".") << QStringLiteral(":") << QStringLiteral("\\") << QStringLiteral("/");
const QStringList separators{
QStringLiteral("::"),
QStringLiteral("."),
QStringLiteral(":"),
QStringLiteral("\\"),
QStringLiteral("/"),
};
QStringList ns;
foreach (const QString& separator, separators)
{
......
......@@ -240,16 +240,16 @@ void ProjectChangesModel::reloadAll()
void ProjectChangesModel::jobUnregistered(KJob* job)
{
static QList<VcsJob::JobType> readOnly = QList<VcsJob::JobType>()
<< KDevelop::VcsJob::Add
<< KDevelop::VcsJob::Remove
<< KDevelop::VcsJob::Pull
<< KDevelop::VcsJob::Commit
<< KDevelop::VcsJob::Move
<< KDevelop::VcsJob::Copy
<< KDevelop::VcsJob::Revert
;
static const QList<VcsJob::JobType> readOnly = QList<VcsJob::JobType>{
KDevelop::VcsJob::Add,
KDevelop::VcsJob::Remove,
KDevelop::VcsJob::Pull,
KDevelop::VcsJob::Commit,
KDevelop::VcsJob::Move,
KDevelop::VcsJob::Copy,
KDevelop::VcsJob::Revert,
};
VcsJob* vcsjob=dynamic_cast<VcsJob*>(job);
if(vcsjob && readOnly.contains(vcsjob->type())) {
reloadAll();
......
......@@ -1083,7 +1083,7 @@ bool DocumentController::openDocumentsWithSplitSeparators( Sublime::AreaIndex* i
Sublime::Area* area = Core::self()->uiControllerInternal()->activeArea();
QList<int> topLevelSeparators; // Indices of the top-level separators (with groups skipped)
QStringList separators = QStringList() << QStringLiteral("/") << QStringLiteral("-");
const QStringList separators {QStringLiteral("/"), QStringLiteral("-")};
QList<QStringList> groups;
bool ret = true;
......
......@@ -64,7 +64,7 @@ LaunchConfigurationDialog::LaunchConfigurationDialog(QWidget* parent)
mainLayout->addWidget(mainWidget);
setupUi(mainWidget);
splitter->setSizes(QList<int>() << 260 << 620);
splitter->setSizes(QList<int>{260, 620});
splitter->setCollapsible(0, false);
addConfig->setToolTip(i18nc("@info:tooltip", "Add a new launch configuration."));
......
......@@ -196,8 +196,7 @@ public:
QPushButton *button = new QPushButton();
button->setIcon(QIcon::fromTheme(QStringLiteral("dialog-information")));
setBlockedEventTypes(button, QList<QEvent::Type>() << QEvent::MouseButtonPress
<< QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick);
setBlockedEventTypes(button, QList<QEvent::Type>{QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick});
connect(button, &QPushButton::clicked, this, &LoadedPluginsDelegate::info);
return QList<QWidget*>()
......
......@@ -50,8 +50,12 @@ QIcon generateIcon(const WorkingSetIconParameters& params)
pixmap.fill(QColor::fromRgba(qRgba(0, 0, 0, 0)));
const uint coloredCount = params.coloredCount;
// coordinates of the rectangles to draw, for 16x16 icons specifically
QList<QRect> rects;
rects << QRect(1, 1, 5, 5) << QRect(1, 9, 5, 5) << QRect(9, 1, 5, 5) << QRect(9, 9, 5, 5);
QList<QRect> rects{
{1, 1, 5, 5},
{1, 9, 5, 5},
{9, 1, 5, 5},
{9, 9, 5, 5},
};
if ( params.swapDiagonal ) {
rects.swap(1, 2);
}
......
......@@ -173,9 +173,10 @@ void IdealDockWidget::contextMenuRequested(const QPoint &point)
//save shortcut config
KConfigGroup config = KSharedConfig::openConfig()->group("UI");
QStringList shortcuts;
shortcuts << w->shortcut().value(0).toString();
shortcuts << w->shortcut().value(1).toString();
const QStringList shortcuts{
w->shortcut().value(0).toString(),
w->shortcut().value(1).toString(),
};
config.writeEntry(QStringLiteral("Shortcut for %1").arg(m_view->document()->title()), shortcuts);
config.sync();
}
......
......@@ -70,9 +70,10 @@ void VcsItemEventModel::addItemEvents( const QList<KDevelop::VcsItemEvent>& list
QMimeType mime = repoUrl.isLocalFile()
? mimeDataBase.mimeTypeForFile(repoUrl.toLocalFile(), QMimeDatabase::MatchExtension)
: mimeDataBase.mimeTypeForUrl(repoUrl);
QList<QStandardItem*> rowItems = QList<QStandardItem*>()
<< new QStandardItem(QIcon::fromTheme(mime.iconName()), ev.repositoryLocation())
<< new QStandardItem(actionStrings.join(i18nc("separes an action list", ", ")));
QList<QStandardItem*> rowItems{
new QStandardItem(QIcon::fromTheme(mime.iconName()), ev.repositoryLocation()),
new QStandardItem(actionStrings.join(i18nc("separes an action list", ", "))),
};
QString loc = ev.repositoryCopySourceLocation();
if(!loc.isEmpty()) { //according to the documentation, those are optional. don't force them on the UI
rowItems << new QStandardItem(ev.repositoryCopySourceLocation());
......
......@@ -534,10 +534,11 @@ QString AppWizardPlugin::knsConfigurationFile() const
QStringList AppWizardPlugin::supportedMimeTypes() const
{
QStringList types;
types << QStringLiteral("application/x-desktop");
types << QStringLiteral("application/x-bzip-compressed-tar");
types << QStringLiteral("application/zip");
const QStringList types{
QStringLiteral("application/x-desktop"),
QStringLiteral("application/x-bzip-compressed-tar"),
QStringLiteral("application/zip"),
};
return types;
}
......
......@@ -56,7 +56,7 @@ ProjectSelectionPage::ProjectSelectionPage(ProjectTemplatesModel *templatesModel
this, &ProjectSelectionPage::nameChanged );
ui->listView->setLevels(2);
ui->listView->setHeaderLabels(QStringList() << i18n("Category") << i18n("Project Type"));
ui->listView->setHeaderLabels(QStringList{i18n("Category"), i18n("Project Type")});
ui->listView->setModel(templatesModel);
ui->listView->setLastLevelViewMode(MultiLevelListView::DirectChildren);
connect (ui->listView, &MultiLevelListView::currentIndexChanged, this, &ProjectSelectionPage::typeChanged);
......
......@@ -359,12 +359,13 @@ public:
QVariant data(const QModelIndex& index, int role, const CodeCompletionModel* model) const override
{
if (role == CodeCompletionModel::CustomHighlight && index.column() == CodeCompletionModel::Arguments && argumentHintDepth()) {
QList<QVariant> highlighting;
highlighting << QVariant(m_range.start);
highlighting << QVariant(m_range.end);
QTextCharFormat boldFormat;
boldFormat.setFontWeight(QFont::Bold);
highlighting << boldFormat;
const QList<QVariant> highlighting {
QVariant(m_range.start),
QVariant(m_range.end),
boldFormat,
};
return highlighting;
}
......
......@@ -46,13 +46,14 @@ void CMakeCacheModel::reset()
void CMakeCacheModel::read()
{
// Set headers
QStringList labels;
labels.append(i18n("Name"));
labels.append(i18n("Type"));
labels.append(i18n("Value"));
labels.append(i18n("Comment"));
labels.append(i18n("Advanced"));
labels.append(i18n("Strings"));
const QStringList labels{
i18n("Name"),
i18n("Type"),
i18n("Value"),
i18n("Comment"),
i18n("Advanced"),
i18n("Strings"),
};
setHorizontalHeaderLabels(labels);
QFile file(m_filePath.toLocalFile());
......@@ -83,11 +84,12 @@ void CMakeCacheModel::read()
QString type=c.type();
QString value=c.value();
QList<QStandardItem*> lineItems;
lineItems.append(new QStandardItem(name));
lineItems.append(new QStandardItem(type));
lineItems.append(new QStandardItem(value));
lineItems.append(new QStandardItem(currentComment.join(QLatin1Char('\n'))));
const QList<QStandardItem*> lineItems{
new QStandardItem(name),
new QStandardItem(type),
new QStandardItem(value),
new QStandardItem(currentComment.join(QLatin1Char('\n'))),
};
if(flag==QLatin1String("INTERNAL"))
{
......
......@@ -65,9 +65,9 @@ private:
CMakeBuilder::CMakeBuilder(QObject *parent, const QVariantList &)
: KDevelop::IPlugin(QStringLiteral("kdevcmakebuilder"), parent)
{
addBuilder(QStringLiteral("Makefile"), QStringList(QStringLiteral("Unix Makefiles"))
<< QStringLiteral("NMake Makefiles")
<< QStringLiteral("MinGW Makefiles"),
addBuilder(QStringLiteral("Makefile"), QStringList{QStringLiteral("Unix Makefiles"),
QStringLiteral("NMake Makefiles"),
QStringLiteral("MinGW Makefiles")},
core()->pluginController()->pluginForExtension(QStringLiteral("org.kdevelop.IMakeBuilder")));
addBuilder(QStringLiteral("build.ninja"), QStringList(QStringLiteral("Ninja")), core()->pluginController()->pluginForExtension(QStringLiteral("org.kdevelop.IProjectBuilder"), QStringLiteral("KDevNinjaBuilder")));
}
......
......@@ -105,11 +105,13 @@ CompilerProvider::CompilerProvider( SettingsManager* settings, QObject* parent )
: QObject( parent )
, m_settings(settings)
{
m_factories.append(CompilerFactoryPointer(new GccFactory()));
m_factories.append(CompilerFactoryPointer(new ClangFactory()));
m_factories = {
CompilerFactoryPointer(new GccFactory()),
CompilerFactoryPointer(new ClangFactory()),
#ifdef _WIN32
m_factories.append(CompilerFactoryPointer(new MsvcFactory()));
CompilerFactoryPointer(new MsvcFactory()),
#endif
};
if (!QStandardPaths::findExecutable( QStringLiteral("clang") ).isEmpty()) {
m_factories[1]->registerDefaultCompilers(this);
......
......@@ -85,11 +85,13 @@ Defines GccLikeCompiler::defines(Utils::LanguageType type, const QString& argume
proc.setProcessChannelMode( QProcess::MergedChannels );
// TODO: what about -mXXX or -target= flags, some of these change search paths/defines
QStringList compilerArguments{languageOption(type), languageStandard(arguments)};
compilerArguments.append(QStringLiteral("-dM"));
compilerArguments.append(QStringLiteral("-E"));
compilerArguments.append(QStringLiteral("-"));
const QStringList compilerArguments{
languageOption(type),
languageStandard(arguments),
QStringLiteral("-dM"),
QStringLiteral("-E"),
QStringLiteral("-"),
};
proc.setStandardInputFile(QProcess::nullDevice());
proc.setProgram(path());
proc.setArguments(compilerArguments);
......@@ -140,10 +142,13 @@ Path::List GccLikeCompiler::includes(Utils::LanguageType type, const QString& ar
// /usr/include
// End of search list.
QStringList compilerArguments{languageOption(type), languageStandard(arguments)};
compilerArguments.append(QStringLiteral("-E"));
compilerArguments.append(QStringLiteral("-v"));
compilerArguments.append(QStringLiteral("-"));
const QStringList compilerArguments{
languageOption(type),
languageStandard(arguments),
QStringLiteral("-E"),
QStringLiteral("-v"),
QStringLiteral("-"),
};
proc.setStandardInputFile(QProcess::nullDevice());
proc.setProgram(path());
......
......@@ -112,13 +112,14 @@ namespace {
QStringList possibleTargets(const QString& targetBaseName) const
{
QStringList ret;
const QStringList ret{
///@todo open the make-file, and read the target-names from there.
//It would be nice if all targets could be processed in one call, the problem is the exit-status of make, so for now make has to be called multiple times.
ret << targetBaseName + ".o";
ret << targetBaseName + ".lo";
targetBaseName + QLatin1String(".o"),
targetBaseName + QLatin1String(".lo"),
//ret << targetBaseName + ".lo " + targetBaseName + ".o";
ret << targetBaseName + ".ko";
targetBaseName + QLatin1String(".ko"),
};
return ret;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment