void ThemeSettingsTableModel::toTheme(Theme *t) const
{
    ThemePrivate *theme = t->d;
    // Colors
    {
        QMetaEnum e = Theme::staticMetaObject.enumerator(Theme::staticMetaObject.indexOfEnumerator("Color"));
        for (int i = 0, total = e.keyCount(); i < total; ++i) {
            ColorRole::Ptr role = colors()->colorRole(i);
            ColorVariable::Ptr var = role->colorVariable();
            theme->colors[i] = qMakePair(var->color(), var->variableName());
        }
    }
    // Flags
    {
        QTC_ASSERT(theme->flags.size() == m_flags.size(), return);
        for (int i = 0; i < theme->flags.size(); ++i)
            theme->flags[i] = m_flags[i].second;
    }
    // ImageFiles
    {
        const int nImageFiles = theme->imageFiles.size();
        for (int i = 0; i < nImageFiles; ++i)
            theme->imageFiles[i] = m_imageFiles.at(i).second;
    }

    theme->widgetStyle = m_widgetStyle;
    theme->name = m_name;
    theme->preferredStyles = m_preferredStyles;
}
void ThemeSettingsTableModel::toTheme(Theme *t) const
{
    ThemePrivate *theme = t->d;
    // Colors
    {
        QMetaEnum e = Theme::staticMetaObject.enumerator(Theme::staticMetaObject.indexOfEnumerator("ColorRole"));
        for (int i = 0, total = e.keyCount(); i < total; ++i) {
            ColorRole::Ptr role = colors()->colorRole(i);
            ColorVariable::Ptr var = role->colorVariable();
            theme->colors[i] = qMakePair(var->color(), var->variableName());
        }
    }
    // Flags
    {
        QTC_ASSERT(theme->flags.size() == m_flags.size(), return);
        for (int i = 0; i < theme->flags.size(); ++i)
            theme->flags[i] = m_flags[i].second;
    }
    // IconOveralys
    {
        const int nOverlays = theme->iconOverlays.size();
        QTC_ASSERT(nOverlays == m_iconOverlays.size(), return);
        for (int i = 0; i < nOverlays; ++i)
            theme->iconOverlays[i] = m_iconOverlays[i].second;
    }

    theme->widgetStyle = m_widgetStyle;
    theme->name = m_name;
    emit t->changed();
}