#ifndef SRCEDIT_STORYUNIT_H
#define SRCEDIT_STORYUNIT_H

#include "srcedit_defaulttext.h"
#include "keywordshighlighter.h"

#include <QSplitter>
#include <QTableView>

namespace Components {

    class StoryunitSourceEdit : public MakeTools::FilePresent, public MakeTools::CompileFeature,
            public Presents::ModeView, public Enhancement::HighlightFeature
    {
    public:
        StoryunitSourceEdit();
        virtual ~StoryunitSourceEdit();

        // ModeView interface
    public:
        virtual void modeReset(const QString &type) const override;
        virtual QList<QString> modes() const override;
        virtual QString currentMode() const override;

    private:
        QTextEdit *edit_square;
        QTableView *const refers_descriptions;
        QStandardItemModel *const refers_model;
        QSplitter *const split;
        QSyntaxHighlighter *const words_highlighter;
        QString name_store;
        QString filepath_store;
        Core::AppCore *core_ins;

        void cursor_contex_query();
        void present_refersed_tips(const QString &unit, const QString &frag);

        // HighlightDemand interface
    public:
      virtual void contexBinding(Core::AppCore *app) override;
      virtual void renderRepeat() const override;

      // ContentPresent interface
    public:
        virtual QList<QString> suffixes() const override;
        virtual std::tuple<bool, QString> create(const QDir &target, const QString &name, const QString &suffix) override;
        virtual MakeTools::FilePresent *newInst() const override;
        virtual void applySetting(const QString &name, Core::AppCore *core) override;
        virtual QString name() const override;
        virtual void load(const QFileInfo &target_file) override;
        virtual void saveAs(const QString &path) override;
        virtual QString relativeTargetPath(const QDir &base) const override;
        virtual QString absoluteTargetPath() const override;
        virtual QString getText() const override;
        virtual bool isModified() const override;
        virtual void jumpTo(const QList<QString> &path) override;
        virtual QWidget *widget() const override;
        virtual Features features() override;
    };

}

#endif // SRCEDIT_STORYUNIT_H
