فهرست منبع

Fixes #8 Loading bar details

isundil 7 ماه پیش
والد
کامیت
60ec0efb51
3فایلهای تغییر یافته به همراه16 افزوده شده و 10 حذف شده
  1. 10 6
      Engine/Engine.cpp
  2. 1 0
      Engine/fileDefinition.h
  3. 5 4
      fakeRaid/mainWindow.cpp

+ 10 - 6
Engine/Engine.cpp

@@ -31,8 +31,8 @@ namespace craftlab::fakeraid
 		void CopyItems(const std::vector<CopyInstruction>& itemsToCopy) const override;
 
 	private:
-		void ListFiles(FileAndSumListByRepositoryIndex& result, const PathParts& currentDir, bool* threadStopping =nullptr);
-		FileAndSumList ListFiles(const std::string& root, const PathParts& path, int repositoryIndex, bool* threadStopping =nullptr);
+		void ListFiles(FileAndSumListByRepositoryIndex& result, const PathParts& currentDir, std::string* lastFileScanned =nullptr, bool* threadStopping =nullptr);
+		FileAndSumList ListFiles(const std::string& root, const PathParts& path, int repositoryIndex, std::string* lastFileScanned =nullptr, bool* threadStopping =nullptr);
 
 		void CopyItem(const CopyInstruction& dst) const;
 
@@ -114,7 +114,7 @@ void Engine::Cd(const std::string& dirName)
 	currentDir.push_back(dirName);
 }
 
-FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::string>& wd, int repositoryIndex, bool* threadStopping)
+FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::string>& wd, int repositoryIndex, std::string* lastFileScanned, bool* threadStopping)
 {
 	FileAndSumList result {};
 	const std::string path = BuildCurrentDirPath(root, wd);
@@ -133,6 +133,7 @@ FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::
 	{
 		bool isDirectory = false;
 		bool isFile = false;
+
 		try
 		{
 			isDirectory = file.is_directory();
@@ -148,6 +149,9 @@ FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::
 			fileInfos.directory = wd;
 			fileInfos.repositoryIndex = repositoryIndex;
 
+			if (nullptr != lastFileScanned)
+				*lastFileScanned = BuildCurrentDirPath(fileInfos);
+
 			try
 			{
 				cryptoEngine.Compute(path, fileInfos);
@@ -163,12 +167,12 @@ FileAndSumList Engine::ListFiles(const std::string& root, const std::deque<std::
 	return result;
 }
 
-void Engine::ListFiles(FileAndSumListByRepositoryIndex& result, const std::deque<std::string>& currentDir, bool* threadStopping)
+void Engine::ListFiles(FileAndSumListByRepositoryIndex& result, const std::deque<std::string>& currentDir, std::string* lastFileScanned, bool* threadStopping)
 {
 	int index = 0;
 	for (const auto& i : rootPaths)
 	{
-		const FileAndSumList files = ListFiles(i, currentDir, index++, threadStopping);
+		const FileAndSumList files = ListFiles(i, currentDir, index++, lastFileScanned, threadStopping);
 		result.FileAndSumListByRepositoryIndex.push_back(files);
 		for (const FileAndSum& file : files)
 			result.FileList[BuildCurrentDirPath(file)] = file;
@@ -192,7 +196,7 @@ void Engine::ListFilesRecur(FileAndSumListByRepositoryIndex* result, bool* threa
 	{
 		FileAndSumListByRepositoryIndex newItems;
 		const PathParts currentPath = itemsToDo.front();
-		ListFiles(newItems, currentPath, threadStopping);
+		ListFiles(newItems, currentPath, &result->lastInsertedFilename, threadStopping);
 		itemsToDo.pop_front();
 		std::copy(newItems.FileAndSumListByRepositoryIndex.begin(), newItems.FileAndSumListByRepositoryIndex.end(), std::back_inserter(result->FileAndSumListByRepositoryIndex));
 		for (const auto& file : newItems.FileList)

+ 1 - 0
Engine/fileDefinition.h

@@ -31,6 +31,7 @@ namespace craftlab::fakeraid
 	{
 		std::vector<FileAndSumList> FileAndSumListByRepositoryIndex;
 		std::map<std::string, FileAndSum> FileList;
+		std::string lastInsertedFilename;
 
 		ENGINEAPI_EXPORT size_t ExistingFileCount() const;
 	};

+ 5 - 4
fakeRaid/mainWindow.cpp

@@ -38,6 +38,7 @@ MainWindow::MainWindow(const std::vector<std::string>& dirList)
 #ifdef _WIN32
 	ui->listView->addAction("Open Containing Folders", [this]() { OpenContainingFolders(ui->listView->currentIndex()); });
 #endif
+	window->setWindowTitle("Fake Raid");
 	window->show();
 
 	if (dirList.empty() || !TryOpenningDir(dirList))
@@ -56,22 +57,24 @@ void MainWindow::RequestDeepScan()
 	DeepScanThread* thread = new DeepScanThread(engine.get());
 
 	window->setEnabled(false);
+	dialog->setWindowTitle("Scanning for errors");
 	dialog->setMinimum(0);
 	dialog->setMaximum(0);
 	dialog->setModal(true);
 	dialog->setWindowFlag(Qt::WindowCloseButtonHint, false);
 	dialog->setAttribute(Qt::WA_DeleteOnClose);
 	dialog->setEnabled(true);
+	dialog->setMinimumDuration(1500);
 
 	connect(thread, &DeepScanThread::FileCountComputed, this, [dialog, thread](size_t fileCount) {
 		if (thread->isRunning())
 			dialog->setMaximum((int) fileCount);
 	});
-	connect(thread, &DeepScanThread::Ping, this, [dialog, thread](size_t fileCount){
+	connect(thread, &DeepScanThread::Ping, this, [dialog, thread](size_t fileCount, const std::string& lastFile){
 		if (thread->isRunning())
 		{
 			dialog->setValue((int)fileCount);
-			///dialog->setLabelText();
+			dialog->setLabelText(lastFile.c_str());
 		}
 	});
 	connect(thread, &DeepScanThread::finished, this, [this, thread, dialog](){
@@ -88,7 +91,6 @@ void MainWindow::RequestDeepScan()
 			else
 				QMessageBox::information(window.get(), window->windowTitle(), "Folders are identical");
 		}
-		thread->deleteLater();
 		window->setEnabled(true);
 	});
 	connect(dialog, &QProgressDialog::canceled, this, [thread, this]() {
@@ -98,7 +100,6 @@ void MainWindow::RequestDeepScan()
 		window->setEnabled(true);
 		QApplication::restoreOverrideCursor();
 	});
-	dialog->show();
 	thread->start();
 }