ui: Indexing UI
* Added DialogView with QtDialogView implementation to handle information dialogs * Implemented QtIndexingDialog class that covers all different dialogs for indexing * Directly communicate with DialogView from Prpject and all Tasks involved in indexing * Block QtMainWindow UI while indexing
This commit is contained in:
+23
-18
@@ -13,6 +13,7 @@
|
||||
#include "utility/UserPaths.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "component/controller/NetworkFactory.h"
|
||||
#include "component/view/MainView.h"
|
||||
@@ -113,12 +114,12 @@ bool Application::hasGUI()
|
||||
|
||||
int Application::handleDialog(const std::string& message)
|
||||
{
|
||||
return m_mainView->confirm(message);
|
||||
return getDialogView()->confirm(message);
|
||||
}
|
||||
|
||||
int Application::handleDialog(const std::string& message, const std::vector<std::string>& options)
|
||||
{
|
||||
return m_mainView->confirm(message, options);
|
||||
return getDialogView()->confirm(message, options);
|
||||
}
|
||||
|
||||
void Application::setTitle(const std::string& title)
|
||||
@@ -135,7 +136,7 @@ void Application::createAndLoadProject(const FilePath& projectSettingsFilePath)
|
||||
|
||||
m_storageCache->clear();
|
||||
|
||||
m_project = Project::create(projectSettingsFilePath, m_storageCache.get());
|
||||
m_project = Project::create(projectSettingsFilePath, m_storageCache.get(), getDialogView());
|
||||
|
||||
if (m_project)
|
||||
{
|
||||
@@ -163,21 +164,14 @@ void Application::createAndLoadProject(const FilePath& projectSettingsFilePath)
|
||||
|
||||
void Application::refreshProject(bool force)
|
||||
{
|
||||
MessageStatus("Refreshing Project").dispatch();
|
||||
|
||||
m_storageCache->clear();
|
||||
if (m_hasGUI)
|
||||
bool indexing = m_project->refresh(force);
|
||||
if (indexing)
|
||||
{
|
||||
m_componentManager->refreshViews();
|
||||
}
|
||||
|
||||
if (force)
|
||||
{
|
||||
m_project->forceRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_project->refresh();
|
||||
m_storageCache->clear();
|
||||
if (m_hasGUI)
|
||||
{
|
||||
m_componentManager->refreshViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +211,7 @@ void Application::handleMessage(MessageLoadProject* message)
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = m_mainView->confirm(
|
||||
int result = handleDialog(
|
||||
"Some settings were changed, the project needs to be fully reindexed. "
|
||||
"Do you want to reindex the project?", options);
|
||||
|
||||
@@ -301,3 +295,14 @@ void Application::updateRecentProjects(const FilePath& projectSettingsFilePath)
|
||||
m_mainView->updateRecentProjectMenu();
|
||||
}
|
||||
}
|
||||
|
||||
DialogView* Application::getDialogView() const
|
||||
{
|
||||
if (m_componentManager)
|
||||
{
|
||||
return m_componentManager->getDialogView();
|
||||
}
|
||||
|
||||
static DialogView dialogView;
|
||||
return &dialogView;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,13 @@
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
|
||||
class DialogView;
|
||||
class IDECommunicationController;
|
||||
class NetworkFactory;
|
||||
class ViewFactory;
|
||||
class MainView;
|
||||
class NetworkFactory;
|
||||
class StorageCache;
|
||||
class Version;
|
||||
class ViewFactory;
|
||||
|
||||
class Application
|
||||
: public MessageListener<MessageActivateWindow>
|
||||
@@ -63,6 +64,8 @@ private:
|
||||
|
||||
void updateRecentProjects(const FilePath& projectSettingsFilePath);
|
||||
|
||||
DialogView* getDialogView() const;
|
||||
|
||||
const bool m_hasGUI;
|
||||
std::shared_ptr<Project> m_project;
|
||||
std::shared_ptr<StorageCache> m_storageCache;
|
||||
|
||||
@@ -43,6 +43,8 @@ add_files(
|
||||
component/view/CodeView.h
|
||||
component/view/CompositeView.cpp
|
||||
component/view/CompositeView.h
|
||||
component/view/DialogView.cpp
|
||||
component/view/DialogView.h
|
||||
component/view/GraphView.cpp
|
||||
component/view/GraphView.h
|
||||
component/view/GraphViewStyle.cpp
|
||||
|
||||
+9
-14
@@ -1,21 +1,15 @@
|
||||
#include "CxxProject.h"
|
||||
|
||||
|
||||
#include "data/parser/cxx/TaskParseCxx.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
|
||||
|
||||
#include "data/parser/cxx/TaskParseCxx.h"
|
||||
|
||||
|
||||
|
||||
CxxProject::~CxxProject()
|
||||
{
|
||||
}
|
||||
@@ -30,8 +24,10 @@ const std::shared_ptr<ProjectSettings> CxxProject::getProjectSettings() const
|
||||
return m_projectSettings;
|
||||
}
|
||||
|
||||
CxxProject::CxxProject(std::shared_ptr<CxxProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy)
|
||||
: Project(storageAccessProxy)
|
||||
CxxProject::CxxProject(
|
||||
std::shared_ptr<CxxProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
|
||||
)
|
||||
: Project(storageAccessProxy, dialogView)
|
||||
, m_projectSettings(projectSettings)
|
||||
{
|
||||
}
|
||||
@@ -66,7 +62,8 @@ std::shared_ptr<Task> CxxProject::createIndexerTask(
|
||||
storage,
|
||||
storageMutex,
|
||||
fileRegister,
|
||||
getParserArguments()
|
||||
getParserArguments(),
|
||||
getDialogView()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,5 +125,3 @@ Parser::Arguments CxxProject::getParserArguments() const
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,11 @@ protected:
|
||||
virtual const std::shared_ptr<ProjectSettings> getProjectSettings() const;
|
||||
|
||||
private:
|
||||
CxxProject(std::shared_ptr<CxxProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy);
|
||||
CxxProject(
|
||||
std::shared_ptr<CxxProjectSettings> projectSettings,
|
||||
StorageAccessProxy* storageAccessProxy,
|
||||
DialogView* dialogView
|
||||
);
|
||||
CxxProject(const CxxProject&);
|
||||
|
||||
virtual bool allowsRefresh();
|
||||
|
||||
@@ -18,8 +18,10 @@ const std::shared_ptr<ProjectSettings> JavaProject::getProjectSettings() const
|
||||
return m_projectSettings;
|
||||
}
|
||||
|
||||
JavaProject::JavaProject(std::shared_ptr<JavaProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy)
|
||||
: Project(storageAccessProxy)
|
||||
JavaProject::JavaProject(
|
||||
std::shared_ptr<JavaProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
|
||||
)
|
||||
: Project(storageAccessProxy, dialogView)
|
||||
, m_projectSettings(projectSettings)
|
||||
{
|
||||
if (!JavaEnvironmentFactory::getInstance() && !isTrial())
|
||||
@@ -69,7 +71,8 @@ std::shared_ptr<Task> JavaProject::createIndexerTask(
|
||||
storage,
|
||||
storageMutex,
|
||||
fileRegister,
|
||||
arguments
|
||||
arguments,
|
||||
getDialogView()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,11 @@ protected:
|
||||
virtual const std::shared_ptr<ProjectSettings> getProjectSettings() const;
|
||||
|
||||
private:
|
||||
JavaProject(std::shared_ptr<JavaProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy);
|
||||
JavaProject(
|
||||
std::shared_ptr<JavaProjectSettings> projectSettings,
|
||||
StorageAccessProxy* storageAccessProxy,
|
||||
DialogView* dialogView
|
||||
);
|
||||
JavaProject(const JavaProject&);
|
||||
|
||||
virtual std::shared_ptr<Task> createIndexerTask(
|
||||
|
||||
+61
-29
@@ -1,12 +1,12 @@
|
||||
#include "Project.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/access/StorageAccessProxy.h"
|
||||
#include "data/graph/Token.h"
|
||||
#include "data/parser/cxx/TaskParseWrapper.h"
|
||||
#include "data/parser/java/TaskParseJava.h"
|
||||
#include "data/PersistentStorage.h"
|
||||
#include "data/TaskCleanStorage.h"
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/scheduling/TaskGroupSequential.h"
|
||||
#include "utility/scheduling/TaskGroupParallel.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
@@ -26,7 +27,8 @@
|
||||
#include "JavaProject.h"
|
||||
#include "isTrial.h"
|
||||
|
||||
std::shared_ptr<Project> Project::create(const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy)
|
||||
std::shared_ptr<Project> Project::create(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView)
|
||||
{
|
||||
std::shared_ptr<Project> project;
|
||||
|
||||
@@ -36,14 +38,14 @@ std::shared_ptr<Project> Project::create(const FilePath& projectSettingsFile, St
|
||||
case LANGUAGE_CPP:
|
||||
{
|
||||
project = std::shared_ptr<CxxProject>(new CxxProject(
|
||||
std::make_shared<CxxProjectSettings>(projectSettingsFile), storageAccessProxy
|
||||
std::make_shared<CxxProjectSettings>(projectSettingsFile), storageAccessProxy, dialogView
|
||||
));
|
||||
}
|
||||
break;
|
||||
case LANGUAGE_JAVA:
|
||||
{
|
||||
project = std::shared_ptr<JavaProject>(new JavaProject(
|
||||
std::make_shared<JavaProjectSettings>(projectSettingsFile), storageAccessProxy
|
||||
std::make_shared<JavaProjectSettings>(projectSettingsFile), storageAccessProxy, dialogView
|
||||
));
|
||||
}
|
||||
break;
|
||||
@@ -60,7 +62,7 @@ Project::~Project()
|
||||
{
|
||||
}
|
||||
|
||||
void Project::refresh()
|
||||
bool Project::refresh(bool forceRefresh)
|
||||
{
|
||||
if (allowsRefresh())
|
||||
{
|
||||
@@ -68,19 +70,14 @@ void Project::refresh()
|
||||
|
||||
updateFileManager(m_fileManager);
|
||||
|
||||
buildIndex();
|
||||
|
||||
m_state = PROJECT_STATE_LOADED;
|
||||
if (buildIndex(forceRefresh))
|
||||
{
|
||||
m_state = PROJECT_STATE_LOADED;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Project::forceRefresh()
|
||||
{
|
||||
if (allowsRefresh())
|
||||
{
|
||||
clearStorage();
|
||||
}
|
||||
refresh();
|
||||
return false;
|
||||
}
|
||||
|
||||
FilePath Project::getProjectSettingsFilePath() const
|
||||
@@ -108,12 +105,18 @@ void Project::logStats() const
|
||||
m_storage->logStats();
|
||||
}
|
||||
|
||||
Project::Project(StorageAccessProxy* storageAccessProxy)
|
||||
Project::Project(StorageAccessProxy* storageAccessProxy, DialogView* dialogView)
|
||||
: m_storageAccessProxy(storageAccessProxy)
|
||||
, m_dialogView(dialogView)
|
||||
, m_state(PROJECT_STATE_NOT_LOADED)
|
||||
{
|
||||
}
|
||||
|
||||
DialogView* Project::getDialogView() const
|
||||
{
|
||||
return m_dialogView;
|
||||
}
|
||||
|
||||
void Project::load()
|
||||
{
|
||||
const std::shared_ptr<ProjectSettings> projectSettings = getProjectSettings();
|
||||
@@ -151,7 +154,7 @@ void Project::load()
|
||||
switch (m_state)
|
||||
{
|
||||
case PROJECT_STATE_EMPTY:
|
||||
buildIndex();
|
||||
buildIndex(false);
|
||||
m_state = PROJECT_STATE_LOADED;
|
||||
break;
|
||||
case PROJECT_STATE_OUTDATED:
|
||||
@@ -169,7 +172,8 @@ void Project::load()
|
||||
// dont break here.
|
||||
case PROJECT_STATE_LOADED:
|
||||
m_storage->finishParsing();
|
||||
MessageFinishedParsing(0, 0, 0, true).dispatch();
|
||||
MessageFinishedParsing().dispatch();
|
||||
MessageStatus("Finished Loading", false, false).dispatch();
|
||||
break;
|
||||
case PROJECT_STATE_OUTVERSIONED:
|
||||
MessageStatus("Can't load project").dispatch();
|
||||
@@ -193,7 +197,7 @@ void Project::load()
|
||||
|
||||
if (reparse)
|
||||
{
|
||||
forceRefresh();
|
||||
refresh(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,17 +218,21 @@ void Project::clearStorage()
|
||||
}
|
||||
}
|
||||
|
||||
void Project::buildIndex()
|
||||
bool Project::buildIndex(bool forceRefresh)
|
||||
{
|
||||
m_storage->setProjectSettingsText(TextAccess::createFromFile(getProjectSettingsFilePath().str())->getText());
|
||||
m_fileManager.fetchFilePaths(
|
||||
forceRefresh ? std::vector<FileInfo>() : m_storage->getInfoOnAllFiles()
|
||||
);
|
||||
|
||||
m_fileManager.fetchFilePaths(m_storage->getInfoOnAllFiles());
|
||||
std::set<FilePath> addedFilePaths = m_fileManager.getAddedFilePaths();
|
||||
std::set<FilePath> updatedFilePaths = m_fileManager.getUpdatedFilePaths();
|
||||
std::set<FilePath> removedFilePaths = m_fileManager.getRemovedFilePaths();
|
||||
|
||||
utility::append(updatedFilePaths, m_storage->getDependingFilePaths(updatedFilePaths));
|
||||
utility::append(updatedFilePaths, m_storage->getDependingFilePaths(removedFilePaths));
|
||||
if (!forceRefresh)
|
||||
{
|
||||
utility::append(updatedFilePaths, m_storage->getDependingFilePaths(updatedFilePaths));
|
||||
utility::append(updatedFilePaths, m_storage->getDependingFilePaths(removedFilePaths));
|
||||
}
|
||||
|
||||
std::vector<FilePath> filesToClean;
|
||||
filesToClean.insert(filesToClean.end(), removedFilePaths.begin(), removedFilePaths.end());
|
||||
@@ -237,12 +245,33 @@ void Project::buildIndex()
|
||||
|
||||
if (!filesToClean.size() && !filesToParse.size())
|
||||
{
|
||||
MessageFinishedParsing(0, 0, 0, true).dispatch();
|
||||
return;
|
||||
MessageStatus("Nothing to refresh, all files are up-to-date.").dispatch();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
bool doIndex = m_dialogView->startIndexingDialog(filesToClean.size(), filesToParse.size());
|
||||
|
||||
if (!doIndex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (forceRefresh)
|
||||
{
|
||||
clearStorage();
|
||||
}
|
||||
|
||||
m_storage->setProjectSettingsText(TextAccess::createFromFile(getProjectSettingsFilePath().str())->getText());
|
||||
|
||||
std::shared_ptr<TaskGroupSequential> taskSequential = std::make_shared<TaskGroupSequential>();
|
||||
taskSequential->addTask(std::make_shared<TaskCleanStorage>(m_storage.get(), filesToClean));
|
||||
|
||||
if (filesToClean.size())
|
||||
{
|
||||
taskSequential->addTask(std::make_shared<TaskCleanStorage>(m_storage.get(), filesToClean, m_dialogView));
|
||||
}
|
||||
|
||||
int indexerThreadCount = ApplicationSettings::getInstance()->getIndexerThreadCount();
|
||||
|
||||
@@ -251,7 +280,8 @@ void Project::buildIndex()
|
||||
|
||||
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(
|
||||
m_storage.get(),
|
||||
fileRegister
|
||||
fileRegister,
|
||||
m_dialogView
|
||||
);
|
||||
taskSequential->addTask(taskParserWrapper);
|
||||
|
||||
@@ -266,6 +296,8 @@ void Project::buildIndex()
|
||||
}
|
||||
|
||||
Task::dispatch(taskSequential);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Project::allowsRefresh()
|
||||
|
||||
+8
-5
@@ -10,6 +10,7 @@
|
||||
#include "settings/ProjectSettings.h" // todo: use forward declaration here
|
||||
#include "utility/scheduling/Task.h"
|
||||
|
||||
class DialogView;
|
||||
class PersistentStorage;
|
||||
class StorageAccessProxy;
|
||||
class FileRegister;
|
||||
@@ -17,12 +18,12 @@ class FileRegister;
|
||||
class Project
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<Project> create(const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy);
|
||||
static std::shared_ptr<Project> create(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView);
|
||||
|
||||
virtual ~Project();
|
||||
|
||||
void refresh();
|
||||
void forceRefresh();
|
||||
bool refresh(bool forceRefresh);
|
||||
|
||||
FilePath getProjectSettingsFilePath() const;
|
||||
LanguageType getLanguage() const;
|
||||
@@ -31,7 +32,8 @@ public:
|
||||
void logStats() const;
|
||||
|
||||
protected:
|
||||
Project(StorageAccessProxy* storageAccessProxy);
|
||||
Project(StorageAccessProxy* storageAccessProxy, DialogView* dialogView);
|
||||
DialogView* getDialogView() const;
|
||||
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings() = 0;
|
||||
virtual const std::shared_ptr<ProjectSettings> getProjectSettings() const = 0;
|
||||
@@ -50,7 +52,7 @@ private:
|
||||
|
||||
void load();
|
||||
void clearStorage();
|
||||
void buildIndex();
|
||||
bool buildIndex(bool forceRefresh);
|
||||
|
||||
virtual bool allowsRefresh();
|
||||
virtual std::shared_ptr<Task> createIndexerTask(
|
||||
@@ -60,6 +62,7 @@ private:
|
||||
virtual void updateFileManager(FileManager& fileManager) = 0;
|
||||
|
||||
StorageAccessProxy* const m_storageAccessProxy;
|
||||
DialogView* m_dialogView;
|
||||
|
||||
ProjectStateType m_state;
|
||||
FileManager m_fileManager;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "component/controller/Controller.h"
|
||||
#include "component/view/CodeView.h"
|
||||
#include "component/view/CompositeView.h"
|
||||
#include "component/view/DialogView.h"
|
||||
#include "component/view/GraphView.h"
|
||||
#include "component/view/RefreshView.h"
|
||||
#include "component/view/SearchView.h"
|
||||
@@ -50,6 +51,8 @@ void ComponentManager::setup(ViewLayout* viewLayout)
|
||||
|
||||
std::shared_ptr<Component> featureComponent = m_componentFactory->createFeatureComponent();
|
||||
m_components.push_back(featureComponent);
|
||||
|
||||
m_dialogView = m_componentFactory->getViewFactory()->createDialogView(viewLayout);
|
||||
}
|
||||
|
||||
void ComponentManager::clearComponents()
|
||||
@@ -83,6 +86,11 @@ void ComponentManager::refreshViews()
|
||||
}
|
||||
}
|
||||
|
||||
DialogView* ComponentManager::getDialogView() const
|
||||
{
|
||||
return m_dialogView.get();
|
||||
}
|
||||
|
||||
ComponentManager::ComponentManager()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "component/ComponentFactory.h"
|
||||
|
||||
class CompositeView;
|
||||
class DialogView;
|
||||
class NetworkFactory;
|
||||
class StorageAccess;
|
||||
class View;
|
||||
@@ -26,6 +27,8 @@ public:
|
||||
void clearComponents();
|
||||
void refreshViews();
|
||||
|
||||
DialogView* getDialogView() const;
|
||||
|
||||
private:
|
||||
ComponentManager();
|
||||
ComponentManager(const ComponentManager&);
|
||||
@@ -34,6 +37,8 @@ private:
|
||||
|
||||
std::vector<std::shared_ptr<CompositeView>> m_compositeViews;
|
||||
std::vector<std::shared_ptr<Component>> m_components;
|
||||
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
};
|
||||
|
||||
#endif // COMPONENT_MANAGER_H
|
||||
|
||||
@@ -32,15 +32,6 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
ErrorCountInfo errorCount = m_storageAccess->getErrorCount();
|
||||
getView()->setErrorCount(errorCount);
|
||||
|
||||
std::string status = message->getStatusStr();
|
||||
status += "; " + std::to_string(errorCount.total) + " error" + (errorCount.total != 1 ? "s" : "");
|
||||
if (errorCount.fatal > 0)
|
||||
{
|
||||
status += " (" + std::to_string(errorCount.fatal) + " fatal)";
|
||||
}
|
||||
|
||||
MessageStatus(status, false).dispatch();
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageRefresh* message)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "component/view/DialogView.h"
|
||||
|
||||
DialogView::DialogView()
|
||||
{
|
||||
}
|
||||
|
||||
DialogView::~DialogView()
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::showProgressDialog(const std::string& title, const std::string& message)
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::hideProgressDialog()
|
||||
{
|
||||
}
|
||||
|
||||
bool DialogView::startIndexingDialog(size_t cleanFileCount, size_t indexFileCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void DialogView::updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath)
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo)
|
||||
{
|
||||
}
|
||||
|
||||
int DialogView::confirm(const std::string& message)
|
||||
{
|
||||
return confirm(message, std::vector<std::string>());
|
||||
}
|
||||
|
||||
int DialogView::confirm(const std::string& message, const std::vector<std::string>& options)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef DIALOG_VIEW_H
|
||||
#define DIALOG_VIEW_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
|
||||
class DialogView
|
||||
{
|
||||
public:
|
||||
DialogView();
|
||||
virtual ~DialogView();
|
||||
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message);
|
||||
virtual void hideProgressDialog();
|
||||
|
||||
virtual bool startIndexingDialog(size_t cleanFileCount, size_t indexFileCount);
|
||||
virtual void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath);
|
||||
virtual void finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo);
|
||||
|
||||
int confirm(const std::string& message);
|
||||
virtual int confirm(const std::string& message, const std::vector<std::string>& options);
|
||||
};
|
||||
|
||||
#endif // DIALOG_VIEW_H
|
||||
@@ -7,8 +7,3 @@ MainView::MainView()
|
||||
MainView::~MainView()
|
||||
{
|
||||
}
|
||||
|
||||
int MainView::confirm(const std::string& message)
|
||||
{
|
||||
return confirm(message, std::vector<std::string>());
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@ public:
|
||||
virtual void setTitle(const std::string& title) = 0;
|
||||
virtual void activateWindow() = 0;
|
||||
virtual void updateRecentProjectMenu() = 0;
|
||||
|
||||
virtual int confirm(const std::string& message);
|
||||
virtual int confirm(const std::string& message, const std::vector<std::string>& options) = 0;
|
||||
};
|
||||
|
||||
#endif // MAIN_VIEW_H
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "component/view/CompositeView.h"
|
||||
|
||||
class CodeView;
|
||||
class DialogView;
|
||||
class GraphView;
|
||||
class MainView;
|
||||
class RefreshView;
|
||||
@@ -30,6 +31,8 @@ public:
|
||||
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<StatusBarView> createStatusBarView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<UndoRedoView> createUndoRedoView(ViewLayout* viewLayout) const = 0;
|
||||
|
||||
virtual std::shared_ptr<DialogView> createDialogView(ViewLayout* viewLayout) const = 0;
|
||||
};
|
||||
|
||||
#endif // VIEW_FACTORY_H
|
||||
|
||||
@@ -366,6 +366,8 @@ void PersistentStorage::logStats() const
|
||||
|
||||
void PersistentStorage::startParsing()
|
||||
{
|
||||
clearCaches();
|
||||
|
||||
MessageClearErrorCount().dispatch();
|
||||
|
||||
m_sqliteStorage.setVersion();
|
||||
|
||||
@@ -1,58 +1,44 @@
|
||||
#include "data/TaskCleanStorage.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/PersistentStorage.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
TaskCleanStorage::TaskCleanStorage(PersistentStorage* storage, const std::vector<FilePath>& filePaths)
|
||||
TaskCleanStorage::TaskCleanStorage(
|
||||
PersistentStorage* storage, const std::vector<FilePath>& filePaths, DialogView* dialogView
|
||||
)
|
||||
: m_storage(storage)
|
||||
, m_filePaths(filePaths)
|
||||
, m_fileCount(filePaths.size())
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskCleanStorage::enter()
|
||||
{
|
||||
m_start = utility::durationStart();
|
||||
m_dialogView->showProgressDialog("Clearing Files", std::to_string(m_filePaths.size()) + " Files");
|
||||
}
|
||||
|
||||
Task::TaskState TaskCleanStorage::update()
|
||||
{
|
||||
if (m_filePaths.size())
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "clearing " << m_filePaths.size() << " files (ESC to quit)";
|
||||
MessageStatus(ss.str(), false, true).dispatch();
|
||||
m_storage->clearFileElements(m_filePaths);
|
||||
|
||||
m_storage->clearFileElements(m_filePaths);
|
||||
|
||||
m_filePaths.clear();
|
||||
|
||||
return Task::STATE_RUNNING;
|
||||
}
|
||||
|
||||
if (m_fileCount)
|
||||
{
|
||||
MessageStatus("Clearing caches (ESC to quit)", false, true).dispatch();
|
||||
m_storage->clearCaches();
|
||||
}
|
||||
m_filePaths.clear();
|
||||
|
||||
return Task::STATE_FINISHED;
|
||||
}
|
||||
|
||||
void TaskCleanStorage::exit()
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "clearing files done, ";
|
||||
ss << std::setprecision(2) << std::fixed << utility::duration(m_start) << " seconds";
|
||||
MessageStatus(ss.str()).dispatch();
|
||||
m_dialogView->hideProgressDialog();
|
||||
}
|
||||
|
||||
void TaskCleanStorage::interrupt()
|
||||
{
|
||||
MessageStatus("clearing files interrupted", false, true).dispatch();
|
||||
}
|
||||
|
||||
void TaskCleanStorage::revert()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskCleanStorage::abort()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/scheduling/Task.h"
|
||||
#include "utility/TimePoint.h"
|
||||
|
||||
class DialogView;
|
||||
class PersistentStorage;
|
||||
|
||||
class TaskCleanStorage
|
||||
@@ -15,7 +15,8 @@ class TaskCleanStorage
|
||||
public:
|
||||
TaskCleanStorage(
|
||||
PersistentStorage* storage,
|
||||
const std::vector<FilePath>& filePaths
|
||||
const std::vector<FilePath>& filePaths,
|
||||
DialogView* dialogView
|
||||
);
|
||||
|
||||
virtual void enter();
|
||||
@@ -24,13 +25,12 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
PersistentStorage* m_storage;
|
||||
std::vector<FilePath> m_filePaths;
|
||||
const size_t m_fileCount;
|
||||
|
||||
TimePoint m_start;
|
||||
DialogView* m_dialogView;
|
||||
};
|
||||
|
||||
#endif // TASK_PARSE_CXX_H
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
#include "utility/scheduling/Task.h"
|
||||
#include "utility/TimePoint.h"
|
||||
|
||||
class PersistentStorage;
|
||||
class FileRegister;
|
||||
class CxxParser;
|
||||
class DialogView;
|
||||
class FileRegister;
|
||||
class PersistentStorage;
|
||||
|
||||
namespace clang
|
||||
{
|
||||
@@ -32,7 +33,8 @@ public:
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
const Parser::Arguments& arguments
|
||||
const Parser::Arguments& arguments,
|
||||
DialogView* dialogView
|
||||
);
|
||||
|
||||
virtual void enter();
|
||||
@@ -41,13 +43,17 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
PersistentStorage* m_storage;
|
||||
std::shared_ptr<std::mutex> m_storageMutex;
|
||||
|
||||
const Parser::Arguments m_arguments;
|
||||
DialogView* m_dialogView;
|
||||
|
||||
std::shared_ptr<CxxParser> m_parser;
|
||||
std::shared_ptr<ParserClientImpl> m_parserClient;
|
||||
const Parser::Arguments m_arguments;
|
||||
|
||||
bool m_isCDB;
|
||||
std::shared_ptr<clang::tooling::JSONCompilationDatabase> m_cdb;
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
#include "utility/scheduling/TaskDecorator.h"
|
||||
#include "utility/TimePoint.h"
|
||||
|
||||
class PersistentStorage;
|
||||
class DialogView;
|
||||
class FileRegister;
|
||||
class PersistentStorage;
|
||||
|
||||
class TaskParseWrapper
|
||||
: public TaskDecorator
|
||||
@@ -17,7 +18,8 @@ class TaskParseWrapper
|
||||
public:
|
||||
TaskParseWrapper(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<FileRegister> fileRegister
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
DialogView* dialogView
|
||||
);
|
||||
virtual ~TaskParseWrapper();
|
||||
|
||||
@@ -27,10 +29,13 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
PersistentStorage* m_storage;
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
DialogView* m_dialogView;
|
||||
|
||||
TimePoint m_start;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "data/parser/Parser.h"
|
||||
#include "utility/scheduling/Task.h"
|
||||
|
||||
class DialogView;
|
||||
class FileRegister;
|
||||
class PersistentStorage;
|
||||
|
||||
@@ -17,7 +18,8 @@ public:
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
const Parser::Arguments& arguments
|
||||
const Parser::Arguments& arguments,
|
||||
DialogView* dialogView
|
||||
);
|
||||
|
||||
virtual void enter();
|
||||
@@ -26,12 +28,14 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
PersistentStorage* m_storage;
|
||||
std::shared_ptr<std::mutex> m_storageMutex;
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
Parser::Arguments m_arguments;
|
||||
DialogView* m_dialogView;
|
||||
};
|
||||
|
||||
#endif // TASK_PARSE_JAVA_H
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#include "TimePoint.h"
|
||||
|
||||
TimePoint TimePoint::now()
|
||||
{
|
||||
return TimePoint(boost::posix_time::microsec_clock::local_time());
|
||||
}
|
||||
|
||||
TimePoint::TimePoint()
|
||||
: m_time(boost::posix_time::not_a_date_time)
|
||||
{
|
||||
@@ -37,4 +42,9 @@ std::string TimePoint::toString() const
|
||||
stream.imbue(std::locale(std::locale::classic(), facet));
|
||||
stream << m_time;
|
||||
return stream.str();
|
||||
}
|
||||
}
|
||||
|
||||
size_t TimePoint::deltaMS(const TimePoint& other) const
|
||||
{
|
||||
return (m_time - other.m_time).total_milliseconds();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
class TimePoint
|
||||
{
|
||||
public:
|
||||
static TimePoint now();
|
||||
|
||||
TimePoint();
|
||||
TimePoint(boost::posix_time::ptime t);
|
||||
//TimePoint(time_t t);
|
||||
@@ -22,7 +24,9 @@ public:
|
||||
inline bool operator<=(const TimePoint& rhs){ return m_time <= rhs.m_time; }
|
||||
inline bool operator>=(const TimePoint& rhs){ return m_time >= rhs.m_time; }
|
||||
|
||||
inline float operator-(const TimePoint& rhs){ return (m_time - rhs.m_time).total_milliseconds() / 1000.0f; }
|
||||
inline float operator-(const TimePoint& rhs){ return deltaMS(rhs) / 1000.0f; }
|
||||
|
||||
size_t deltaMS(const TimePoint& other) const;
|
||||
|
||||
private:
|
||||
boost::posix_time::ptime m_time;
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
#ifndef MESSAGE_FINISHED_PARSING_H
|
||||
#define MESSAGE_FINISHED_PARSING_H
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
class MessageFinishedParsing
|
||||
: public Message<MessageFinishedParsing>
|
||||
{
|
||||
public:
|
||||
MessageFinishedParsing(size_t fileCount, size_t totalFileCount, float parseTime, bool loadedOnly = false)
|
||||
: fileCount(fileCount)
|
||||
, totalFileCount(totalFileCount)
|
||||
, parseTime(parseTime)
|
||||
, loadedOnly(loadedOnly)
|
||||
MessageFinishedParsing()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,55 +15,6 @@ public:
|
||||
{
|
||||
return "MessageFinishedParsing";
|
||||
}
|
||||
|
||||
std::string getStatusStr() const
|
||||
{
|
||||
if (loadedOnly)
|
||||
{
|
||||
return "Finished loading";
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Finished indexing: ";
|
||||
ss << fileCount << "/" << totalFileCount << " files; ";
|
||||
|
||||
float secondsLeft = parseTime;
|
||||
int hours = int(secondsLeft / 3600);
|
||||
secondsLeft -= hours * 3600;
|
||||
int minutes = int(secondsLeft / 60);
|
||||
secondsLeft -= minutes * 60;
|
||||
int seconds = int(secondsLeft);
|
||||
secondsLeft -= seconds;
|
||||
int milliSeconds = secondsLeft * 1000;
|
||||
|
||||
if (hours > 9)
|
||||
{
|
||||
ss << hours;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << std::setw(2) << std::setfill('0') << hours;
|
||||
}
|
||||
ss << ":" << std::setw(2) << std::setfill('0') << minutes;
|
||||
ss << ":" << std::setw(2) << std::setfill('0') << seconds;
|
||||
|
||||
if (!hours && !minutes)
|
||||
{
|
||||
ss << ":" << std::setw(3) << std::setfill('0') << milliSeconds;
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << getStatusStr();
|
||||
}
|
||||
|
||||
size_t fileCount;
|
||||
size_t totalFileCount;
|
||||
float parseTime;
|
||||
bool loadedOnly;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_FINISHED_PARSING_H
|
||||
|
||||
@@ -62,6 +62,8 @@ Task::TaskState Task::interruptTask()
|
||||
switch (m_state)
|
||||
{
|
||||
case STATE_NEW:
|
||||
abort();
|
||||
break;
|
||||
case STATE_CANCELED:
|
||||
break;
|
||||
case STATE_RUNNING:
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
|
||||
virtual void interrupt() = 0;
|
||||
virtual void revert() = 0;
|
||||
virtual void abort() = 0;
|
||||
|
||||
protected:
|
||||
void setState(TaskState state);
|
||||
|
||||
@@ -62,6 +62,11 @@ void TaskGroupParallel::revert()
|
||||
m_interrupt = true;
|
||||
}
|
||||
|
||||
void TaskGroupParallel::abort()
|
||||
{
|
||||
m_interrupt = true;
|
||||
}
|
||||
|
||||
|
||||
void TaskGroupParallel::processTaskThreaded(std::shared_ptr<Task> task)
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
void processTaskThreaded(std::shared_ptr<Task> task);
|
||||
|
||||
@@ -43,12 +43,9 @@ void TaskGroupSequential::exit()
|
||||
|
||||
void TaskGroupSequential::interrupt()
|
||||
{
|
||||
if (m_taskIndex >= 0 && size_t(m_taskIndex) < m_tasks.size())
|
||||
for (size_t i = 0; i < m_tasks.size(); i++)
|
||||
{
|
||||
for (int i = m_taskIndex; i >= 0; i--)
|
||||
{
|
||||
m_tasks[i]->interruptTask();
|
||||
}
|
||||
m_tasks[i]->interruptTask();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,3 +56,8 @@ void TaskGroupSequential::revert()
|
||||
m_tasks[i]->interruptTask();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskGroupSequential::abort()
|
||||
{
|
||||
interrupt();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
int m_taskIndex;
|
||||
|
||||
@@ -30,3 +30,7 @@ void TaskLambda::interrupt()
|
||||
void TaskLambda::revert()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskLambda::abort()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
std::function<void()> m_func;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#include "utility/utility.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include "boost/date_time/time_clock.hpp"
|
||||
|
||||
TimePoint utility::durationStart()
|
||||
{
|
||||
return TimePoint(boost::posix_time::microsec_clock::local_time());
|
||||
return TimePoint::now();
|
||||
}
|
||||
|
||||
float utility::duration(const TimePoint& start)
|
||||
@@ -33,6 +37,37 @@ std::string utility::timeToString(const boost::posix_time::ptime time)
|
||||
return TimePoint(time).toString();
|
||||
}
|
||||
|
||||
std::string utility::timeToString(float secondsTotal)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
int hours = int(secondsTotal / 3600);
|
||||
secondsTotal -= hours * 3600;
|
||||
int minutes = int(secondsTotal / 60);
|
||||
secondsTotal -= minutes * 60;
|
||||
int seconds = int(secondsTotal);
|
||||
secondsTotal -= seconds;
|
||||
int milliSeconds = secondsTotal * 1000;
|
||||
|
||||
if (hours > 9)
|
||||
{
|
||||
ss << hours;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << std::setw(2) << std::setfill('0') << hours;
|
||||
}
|
||||
ss << ":" << std::setw(2) << std::setfill('0') << minutes;
|
||||
ss << ":" << std::setw(2) << std::setfill('0') << seconds;
|
||||
|
||||
if (!hours && !minutes)
|
||||
{
|
||||
ss << ":" << std::setw(3) << std::setfill('0') << milliSeconds;
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool utility::intersectionPoint(Vec2f a1, Vec2f b1, Vec2f a2, Vec2f b2, Vec2f* i)
|
||||
{
|
||||
Vec2f p = a1;
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace utility
|
||||
|
||||
std::string timeToString(const time_t time);
|
||||
std::string timeToString(const boost::posix_time::ptime time);
|
||||
std::string timeToString(float seconds);
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> concat(const std::vector<T>& a, const std::vector<T>& b);
|
||||
|
||||
Reference in New Issue
Block a user