ui: file clearing progress
* display some progress information when clearing files
This commit is contained in:
@@ -192,8 +192,8 @@ add_files(
|
||||
data/TaskFinishParsing.h
|
||||
data/TaskInjectStorage.cpp
|
||||
data/TaskInjectStorage.h
|
||||
data/TaskShowDialogView.cpp
|
||||
data/TaskShowDialogView.h
|
||||
data/TaskShowStatusDialog.cpp
|
||||
data/TaskShowStatusDialog.h
|
||||
|
||||
settings/ApplicationSettings.cpp
|
||||
settings/ApplicationSettings.h
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
#include "data/StorageProvider.h"
|
||||
#include "data/PersistentStorage.h"
|
||||
#include "data/TaskCleanStorage.h"
|
||||
#include "data/TaskShowDialogView.h"
|
||||
#include "data/TaskShowStatusDialog.h"
|
||||
#include "data/TaskFinishParsing.h"
|
||||
#include "data/TaskInjectStorage.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
@@ -407,7 +407,7 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, const std::set<
|
||||
);
|
||||
|
||||
taskSequential->addTask( // we don't need to hide this dialog again, because it's overridden by other dialogs later on.
|
||||
std::make_shared<TaskShowDialogView>("Finish Indexing", "Saving\nRemaining Data", m_dialogView)
|
||||
std::make_shared<TaskShowStatusDialog>("Finish Indexing", "Saving\nRemaining Data", m_dialogView)
|
||||
);
|
||||
|
||||
taskSequential->addTask(
|
||||
|
||||
@@ -9,7 +9,15 @@ DialogView::~DialogView()
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::showProgressDialog(const std::string& title, const std::string& message)
|
||||
void DialogView::showStatusDialog(const std::string& title, const std::string& message)
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::hideStatusDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::showProgressDialog(const std::string& title, const std::string& message, int progress)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,10 @@ public:
|
||||
DialogView(StorageAccess* storageAccess);
|
||||
virtual ~DialogView();
|
||||
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message);
|
||||
virtual void showStatusDialog(const std::string& title, const std::string& message);
|
||||
virtual void hideStatusDialog();
|
||||
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress);
|
||||
virtual void hideProgressDialog();
|
||||
|
||||
virtual IndexMode startIndexingDialog(
|
||||
|
||||
@@ -323,7 +323,7 @@ std::set<FilePath> PersistentStorage::getReferencing(const std::set<FilePath>& f
|
||||
return referencing;
|
||||
}
|
||||
|
||||
void PersistentStorage::clearFileElements(const std::vector<FilePath>& filePaths)
|
||||
void PersistentStorage::clearFileElements(const std::vector<FilePath>& filePaths, std::function<void(int)> updateStatusCallback)
|
||||
{
|
||||
TRACE();
|
||||
|
||||
@@ -331,7 +331,7 @@ void PersistentStorage::clearFileElements(const std::vector<FilePath>& filePaths
|
||||
|
||||
if (!fileNodeIds.empty())
|
||||
{
|
||||
m_sqliteStorage.removeElementsWithLocationInFiles(fileNodeIds);
|
||||
m_sqliteStorage.removeElementsWithLocationInFiles(fileNodeIds, updateStatusCallback);
|
||||
m_sqliteStorage.removeElements(fileNodeIds);
|
||||
|
||||
m_sqliteStorage.removeErrorsInFiles(filePaths);
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
std::set<FilePath> getReferenced(const std::set<FilePath>& filePaths);
|
||||
std::set<FilePath> getReferencing(const std::set<FilePath>& filePaths);
|
||||
|
||||
void clearFileElements(const std::vector<FilePath>& filePaths);
|
||||
void clearFileElements(const std::vector<FilePath>& filePaths, std::function<void(int)> updateStatusCallback);
|
||||
|
||||
std::vector<FileInfo> getInfoOnAllFiles() const;
|
||||
|
||||
|
||||
@@ -342,17 +342,32 @@ void SqliteStorage::removeElements(const std::vector<Id>& ids)
|
||||
);
|
||||
}
|
||||
|
||||
void SqliteStorage::removeElementsWithLocationInFiles(const std::vector<Id>& fileIds)
|
||||
void SqliteStorage::removeElementsWithLocationInFiles(const std::vector<Id>& fileIds, std::function<void(int)> updateStatusCallback)
|
||||
{
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(1);
|
||||
}
|
||||
|
||||
// preparing
|
||||
executeStatement("DROP TABLE IF EXISTS main.element_id_to_clear;");
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(2);
|
||||
}
|
||||
|
||||
executeStatement(
|
||||
"CREATE TABLE IF NOT EXISTS element_id_to_clear("
|
||||
"id INTEGER NOT NULL, "
|
||||
"PRIMARY KEY(id));"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(3);
|
||||
}
|
||||
|
||||
// store ids of all elements located in fileIds into element_id_to_clear
|
||||
executeStatement(
|
||||
"INSERT INTO element_id_to_clear "
|
||||
@@ -365,16 +380,31 @@ void SqliteStorage::removeElementsWithLocationInFiles(const std::vector<Id>& fil
|
||||
" GROUP BY (occurrence.element_id)"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(4);
|
||||
}
|
||||
|
||||
// delete all edges in element_id_to_clear
|
||||
executeStatement(
|
||||
"DELETE FROM element WHERE element.id IN (SELECT element_id_to_clear.id FROM element_id_to_clear INNER JOIN edge ON (element_id_to_clear.id = edge.id))"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(22);
|
||||
}
|
||||
|
||||
// delete all edges originating from element_id_to_clear
|
||||
executeStatement(
|
||||
"DELETE FROM element WHERE element.id IN (SELECT id FROM edge WHERE source_node_id IN (SELECT id FROM element_id_to_clear))"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(23);
|
||||
}
|
||||
|
||||
// remove all edges from element_id_to_clear (they have been cleared by now and we can disregard them)
|
||||
executeStatement(
|
||||
"DELETE FROM element_id_to_clear WHERE id IN ("
|
||||
@@ -382,6 +412,11 @@ void SqliteStorage::removeElementsWithLocationInFiles(const std::vector<Id>& fil
|
||||
")"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(24);
|
||||
}
|
||||
|
||||
// remove all files from element_id_to_clear (they will be cleared later)
|
||||
executeStatement(
|
||||
"DELETE FROM element_id_to_clear WHERE id IN ("
|
||||
@@ -389,11 +424,21 @@ void SqliteStorage::removeElementsWithLocationInFiles(const std::vector<Id>& fil
|
||||
")"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(25);
|
||||
}
|
||||
|
||||
// delete source locations from fileIds (this also deletes the respective occurrences)
|
||||
executeStatement(
|
||||
"DELETE FROM source_location WHERE file_node_id IN (" + utility::join(utility::toStrings(fileIds), ',') + ");"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(34);
|
||||
}
|
||||
|
||||
// remove all ids from element_id_to_clear that still have occurrences
|
||||
executeStatement(
|
||||
"DELETE FROM element_id_to_clear WHERE id IN ("
|
||||
@@ -401,6 +446,11 @@ void SqliteStorage::removeElementsWithLocationInFiles(const std::vector<Id>& fil
|
||||
")"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(35);
|
||||
}
|
||||
|
||||
// remove all ids from element_id_to_clear that still have an edge pointing to them
|
||||
executeStatement(
|
||||
"DELETE FROM element_id_to_clear WHERE id IN ("
|
||||
@@ -408,6 +458,11 @@ void SqliteStorage::removeElementsWithLocationInFiles(const std::vector<Id>& fil
|
||||
")"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(44);
|
||||
}
|
||||
|
||||
// delete all elements that are still listed in element_id_to_clear
|
||||
executeStatement(
|
||||
"DELETE FROM element WHERE id IN ("
|
||||
@@ -415,8 +470,18 @@ void SqliteStorage::removeElementsWithLocationInFiles(const std::vector<Id>& fil
|
||||
")"
|
||||
);
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(80);
|
||||
}
|
||||
|
||||
// cleaning up
|
||||
executeStatement("DROP TABLE IF EXISTS main.element_id_to_clear;");
|
||||
|
||||
if (updateStatusCallback != nullptr)
|
||||
{
|
||||
updateStatusCallback(89);
|
||||
}
|
||||
}
|
||||
|
||||
void SqliteStorage::removeErrorsInFiles(const std::vector<FilePath>& filePaths)
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
|
||||
void removeElement(Id id);
|
||||
void removeElements(const std::vector<Id>& ids);
|
||||
void removeElementsWithLocationInFiles(const std::vector<Id>& fileIds);
|
||||
void removeElementsWithLocationInFiles(const std::vector<Id>& fileIds, std::function<void(int)> updateStatusCallback);
|
||||
|
||||
void removeErrorsInFiles(const std::vector<FilePath>& filePaths);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ TaskCleanStorage::TaskCleanStorage(
|
||||
|
||||
void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_dialogView->showProgressDialog("Clearing Files", std::to_string(m_filePaths.size()) + " Files");
|
||||
m_dialogView->showStatusDialog("Clearing Files", std::to_string(m_filePaths.size()) + " Files");
|
||||
|
||||
m_start = utility::durationStart();
|
||||
|
||||
@@ -28,7 +28,15 @@ void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
|
||||
Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_storage->clearFileElements(m_filePaths);
|
||||
DialogView* dialogView = m_dialogView;
|
||||
m_storage->clearFileElements(m_filePaths, [=](int progress)
|
||||
{
|
||||
if (dialogView != nullptr)
|
||||
{
|
||||
dialogView->showProgressDialog("Clearing", std::to_string(m_filePaths.size()) + " Files", progress);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
m_filePaths.clear();
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
{
|
||||
TimePoint start = utility::durationStart();
|
||||
|
||||
m_dialogView->showProgressDialog("Finish Indexing", "Optimizing database");
|
||||
m_dialogView->showStatusDialog("Finish Indexing", "Optimizing database");
|
||||
m_storage->optimizeMemory();
|
||||
|
||||
m_dialogView->showProgressDialog("Finish Indexing", "Building caches");
|
||||
m_dialogView->showStatusDialog("Finish Indexing", "Building caches");
|
||||
m_storage->buildCaches();
|
||||
|
||||
m_dialogView->hideProgressDialog();
|
||||
m_dialogView->hideStatusDialog();
|
||||
MessageFinishedParsing().dispatch();
|
||||
|
||||
float time = utility::duration(start);
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#include "data/TaskShowDialogView.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
|
||||
TaskShowDialogView::TaskShowDialogView(
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
DialogView* dialogView
|
||||
)
|
||||
: m_title(title)
|
||||
, m_message(message)
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
}
|
||||
|
||||
TaskShowDialogView::~TaskShowDialogView()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskShowDialogView::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
Task::TaskState TaskShowDialogView::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_dialogView->showProgressDialog(m_title, m_message);
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
void TaskShowDialogView::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskShowDialogView::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "data/TaskShowStatusDialog.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
|
||||
TaskShowStatusDialog::TaskShowStatusDialog(
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
DialogView* dialogView
|
||||
)
|
||||
: m_title(title)
|
||||
, m_message(message)
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
}
|
||||
|
||||
TaskShowStatusDialog::~TaskShowStatusDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskShowStatusDialog::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
Task::TaskState TaskShowStatusDialog::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_dialogView->showStatusDialog(m_title, m_message);
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
void TaskShowStatusDialog::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskShowStatusDialog::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef TASK_SHOW_DIALOG_VIEW_H
|
||||
#define TASK_SHOW_DIALOG_VIEW_H
|
||||
#ifndef TASK_SHOW_STATUS_DIALOG_H
|
||||
#define TASK_SHOW_STATUS_DIALOG_H
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
|
||||
class DialogView;
|
||||
|
||||
class TaskShowDialogView
|
||||
class TaskShowStatusDialog
|
||||
: public Task
|
||||
{
|
||||
public:
|
||||
TaskShowDialogView(
|
||||
TaskShowStatusDialog(
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
DialogView* dialogView
|
||||
);
|
||||
|
||||
virtual ~TaskShowDialogView();
|
||||
virtual ~TaskShowStatusDialog();
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
@@ -30,4 +30,4 @@ private:
|
||||
DialogView* m_dialogView;
|
||||
};
|
||||
|
||||
#endif // TASK_SHOW_DIALOG_VIEW_H
|
||||
#endif // TASK_SHOW_STATUS_DIALOG_H
|
||||
Reference in New Issue
Block a user