as_amount.cpp

changeset 1
d64aaa7d146f
child 3
c1941114ca88
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/as_amount.cpp	Fri Nov 28 11:21:08 2008 +0100
     1.3 @@ -0,0 +1,70 @@
     1.4 +//
     1.5 +//  OSSP asgui - Accounting system graphical user interface
     1.6 +//  Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/)
     1.7 +//  Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com>
     1.8 +//  Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com>
     1.9 +//  Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH
    1.10 +//
    1.11 +//  This file is part of OSSP asgui, an accounting system graphical user
    1.12 +//  interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
    1.13 +//
    1.14 +//  Permission to use, copy, modify, and distribute this software for
    1.15 +//  any purpose with or without fee is hereby granted, provided that
    1.16 +//  the above copyright notice and this permission notice appear in all
    1.17 +//  copies.
    1.18 +//
    1.19 +//  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    1.20 +//  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    1.21 +//  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    1.22 +//  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    1.23 +//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.24 +//  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.25 +//  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    1.26 +//  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    1.27 +//  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    1.28 +//  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    1.29 +//  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.30 +//  SUCH DAMAGE.
    1.31 +//
    1.32 +//  as_amount.cpp: ISO C++ implementation
    1.33 +//
    1.34 +
    1.35 +//#include <qregexp.h>
    1.36 +
    1.37 +//#include "as_amount.h"
    1.38 +//#include "as_const.h"
    1.39 +
    1.40 +
    1.41 +//// Sets a text formatted representation
    1.42 +//void AmountBox::setText(const QString &Strval)
    1.43 +//{
    1.44 +//    int nTotal = 0;                                 // The total amount of minutes
    1.45 +//    QRegExp Strexpr("(\\d+):(\\d+)");               // Pattern in amount text
    1.46 +//    QString Stramount = QRegExp::escape(Strval);    // Incoming string escaped
    1.47 +//
    1.48 +//    if (Strval.isEmpty()) {                         // Shortcircuit in the
    1.49 +//        this->setValue(0);                          // case of empty string
    1.50 +//    }
    1.51 +//    else {                                          // Do the real work then
    1.52 +//        Strexpr.search(Stramount);
    1.53 +//        nTotal = Strexpr.cap(Strexpr.numCaptures() - 1).toInt() * TITRAQ_MINSINHOUR;
    1.54 +//        nTotal += Strexpr.cap(Strexpr.numCaptures()).toInt();
    1.55 +//        this->setValue(nTotal);
    1.56 +//    }
    1.57 +//}
    1.58 +
    1.59 +//// Return a text formatted representation
    1.60 +//QString AmountBox::text(void) const
    1.61 +//{
    1.62 +//    QString Strfirst, Strsecond;
    1.63 +//    int nHours = 0;
    1.64 +//    int nMins = this->value();
    1.65 +//
    1.66 +//    nHours    = nMins / TITRAQ_MINSINHOUR;      // Calculate total hours
    1.67 +//    nMins     = nMins % TITRAQ_MINSINHOUR;      // Calculate total minutes
    1.68 +//    Strfirst  = trUtf8("%1:").arg(nHours);      // Format the first part
    1.69 +//    Strsecond = trUtf8("%1").arg(nMins);        // Format the second part
    1.70 +//
    1.71 +//    // Pad the resulting concatination before sending it out the back
    1.72 +//    return Strfirst.rightJustify(3, '0') + Strsecond.rightJustify(2, '0');
    1.73 +//}

mercurial