ICS

QicsTable Documentation Set

custom_data_type.h

/****************************************************************************
** $RCSfile: cdt_h.html,v $ $Date: 2008/06/23 16:31:51 $
**
** Copyright ( C ) 2002-2006 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.
**
*****************************************************************************/

#ifndef _CUSTOM_DATA_TYPE_H
#define _CUSTOM_DATA_TYPE_H

#include <QicsDataItem.h>
#include <QPoint>

// This is an example of a custom data type.  This data type represents
// a QPoint value.

class QicsDataQPoint : public QicsDataItem
{
public:
    QicsDataQPoint();
    QicsDataQPoint(const QPoint &p);
    QicsDataQPoint(const QicsDataQPoint &di);

    inline QicsDataItem *create(void) const
    { return new QicsDataQPoint(); }
    inline QicsDataItem *clone(void) const
    { return new QicsDataQPoint(*this); }

    inline virtual QicsDataItemType type(void) const
    { return (QicsDataItem_UserDefined); }

    inline static QString typeName(void)
    { return QString("qpoint"); }

    inline virtual QString typeString(void) const
    { return QicsDataQPoint::typeName(); }

    inline virtual QicsDataQPoint& operator=(const QPoint & p)
    { setData(p); return *this;}

    inline virtual const QString string(void) const
    { return QString("(%1, %2)").arg(myData.x()) .arg(myData.y()); }

    virtual bool setString(const QString &str);

    inline QPoint data(void) const
    { return myData; }
    inline void setData(const QPoint & p)
    { myData = p;}

    virtual QString format(const char *fmt_string) const;

    int compareTo(const QicsDataItem &x) const;

    void encode(QDataStream &ds) const;

    static QicsDataItem *fromString(const QString &str);
    static QicsDataItem *decode(QDataStream &ds);

protected:
    QPoint myData;
};


#endif /* _CUSTOM_DATA_TYPE_H */

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