Backward compatibility with <= Qt 5.1.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-11-28 21:04:51 +02:00
parent a9d4e6271e
commit 40fc6bea54
2 changed files with 38 additions and 0 deletions

View File

@ -108,10 +108,18 @@ void TapeConfigurationPage::LangChanged()
void TapeConfigurationPage::SystemChanged() void TapeConfigurationPage::SystemChanged()
{ {
systemChanged = true; systemChanged = true;
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->itemData(systemCombo->currentIndex()).toString());
#else
QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->currentData().toString()); QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->currentData().toString());
#endif
systemAuthorValueLabel->setText(text); systemAuthorValueLabel->setText(text);
systemAuthorValueLabel->setToolTip(text); systemAuthorValueLabel->setToolTip(text);
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
text = qApp->TrVars()->PMSystemBook(systemCombo->itemData(systemCombo->currentIndex()).toString());
#else
text = qApp->TrVars()->PMSystemBook(systemCombo->currentData().toString()); text = qApp->TrVars()->PMSystemBook(systemCombo->currentData().toString());
#endif
systemBookValueLabel->setText(text); systemBookValueLabel->setText(text);
systemBookValueLabel->setToolTip(text); systemBookValueLabel->setToolTip(text);
} }
@ -263,10 +271,18 @@ void TapeConfigurationPage::RetranslateUi()
systemAuthorLabel->setText(tr("Author:")); systemAuthorLabel->setText(tr("Author:"));
systemBookLabel->setText(tr("Book:")); systemBookLabel->setText(tr("Book:"));
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->itemData(systemCombo->currentIndex()).toString());
#else
QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->currentData().toString()); QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->currentData().toString());
#endif
systemAuthorValueLabel->setText(text); systemAuthorValueLabel->setText(text);
systemAuthorValueLabel->setToolTip(text); systemAuthorValueLabel->setToolTip(text);
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
text = qApp->TrVars()->PMSystemBook(systemCombo->itemData(systemCombo->currentIndex()).toString());
#else
text = qApp->TrVars()->PMSystemBook(systemCombo->currentData().toString()); text = qApp->TrVars()->PMSystemBook(systemCombo->currentData().toString());
#endif
systemBookValueLabel->setText(text); systemBookValueLabel->setText(text);
systemBookValueLabel->setToolTip(text); systemBookValueLabel->setToolTip(text);

View File

@ -62,13 +62,21 @@ DialogNewMeasurements::~DialogNewMeasurements()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MeasurementsType DialogNewMeasurements::Type() const MeasurementsType DialogNewMeasurements::Type() const
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
return static_cast<Unit>(ui->comboBoxMType->itemData(ui->comboBoxMType->currentIndex()).toInt());
#else
return static_cast<MeasurementsType>(ui->comboBoxMType->currentData().toInt()); return static_cast<MeasurementsType>(ui->comboBoxMType->currentData().toInt());
#endif
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Unit DialogNewMeasurements::MUnit() const Unit DialogNewMeasurements::MUnit() const
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
return static_cast<Unit>(ui->comboBoxUnit->itemData(ui->comboBoxUnit->currentIndex()).toInt());
#else
return static_cast<Unit>(ui->comboBoxUnit->currentData().toInt()); return static_cast<Unit>(ui->comboBoxUnit->currentData().toInt());
#endif
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -91,7 +99,13 @@ void DialogNewMeasurements::changeEvent(QEvent *event)
// retranslate designer form (single inheritance approach) // retranslate designer form (single inheritance approach)
ui->retranslateUi(this); ui->retranslateUi(this);
InitMTypes(); InitMTypes();
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const MeasurementsType type =
static_cast<MeasurementsType>(ui->comboBoxMType->itemData(ui->comboBoxMType->currentIndex()).toInt());
#else
const MeasurementsType type = static_cast<MeasurementsType>(ui->comboBoxMType->currentData().toInt()); const MeasurementsType type = static_cast<MeasurementsType>(ui->comboBoxMType->currentData().toInt());
#endif
InitUnits(type); InitUnits(type);
} }
@ -151,7 +165,11 @@ void DialogNewMeasurements::InitMTypes()
int val = static_cast<int>(MeasurementsType::Unknown); int val = static_cast<int>(MeasurementsType::Unknown);
if (ui->comboBoxMType->currentIndex() != -1) if (ui->comboBoxMType->currentIndex() != -1)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
val = ui->comboBoxMType->itemData(ui->comboBoxMType->currentIndex()).toInt();
#else
val = ui->comboBoxMType->currentData().toInt(); val = ui->comboBoxMType->currentData().toInt();
#endif
} }
ui->comboBoxMType->blockSignals(true); ui->comboBoxMType->blockSignals(true);
@ -189,7 +207,11 @@ void DialogNewMeasurements::InitUnits(const MeasurementsType &type)
int val = static_cast<int>(Unit::Cm); int val = static_cast<int>(Unit::Cm);
if (ui->comboBoxUnit->currentIndex() != -1) if (ui->comboBoxUnit->currentIndex() != -1)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
val = ui->comboBoxUnit->itemData(ui->comboBoxUnit->currentIndex()).toInt();
#else
val = ui->comboBoxUnit->currentData().toInt(); val = ui->comboBoxUnit->currentData().toInt();
#endif
} }
ui->comboBoxUnit->blockSignals(true); ui->comboBoxUnit->blockSignals(true);