Commit e919bb96 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

VCS: Make editorparameterwidget comboboxes work with indexes

Change-Id: Id3d81e59f85d9b7d2dbadef337b97be13a37a598
Reviewed-on: http://codereview.qt-project.org/6160

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 8a857ecc
......@@ -42,35 +42,42 @@ namespace VCSBase {
namespace Internal {
struct SettingMappingData
class SettingMappingData
{
public:
enum Type
{
Invalid,
Bool,
String
String,
Int
};
SettingMappingData() : boolSetting(0), stringSetting(0)
SettingMappingData() : boolSetting(0), m_type(Invalid)
{ }
SettingMappingData(bool *setting) : boolSetting(setting), m_type(Bool)
{ }
SettingMappingData(bool *setting) : boolSetting(setting), stringSetting(0)
SettingMappingData(QString *setting) : stringSetting(setting), m_type(String)
{ }
SettingMappingData(QString *setting) : boolSetting(0), stringSetting(setting)
SettingMappingData(int *setting) : intSetting(setting), m_type(Int)
{ }
Type type() const
{
if (boolSetting)
return Bool;
if (stringSetting)
return String;
return Invalid;
return m_type;
}
bool *boolSetting;
QString *stringSetting;
union {
bool *boolSetting;
QString *stringSetting;
int *intSetting;
};
private:
Type m_type;
};
} // namespace Internal
......@@ -196,6 +203,21 @@ void VCSBaseEditorParameterWidget::mapSetting(QComboBox *comboBox, QString *sett
}
}
void VCSBaseEditorParameterWidget::mapSetting(QComboBox *comboBox, int *setting)
{
if (d->m_settingMapping.contains(comboBox) || !comboBox)
return;
d->m_settingMapping.insert(comboBox, Internal::SettingMappingData(setting));
if (!setting || *setting < 0 || *setting >= comboBox->count())
return;
comboBox->blockSignals(true);
comboBox->setCurrentIndex(*setting);
comboBox->blockSignals(false);
}
/*!
\brief This property holds the format (template) of assignable command line
options (like --file=<file> for example)
......@@ -287,6 +309,13 @@ void VCSBaseEditorParameterWidget::updateMappedSettings()
*settingData.stringSetting = cb->itemData(cb->currentIndex()).toString();
break;
}
case Internal::SettingMappingData::Int:
{
const QComboBox *cb = qobject_cast<const QComboBox *>(optMapping.widget);
if (cb && cb->currentIndex() != -1)
*settingData.intSetting = cb->currentIndex();
break;
}
case Internal::SettingMappingData::Invalid : break;
} // end switch ()
}
......
......@@ -73,6 +73,7 @@ public:
void mapSetting(QToolButton *button, bool *setting);
void mapSetting(QComboBox *comboBox, QString *setting);
void mapSetting(QComboBox *comboBox, int *setting);
QStringList comboBoxOptionTemplate() const;
void setComboBoxOptionTemplate(const QStringList &optTemplate) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment