forked from qt-creator/qt-creator
VCS: Make editorparameterwidget comboboxes work with indexes
Change-Id: Id3d81e59f85d9b7d2dbadef337b97be13a37a598 Reviewed-on: http://codereview.qt-project.org/6160 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -42,35 +42,42 @@ namespace VCSBase {
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
struct SettingMappingData
|
class SettingMappingData
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
enum Type
|
enum Type
|
||||||
{
|
{
|
||||||
Invalid,
|
Invalid,
|
||||||
Bool,
|
Bool,
|
||||||
String
|
String,
|
||||||
|
Int
|
||||||
};
|
};
|
||||||
|
|
||||||
SettingMappingData() : boolSetting(0), stringSetting(0)
|
SettingMappingData() : boolSetting(0), m_type(Invalid)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
SettingMappingData(bool *setting) : boolSetting(setting), stringSetting(0)
|
SettingMappingData(bool *setting) : boolSetting(setting), m_type(Bool)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
SettingMappingData(QString *setting) : boolSetting(0), stringSetting(setting)
|
SettingMappingData(QString *setting) : stringSetting(setting), m_type(String)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
SettingMappingData(int *setting) : intSetting(setting), m_type(Int)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Type type() const
|
Type type() const
|
||||||
{
|
{
|
||||||
if (boolSetting)
|
return m_type;
|
||||||
return Bool;
|
|
||||||
if (stringSetting)
|
|
||||||
return String;
|
|
||||||
return Invalid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool *boolSetting;
|
union {
|
||||||
QString *stringSetting;
|
bool *boolSetting;
|
||||||
|
QString *stringSetting;
|
||||||
|
int *intSetting;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type m_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // 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
|
\brief This property holds the format (template) of assignable command line
|
||||||
options (like --file=<file> for example)
|
options (like --file=<file> for example)
|
||||||
@@ -287,6 +309,13 @@ void VCSBaseEditorParameterWidget::updateMappedSettings()
|
|||||||
*settingData.stringSetting = cb->itemData(cb->currentIndex()).toString();
|
*settingData.stringSetting = cb->itemData(cb->currentIndex()).toString();
|
||||||
break;
|
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;
|
case Internal::SettingMappingData::Invalid : break;
|
||||||
} // end switch ()
|
} // end switch ()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ public:
|
|||||||
|
|
||||||
void mapSetting(QToolButton *button, bool *setting);
|
void mapSetting(QToolButton *button, bool *setting);
|
||||||
void mapSetting(QComboBox *comboBox, QString *setting);
|
void mapSetting(QComboBox *comboBox, QString *setting);
|
||||||
|
void mapSetting(QComboBox *comboBox, int *setting);
|
||||||
|
|
||||||
QStringList comboBoxOptionTemplate() const;
|
QStringList comboBoxOptionTemplate() const;
|
||||||
void setComboBoxOptionTemplate(const QStringList &optTemplate) const;
|
void setComboBoxOptionTemplate(const QStringList &optTemplate) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user