ICS

QicsTable Documentation Set

QicsDataItemCurrencyFormatter.cpp

/****************************************************************************
** $RCSfile: spread_curr_fmt_cpp.html,v $ $Date: 2008/06/23 16:32:03 $
**
** Copyright ( C ) 2002-2003 Integrated Computer Solutions, Inc.
** All rights reserved.
**
** This file is part of an example program for QicsTable.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

//   This class is used to display a QicsDataItem in a specified format, ie
//   provide a "view" on the "model".  Currently a very simple class to
//   display US Dollars in "$ 12.34" style.

#include "QicsDataItemCurrencyFormatter.h"

QicsDataItemCurrencyFormatter::QicsDataItemCurrencyFormatter()
{
}

QString
QicsDataItemCurrencyFormatter::format(const QicsDataItem &itm) const
{

    switch (itm.type())
    {
    case QicsDataItem_Int:
        {
        QicsDataInt* ptr = (QicsDataInt*) &itm;

        if (ptr->data() < 0)
        {
            // Not quite right.  What we really want is to get rid of the
            // negative sign and replace it with the ( )

            //return itm.format("$ (%d.00)");
        }

        return itm.format("$ %d.00");
        }
        break;

    case QicsDataItem_Float:
    case QicsDataItem_Double:
        {
        return itm.format("$ %1.2f");
        }
        break;

    }

    return itm.string();
}

All trademarks and copyrights on this page are properties of their respective owners.
The rest is copyright 1999-2006 Integrated Computer Solutions, Inc.