#ifndef STORYCHAINSPRESENT_H
#define STORYCHAINSPRESENT_H

#include "DocsManager.h"
#include "appcore.h"
#include "tools.h"

#include <QPlainTextEdit>
#include <QStandardItemModel>
#include <QTreeView>
#include <QWidget>
#include <libParse.h>

namespace DataModel {

    /**
     * @brief 情节链展示后端
     */
    class StorychainsPresentModel : public Schedule::AccessibleObject {
      public:
        StorychainsPresentModel(Core::AppCore *core);
        virtual ~StorychainsPresentModel();

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

        void refreshTree();
        void showDetails(const QList<QString> &chain_path);

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

      private:
        Core::AppCore *const core_ins;
        QStandardItemModel *const model_base;
        QTextDocument *const details_base;
        Tools::TreeSyncs<Parse::Result::DesNode *> *sync_tools;
    };

} // namespace DataModel

namespace Components {

    /**
     * @brief 情节链展示视图
     */
    class StorychainsPresent : public QWidget, public MakeTools::PresentBase {
        Q_OBJECT
    public:
      explicit StorychainsPresent(Schedule::CommandsDispatcher *disp, DataModel::StorychainsPresentModel *back, QWidget *parent = nullptr);

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

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

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

        void jump_to(const QModelIndex &curr);
        void detail_show(const QModelIndex &curr);
    };
}


#endif // STORYCHAINSPRESENT_H
