OSSP CVS Repository

ossp - Check-in [2888]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2888
Date: 2002-Nov-25 16:45:56 (local)
2002-Nov-25 15:45:56 (UTC)
User:ms
Branch:
Comment: Add AmountBox class to introduce missing functionality from QSpinBox, and implement most edit control updates.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/as_amount.cpp      added-> 1.1
ossp-pkg/titraq/titamount.cpp      added-> 1.1

ossp-pkg/as/as-gui/as_amount.cpp -> 1.1

*** /dev/null    Sat Nov 23 01:25:36 2024
--- -    Sat Nov 23 01:25:38 2024
***************
*** 0 ****
--- 1,34 ----
+ #include <qregexp.h>
+ 
+ #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;
+ }


CVSTrac 2.0.1