Skip to content
Snippets Groups Projects
SkillDetailsTreeWidget.h 2.1 KiB
Newer Older
#ifndef SKILLDETAILSTREEWIDGET_H
#define SKILLDETAILSTREEWIDGET_H

#include <vector>
#include <QTreeWidget>

Peter Albrecht's avatar
Peter Albrecht committed
#include "RobotAPI/libraries/aron/core/data/variant/container/Dict.h"
#include "RobotAPI/libraries/skills/core/SkillID.h"
#include "RobotAPI/libraries/skills_gui/aron_tree_widget/AronTreeWidgetController.h"

#include "../memory/MemoryCommunicatorBase.h"

namespace armarx::skills::gui
{
    class SkillDetailsTreeWidget : public QTreeWidget, public MemoryCommunicatorBase
    {
    public:
        SkillDetailsTreeWidget(std::shared_ptr<SkillManagerWrapper> _memory,
                               QWidget* parent = nullptr);
        std::optional<skills::SkillID> getShownId();
        void updateContents(skills::SkillID const& skillId, skills::SkillDescription const& descr);

        aron::data::DictPtr getConfigAsAron();
        void pasteCurrentConfig();
    signals:
        void updated(const skills::SkillID shownSkill);

        // this will reset the args to the profile defaults
        void resetCurrentConfig();
Peter Albrecht's avatar
Peter Albrecht committed
        void copyCurrentConfig();
Peter Albrecht's avatar
Peter Albrecht committed
        void copyCurrentSkillID();
        void disconnectGui();
        void updateGui(SkillManagerWrapper::Snapshot update);
        void resizeContents();
        void reloadLastParameters();
 
    private:
        struct ShownSkill
        {
            skills::SkillID skillId;
            skills::SkillDescription descr;
Peter Albrecht's avatar
Peter Albrecht committed
            armarx::aron::data::DictPtr originalParameters;
        };

        std::optional<ShownSkill> shownSkill;

        // The size, which we assume the last column to be.
        // If the last column has too little space, increase this value.
        const int typeWidth = 200;

        AronTreeWidgetControllerPtr aronTreeWidgetController = nullptr;
        void setupUi();
        void checkIfShownSkillIsAvailable(SkillManagerWrapper::Snapshot& update);
Peter Albrecht's avatar
Peter Albrecht committed
        bool askUserToConfirmWidgetReset();
        bool checkIfParametersAreModified();

        bool showWidgetResetConfirmation_ = true;
    };
} // namespace armarx::skills::gui

#endif // SKILLDETAILSTREEWIDGET_H