[studio] Add ability to move directories
All checks were successful
Build / build (push) Successful in 3m29s
All checks were successful
Build / build (push) Successful in 3m29s
This commit is contained in:
@ -30,6 +30,10 @@ void ProjectExplorer::fileMoved(ox::StringViewCR src, ox::StringViewCR dst) cons
|
||||
moveItem.emit(src, dst);
|
||||
}
|
||||
|
||||
void ProjectExplorer::dirMoved(ox::StringViewCR src, ox::StringViewCR dst) const noexcept {
|
||||
moveDir.emit(src, dst);
|
||||
}
|
||||
|
||||
void ProjectExplorer::fileContextMenu(ox::StringViewCR path) const noexcept {
|
||||
if (ImGui::BeginPopupContextItem("FileMenu", ImGuiPopupFlags_MouseButtonRight)) {
|
||||
if (ImGui::MenuItem("Delete")) {
|
||||
|
@ -20,6 +20,7 @@ class ProjectExplorer final: public FileExplorer {
|
||||
ox::Signal<ox::Error(ox::StringViewCR)> addDir;
|
||||
ox::Signal<ox::Error(ox::StringViewCR)> deleteItem;
|
||||
ox::Signal<ox::Error(ox::StringViewCR)> renameItem;
|
||||
ox::Signal<ox::Error(ox::StringViewCR src, ox::StringViewCR dst)> moveDir;
|
||||
ox::Signal<ox::Error(ox::StringViewCR src, ox::StringViewCR dst)> moveItem;
|
||||
|
||||
explicit ProjectExplorer(keel::Context &kctx) noexcept;
|
||||
@ -33,6 +34,8 @@ class ProjectExplorer final: public FileExplorer {
|
||||
|
||||
void fileMoved(ox::StringViewCR src, ox::StringViewCR dst) const noexcept override;
|
||||
|
||||
void dirMoved(ox::StringViewCR src, ox::StringViewCR dst) const noexcept override;
|
||||
|
||||
void fileContextMenu(ox::StringViewCR path) const noexcept override;
|
||||
|
||||
void dirContextMenu(ox::StringViewCR path) const noexcept override;
|
||||
|
@ -59,6 +59,7 @@ StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexce
|
||||
m_projectExplorer.addItem.connect(this, &StudioUI::addFile);
|
||||
m_projectExplorer.deleteItem.connect(this, &StudioUI::deleteFile);
|
||||
m_projectExplorer.renameItem.connect(this, &StudioUI::renameFile);
|
||||
m_projectExplorer.moveDir.connect(this, &StudioUI::queueDirMove);
|
||||
m_projectExplorer.moveItem.connect(this, &StudioUI::queueFileMove);
|
||||
m_renameFile.moveFile.connect(this, &StudioUI::queueFileMove);
|
||||
m_newProject.finished.connect(this, &StudioUI::createOpenProject);
|
||||
@ -486,6 +487,11 @@ ox::Error StudioUI::closeFile(ox::StringViewCR path) noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error StudioUI::queueDirMove(ox::StringParam src, ox::StringParam dst) noexcept {
|
||||
m_queuedDirMoves.emplace_back(std::move(src), std::move(dst));
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error StudioUI::queueFileMove(ox::StringParam src, ox::StringParam dst) noexcept {
|
||||
m_queuedMoves.emplace_back(std::move(src), std::move(dst));
|
||||
return {};
|
||||
@ -496,6 +502,10 @@ void StudioUI::procFileMoves() noexcept {
|
||||
oxLogError(m_project->moveItem(m.a, m.b));
|
||||
}
|
||||
m_queuedMoves.clear();
|
||||
for (auto const &m : m_queuedDirMoves) {
|
||||
oxLogError(m_project->moveDir(m.a, m.b));
|
||||
}
|
||||
m_queuedDirMoves.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ class StudioUI: public ox::SignalHandler {
|
||||
BaseEditor *m_activeEditorOnLastDraw = nullptr;
|
||||
BaseEditor *m_activeEditor = nullptr;
|
||||
BaseEditor *m_activeEditorUpdatePending = nullptr;
|
||||
ox::Vector<ox::Pair<ox::String, ox::String>> m_queuedMoves;
|
||||
ox::Vector<ox::Pair<ox::String>> m_queuedMoves;
|
||||
ox::Vector<ox::Pair<ox::String>> m_queuedDirMoves;
|
||||
NewMenu m_newMenu{keelCtx(m_tctx)};
|
||||
DeleteConfirmation m_deleteConfirmation;
|
||||
NewDir m_newDirDialog;
|
||||
@ -113,6 +114,8 @@ class StudioUI: public ox::SignalHandler {
|
||||
|
||||
ox::Error closeFile(ox::StringViewCR path) noexcept;
|
||||
|
||||
ox::Error queueDirMove(ox::StringParam src, ox::StringParam dst) noexcept;
|
||||
|
||||
ox::Error queueFileMove(ox::StringParam src, ox::StringParam dst) noexcept;
|
||||
|
||||
void procFileMoves() noexcept;
|
||||
|
Reference in New Issue
Block a user