Merge remote-tracking branch 'origin/4.4'

Conflicts:
	qtcreator.pri

Change-Id: If5f4a9821a23ac0df81eb84b3980f9cf7ecd70ba
This commit is contained in:
Eike Ziller
2017-07-25 11:54:44 +02:00
139 changed files with 2523 additions and 1053 deletions

View File

@@ -17,19 +17,19 @@
\"Url\" : \"http://www.qt.io\",
$$dependencyList,
\"Mimetypes\" : \"
<?xml version=\'1.0\'?>
<mime-info xmlns=\'http://www.freedesktop.org/standards/shared-mime-info\'>
<mime-type type=\'text/x-cmake\'>
<sub-class-of type=\'text/plain\'/>
<comment>CMake Project file</comment>
<glob pattern=\'*.cmake\'/>
</mime-type>
<mime-type type=\'text/x-cmake-project\'>
<sub-class-of type=\'text/x-cmake\'/>
<comment>CMake Project file</comment>
<glob pattern=\'CMakeLists.txt\'/>
</mime-type>
</mime-info>
\"
\"Mimetypes\" : [
\"<?xml version=\'1.0\'?>\",
\"<mime-info xmlns=\'http://www.freedesktop.org/standards/shared-mime-info\'>\",
\" <mime-type type=\'text/x-cmake\'>\",
\" <sub-class-of type=\'text/plain\'/>\",
\" <comment>CMake Project file</comment>\",
\" <glob pattern=\'*.cmake\'/>\",
\" </mime-type>\",
\" <mime-type type=\'text/x-cmake-project\'>\",
\" <sub-class-of type=\'text/x-cmake\'/>\",
\" <comment>CMake Project file</comment>\",
\" <glob pattern=\'CMakeLists.txt\'/>\",
\" </mime-type>\",
\"</mime-info>\"
]
}

View File

@@ -61,6 +61,9 @@ private slots:
void testCMakeProjectImporterToolChain_data();
void testCMakeProjectImporterToolChain();
void testServerModeReaderProgress_data();
void testServerModeReaderProgress();
#endif
private:

View File

@@ -417,8 +417,7 @@ void ServerModeReader::handleProgress(int min, int cur, int max, const QString &
if (!m_future)
return;
int progress = m_progressStepMinimum
+ (((max - min) / (cur - min)) * (m_progressStepMaximum - m_progressStepMinimum));
const int progress = calculateProgress(m_progressStepMinimum, min, cur, max, m_progressStepMaximum);
m_future->setProgressValue(progress);
}
@@ -430,6 +429,14 @@ void ServerModeReader::handleSignal(const QString &signal, const QVariantMap &da
emit dirty();
}
int ServerModeReader::calculateProgress(const int minRange, const int min, const int cur, const int max, const int maxRange)
{
if (minRange == maxRange || min == max)
return minRange;
const int clampedCur = std::min(std::max(cur, min), max);
return minRange + ((clampedCur - min) / (max - min)) * (maxRange - minRange);
}
void ServerModeReader::extractCodeModelData(const QVariantMap &data)
{
const QVariantList configs = data.value("configurations").toList();
@@ -880,3 +887,59 @@ void ServerModeReader::addHeaderNodes(ProjectNode *root, const QList<FileNode *>
} // namespace Internal
} // namespace CMakeProjectManager
#if defined(WITH_TESTS)
#include "cmakeprojectplugin.h"
#include <QTest>
namespace CMakeProjectManager {
namespace Internal {
void CMakeProjectPlugin::testServerModeReaderProgress_data()
{
QTest::addColumn<int>("minRange");
QTest::addColumn<int>("min");
QTest::addColumn<int>("cur");
QTest::addColumn<int>("max");
QTest::addColumn<int>("maxRange");
QTest::addColumn<int>("expected");
QTest::newRow("empty range") << 100 << 10 << 11 << 20 << 100 << 100;
QTest::newRow("one range (low)") << 0 << 10 << 11 << 20 << 1 << 0;
QTest::newRow("one range (high)") << 20 << 10 << 19 << 20 << 20 << 20;
QTest::newRow("large range") << 30 << 10 << 11 << 20 << 100000 << 30;
QTest::newRow("empty progress") << -5 << 10 << 10 << 10 << 99995 << -5;
QTest::newRow("one progress (low)") << 42 << 10 << 10 << 11 << 100042 << 42;
QTest::newRow("one progress (high)") << 0 << 10 << 11 << 11 << 100000 << 100000;
QTest::newRow("large progress") << 0 << 10 << 10 << 11 << 100000 << 0;
QTest::newRow("cur too low") << 0 << 10 << 9 << 100 << 100000 << 0;
QTest::newRow("cur too high") << 0 << 10 << 101 << 100 << 100000 << 100000;
QTest::newRow("cur much too low") << 0 << 10 << -1000 << 100 << 100000 << 0;
QTest::newRow("cur much too high") << 0 << 10 << 1110000 << 100 << 100000 << 100000;
}
void CMakeProjectPlugin::testServerModeReaderProgress()
{
QFETCH(int, minRange);
QFETCH(int, min);
QFETCH(int, cur);
QFETCH(int, max);
QFETCH(int, maxRange);
QFETCH(int, expected);
ServerModeReader reader;
const int r = reader.calculateProgress(minRange, min, cur, max, maxRange);
QCOMPARE(r, expected);
QVERIFY(r <= maxRange);
QVERIFY(r >= minRange);
}
} // namespace Internal
} // namespace CMakeProjectManager
#endif

View File

@@ -69,6 +69,10 @@ private:
void handleProgress(int min, int cur, int max, const QString &inReplyTo);
void handleSignal(const QString &signal, const QVariantMap &data);
int calculateProgress(const int minRange, const int min,
const int cur,
const int max, const int maxRange);
struct Target;
struct Project;
@@ -175,6 +179,10 @@ private:
QList<FileGroup *> m_fileGroups;
CMakeParser m_parser;
#if defined(WITH_TESTS)
friend class CMakeProjectPlugin;
#endif
};
} // namespace Internal