|
|
@@ -13,7 +13,8 @@ using namespace craftlab::fakeraid::ui;
|
|
|
|
|
|
MainWindow::MainWindow(const std::vector<std::string>& dirList)
|
|
|
: fileListItemModel(std::make_unique<QStandardItemModel>(this)),
|
|
|
- ui(std::make_unique<Ui_MainWindow>())
|
|
|
+ ui(std::make_unique<Ui_MainWindow>()),
|
|
|
+ fileWatcher(new QFileSystemWatcher())
|
|
|
{
|
|
|
window = std::make_unique<QMainWindow>();
|
|
|
|
|
|
@@ -39,6 +40,7 @@ MainWindow::MainWindow(const std::vector<std::string>& dirList)
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
{
|
|
|
+ fileWatcher->deleteLater();
|
|
|
}
|
|
|
|
|
|
void MainWindow::FileListItemEntered(const QModelIndex& index)
|
|
|
@@ -122,15 +124,14 @@ void MainWindow::UpdateFileList()
|
|
|
std::sort(allFilenames.begin(), allFilenames.end());
|
|
|
for (const std::string& file : allFilenames)
|
|
|
fileListItemModel->appendRow(new FileItem(*ui->listView, engine->GetRootPaths(), currentDiffResult->FileList[file], false));
|
|
|
- UpdateBreadcrumb();
|
|
|
}
|
|
|
|
|
|
-void MainWindow::ListFiles()
|
|
|
+void MainWindow::ListFiles(bool ignoreAll)
|
|
|
{
|
|
|
if (!engine)
|
|
|
return;
|
|
|
currentDiffResult = std::make_unique<DiffResult>(FileDiff().Process(engine->ListFiles()));
|
|
|
- if (!currentDiffResult->differentFiles.empty() || !currentDiffResult->missingDirs.empty() || !currentDiffResult->missingFiles.empty())
|
|
|
+ if (!ignoreAll && (!currentDiffResult->differentFiles.empty() || !currentDiffResult->missingDirs.empty() || !currentDiffResult->missingFiles.empty()))
|
|
|
currentDiffResult = std::make_unique<DiffResult>(ConflictModal::Display(*engine, *currentDiffResult));
|
|
|
std::sort(currentDiffResult->correctFiles.begin(), currentDiffResult->correctFiles.end(), [](const File& a, const File& b) { return a.fileName < b.fileName; });
|
|
|
|
|
|
@@ -203,10 +204,21 @@ void MainWindow::OnListViewDoubleClick(const FileAndSum& file)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void MainWindow::OnFileWatcherTrigger(const QString& path)
|
|
|
+{
|
|
|
+ ListFiles(true);
|
|
|
+}
|
|
|
+
|
|
|
void MainWindow::OnEngineUpdated()
|
|
|
{
|
|
|
window->setEnabled(false);
|
|
|
+ fileWatcher->deleteLater();
|
|
|
+ fileWatcher = new QFileSystemWatcher();
|
|
|
+ fileWatcher->connect(fileWatcher, &QFileSystemWatcher::directoryChanged, this, &MainWindow::OnFileWatcherTrigger);
|
|
|
+ for (const std::string& path: engine->GetPaths())
|
|
|
+ fileWatcher->addPath(path.c_str());
|
|
|
ListFiles();
|
|
|
+ UpdateBreadcrumb();
|
|
|
window->setEnabled(true);
|
|
|
}
|
|
|
|