<commit_before>/// HEADER
#include <csapex/view/node/parameter_context_menu.h>

/// PROJECT
#include <csapex/param/parameter.h>

using namespace csapex;

ParameterContextMenu::ParameterContextMenu(csapex::param::ParameterWeakPtr p)
    : param_(p)
{

}

void ParameterContextMenu::addAction(QAction *action, const std::function<void()>& callback)
{
    actions_[action] = callback;
}

void ParameterContextMenu::doShowContextMenu(const QPoint& global_pt)
{
    auto param = param_.lock();
    if(!param) {
        return;
    }
    QMenu menu;
    ContextMenuHandler::addHeader(menu, std::string("Parameter: ") + param->name());

    if(!actions_.empty()) {
        for(auto pair : actions_) {
            menu.addAction(pair.first);
        }

        menu.addSeparator();
    }

    QAction* connector = new QAction("make connectable", &menu);
    connector->setCheckable(true);
    connector->setChecked(param->isInteractive());
    connector->setIcon(QIcon(":/connector.png"));

    connector->setIconVisibleInMenu(true);
    menu.addAction(connector);

    QAction* selectedItem = menu.exec(global_pt);
    if (selectedItem) {
        if(selectedItem == connector) {
            param->setInteractive(!param->isInteractive());
        } else {
            actions_[selectedItem]();
        }
    }
}<commit_msg>Fixes #124: Temporary are not allowd to be conntected -> disabled context menu option for it<commit_after>/// HEADER
#include <csapex/view/node/parameter_context_menu.h>

/// PROJECT
#include <csapex/param/parameter.h>

using namespace csapex;

ParameterContextMenu::ParameterContextMenu(csapex::param::ParameterWeakPtr p)
    : param_(p)
{

}

void ParameterContextMenu::addAction(QAction *action, const std::function<void()>& callback)
{
    actions_[action] = callback;
}

void ParameterContextMenu::doShowContextMenu(const QPoint& global_pt)
{
    auto param = param_.lock();
    if(!param) {
        return;
    }
    QMenu menu;
    ContextMenuHandler::addHeader(menu, std::string("Parameter: ") + param->name());

    if(!actions_.empty()) {
        for(auto pair : actions_) {
            menu.addAction(pair.first);
        }

        menu.addSeparator();
    }

        QAction* connector = new QAction("make connectable", &menu);
        connector->setCheckable(true);
        connector->setChecked(param->isInteractive());
        connector->setIcon(QIcon(":/connector.png"));

        connector->setIconVisibleInMenu(true);
        if(param->isTemporary()) {
            connector->setEnabled(false);
        }
        menu.addAction(connector);

        QAction* selectedItem = menu.exec(global_pt);
        if (selectedItem) {
            if(selectedItem == connector) {
                param->setInteractive(!param->isInteractive());
            } else {
                actions_[selectedItem]();
            }
        }
}
{'fraction_non_alphanumeric': 0.13980378416257883, 'fraction_numerical': 0.001051156271899089, 'mean_word_length': 3.1079136690647484, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6810488', 'n_tokens_mistral': 861, 'n_tokens_neox': 832, 'n_words': 140}