From 7e49c3524fd506547bd158f3d7a79a12b769f15d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 2 Apr 2015 12:51:27 +0300 Subject: [PATCH] QCombobox::currentData was introduced since Qt 5.2. --HG-- branch : develop --- src/app/dialogs/app/dialoglayoutsettings.cpp | 18 +++++++++++++++++- src/app/dialogs/app/dialogsavelayout.cpp | 4 ++++ src/app/dialogs/tools/dialogline.cpp | 8 ++++++++ src/app/dialogs/tools/dialogtool.cpp | 7 ++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/app/dialogs/app/dialoglayoutsettings.cpp b/src/app/dialogs/app/dialoglayoutsettings.cpp index 39f141384..bc57af02d 100644 --- a/src/app/dialogs/app/dialoglayoutsettings.cpp +++ b/src/app/dialogs/app/dialoglayoutsettings.cpp @@ -324,7 +324,13 @@ void DialogLayoutSettings::InitTemplates() //--------------------------------------------------------------------------------------------------------------------- QSizeF DialogLayoutSettings::Template() { - const PaperSizeTemplate temp = static_cast(ui->comboBoxTemplates->currentData().toInt()); + PaperSizeTemplate temp; +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) + temp = static_cast(ui->comboBoxTemplates->itemData(ui->comboBoxTemplates->currentIndex()) + .toInt()); +#else + temp = static_cast(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 } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/app/dialogsavelayout.cpp b/src/app/dialogs/app/dialogsavelayout.cpp index 0e84a6510..8ee9364db 100644 --- a/src/app/dialogs/app/dialogsavelayout.cpp +++ b/src/app/dialogs/app/dialogsavelayout.cpp @@ -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 } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp index 8d5ba671f..fb0e8e3b2 100644 --- a/src/app/dialogs/tools/dialogline.cpp +++ b/src/app/dialogs/tools/dialogline.cpp @@ -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(ui->comboBoxFirstPoint->currentData(ui->comboBoxFirstPoint->currentIndex())); +#else return qvariant_cast(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(ui->comboBoxSecondPoint->currentData(ui->comboBoxSecondPoint->currentIndex())); +#else return qvariant_cast(ui->comboBoxSecondPoint->currentData()); +#endif } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 99fc95b5a..77ebae61e 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -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;