[SCM] massXpert mass spectrometry suite: debian packaging branch, upstream, updated. 41a70205093791df401b34b6867e830c5a46d1f9
Filippo Rusconi
rusconi at mnhn.fr
Wed Apr 15 15:42:55 UTC 2009
The following commit has been merged in the upstream branch:
commit 10b12d63ef8042f8fce89b52a23d47b7f1572baf
Author: Filippo Rusconi <rusconi at mnhn.fr>
Date: Wed Apr 15 15:57:35 2009 +0200
Fixed locale-specific input/output.
diff --git a/gui/mzCalculationDlg.cpp b/gui/mzCalculationDlg.cpp
index 9833c01..2c8020e 100644
--- a/gui/mzCalculationDlg.cpp
+++ b/gui/mzCalculationDlg.cpp
@@ -414,6 +414,9 @@ namespace massXpert
void
MzCalculationDlg::prepareResultsTxtString()
{
+ Application *application = static_cast<Application *>(qApp);
+ QLocale locale = application->locale();
+
mpa_resultsString->clear();
*mpa_resultsString += QObject::tr("\n---------------------------\n"
@@ -471,35 +474,65 @@ namespace massXpert
QModelIndex currentIndex = model->index(iter,
MZ_CALC_LEVEL_COLUMN,
QModelIndex());
-
Q_ASSERT(currentIndex.isValid());
- mzString +=
- QObject::tr("Level: %1 -- ").arg(model->data(currentIndex,
- Qt::DisplayRole)
- .toString());
-
+ // We have to make sure we translate correctly from
+ // locale-based textual representation of double numbers
+ // to real double numbers.
+
+ bool ok = false;
+
+ QString valueString =
+ model->data(currentIndex, Qt::DisplayRole).toString();
+
+ double value = locale.toDouble(valueString, &ok);
+
+ if (!value && !ok)
+ qFatal("Fatal error at %s@%d. Program aborted.",
+ __FILE__, __LINE__);
+
+ mzString += QObject::tr("Level: %1 -- ")
+ .arg(locale.toString(value, 'f', MXP_PH_PKA_DEC_PLACES));
+
currentIndex = model->index(iter,
MZ_CALC_MONO_COLUMN,
QModelIndex());
-
Q_ASSERT(currentIndex.isValid());
- mzString +=
- QObject::tr("Mono: %1 -- ").arg(model->data(currentIndex,
- Qt::DisplayRole)
- .toString());
+ ok = false;
+
+ valueString =
+ model->data(currentIndex, Qt::DisplayRole).toString();
+
+ value = locale.toDouble(valueString, &ok);
+
+ if (!value && !ok)
+ qFatal("Fatal error at %s@%d. Program aborted.",
+ __FILE__, __LINE__);
+
+ mzString += QObject::tr("Mono: %1 -- ")
+ .arg(locale.toString(value, 'f', MXP_OLIGOMER_DEC_PLACES));
currentIndex = model->index(iter,
MZ_CALC_AVG_COLUMN,
QModelIndex());
-
Q_ASSERT(currentIndex.isValid());
-
- mzString +=
- QObject::tr("Avg: %1\n").arg(model->data(currentIndex,
- Qt::DisplayRole)
- .toString());
+
+ ok = false;
+
+ valueString =
+ model->data(currentIndex, Qt::DisplayRole).toString();
+
+ value = locale.toDouble(valueString, &ok);
+
+ if (!value && !ok)
+ qFatal("Fatal error at %s@%d. Program aborted.",
+ __FILE__, __LINE__);
+
+ mzString += QObject::tr("Avg: %1")
+ .arg(locale.toString(value, 'f', MXP_OLIGOMER_DEC_PLACES));
+
+ mzString += ("\n");
}
*mpa_resultsString += mzString;
diff --git a/gui/mzCalculationTreeViewModel.cpp b/gui/mzCalculationTreeViewModel.cpp
index 2f11dc6..d48d640 100644
--- a/gui/mzCalculationTreeViewModel.cpp
+++ b/gui/mzCalculationTreeViewModel.cpp
@@ -232,6 +232,9 @@ namespace massXpert
void
MzCalculationTreeViewModel::addIonizable(Ionizable *ionizable)
{
+ Application *application = static_cast<Application *>(qApp);
+ QLocale locale = application->locale();
+
Q_ASSERT(ionizable);
QList<QVariant> columnData;
@@ -239,8 +242,11 @@ namespace massXpert
int level =
ionizable->ionizeRule()->charge() * ionizable->ionizeRule()->level() ;
+ QString mono = ionizable->mono(locale, MXP_OLIGOMER_DEC_PLACES);
+ QString avg = ionizable->avg(locale, MXP_OLIGOMER_DEC_PLACES);
+
columnData
- << level << ionizable->mono() << ionizable->avg() ;
+ << level << mono << avg ;
mp_list->append(ionizable);
@@ -297,6 +303,9 @@ namespace massXpert
MzCalculationTreeViewModel::setupModelData(MzCalculationTreeViewItem *
parent)
{
+ Application *application = static_cast<Application *>(qApp);
+ QLocale locale = application->locale();
+
QList<MzCalculationTreeViewItem *> parents;
MzCalculationTreeViewItem *currentItem = 0;
@@ -318,8 +327,12 @@ namespace massXpert
ionizable->ionizeRule()->charge() *
ionizable->ionizeRule()->level() ;
+ QString mono = ionizable->mono(locale, MXP_OLIGOMER_DEC_PLACES);
+ QString avg = ionizable->avg(locale, MXP_OLIGOMER_DEC_PLACES);
+
columnData
- << charge << ionizable->mono() << ionizable->avg() ;
+ << charge << mono << avg ;
+
// Create an item with those columnar strings. The parent of the
// current item is parents.
--
massXpert mass spectrometry suite: debian packaging
More information about the debian-science-commits
mailing list