Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.78 KB | None | 0 0
  1. diff --git a/src/mobility/organizertreemodel.cpp b/src/mobility/organizertreemodel.cpp
  2. index bca8f8a..db4b25f 100644
  3. --- a/src/mobility/organizertreemodel.cpp
  4. +++ b/src/mobility/organizertreemodel.cpp
  5. @@ -13,15 +13,15 @@ using namespace QtMobility;
  6.  
  7.  namespace {
  8.      int itemIdFromPath(const QString &path) {
  9. -        return path.section("/", 1, 1).toInt();
  10. +        return QLocale().toInt(path.section("/", 1, 1));
  11.      }
  12.  
  13.      int detailIdFromPath(const QString &path) {
  14. -        return path.section("/", 3, 3).toInt();
  15. +        return QLocale().toInt(path.section("/", 3, 3));
  16.      }
  17.  
  18.      int valueKeyIdFromPath(const QString &path) {
  19. -        return path.section("/", 5, 5).toInt();
  20. +        return QLocale().toInt(path.section("/", 5, 5));
  21.      }
  22.  }
  23.  
  24. @@ -214,17 +214,17 @@ QModelIndex OrganizerTreeModel::index(int row, int column, const QModelIndex &pa
  25.              }
  26.  
  27.              path = parentPath + "/value/%1";
  28. -            path = path.arg(QString::number(row));
  29. +            path = path.arg(QLocale().toString(row));
  30.          } else if (parentPath.contains("QOrganizerItemId")) { //parent is an organizer item
  31.              if (itemFromPath(parentPath).details().count() <= row) {
  32.                  return QModelIndex();
  33.              }
  34.              path = parentPath + "/QOrganizerItemDetail/%1";
  35. -            path = path.arg(QString::number(row));
  36. +            path = path.arg(QLocale().toString(row));
  37.          }
  38.      } else { //no parent means it is a root item
  39.          path = "QOrganizerItemId/%1";
  40. -        path = path.arg(QString::number(row));
  41. +        path = path.arg(QLocale().toString(row));
  42.      }
  43.      return createIndex(row, column, cachedPostion(path));
  44.  }
  45. diff --git a/src/other/applicationmanager.cpp b/src/other/applicationmanager.cpp
  46. index b59a534..d2c43a0 100644
  47. --- a/src/other/applicationmanager.cpp
  48. +++ b/src/other/applicationmanager.cpp
  49. @@ -115,7 +115,7 @@ void ApplicationManager::registerApplication(Application *newApp)
  50.  
  51.      // add to debug application table
  52.      mTableWidget->insertRow(0);
  53. -    QTableWidgetItem *item = new QTableWidgetItem(QString::number(newApp->id()));
  54. +    QTableWidgetItem *item = new QTableWidgetItem(QLocale().toString(newApp->id()));
  55.      item->setData(0, newApp->id());
  56.      mTableWidget->setItem(0, 0, item);
  57.      mTableWidget->setItem(0, 1, new QTableWidgetItem(newApp->name()));
  58. diff --git a/src/other/widgetmanager.cpp b/src/other/widgetmanager.cpp
  59. index 257d451..46573e7 100644
  60. --- a/src/other/widgetmanager.cpp
  61. +++ b/src/other/widgetmanager.cpp
  62. @@ -35,6 +35,7 @@
  63.  
  64.  #include <QtCore/QDebug>
  65.  #include <QtCore/QSharedMemory>
  66. +#include <QtCore/QLocale>
  67.  #include <QtGui/QWidget>
  68.  #include <QtGui/QTableWidget>
  69.  #include <QtGui/QLayout>
  70. @@ -46,8 +47,9 @@ namespace {
  71.  inline QString stringForCoord(QRect geometry)
  72.  {
  73.      QString result;
  74. -    result += QString::number(geometry.left()) + QLatin1String(",") + QString::number(geometry.top()) + QLatin1String(";");
  75. -    result += QString::number(geometry.width()) + QLatin1String(",") + QString::number(geometry.height());
  76. +    QLocale locale;
  77. +    result += locale.toString(geometry.left()) + QLatin1String(",") + locale.toString(geometry.top()) + QLatin1String(";");
  78. +    result += locale.toString(geometry.width()) + QLatin1String(",") + locale.toString(geometry.height());
  79.      return result;
  80.  }
  81.  
  82. @@ -178,7 +180,7 @@ QtSimulatorPrivate::NewWindowInfo WidgetManager::create(
  83.  
  84.      // insert into debug window widgets list
  85.      tableWidget->insertRow(0);
  86. -    tableWidget->setItem(0, 0, new QTableWidgetItem(QString::number(w->widgetId)));
  87. +    tableWidget->setItem(0, 0, new QTableWidgetItem(QLocale().toString(w->widgetId)));
  88.      tableWidget->setItem(0, 1, new QTableWidgetItem(w->title));
  89.      tableWidget->setItem(0, 2, new QTableWidgetItem(stringForCoord(w->geometry())));
  90.  
  91. @@ -244,7 +246,7 @@ void WidgetManager::updateLogItem(int id)
  92.      // Find the list item
  93.      int row = -1;
  94.      for (int i = 0; i < tableWidget->rowCount(); ++i) {
  95. -        if (tableWidget->item(i,0)->text().toInt() == id) {
  96. +        if (QLocale().toInt(tableWidget->item(i,0)->text()) == id) {
  97.              row = i;
  98.              break;
  99.          }
  100. @@ -261,12 +263,13 @@ void WidgetManager::updateLogItem(int id)
  101.      if (row == -1 || w == 0)
  102.          return;
  103.  
  104. +    QLocale locale;
  105.      // update the content
  106. -    tableWidget->setItem(row, 0, new QTableWidgetItem(QString::number(w->widgetId)));
  107. +    tableWidget->setItem(row, 0, new QTableWidgetItem(locale.toString(w->widgetId)));
  108.      tableWidget->setItem(row, 1, new QTableWidgetItem(w->title));
  109.      QRect actualGeometry = w->geometry();
  110.      actualGeometry.adjust(-mOffset.x(), -mOffset.y(), 0, 0);
  111. -    tableWidget->setItem(row, 2, new QTableWidgetItem(stringForCoord(actualGeometry) + QString(";z:") + QString::number(w->zValue())));
  112. +    tableWidget->setItem(row, 2, new QTableWidgetItem(stringForCoord(actualGeometry) + QString(";z:") + locale.toString(w->zValue())));
  113.  }
  114.  
  115.  void WidgetManager::hideWidget(int id)
  116. @@ -322,7 +325,7 @@ void WidgetManager::removeWidgetFromTable(int id)
  117.      // Find the list item
  118.      int row = -1;
  119.      for (int i = 0; i < tableWidget->rowCount(); ++i) {
  120. -        if (tableWidget->item(i,0)->text().toInt() == id) {
  121. +        if (QLocale().toInt(tableWidget->item(i,0)->text()) == id) {
  122.              row = i;
  123.              break;
  124.          }
  125. diff --git a/src/ui/docgalleryui.cpp b/src/ui/docgalleryui.cpp
  126. index c3a1065..1ef59cd 100644
  127. --- a/src/ui/docgalleryui.cpp
  128. +++ b/src/ui/docgalleryui.cpp
  129. @@ -46,6 +46,7 @@ void DocGalleryUi::addStandardItems()
  130.      // Add some images
  131.      QString modelPath = qApp->applicationDirPath() + "/models";
  132.      QDirIterator it(modelPath, QDirIterator::Subdirectories);
  133. +    QLocale locale;
  134.      while (it.hasNext()) {
  135.          QString item = it.next();
  136.          QImage image(item);
  137. @@ -53,8 +54,8 @@ void DocGalleryUi::addStandardItems()
  138.              continue;
  139.          QTreeWidgetItem* treeItem = new QTreeWidgetItem(imageHead);
  140.          treeItem->setText(0, item);
  141. -        treeItem->setText(1, QString::number(image.width()));
  142. -        treeItem->setText(2, QString::number(image.height()));
  143. +        treeItem->setText(1, locale.toString(image.width()));
  144. +        treeItem->setText(2, locale.toString(image.height()));
  145.          treeItem->setText(3, QLatin1String("Some model image"));
  146.          treeItem->setText(4, QLatin1String("Simulator Model"));
  147.  
  148. diff --git a/src/ui/feedbackui.cpp b/src/ui/feedbackui.cpp
  149. index 6dc5096..7d8581c 100644
  150. --- a/src/ui/feedbackui.cpp
  151. +++ b/src/ui/feedbackui.cpp
  152. @@ -115,7 +115,7 @@ void FeedbackUi::showActuatorInfo()
  153.          return;
  154.      }
  155.  
  156. -    int actuatorId = mActuators->itemData(mActuators->currentIndex()).toInt();
  157. +    int actuatorId = QLocale().toInt(mActuators->itemData(mActuators->currentIndex()));
  158.      const QtMobility::ActuatorData &actuator = mFeedback->actuator(actuatorId);
  159.      if (actuator.id != actuatorId) {
  160.          setEnabled(false);
  161. @@ -142,7 +142,7 @@ void FeedbackUi::showActuatorInfo()
  162.          if (effect.duration == QtMobility::QFeedbackEffect::Infinite)
  163.              mEffectDuration->setText(tr("infinite"));
  164.          else
  165. -            mEffectDuration->setText(QString::number(effect.duration));
  166. +            mEffectDuration->setText(QLocale().toString(effect.duration));
  167.      }
  168.  }
  169.  
  170. @@ -155,7 +155,7 @@ void FeedbackUi::addActuator(const QtMobility::ActuatorData &data)
  171.  void FeedbackUi::removeActuator(int actuatorId)
  172.  {
  173.      for (int i = mActuators->count()-1; i >= 0; --i) {
  174. -        const int itemActuatorId = mActuators->itemData(i).toInt();
  175. +        const int itemActuatorId = QLocale().toInt(mActuators->itemData(i));
  176.          if (itemActuatorId == actuatorId)
  177.              mActuators->removeItem(i);
  178.      }
  179. @@ -182,7 +182,7 @@ void FeedbackUi::removeActuatorClicked()
  180.      if (mActuators->count() == 0)
  181.          return;
  182.  
  183. -    const int actuatorId = mActuators->itemData(mActuators->currentIndex()).toInt();
  184. +    const int actuatorId = QLocale().toInt(mActuators->itemData(mActuators->currentIndex()));
  185.      mFeedback->removeActuator(actuatorId);
  186.  }
  187.  
  188. @@ -191,7 +191,7 @@ void FeedbackUi::changeActuatorData()
  189.      if (mActuators->count() == 0)
  190.          return;
  191.  
  192. -    const int actuatorId = mActuators->itemData(mActuators->currentIndex()).toInt();
  193. +    const int actuatorId = QLocale().toInt(mActuators->itemData(mActuators->currentIndex()));
  194.      const QtMobility::ActuatorData &actuator = mFeedback->actuator(actuatorId);
  195.      if (actuator.id != actuatorId)
  196.          return;
  197. @@ -212,7 +212,7 @@ void FeedbackUi::changeEffectState()
  198.      if (mActuators->count() == 0)
  199.          return;
  200.  
  201. -    const int actuatorId = mActuators->itemData(mActuators->currentIndex()).toInt();
  202. +    const int actuatorId = QLocale().toInt(mActuators->itemData(mActuators->currentIndex()));
  203.      mFeedback->setEffectState(actuatorId, static_cast<QtMobility::QFeedbackEffect::State>(mEffectState->currentIndex()));
  204.  }
  205.  
  206. diff --git a/src/ui/sensorsui.cpp b/src/ui/sensorsui.cpp
  207. index 15ff564..728ac6b 100644
  208. --- a/src/ui/sensorsui.cpp
  209. +++ b/src/ui/sensorsui.cpp
  210. @@ -73,7 +73,7 @@ void SensorDoubleEdit::setValue(double newValue, bool skipSignal)
  211.      if (mValue != newValue)
  212.      {
  213.          mValue = newValue;
  214. -        mLineEdit->setText(QString::number(newValue, 'f', mDecimalPlaces));
  215. +        mLineEdit->setText(QLocale().toString(newValue, 'f', mDecimalPlaces));
  216.          int sliderPos = qRound(newValue * mCorrectionFactor);
  217.          if (mSlider->value() != sliderPos)
  218.              mSlider->setValue(sliderPos);
  219. @@ -92,11 +92,11 @@ void SensorDoubleEdit::changeValue(int newValue)
  220.  
  221.  void SensorDoubleEdit::updateValueFromLineEdit()
  222.  {
  223. -    double newValue = mLineEdit->text().toDouble(0);
  224. +    double newValue = QLocale().toDouble(mLineEdit->text());
  225.      if (newValue >= mRange.first && newValue <= mRange.second)
  226.          setValue(newValue);
  227.      else
  228. -        mLineEdit->setText(QString::number(mValue));
  229. +        mLineEdit->setText(QLocale().toString(mValue));
  230.  }
  231.  
  232.  void SensorDoubleEdit::setRange(double min, double max)
  233. diff --git a/src/ui/systeminfostorageui.cpp b/src/ui/systeminfostorageui.cpp
  234. index 4916874..d896930 100644
  235. --- a/src/ui/systeminfostorageui.cpp
  236. +++ b/src/ui/systeminfostorageui.cpp
  237. @@ -158,8 +158,9 @@ void StorageSystemInfoUi::showDriveInfo()
  238.  
  239.      const QString curDrive = systemInfoDrives->currentText();
  240.      systemInfoDriveType->setCurrentIndex(static_cast<int>(mScriptInterface->typeForDrive(curDrive)));
  241. -    systemInfoDriveAvailableSpace->setText(QString::number(mScriptInterface->availableDiskSpace(curDrive)));
  242. -    systemInfoDriveTotalSpace->setText(QString::number(mScriptInterface->totalDiskSpace(curDrive)));
  243. +    QLocale locale;
  244. +    systemInfoDriveAvailableSpace->setText(locale.toString(mScriptInterface->availableDiskSpace(curDrive)));
  245. +    systemInfoDriveTotalSpace->setText(locale.toString(mScriptInterface->totalDiskSpace(curDrive)));
  246.  }
  247.  
  248.  void StorageSystemInfoUi::editDriveInfo()
  249. @@ -167,11 +168,12 @@ void StorageSystemInfoUi::editDriveInfo()
  250.      if (systemInfoDrives->count() == 0)
  251.          return;
  252.  
  253. +    QLocale locale;
  254.      const QString curDrive = systemInfoDrives->currentText();
  255.      StorageData::DriveInfo &driveInfo = mData.drives[curDrive];
  256.      driveInfo.type = static_cast<StorageSystemInfoScriptInterface::DriveType>(systemInfoDriveType->currentIndex());
  257. -    driveInfo.totalSpace = systemInfoDriveTotalSpace->text().toLongLong();
  258. -    driveInfo.availableSpace = systemInfoDriveAvailableSpace->text().toLongLong();
  259. +    driveInfo.totalSpace = locale.toLongLong(systemInfoDriveTotalSpace->text());
  260. +    driveInfo.availableSpace = locale.toLongLong(systemInfoDriveAvailableSpace->text());
  261.  
  262.      emitStorageDataChange();
  263.  }
  264. diff --git a/src/ui/viewconfiguration.cpp b/src/ui/viewconfiguration.cpp
  265. index c472a2c..4838c46 100644
  266. --- a/src/ui/viewconfiguration.cpp
  267. +++ b/src/ui/viewconfiguration.cpp
  268. @@ -47,7 +47,7 @@ ViewConfiguration::ViewConfiguration(qreal correctionFactor, QWidget *parent)
  269.      qreal widthInInch = qApp->desktop()->width() / qApp->desktop()->logicalDpiX();
  270.      qreal heightInInch = qApp->desktop()->height() / qApp->desktop()->logicalDpiY();
  271.      mDiagonalInInch = sqrt(pow(widthInInch, 2) + pow(heightInInch, 2));
  272. -    ui.diagonalInInch->setText(QString::number(mDiagonalInInch));
  273. +    ui.diagonalInInch->setText(QLocale().toString(mDiagonalInInch));
  274.  
  275.      connect(ui.horizontalSlider, SIGNAL(valueChanged(int)), SLOT(updateCorrectionFromSlider()));
  276.      connect(ui.cmRadioButton, SIGNAL(toggled(bool)), SLOT(updateUnit()));
  277. @@ -68,8 +68,9 @@ void ViewConfiguration::updateValues(qreal factor)
  278.  {
  279.      ui.horizontalSlider->setValue(factor * 100);
  280.      updateLine();
  281. -    ui.correctionFactorEdit->setText(QString::number(factor));
  282. -    ui.diagonalInInch->setText(QString::number(mDiagonalInInch / factor));
  283. +    QLocale locale;
  284. +    ui.correctionFactorEdit->setText(locale.toString(factor));
  285. +    ui.diagonalInInch->setText(locale.toString(mDiagonalInInch / factor));
  286.  }
  287.  void ViewConfiguration::updateLine()
  288.  {
  289. @@ -103,7 +104,7 @@ void ViewConfiguration::updateCorrectionFromSlider()
  290.  
  291.  void ViewConfiguration::updateCorrectionFromMonitorValues()
  292.  {
  293. -    mCurrentCorrectionFactor = mDiagonalInInch / ui.diagonalInInch->text().toDouble();
  294. +    mCurrentCorrectionFactor = mDiagonalInInch / QLocale().toDouble(ui.diagonalInInch->text());
  295.      if (mCurrentCorrectionFactor > 2)
  296.          mCurrentCorrectionFactor = 2;
  297.      else if (mCurrentCorrectionFactor < 0.5)
  298. @@ -113,7 +114,7 @@ void ViewConfiguration::updateCorrectionFromMonitorValues()
  299.  
  300.  void ViewConfiguration::updateCorrectionFromLineEdit()
  301.  {
  302. -    qreal newValue = ui.correctionFactorEdit->text().toDouble();
  303. +    qreal newValue = QLocale().toDouble(ui.correctionFactorEdit->text());
  304.      if (newValue < 0.5)
  305.          newValue = 0.5;
  306.      else if (newValue > 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement