aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/clangpchmanager
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2018-09-27 17:52:44 +0200
committerMarco Bubke <marco.bubke@qt.io>2018-10-08 08:20:22 +0000
commit391cfab5d7cb7f4b38cf4a73995ac84b5b3a6ff9 (patch)
tree9cb7902e34339283d9caf3703706e2036b6c5ad4 /src/plugins/clangpchmanager
parentffc070a3f2605d4b85d839830eb4f30120415c9b (diff)
Clang: Add progress bars for creating PCHs and indexing
Task-number: QTCREATORBUG-21112 Change-Id: Ie0c00a58f479a2fe7cbc7322490808509733ff0f Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/plugins/clangpchmanager')
-rw-r--r--src/plugins/clangpchmanager/clangpchmanager-source.pri4
-rw-r--r--src/plugins/clangpchmanager/clangpchmanager.pro1
-rw-r--r--src/plugins/clangpchmanager/clangpchmanagerplugin.cpp11
-rw-r--r--src/plugins/clangpchmanager/pchmanagerclient.cpp8
-rw-r--r--src/plugins/clangpchmanager/pchmanagerclient.h9
-rw-r--r--src/plugins/clangpchmanager/progressmanager.h84
-rw-r--r--src/plugins/clangpchmanager/progressmanagerinterface.h39
7 files changed, 151 insertions, 5 deletions
diff --git a/src/plugins/clangpchmanager/clangpchmanager-source.pri b/src/plugins/clangpchmanager/clangpchmanager-source.pri
index 27e35dc7409..c0eb7ba90a4 100644
--- a/src/plugins/clangpchmanager/clangpchmanager-source.pri
+++ b/src/plugins/clangpchmanager/clangpchmanager-source.pri
@@ -12,7 +12,9 @@ HEADERS += \
$$PWD/pchmanagerconnectionclient.h \
$$PWD/clangpchmanager_global.h \
$$PWD/projectupdater.h \
- $$PWD/pchmanagerprojectupdater.h
+ $$PWD/pchmanagerprojectupdater.h \
+ $$PWD/progressmanager.h \
+ $$PWD/progressmanagerinterface.h
SOURCES += \
$$PWD/pchmanagerclient.cpp \
diff --git a/src/plugins/clangpchmanager/clangpchmanager.pro b/src/plugins/clangpchmanager/clangpchmanager.pro
index 204f740a28c..e222ffd3d46 100644
--- a/src/plugins/clangpchmanager/clangpchmanager.pro
+++ b/src/plugins/clangpchmanager/clangpchmanager.pro
@@ -13,6 +13,7 @@ win32 {
HEADERS += \
$$PWD/clangpchmanagerplugin.h \
qtcreatorprojectupdater.h
+
SOURCES += \
$$PWD/clangpchmanagerplugin.cpp \
qtcreatorprojectupdater.cpp
diff --git a/src/plugins/clangpchmanager/clangpchmanagerplugin.cpp b/src/plugins/clangpchmanager/clangpchmanagerplugin.cpp
index 098faf50b31..90ba8f62bc0 100644
--- a/src/plugins/clangpchmanager/clangpchmanagerplugin.cpp
+++ b/src/plugins/clangpchmanager/clangpchmanagerplugin.cpp
@@ -27,6 +27,7 @@
#include "pchmanagerconnectionclient.h"
#include "pchmanagerclient.h"
+#include "progressmanager.h"
#include "qtcreatorprojectupdater.h"
#include <filepathcaching.h>
@@ -34,10 +35,13 @@
#include <sqlitedatabase.h>
#include <coreplugin/icore.h>
+#include <coreplugin/progressmanager/progressmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/hostosinfo.h>
+#include <QFutureInterface>
+
#include <chrono>
using namespace std::chrono_literals;
@@ -61,7 +65,12 @@ public:
Sqlite::Database database{Utils::PathString{Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"}, 1000ms};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
- PchManagerClient pchManagerClient;
+ ClangPchManager::ProgressManager progressManager{
+ [] (QFutureInterface<void> &promise) {
+ auto title = QCoreApplication::translate("ClangPchProgressManager", "Creating PCHs", "PCH stands for precompiled header");
+ Core::ProgressManager::addTask(promise.future(), title, "pch creation", nullptr);
+ }};
+ PchManagerClient pchManagerClient{progressManager};
PchManagerConnectionClient connectionClient{&pchManagerClient};
QtCreatorProjectUpdater<PchManagerProjectUpdater> projectUpdate{connectionClient.serverProxy(),
pchManagerClient,
diff --git a/src/plugins/clangpchmanager/pchmanagerclient.cpp b/src/plugins/clangpchmanager/pchmanagerclient.cpp
index 81af53308e5..56e64b2b56f 100644
--- a/src/plugins/clangpchmanager/pchmanagerclient.cpp
+++ b/src/plugins/clangpchmanager/pchmanagerclient.cpp
@@ -26,8 +26,9 @@
#include "pchmanagerclient.h"
#include <precompiledheadersupdatedmessage.h>
+#include <progressmanagerinterface.h>
+#include <progressmessage.h>
#include <pchmanagerconnectionclient.h>
-
#include <pchmanagernotifierinterface.h>
#include <algorithm>
@@ -50,6 +51,11 @@ void PchManagerClient::precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeader
}
}
+void PchManagerClient::progress(ClangBackEnd::ProgressMessage &&message)
+{
+ m_progressManager.setProgress(message.progress, message.total);
+}
+
void PchManagerClient::precompiledHeaderRemoved(const QString &projectPartId)
{
for (auto notifier : m_notifiers) {
diff --git a/src/plugins/clangpchmanager/pchmanagerclient.h b/src/plugins/clangpchmanager/pchmanagerclient.h
index 92c44465f23..d7c0b68f713 100644
--- a/src/plugins/clangpchmanager/pchmanagerclient.h
+++ b/src/plugins/clangpchmanager/pchmanagerclient.h
@@ -34,7 +34,7 @@
namespace ClangPchManager {
class PchManagerConnectionClient;
-
+class ProgressManagerInterface;
class PchManagerNotifierInterface;
class CLANGPCHMANAGER_EXPORT PchManagerClient final : public ClangBackEnd::PchManagerClientInterface,
@@ -42,9 +42,13 @@ class CLANGPCHMANAGER_EXPORT PchManagerClient final : public ClangBackEnd::PchMa
{
friend class PchManagerNotifierInterface;
public:
- PchManagerClient() = default;
+ PchManagerClient(ProgressManagerInterface &progressManager)
+ : m_progressManager(progressManager)
+ {}
+
void alive() override;
void precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeadersUpdatedMessage &&message) override;
+ void progress(ClangBackEnd::ProgressMessage &&message) override;
void precompiledHeaderRemoved(const QString &projectPartId);
@@ -74,6 +78,7 @@ private:
ClangBackEnd::ProjectPartPchs m_projectPartPchs;
std::vector<PchManagerNotifierInterface*> m_notifiers;
PchManagerConnectionClient *m_connectionClient=nullptr;
+ ProgressManagerInterface &m_progressManager;
};
} // namespace ClangPchManager
diff --git a/src/plugins/clangpchmanager/progressmanager.h b/src/plugins/clangpchmanager/progressmanager.h
new file mode 100644
index 00000000000..cc6ab1946cb
--- /dev/null
+++ b/src/plugins/clangpchmanager/progressmanager.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include "progressmanagerinterface.h"
+
+#include <QFutureInterface>
+#include <QCoreApplication>
+#include <QString>
+
+#include <functional>
+#include <memory>
+
+namespace ClangPchManager {
+
+class ProgressManager : public ProgressManagerInterface
+{
+public:
+ using Promise = QFutureInterface<void>;
+ using Callback = std::function<void(Promise &)>;
+
+ ProgressManager(Callback &&callback)
+ : m_callback(std::move(callback))
+ {}
+
+
+ void setProgress(int currentProgress, int maximumProgress)
+ {
+ if (!m_promise)
+ initialize();
+
+ m_promise->setExpectedResultCount(maximumProgress);
+ m_promise->setProgressValue(currentProgress);
+
+ if (currentProgress >= maximumProgress)
+ finish();
+ }
+
+ Promise *promise()
+ {
+ return m_promise.get();
+ }
+private:
+ void initialize()
+ {
+ m_promise = std::make_unique<Promise>();
+ m_callback(*m_promise);
+ }
+
+ void finish()
+ {
+ m_promise->reportFinished();
+ m_promise.reset();
+ }
+
+private:
+ Callback m_callback;
+ std::unique_ptr<Promise> m_promise;
+};
+
+} // namespace ClangPchManager
diff --git a/src/plugins/clangpchmanager/progressmanagerinterface.h b/src/plugins/clangpchmanager/progressmanagerinterface.h
new file mode 100644
index 00000000000..5653e5cd7f5
--- /dev/null
+++ b/src/plugins/clangpchmanager/progressmanagerinterface.h
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+namespace ClangPchManager {
+
+class ProgressManagerInterface
+{
+public:
+ virtual void setProgress(int currentProgress, int maximumProgress) = 0;
+
+protected:
+ ~ProgressManagerInterface() = default;
+};
+
+} // namespace ClangPchManager