#ifndef STORYUNITSPRESENT_H
#define STORYUNITSPRESENT_H

#include <QPlainTextEdit>
#include <QStandardItemModel>
#include <QTextEdit>
#include <QTreeView>
#include <QWidget>

#include "DocsManager.h"
#include "appcore.h"
#include "libParse.h"

namespace DataModel {

    class StoryunitsPresentModel : public Schedule::AccessibleObject {
      public:
        StoryunitsPresentModel(Core::AppCore *core);
        virtual ~StoryunitsPresentModel();

        QStandardItemModel *treeModel() const;
        QTextDocument *detailsBackend() const;

        void refreshTree();
        void details_show(const QList<QString> &path);

        // AccessibleObject interface
      public:
        virtual QString name() const override;

      private:
        Core::AppCore *const core_ins;
        QStandardItemModel *const model_ins;
        QTextDocument *const details_backend;
    };

} // namespace DataModel

namespace Components {

    class StoryunitsPresent : public QWidget, public MakeTools::PresentBase {
        Q_OBJECT
      public:
        explicit StoryunitsPresent(Schedule::CommandsDispatcher *core, DataModel::StoryunitsPresentModel *backend, QWidget *parent = nullptr);

        // AccessibleObject interface
      public:
        virtual QString name() const override;
        // PresentBase interface
      public:
        virtual QWidget *widget() const override;

      private:
        Schedule::CommandsDispatcher *const disp_core;
        QTreeView *const units_view;
        QTextEdit *const details_show;

        void jump_to(const QModelIndex &curr);
        void show_details(const QModelIndex &curr);
    };
} // namespace Components

#endif // STORYUNITSPRESENT_H
