|
|
@@ -8,7 +8,7 @@
|
|
|
|
|
|
using namespace craftlab::fakeraid::ui;
|
|
|
|
|
|
-MainWindow::MainWindow()
|
|
|
+MainWindow::MainWindow(const std::vector<std::string>& dirList)
|
|
|
: fileListItemModel(std::make_unique<QStandardItemModel>(this)),
|
|
|
ui(std::make_unique<Ui_MainWindow>())
|
|
|
{
|
|
|
@@ -17,6 +17,7 @@ MainWindow::MainWindow()
|
|
|
ui->setupUi(window.get());
|
|
|
ui->listView->setModel(fileListItemModel.get());
|
|
|
ui->listView->setItemDelegate(new FileItemDelegate(this));
|
|
|
+ ui->breadcrumb->setFixedHeight(36);
|
|
|
|
|
|
connect(ui->actionOuvrir, &QAction::triggered, this, &MainWindow::MenuBarActionTrigerred);
|
|
|
connect(ui->listView, &QListView::doubleClicked, this, [this](const QModelIndex& index)
|
|
|
@@ -30,7 +31,8 @@ MainWindow::MainWindow()
|
|
|
});
|
|
|
window->show();
|
|
|
|
|
|
- DisplaySourceWindow(false, std::vector<std::string>({ "C:\\Users\\isund\\projects\\fakeRaid\\test\\A", "C:\\Users\\isund\\projects\\fakeRaid\\test\\B" }));
|
|
|
+ if (dirList.empty() || !TryOpenningDir(dirList))
|
|
|
+ DisplaySourceWindow(false, std::vector<std::string>({ "", "" }));
|
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
@@ -51,6 +53,12 @@ bool MainWindow::PathExists(const IEngine& engine) const
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+void MainWindow::UpdateBreadcrumb()
|
|
|
+{
|
|
|
+ craftlab::ui::Breadcrumb* breadcrumb = ui->breadcrumb;
|
|
|
+ breadcrumb->clear();
|
|
|
+}
|
|
|
+
|
|
|
void MainWindow::UpdateFileList()
|
|
|
{
|
|
|
fileListItemModel->clear();
|
|
|
@@ -62,9 +70,8 @@ void MainWindow::UpdateFileList()
|
|
|
std::transform(currentDiffResult->missingDirs.begin(), currentDiffResult->missingDirs.end(), std::back_inserter(allFilenames), [](const std::pair<std::string, std::vector<bool>>& i) { return i.first; });
|
|
|
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()
|
|
|
@@ -146,23 +153,31 @@ void MainWindow::OnEngineUpdated()
|
|
|
ListFiles();
|
|
|
}
|
|
|
|
|
|
-void MainWindow::DisplaySourceWindow(bool canCancel, const std::vector<std::string>& previous)
|
|
|
+bool MainWindow::TryOpenningDir(const std::vector<std::string>& folders)
|
|
|
{
|
|
|
- const std::vector<std::string> folders = BrowseModal::Display(canCancel, previous);
|
|
|
- if (folders.empty())
|
|
|
- {
|
|
|
- if (canCancel)
|
|
|
- return;
|
|
|
- return DisplaySourceWindow(canCancel, previous);
|
|
|
- }
|
|
|
IEngine* newEngine = EngineManager::Open(folders);
|
|
|
if (!PathExists(*newEngine))
|
|
|
{
|
|
|
delete newEngine;
|
|
|
- return DisplaySourceWindow(false, folders);
|
|
|
+ return false;
|
|
|
}
|
|
|
engine.reset(newEngine);
|
|
|
OnEngineUpdated();
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::DisplaySourceWindow(bool canCancel, const std::vector<std::string>& previous)
|
|
|
+{
|
|
|
+ const std::vector<std::string> folders = BrowseModal::Display(canCancel, previous);
|
|
|
+
|
|
|
+ if (folders.empty())
|
|
|
+ {
|
|
|
+ if (!canCancel)
|
|
|
+ DisplaySourceWindow(canCancel, previous);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!TryOpenningDir(folders))
|
|
|
+ DisplaySourceWindow(canCancel, folders);
|
|
|
}
|
|
|
void MainWindow::DisplaySourceWindow(bool canCancel)
|
|
|
{
|