Return progress as double, not int
This commit is contained in:
parent
48ddf3d5ae
commit
d54c6743e7
3 changed files with 6 additions and 6 deletions
|
@ -151,7 +151,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: factorizationController.progress.toFixed(0) + "%"
|
text: factorizationController.progress.toFixed(1) + "%"
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
font.pixelSize: 16
|
font.pixelSize: 16
|
||||||
color: "black"
|
color: "black"
|
||||||
|
|
|
@ -16,7 +16,7 @@ unsigned long long FactorizationController::curFactNumber() const {
|
||||||
return m_currentFactNumber;
|
return m_currentFactNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FactorizationController::progress() const {
|
double FactorizationController::progress() const {
|
||||||
// If the original number is set to 0, the computation wasn't yet initialized / was reset.
|
// If the original number is set to 0, the computation wasn't yet initialized / was reset.
|
||||||
// If the current factor is at 2, the computation has just started, return early to avoid
|
// If the current factor is at 2, the computation has just started, return early to avoid
|
||||||
// zero division issues.
|
// zero division issues.
|
||||||
|
@ -32,8 +32,8 @@ int FactorizationController::progress() const {
|
||||||
// since factor being <= 2 means 100%, we sub 2 here.
|
// since factor being <= 2 means 100%, we sub 2 here.
|
||||||
double progress = static_cast<double>(m_currentFactor - 2) / static_cast<double>(m_stopFactor - 2);
|
double progress = static_cast<double>(m_currentFactor - 2) / static_cast<double>(m_stopFactor - 2);
|
||||||
|
|
||||||
// Return the value as int percentage
|
// Return the value as percentage
|
||||||
return static_cast<int>(std::clamp(progress * 100, 0.0, 100.0));
|
return std::clamp(progress * 100, 0.0, 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FactorizationController::isFinished() const {
|
bool FactorizationController::isFinished() const {
|
||||||
|
|
|
@ -31,7 +31,7 @@ class FactorizationController : public QObject {
|
||||||
Q_PROPERTY(unsigned long long curFactNumber READ curFactNumber NOTIFY curFactNumberChanged)
|
Q_PROPERTY(unsigned long long curFactNumber READ curFactNumber NOTIFY curFactNumberChanged)
|
||||||
Q_PROPERTY(unsigned long long currentFactor READ currentFactor NOTIFY currentFactorChanged)
|
Q_PROPERTY(unsigned long long currentFactor READ currentFactor NOTIFY currentFactorChanged)
|
||||||
Q_PROPERTY(unsigned long long stopFactor READ stopFactor NOTIFY stopFactorChanged)
|
Q_PROPERTY(unsigned long long stopFactor READ stopFactor NOTIFY stopFactorChanged)
|
||||||
Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
|
Q_PROPERTY(double progress READ progress NOTIFY progressChanged)
|
||||||
Q_PROPERTY(QList<unsigned long long> factors READ factors NOTIFY factorsChanged)
|
Q_PROPERTY(QList<unsigned long long> factors READ factors NOTIFY factorsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -43,7 +43,7 @@ class FactorizationController : public QObject {
|
||||||
* @brief Gets the current progress of factorization.
|
* @brief Gets the current progress of factorization.
|
||||||
* @return The progress percentage (0-100).
|
* @return The progress percentage (0-100).
|
||||||
*/
|
*/
|
||||||
int progress() const;
|
double progress() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Checks if the factorization process is running.
|
* @brief Checks if the factorization process is running.
|
||||||
|
|
Loading…
Add table
Reference in a new issue