void DisplayedElementsModel::setSelection(
        const Selection & s)
{
    for_each_in_tuple(elements(), [&] (auto elt) {
        elt->selection.set(s.contains(elt.data())); // OPTIMIZEME
    });
 }
Beispiel #2
0
Selection BaseScenario::selectedChildren() const
{
    Selection s;
    for_each_in_tuple(elements(), [&] (auto elt) {
        if(elt->selection.get())
            s.append(elt);
    });
    return s;
}
    void setupDefaultSettings(QSettings& set, const T& tuple, Model& model)
    {
        for_each_in_tuple(tuple, [&] (auto& e) {
            using type = std::remove_reference_t<decltype(e)>;
            using data_type = typename type::data_type;
            using param_type = typename type::parameter_type;

            // If we cannot find the key, it means that it's a new setting.
            // Hence we set the default value both in the QSettings and in the model.
            if(!set.contains(e.key))
            {
                set.setValue(e.key, QVariant::fromValue(e.def));
                (model.*param_type::set())(e.def);
            }
            else
            {
                // We fetch the value from the settings.
                auto val = set.value(e.key).template value<data_type>();
                (model.*param_type::set())(val);
            }
        });
    }
Beispiel #4
0
int main()
{
    std::tuple<int, double, std::string> t{42, 3.14, "Hello World!"};
    
    for_each_in_tuple(t, my_functor());
}