summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-05-08 13:46:54 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-05-08 13:46:58 (GMT)
commit830637192d0c751161d1131061b1f67dc4ffe8f6 (patch)
tree08e868e3f6e73dda4bb0e071a68dde3728722359 /Source
parent4c17299647c62ab698942bf1134f0e61c1ce07a2 (diff)
parent422359fe79b9313a45aff6cdbb6ef36d6fc52a46 (diff)
downloadCMake-830637192d0c751161d1131061b1f67dc4ffe8f6.zip
CMake-830637192d0c751161d1131061b1f67dc4ffe8f6.tar.gz
CMake-830637192d0c751161d1131061b1f67dc4ffe8f6.tar.bz2
Merge topic 'clazy-cleanup'
422359fe CMakeSetupDialog: use multi-arg 1ffe47e3 QCMakeCacheView: prever QVector over QList 726b3b6f QtDialog: add reference in foreach 377d4df2 QCMakeCacheView: avoid temporary containers for iteration a57b30bb QtDialog: add missing emit keywords 7a0e2392 cmFileMonitor: use cmDeleteAll Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !805
Diffstat (limited to 'Source')
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx15
-rw-r--r--Source/QtDialog/FirstConfigure.cxx2
-rw-r--r--Source/QtDialog/QCMake.cxx4
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx26
-rw-r--r--Source/QtDialog/QCMakeWidgets.cxx8
-rw-r--r--Source/cmFileMonitor.cxx12
6 files changed, 32 insertions, 35 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 111b28a..57f8e10 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -990,10 +990,10 @@ void CMakeSetupDialog::removeSelectedCacheEntries()
{
QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows();
QList<QPersistentModelIndex> pidxs;
- foreach (QModelIndex i, idxs) {
+ foreach (QModelIndex const& i, idxs) {
pidxs.append(i);
}
- foreach (QPersistentModelIndex pi, pidxs) {
+ foreach (QPersistentModelIndex const& pi, pidxs) {
this->CacheValues->model()->removeRow(pi.row(), pi.parent());
}
}
@@ -1152,7 +1152,7 @@ void CMakeSetupDialog::showUserChanges()
QString command;
QString cache;
- foreach (QCMakeProperty prop, changes) {
+ foreach (QCMakeProperty const& prop, changes) {
QString type;
switch (prop.Type) {
case QCMakeProperty::BOOL:
@@ -1175,12 +1175,9 @@ void CMakeSetupDialog::showUserChanges()
value = prop.Value.toString();
}
- QString line("%1:%2=");
- line = line.arg(prop.Key);
- line = line.arg(type);
-
- command += QString("-D%1\"%2\" ").arg(line).arg(value);
- cache += QString("%1%2\n").arg(line).arg(value);
+ QString const line = QString("%1:%2=").arg(prop.Key, type);
+ command += QString("-D%1\"%2\" ").arg(line, value);
+ cache += QString("%1%2\n").arg(line, value);
}
textedit->append(tr("Commandline options:"));
diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx
index 2f1df4f..b193a27 100644
--- a/Source/QtDialog/FirstConfigure.cxx
+++ b/Source/QtDialog/FirstConfigure.cxx
@@ -130,7 +130,7 @@ bool StartCompilerSetup::crossCompilerSetup() const
void StartCompilerSetup::onSelectionChanged(bool on)
{
if (on) {
- selectionChanged();
+ emit selectionChanged();
}
}
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index abeff97..28820a6 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -219,14 +219,14 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
}
// remove some properites
- foreach (QString s, toremove) {
+ foreach (QString const& s, toremove) {
this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data());
state->RemoveCacheEntry(s.toLocal8Bit().data());
}
// add some new properites
- foreach (QCMakeProperty s, props) {
+ foreach (QCMakeProperty const& s, props) {
this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data());
if (s.Type == QCMakeProperty::BOOL) {
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index 9f5208a..08c2d58 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -47,7 +47,7 @@ protected:
}
// check all strings for a match
- foreach (QString str, strs) {
+ foreach (QString const& str, strs) {
if (str.contains(this->filterRegExp())) {
return true;
}
@@ -236,12 +236,12 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
qSort(newP);
qSort(newP2);
int row_count = 0;
- foreach (QCMakeProperty p, newP) {
+ foreach (QCMakeProperty const& p, newP) {
this->insertRow(row_count);
this->setPropertyData(this->index(row_count, 0), p, true);
row_count++;
}
- foreach (QCMakeProperty p, newP2) {
+ foreach (QCMakeProperty const& p, newP2) {
this->insertRow(row_count);
this->setPropertyData(this->index(row_count, 0), p, false);
row_count++;
@@ -254,8 +254,11 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
QStandardItem* root = this->invisibleRootItem();
- foreach (QString key, newPropsTree.keys()) {
- QCMakePropertyList props2 = newPropsTree[key];
+ for (QMap<QString, QCMakePropertyList>::const_iterator iter =
+ newPropsTree.begin();
+ iter != newPropsTree.end(); ++iter) {
+ QString const& key = iter.key();
+ QCMakePropertyList const& props2 = iter.value();
QList<QStandardItem*> parentItems;
parentItems.append(
@@ -280,8 +283,11 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
}
}
- foreach (QString key, newPropsTree2.keys()) {
- QCMakePropertyList props2 = newPropsTree2[key];
+ for (QMap<QString, QCMakePropertyList>::const_iterator iter =
+ newPropsTree2.begin();
+ iter != newPropsTree2.end(); ++iter) {
+ QString const& key = iter.key();
+ QCMakePropertyList const& props2 = iter.value();
QStandardItem* parentItem =
new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key);
@@ -393,7 +399,7 @@ void QCMakeCacheModel::breakProperties(
{
QMap<QString, QCMakePropertyList> tmp;
// return a map of properties grouped by prefixes, and sorted
- foreach (QCMakeProperty p, props) {
+ foreach (QCMakeProperty const& p, props) {
QString prefix = QCMakeCacheModel::prefix(p.Key);
tmp[prefix].append(p);
}
@@ -423,7 +429,7 @@ QCMakePropertyList QCMakeCacheModel::properties() const
return props;
}
- QList<QModelIndex> idxs;
+ QVector<QModelIndex> idxs;
idxs.append(this->index(0, 0));
// walk the entire model for property entries
@@ -448,7 +454,7 @@ QCMakePropertyList QCMakeCacheModel::properties() const
(idxs.last().row() + 1) >= rowCount(idxs.last().parent()) ||
#endif
!idxs.last().sibling(idxs.last().row() + 1, 0).isValid())) {
- idxs.removeLast();
+ idxs.remove(idxs.size() - 1);
}
if (!idxs.isEmpty()) {
idxs.last() = idxs.last().sibling(idxs.last().row() + 1, 0);
diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx
index 6a55a76..7f0cafa 100644
--- a/Source/QtDialog/QCMakeWidgets.cxx
+++ b/Source/QtDialog/QCMakeWidgets.cxx
@@ -54,11 +54,11 @@ void QCMakeFilePathEditor::chooseFile()
title = tr("Select File for %1");
title = title.arg(this->Variable);
}
- this->fileDialogExists(true);
+ emit this->fileDialogExists(true);
path =
QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(),
CM_NULLPTR, QFileDialog::DontResolveSymlinks);
- this->fileDialogExists(false);
+ emit this->fileDialogExists(false);
if (!path.isEmpty()) {
this->setText(QDir::fromNativeSeparators(path));
@@ -76,11 +76,11 @@ void QCMakePathEditor::chooseFile()
title = tr("Select Path for %1");
title = title.arg(this->Variable);
}
- this->fileDialogExists(true);
+ emit this->fileDialogExists(true);
path = QFileDialog::getExistingDirectory(this, title, this->text(),
QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks);
- this->fileDialogExists(false);
+ emit this->fileDialogExists(false);
if (!path.isEmpty()) {
this->setText(QDir::fromNativeSeparators(path));
}
diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx
index ed794c3..499ee84 100644
--- a/Source/cmFileMonitor.cxx
+++ b/Source/cmFileMonitor.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileMonitor.h"
+#include "cmAlgorithms.h"
#include "cmsys/SystemTools.hxx"
#include <cassert>
@@ -36,12 +37,7 @@ public:
class cmVirtualDirectoryWatcher : public cmIBaseWatcher
{
public:
- ~cmVirtualDirectoryWatcher() override
- {
- for (auto i : this->Children) {
- delete i.second;
- }
- }
+ ~cmVirtualDirectoryWatcher() override { cmDeleteAll(this->Children); }
cmIBaseWatcher* Find(const std::string& ps)
{
@@ -102,9 +98,7 @@ public:
void Reset()
{
- for (auto c : this->Children) {
- delete c.second;
- }
+ cmDeleteAll(this->Children);
this->Children.clear();
}