diff --git a/src/ViewWidgets/LogDownload.qml b/src/ViewWidgets/LogDownload.qml index ed7f6907153c3db702f720839546d1ef129fdae7..b9d1a95a8b40e6c914f50024d3737a74df35e75a 100644 --- a/src/ViewWidgets/LogDownload.qml +++ b/src/ViewWidgets/LogDownload.qml @@ -36,10 +36,6 @@ QGCView { property real _margins: ScreenTools.defaultFontPixelHeight - function numberWithCommas(x) { - return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",").replace(/,,/g, ","); - } - LogDownloadController { id: controller factPanel: panel @@ -113,7 +109,7 @@ QGCView { horizontalAlignment: Text.AlignRight text: { var o = controller.model.get(styleData.row) - return o ? numberWithCommas(o.size) : "" + return o ? o.sizeStr : "" } } } diff --git a/src/ViewWidgets/LogDownloadController.cc b/src/ViewWidgets/LogDownloadController.cc index b570d77224f3e3bd9ebeed9601631058ac8c3a4f..b2a05b75d562d227db1d2aa084e0716bcf70e6d0 100644 --- a/src/ViewWidgets/LogDownloadController.cc +++ b/src/ViewWidgets/LogDownloadController.cc @@ -39,6 +39,8 @@ QGC_LOGGING_CATEGORY(LogDownloadLog, "LogDownloadLog") +static QLocale kLocale; + //---------------------------------------------------------------------------------------- LogDownloadData::LogDownloadData(QGCLogEntry* entry_) : ID(entry_->id()) @@ -49,7 +51,7 @@ LogDownloadData::LogDownloadData(QGCLogEntry* entry_) } //---------------------------------------------------------------------------------------- -QGCLogEntry:: QGCLogEntry(uint logId, const QDateTime& dateTime, uint logSize, bool received) +QGCLogEntry::QGCLogEntry(uint logId, const QDateTime& dateTime, uint logSize, bool received) : _logID(logId) , _logSize(logSize) , _logTimeUTC(dateTime) @@ -59,6 +61,13 @@ QGCLogEntry:: QGCLogEntry(uint logId, const QDateTime& dateTime, uint logSize, b _status = "Pending"; } +//---------------------------------------------------------------------------------------- +QString +QGCLogEntry::sizeStr() const +{ + return kLocale.toString(_logSize); +} + //---------------------------------------------------------------------------------------- LogDownloadController::LogDownloadController(void) : _uas(NULL) @@ -275,7 +284,8 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui if(_downloadData->file.write((const char*)data, count)) { _downloadData->written += count; //-- Update status - _downloadData->entry->setStatus(QString::number(_downloadData->written)); + QString comma_value = kLocale.toString(_downloadData->written); + _downloadData->entry->setStatus(comma_value); result = true; //-- reset retries _retries = 0; diff --git a/src/ViewWidgets/LogDownloadController.h b/src/ViewWidgets/LogDownloadController.h index 99c909b52caeba16e0c44c34a8de1f5d50d246bb..f4d306fdbb1f5568eb147559646382eefd26cb96 100644 --- a/src/ViewWidgets/LogDownloadController.h +++ b/src/ViewWidgets/LogDownloadController.h @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -80,6 +81,7 @@ class QGCLogEntry : public QObject { Q_PROPERTY(uint id READ id CONSTANT) Q_PROPERTY(QDateTime time READ time NOTIFY timeChanged) Q_PROPERTY(uint size READ size NOTIFY sizeChanged) + Q_PROPERTY(QString sizeStr READ sizeStr NOTIFY sizeChanged) Q_PROPERTY(bool received READ received NOTIFY receivedChanged) Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged) Q_PROPERTY(QString status READ status NOTIFY statusChanged) @@ -89,6 +91,7 @@ public: uint id () const { return _logID; } uint size () const { return _logSize; } + QString sizeStr () const; QDateTime time () const { return _logTimeUTC; } bool received () const { return _received; } bool selected () const { return _selected; }