logic: Added full refresh checkbox to indexing start dialog
* Checkbox allows for switching between refresh and full refresh * Renamed menu option Force Refresh to Full Refresh * Checkbox is not visible when project needs to be fully refreshed
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
QLabel {
|
||||
QLabel, QCheckBox {
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ add_files(
|
||||
utility/messaging/type/MessageWindowClosed.h
|
||||
utility/messaging/type/MessageWindowFocus.h
|
||||
utility/messaging/type/MessageZoom.h
|
||||
|
||||
|
||||
utility/messaging/Message.h
|
||||
utility/messaging/MessageBase.h
|
||||
utility/messaging/MessageInterruptTasksCounter.cpp
|
||||
@@ -327,7 +327,6 @@ add_files(
|
||||
utility/scheduling/TaskGroupSequence.h
|
||||
utility/scheduling/TaskLambda.cpp
|
||||
utility/scheduling/TaskLambda.h
|
||||
utility/scheduling/TaskReturnSuccessWhile.cpp
|
||||
utility/scheduling/TaskReturnSuccessWhile.h
|
||||
utility/scheduling/TaskRunner.cpp
|
||||
utility/scheduling/TaskRunner.h
|
||||
|
||||
+83
-71
@@ -43,52 +43,50 @@ bool Project::refresh(bool forceRefresh)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool needsFullRefresh = false;
|
||||
std::string question;
|
||||
|
||||
if (!forceRefresh)
|
||||
switch (m_state)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case PROJECT_STATE_EMPTY:
|
||||
forceRefresh = true;
|
||||
break;
|
||||
case PROJECT_STATE_EMPTY:
|
||||
needsFullRefresh = true;
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_LOADED:
|
||||
break;
|
||||
case PROJECT_STATE_LOADED:
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_OUTDATED:
|
||||
question =
|
||||
"The project file was changed after the last indexing. The project needs to get fully reindexed to "
|
||||
"reflect the current project state. Do you want to reindex the project?";
|
||||
forceRefresh = true;
|
||||
break;
|
||||
case PROJECT_STATE_OUTDATED:
|
||||
question =
|
||||
"The project file was changed after the last indexing. The project needs to get fully reindexed to "
|
||||
"reflect the current project state. Do you want to reindex the project?";
|
||||
needsFullRefresh = true;
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_OUTVERSIONED:
|
||||
question =
|
||||
"This project was indexed with a different version of Coati. It needs to be fully reindexed to be used "
|
||||
"with this version of Coati. Do you want to reindex the project?";
|
||||
forceRefresh = true;
|
||||
break;
|
||||
case PROJECT_STATE_OUTVERSIONED:
|
||||
question =
|
||||
"This project was indexed with a different version of Coati. It needs to be fully reindexed to be used "
|
||||
"with this version of Coati. Do you want to reindex the project?";
|
||||
needsFullRefresh = true;
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_SETTINGS_UPDATED:
|
||||
question =
|
||||
"Some settings were changed, the project needs to be fully reindexed. "
|
||||
"Do you want to reindex the project?";
|
||||
forceRefresh = true;
|
||||
break;
|
||||
case PROJECT_STATE_SETTINGS_UPDATED:
|
||||
question =
|
||||
"Some settings were changed, the project needs to be fully reindexed. "
|
||||
"Do you want to reindex the project?";
|
||||
needsFullRefresh = true;
|
||||
break;
|
||||
|
||||
case PROJECT_STATE_NEEDS_MIGRATION:
|
||||
question =
|
||||
"This project was created with a different version of Coati. The project file needs to get updated and "
|
||||
"the project fully reindexed. Do you want to update the project file and reindex the project?";
|
||||
forceRefresh = true;
|
||||
case PROJECT_STATE_NEEDS_MIGRATION:
|
||||
question =
|
||||
"This project was created with a different version of Coati. The project file needs to get updated and "
|
||||
"the project fully reindexed. Do you want to update the project file and reindex the project?";
|
||||
needsFullRefresh = true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (forceRefresh && question.size() && Application::getInstance()->hasGUI())
|
||||
if (!forceRefresh && needsFullRefresh && question.size() && Application::getInstance()->hasGUI())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
@@ -115,7 +113,7 @@ bool Project::refresh(bool forceRefresh)
|
||||
|
||||
updateFileManager(m_fileManager);
|
||||
|
||||
if (buildIndex(forceRefresh))
|
||||
if (requestIndex(forceRefresh, needsFullRefresh))
|
||||
{
|
||||
m_storageAccessProxy->setSubject(m_storage.get());
|
||||
|
||||
@@ -242,66 +240,84 @@ void Project::load()
|
||||
}
|
||||
}
|
||||
|
||||
bool Project::buildIndex(bool forceRefresh)
|
||||
bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
{
|
||||
if (!prepareIndexing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<FileInfo> fileInfos = m_storage->getInfoOnAllFiles();
|
||||
|
||||
m_fileManager.fetchFilePaths(forceRefresh ? std::vector<FileInfo>() : fileInfos);
|
||||
|
||||
std::set<FilePath> addedFilePaths = m_fileManager.getAddedFilePaths();
|
||||
std::set<FilePath> updatedFilePaths = m_fileManager.getUpdatedFilePaths();
|
||||
std::set<FilePath> removedFilePaths = m_fileManager.getRemovedFilePaths();
|
||||
FileManager::FileSets fileSets = m_fileManager.fetchFilePaths(m_storage->getInfoOnAllFiles());
|
||||
|
||||
std::set<FilePath> filesToClean;
|
||||
std::set<FilePath> filesToParse;
|
||||
std::set<FilePath> filesToIndex;
|
||||
|
||||
if (!forceRefresh)
|
||||
if (!needsFullRefresh)
|
||||
{
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
utility::append(dependingFilePaths, m_storage->getDependingFilePaths(updatedFilePaths));
|
||||
utility::append(dependingFilePaths, m_storage->getDependingFilePaths(removedFilePaths));
|
||||
utility::append(dependingFilePaths, m_storage->getDependingFilePaths(fileSets.updatedFiles));
|
||||
utility::append(dependingFilePaths, m_storage->getDependingFilePaths(fileSets.removedFiles));
|
||||
|
||||
for (const FilePath& path : dependingFilePaths)
|
||||
{
|
||||
if (removedFilePaths.find(path) == removedFilePaths.end())
|
||||
if (fileSets.removedFiles.find(path) == fileSets.removedFiles.end())
|
||||
{
|
||||
updatedFilePaths.insert(path);
|
||||
fileSets.updatedFiles.insert(path);
|
||||
}
|
||||
}
|
||||
|
||||
utility::append(filesToClean, fileSets.removedFiles);
|
||||
utility::append(filesToClean, fileSets.updatedFiles);
|
||||
utility::append(filesToClean, dependingFilePaths);
|
||||
|
||||
utility::append(filesToIndex, fileSets.addedFiles);
|
||||
utility::append(filesToIndex, fileSets.updatedFiles);
|
||||
}
|
||||
|
||||
utility::append(filesToClean, removedFilePaths);
|
||||
utility::append(filesToClean, updatedFilePaths);
|
||||
bool fullRefresh = forceRefresh | needsFullRefresh;
|
||||
|
||||
utility::append(filesToParse, addedFilePaths);
|
||||
utility::append(filesToParse, updatedFilePaths);
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
DialogView::IndexMode mode = m_dialogView->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), fileSets.allFiles.size(),
|
||||
forceRefresh, needsFullRefresh
|
||||
);
|
||||
|
||||
if (!filesToClean.size() && !filesToParse.size() && (!forceRefresh || !fileInfos.size()))
|
||||
switch (mode)
|
||||
{
|
||||
case DialogView::INDEX_ABORT:
|
||||
return false;
|
||||
case DialogView::INDEX_REFRESH:
|
||||
fullRefresh = false;
|
||||
break;
|
||||
case DialogView::INDEX_FULL:
|
||||
fullRefresh = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fullRefresh)
|
||||
{
|
||||
filesToClean.clear();
|
||||
filesToIndex = fileSets.allFiles;
|
||||
}
|
||||
|
||||
if (!filesToClean.size() && !filesToIndex.size())
|
||||
{
|
||||
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());
|
||||
buildIndex(filesToClean, filesToIndex, fullRefresh);
|
||||
|
||||
if (!doIndex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::buildIndex(const std::set<FilePath>& filesToClean, const std::set<FilePath>& filesToIndex, bool fullRefresh)
|
||||
{
|
||||
MessageClearErrorCount().dispatch();
|
||||
|
||||
if (forceRefresh)
|
||||
if (fullRefresh)
|
||||
{
|
||||
m_storage->clear();
|
||||
}
|
||||
@@ -323,9 +339,9 @@ bool Project::buildIndex(bool forceRefresh)
|
||||
|
||||
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(&m_fileManager, indexerThreadCount > 1);
|
||||
|
||||
if (!filesToParse.empty())
|
||||
if (!filesToIndex.empty())
|
||||
{
|
||||
fileRegister->setFilePaths(utility::toVector(filesToParse));
|
||||
fileRegister->setFilePaths(utility::toVector(filesToIndex));
|
||||
|
||||
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(
|
||||
m_storage.get(),
|
||||
@@ -339,7 +355,7 @@ bool Project::buildIndex(bool forceRefresh)
|
||||
|
||||
std::shared_ptr<StorageProvider> storageProvider = std::make_shared<StorageProvider>();
|
||||
|
||||
for (size_t i = 0; i < indexerThreadCount && i < filesToParse.size(); i++)
|
||||
for (size_t i = 0; i < indexerThreadCount && i < filesToIndex.size(); i++)
|
||||
{
|
||||
taskParallelIndexing->addChildTasks(
|
||||
std::make_shared<TaskDecoratorRepeat>(TaskDecoratorRepeat::CONDITION_WHILE_SUCCESS, Task::STATE_SUCCESS)->addChildTask(
|
||||
@@ -378,13 +394,9 @@ bool Project::buildIndex(bool forceRefresh)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
taskSequential->addTask(std::make_shared<TaskFinishParsing>(m_storage.get(), m_storageAccessProxy, fileRegister, m_dialogView));
|
||||
|
||||
Task::dispatch(taskSequential);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Project::prepareIndexing()
|
||||
|
||||
+3
-1
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
#include "utility/file/FileManager.h"
|
||||
|
||||
@@ -57,7 +58,8 @@ public: // todo: make private again
|
||||
void load();
|
||||
|
||||
private:
|
||||
bool buildIndex(bool forceRefresh);
|
||||
bool requestIndex(bool forceRefresh, bool needsFullRefresh);
|
||||
void buildIndex(const std::set<FilePath>& filesToClean, const std::set<FilePath>& filesToIndex, bool fullRefresh);
|
||||
|
||||
virtual bool prepareIndexing();
|
||||
virtual bool prepareRefresh();
|
||||
|
||||
@@ -17,9 +17,10 @@ void DialogView::hideProgressDialog()
|
||||
{
|
||||
}
|
||||
|
||||
bool DialogView::startIndexingDialog(size_t cleanFileCount, size_t indexFileCount)
|
||||
{
|
||||
return false;
|
||||
DialogView::IndexMode DialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh
|
||||
){
|
||||
return INDEX_ABORT;
|
||||
}
|
||||
|
||||
void DialogView::updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath)
|
||||
|
||||
@@ -11,13 +11,21 @@ class StorageAccess;
|
||||
class DialogView
|
||||
{
|
||||
public:
|
||||
enum IndexMode
|
||||
{
|
||||
INDEX_ABORT,
|
||||
INDEX_REFRESH,
|
||||
INDEX_FULL
|
||||
};
|
||||
|
||||
DialogView(StorageAccess* storageAccess);
|
||||
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 IndexMode startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh);
|
||||
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);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ void FileManager::setPaths(
|
||||
m_sourceExtensions = sourceExtensions;
|
||||
}
|
||||
|
||||
void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
FileManager::FileSets FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
{
|
||||
m_files.clear();
|
||||
for (FileInfo oldFileInfo: oldFileInfos)
|
||||
@@ -40,9 +40,7 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
m_files.emplace(oldFileInfo.path, oldFileInfo);
|
||||
}
|
||||
|
||||
m_addedFiles.clear();
|
||||
m_updatedFiles.clear();
|
||||
m_removedFiles.clear();
|
||||
FileSets fileSets;
|
||||
|
||||
for (std::map<FilePath, FileInfo>::iterator it = m_files.begin(); it != m_files.end(); it++)
|
||||
{
|
||||
@@ -54,17 +52,15 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
if (fileInfo.lastWriteTime > it->second.lastWriteTime)
|
||||
{
|
||||
it->second.lastWriteTime = fileInfo.lastWriteTime;
|
||||
m_updatedFiles.insert(filePath);
|
||||
fileSets.updatedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_removedFiles.insert(filePath);
|
||||
fileSets.removedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
m_sourceFiles.clear();
|
||||
|
||||
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions);
|
||||
for (FileInfo fileInfo: fileInfos)
|
||||
{
|
||||
@@ -74,44 +70,33 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
continue;
|
||||
}
|
||||
|
||||
m_sourceFiles.insert(filePath);
|
||||
fileSets.allFiles.insert(filePath);
|
||||
|
||||
std::map<FilePath, FileInfo>::iterator it = m_files.find(filePath);
|
||||
if (it != m_files.end())
|
||||
{
|
||||
m_removedFiles.erase(filePath);
|
||||
fileSets.removedFiles.erase(filePath);
|
||||
if (fileInfo.lastWriteTime > it->second.lastWriteTime)
|
||||
{
|
||||
it->second.lastWriteTime = fileInfo.lastWriteTime;
|
||||
m_updatedFiles.insert(filePath);
|
||||
fileSets.updatedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_files.insert(std::pair<FilePath, FileInfo>(filePath, fileInfo));
|
||||
m_addedFiles.insert(filePath);
|
||||
fileSets.addedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
for (const FilePath& filePath : m_removedFiles)
|
||||
for (const FilePath& filePath : fileSets.removedFiles)
|
||||
{
|
||||
m_files.erase(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> FileManager::getAddedFilePaths() const
|
||||
{
|
||||
return m_addedFiles;
|
||||
}
|
||||
m_sourceFiles = fileSets.allFiles;
|
||||
|
||||
std::set<FilePath> FileManager::getUpdatedFilePaths() const
|
||||
{
|
||||
return m_updatedFiles;
|
||||
}
|
||||
|
||||
std::set<FilePath> FileManager::getRemovedFilePaths() const
|
||||
{
|
||||
return m_removedFiles;
|
||||
return fileSets;
|
||||
}
|
||||
|
||||
bool FileManager::hasFilePath(const FilePath& filePath) const
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
struct FileSets
|
||||
{
|
||||
std::set<FilePath> allFiles;
|
||||
std::set<FilePath> addedFiles;
|
||||
std::set<FilePath> updatedFiles;
|
||||
std::set<FilePath> removedFiles;
|
||||
};
|
||||
|
||||
FileManager();
|
||||
virtual ~FileManager();
|
||||
|
||||
@@ -22,11 +30,7 @@ public:
|
||||
std::vector<std::string> sourceExtensions
|
||||
);
|
||||
|
||||
void fetchFilePaths(const std::vector<FileInfo>& oldFileInfos);
|
||||
|
||||
std::set<FilePath> getAddedFilePaths() const;
|
||||
std::set<FilePath> getUpdatedFilePaths() const;
|
||||
std::set<FilePath> getRemovedFilePaths() const;
|
||||
FileSets fetchFilePaths(const std::vector<FileInfo>& oldFileInfos);
|
||||
|
||||
virtual bool hasFilePath(const FilePath& filePath) const;
|
||||
virtual bool hasSourceFilePath(const FilePath& filePath) const;
|
||||
@@ -45,10 +49,6 @@ private:
|
||||
|
||||
std::vector<std::string> m_sourceExtensions;
|
||||
|
||||
std::set<FilePath> m_addedFiles;
|
||||
std::set<FilePath> m_updatedFiles;
|
||||
std::set<FilePath> m_removedFiles;
|
||||
|
||||
std::set<FilePath> m_sourceFiles;
|
||||
};
|
||||
|
||||
|
||||
@@ -67,19 +67,23 @@ void QtDialogView::hideProgressDialog()
|
||||
);
|
||||
}
|
||||
|
||||
bool QtDialogView::startIndexingDialog(size_t cleanFileCount, size_t indexFileCount)
|
||||
DialogView::IndexMode QtDialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh)
|
||||
{
|
||||
bool result = false;
|
||||
IndexMode result = INDEX_ABORT;
|
||||
m_resultReady = false;
|
||||
|
||||
m_onQtThread(
|
||||
[=, &result]()
|
||||
{
|
||||
QtIndexingDialog* window = createWindow<QtIndexingDialog>();
|
||||
window->setupStart(cleanFileCount, indexFileCount,
|
||||
[&](bool start)
|
||||
window->setupStart(cleanFileCount, indexFileCount, totalFileCount, forceRefresh, needsFullRefresh,
|
||||
[&](bool start, bool fullRefresh)
|
||||
{
|
||||
result = start;
|
||||
if (start)
|
||||
{
|
||||
result = (!fullRefresh && !needsFullRefresh ? INDEX_REFRESH : INDEX_FULL);
|
||||
}
|
||||
m_resultReady = true;
|
||||
|
||||
setUIBlocked(false);
|
||||
|
||||
@@ -31,7 +31,8 @@ public:
|
||||
void showProgressDialog(const std::string& title, const std::string& message) override;
|
||||
void hideProgressDialog() override;
|
||||
|
||||
bool startIndexingDialog(size_t cleanFileCount, size_t indexFileCount) override;
|
||||
DialogView::IndexMode startIndexingDialog(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh) override;
|
||||
void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath) override;
|
||||
void finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo) override;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "qt/window/QtIndexingDialog.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <QPainter>
|
||||
@@ -21,8 +22,9 @@ QtIndexingDialog::QtIndexingDialog(QWidget* parent)
|
||||
, m_messageLabel(nullptr)
|
||||
, m_filePathLabel(nullptr)
|
||||
, m_errorLabel(nullptr)
|
||||
, m_checkBox(nullptr)
|
||||
, m_sizeHint(QSize(450, 450))
|
||||
, m_callback([](bool){})
|
||||
, m_callback([](bool, bool){})
|
||||
{
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
setSizeGripStyle(false);
|
||||
@@ -38,26 +40,60 @@ QtIndexingDialog::DialogType QtIndexingDialog::getType() const
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void QtIndexingDialog::setupStart(size_t cleanFileCount, size_t indexFileCount, std::function<void(bool)> callback)
|
||||
void QtIndexingDialog::setupStart(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback)
|
||||
{
|
||||
QBoxLayout* layout = createLayout();
|
||||
|
||||
addTitle("Start Indexing", layout);
|
||||
layout->addSpacing(5);
|
||||
|
||||
if (cleanFileCount)
|
||||
{
|
||||
QLabel* cleanLabel = new QLabel("Clear: " + QString::number(cleanFileCount) + " File" + (cleanFileCount > 1 ? "s" : ""));
|
||||
cleanLabel->setObjectName("message");
|
||||
cleanLabel->setAlignment(Qt::AlignRight);
|
||||
layout->addWidget(cleanLabel, 0, Qt::AlignRight);
|
||||
}
|
||||
QLabel* clearLabel = createMessageLabel(layout);
|
||||
QLabel* indexLabel = createMessageLabel(layout);
|
||||
QLabel* fullLabel = createMessageLabel(layout);
|
||||
|
||||
addMessageLabel(layout);
|
||||
updateMessage("Index: " + QString::number(indexFileCount) + " File" + (indexFileCount > 1 ? "s" : ""));
|
||||
clearLabel->setText("Clear: " + QString::number(cleanFileCount) + " File" + (cleanFileCount != 1 ? "s" : ""));
|
||||
indexLabel->setText("Index: " + QString::number(indexFileCount) + " File" + (indexFileCount != 1 ? "s" : ""));
|
||||
fullLabel->setText("Index: " + QString::number(totalFileCount) + " File" + (totalFileCount != 1 ? "s" : ""));
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
if (needsFullRefresh)
|
||||
{
|
||||
clearLabel->hide();
|
||||
indexLabel->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_checkBox = new QCheckBox("full refresh", this);
|
||||
m_checkBox->setObjectName("message");
|
||||
|
||||
connect(m_checkBox, static_cast<void(QCheckBox::*)(bool)>(&QCheckBox::toggled),
|
||||
[=](bool checked = false)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
clearLabel->hide();
|
||||
indexLabel->hide();
|
||||
fullLabel->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
clearLabel->show();
|
||||
indexLabel->show();
|
||||
fullLabel->hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
m_checkBox->setChecked(!forceRefresh);
|
||||
m_checkBox->setChecked(forceRefresh);
|
||||
|
||||
layout->addWidget(m_checkBox, 0, Qt::AlignRight);
|
||||
layout->addSpacing(30);
|
||||
}
|
||||
|
||||
addButtons(layout);
|
||||
updateNextButton("Start");
|
||||
updateCloseButton("Cancel");
|
||||
@@ -211,7 +247,7 @@ void QtIndexingDialog::handleNext()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(true);
|
||||
m_callback(true, !m_checkBox || m_checkBox->isChecked());
|
||||
}
|
||||
|
||||
QtWindow::handleNext();
|
||||
@@ -221,7 +257,7 @@ void QtIndexingDialog::handleClose()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(false);
|
||||
m_callback(false, false);
|
||||
}
|
||||
|
||||
if (m_type == DIALOG_INDEXING)
|
||||
@@ -308,6 +344,16 @@ void QtIndexingDialog::addMessageLabel(QBoxLayout* layout)
|
||||
layout->addWidget(m_messageLabel, 0, Qt::AlignRight);
|
||||
}
|
||||
|
||||
QLabel* QtIndexingDialog::createMessageLabel(QBoxLayout* layout)
|
||||
{
|
||||
QLabel* label = new QLabel();
|
||||
label->setObjectName("message");
|
||||
label->setAlignment(Qt::AlignRight);
|
||||
label->setWordWrap(true);
|
||||
layout->addWidget(label, 0, Qt::AlignRight);
|
||||
return label;
|
||||
}
|
||||
|
||||
void QtIndexingDialog::addFilePathLabel(QBoxLayout* layout)
|
||||
{
|
||||
m_filePathLabel = new QLabel();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "qt/window/QtWindow.h"
|
||||
|
||||
class QCheckBox;
|
||||
class QLabel;
|
||||
class QtProgressBar;
|
||||
|
||||
@@ -26,7 +27,8 @@ public:
|
||||
|
||||
DialogType getType() const;
|
||||
|
||||
void setupStart(size_t cleanFileCount, size_t indexFileCount, std::function<void(bool)> callback);
|
||||
void setupStart(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback);
|
||||
void setupProgress();
|
||||
void setupIndexing();
|
||||
void setupReport(size_t fileCount, size_t totalFileCount, float time);
|
||||
@@ -50,6 +52,7 @@ private:
|
||||
|
||||
void addPercentLabel(QBoxLayout* layout);
|
||||
void addMessageLabel(QBoxLayout* layout);
|
||||
QLabel* createMessageLabel(QBoxLayout* layout);
|
||||
void addFilePathLabel(QBoxLayout* layout);
|
||||
void addErrorLabel(QBoxLayout* layout);
|
||||
|
||||
@@ -69,10 +72,11 @@ private:
|
||||
QLabel* m_messageLabel;
|
||||
QLabel* m_filePathLabel;
|
||||
QPushButton* m_errorLabel;
|
||||
QCheckBox* m_checkBox;
|
||||
|
||||
QSize m_sizeHint;
|
||||
|
||||
std::function<void(bool)> m_callback;
|
||||
std::function<void(bool, bool)> m_callback;
|
||||
QString m_sourcePath;
|
||||
};
|
||||
|
||||
|
||||
@@ -593,13 +593,13 @@ void QtMainWindow::setupEditMenu()
|
||||
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
|
||||
{
|
||||
m_trialDisabledActions.push_back(
|
||||
menu->addAction(tr("&Force Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::Key_F5))
|
||||
menu->addAction(tr("&Full Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::Key_F5))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_trialDisabledActions.push_back(menu->addAction(
|
||||
tr("&Force Refresh"),
|
||||
tr("&Full Refresh"),
|
||||
this,
|
||||
SLOT(forceRefresh()),
|
||||
QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_R)
|
||||
|
||||
@@ -139,9 +139,9 @@ void JavaProject::fetchRootDirectories()
|
||||
m_projectSettings->getAbsoluteExcludePaths(),
|
||||
m_projectSettings->getSourceExtensions()
|
||||
);
|
||||
fileManager.fetchFilePaths(std::vector<FileInfo>());
|
||||
FileManager::FileSets fileSets = fileManager.fetchFilePaths(std::vector<FileInfo>());
|
||||
std::shared_ptr<JavaEnvironment> javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment();
|
||||
for (FilePath filePath: fileManager.getAddedFilePaths())
|
||||
for (FilePath filePath: fileSets.addedFiles)
|
||||
{
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath.str());
|
||||
|
||||
|
||||
@@ -5,15 +5,6 @@
|
||||
class FileManagerTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_file_manager_is_created_empty()
|
||||
{
|
||||
FileManager fm = FileManager();
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 0);
|
||||
TS_ASSERT_EQUALS(fm.getUpdatedFilePaths().size(), 0);
|
||||
TS_ASSERT_EQUALS(fm.getRemovedFilePaths().size(), 0);
|
||||
}
|
||||
|
||||
void test_file_manager_has_added_file_paths_after_first_fetch()
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
@@ -27,8 +18,8 @@ public:
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions);
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
FileManager::FileSets fileSets = fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 2);
|
||||
TS_ASSERT_EQUALS(fileSets.addedFiles.size(), 2);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user