QCombobox::currentData was introduced since Qt 5.2.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-04-02 12:51:27 +03:00
parent 07ec5aacf8
commit 7e49c3524f
4 changed files with 35 additions and 2 deletions

View File

@ -324,7 +324,13 @@ void DialogLayoutSettings::InitTemplates()
//---------------------------------------------------------------------------------------------------------------------
QSizeF DialogLayoutSettings::Template()
{
const PaperSizeTemplate temp = static_cast<PaperSizeTemplate>(ui->comboBoxTemplates->currentData().toInt());
PaperSizeTemplate temp;
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
temp = static_cast<PaperSizeTemplate>(ui->comboBoxTemplates->itemData(ui->comboBoxTemplates->currentIndex())
.toInt());
#else
temp = static_cast<PaperSizeTemplate>(ui->comboBoxTemplates->currentData().toInt());
#endif
const Unit paperUnit = PaperUnit();
qreal width = 0;
@ -361,13 +367,23 @@ QSizeF DialogLayoutSettings::Template()
//---------------------------------------------------------------------------------------------------------------------
Unit DialogLayoutSettings::PaperUnit() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
return VDomDocument::StrToUnits(ui->comboBoxPaperSizeUnit->itemData(ui->comboBoxPaperSizeUnit->currentIndex())
.toString());
#else
return VDomDocument::StrToUnits(ui->comboBoxPaperSizeUnit->currentData().toString());
#endif
}
//---------------------------------------------------------------------------------------------------------------------
Unit DialogLayoutSettings::LayoutUnit() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
return VDomDocument::StrToUnits(ui->comboBoxLayoutUnit->itemData(ui->comboBoxLayoutUnit->currentIndex())
.toString());
#else
return VDomDocument::StrToUnits(ui->comboBoxLayoutUnit->currentData().toString());
#endif
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -92,7 +92,11 @@ QString DialogSaveLayout::FileName() const
//---------------------------------------------------------------------------------------------------------------------
QString DialogSaveLayout::Formate() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
return ui->comboBoxFormat->currentData(ui->comboBoxFormat->currentIndex()).toString();
#else
return ui->comboBoxFormat->currentData().toString();
#endif
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -216,7 +216,11 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type)
*/
quint32 DialogLine::GetFirstPoint() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
return qvariant_cast<quint32>(ui->comboBoxFirstPoint->currentData(ui->comboBoxFirstPoint->currentIndex()));
#else
return qvariant_cast<quint32>(ui->comboBoxFirstPoint->currentData());
#endif
}
//---------------------------------------------------------------------------------------------------------------------
@ -226,7 +230,11 @@ quint32 DialogLine::GetFirstPoint() const
*/
quint32 DialogLine::GetSecondPoint() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
return qvariant_cast<quint32>(ui->comboBoxSecondPoint->currentData(ui->comboBoxSecondPoint->currentIndex()));
#else
return qvariant_cast<quint32>(ui->comboBoxSecondPoint->currentData());
#endif
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -319,7 +319,12 @@ void DialogTool::FillComboBoxLineColors(QComboBox *box) const
QString DialogTool::GetComboBoxCurrentData(const QComboBox *box) const
{
SCASSERT(box != nullptr)
QString value = box->currentData().toString();
QString value;
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
value = box->itemData(box->currentIndex()).toString();
#else
value = box->currentData().toString();
#endif
if (value.isEmpty())
{
value = VAbstractTool::TypeLineLine;