MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / OnBrowserAddMenuItem

Method OnBrowserAddMenuItem

src/gui/browserpanel.cc:379–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377 }
378
379 void OnBrowserAddMenuItem(wxCommandEvent&) override
380 {
381 auto item = browserTree->GetSelection();
382 auto dirNode = GetTargetDirectoryNode(item);
383 if (!dirNode)
384 return;
385
386 auto localPath = wxFileSelector("Choose the name of the file to add",
387 /* default_path= */ wxEmptyString,
388 /* default_filename= */ wxEmptyString,
389 /* default_extension= */ wxEmptyString,
390 /* wildcard= */ wxEmptyString,
391 /* flags= */ wxFD_OPEN | wxFD_FILE_MUST_EXIST)
392 .ToStdString();
393 if (localPath.empty())
394 return;
395 auto path = dirNode->dirent->path.concat(
396 wxFileName(localPath).GetFullName().ToStdString());
397
398 QueueJob(
399 [this, path, localPath]() mutable
400 {
401 path = ResolveFileConflicts_WT(path);
402 if (path.empty())
403 return;
404
405 auto bytes = Bytes::readFromFile(localPath);
406 _filesystem->putFile(path, bytes);
407
408 auto dirent = _filesystem->getDirent(path);
409
410 runOnUiThread(
411 [&]()
412 {
413 _filesystemModel->Add(dirent);
414 UpdateFilesystemData();
415 });
416 });
417 }
418
419 void OnBrowserDeleteMenuItem(wxCommandEvent&) override
420 {

Callers

nothing calls this directly

Calls 6

concatMethod · 0.80
AddMethod · 0.80
runOnUiThreadFunction · 0.70
emptyMethod · 0.45
putFileMethod · 0.45
getDirentMethod · 0.45

Tested by

no test coverage detected