Index: ossp-pkg/as/as-gui/as_amount.cpp RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_amount.cpp,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/as/as-gui/as_amount.cpp,v' | diff -u /dev/null - -L'ossp-pkg/as/as-gui/as_amount.cpp' 2>/dev/null --- ossp-pkg/as/as-gui/as_amount.cpp +++ - 2025-04-11 21:54:16.441122632 +0200 @@ -0,0 +1,34 @@ +#include + +#include "titamount.h" + +#define HOURAMOUNT 60 + + +// Sets a text formatted representation +void AmountBox::setText(const QString &Strval) +{ + int nTotal = 0; // The total amount of minutes + QRegExp Strexpr("(\\d+):(\\d+)"); // Pattern in amount text + QString Stramount = QRegExp::escape(Strval); // Incoming string escaped + Strexpr.search(Stramount); + + nTotal = Strexpr.cap(Strexpr.numCaptures() - 1).toInt() * HOURAMOUNT; // Calculate hours + nTotal += Strexpr.cap(Strexpr.numCaptures()).toInt(); // Calculate minutes + + this->setValue(nTotal); +} + +// Return a text formatted representation +QString AmountBox::text(void) const +{ + QString Strout; + int nHours = 0; + int nMins = this->value(); + + nHours = nMins / HOURAMOUNT; // Calculate total hours + nMins = nMins % HOURAMOUNT; // Calculate total minutes + Strout = trUtf8("%1:%2").arg(nHours).arg(nMins); // Format string + + return Strout; +}