/*
 * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#pragma once

#include <ox/event/signal.hpp>
#include <ox/std/memory.hpp>

#include "lib/widget.hpp"
#include "projecttreemodel.hpp"

namespace nostalgia {

class ProjectExplorer: public studio::Widget {
	private:
		ox::UniquePtr<ProjectTreeModel> m_treeModel;
		core::Context *m_ctx = nullptr;
	public:
		explicit ProjectExplorer(core::Context *ctx) noexcept;

		void draw(core::Context *ctx) noexcept override;

		void setModel(ox::UniquePtr<ProjectTreeModel> model) noexcept;

		ox::Error refreshProjectTreeModel(const ox::String& = {}) noexcept;

		[[nodiscard]]
		constexpr ox::FileSystem *romFs() noexcept {
			return m_ctx->rom.get();
		}

	// slots
	public:
		ox::Signal<ox::Error(const ox::String&)> fileChosen;
};

}