Qtopia library API Documentation

palmtoprecord.h

00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef QTPALMTOP_RECORD_H
00021 #define QTPALMTOP_RECORD_H
00022 #include <qglobal.h>
00023 #include "qpcglobal.h"
00024 #include "palmtopuidgen.h"
00025 #include <qarray.h>
00026 #include <qmap.h>
00027 
00028 #if defined(QPC_TEMPLATEDLL)
00029 // MOC_SKIP_BEGIN
00030 QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<QString, QString>;
00031 // MOC_SKIP_END
00032 #endif
00033 
00034 class QRegExp;
00039 namespace Qtopia {
00040 
00041 class RecordPrivate;
00050 class QPC_EXPORT Record
00051 {
00052 public:
00053     Record() : mUid(0), mCats() { }
00054     Record( const Record &c ) : mUid( c.mUid ), mCats ( c.mCats ), customMap(c.customMap) { }
00055     virtual ~Record() { }
00056 
00057     Record &operator=( const Record &c );
00058 
00059     virtual bool match( const QRegExp & ) const { return FALSE; }
00060 
00061     void setCategories( const QArray<int> &v ) { mCats = v; mCats.sort(); }
00062     void setCategories( int single );
00063     const QArray<int> &categories() const { return mCats; }
00064 
00065     void reassignCategoryId( int oldId, int newId )
00066     {
00067     int index = mCats.find( oldId );
00068     if ( index >= 0 )
00069         mCats[index] = newId;
00070     }
00071 
00072     int uid() const { return mUid; };
00073     virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); }
00074     bool isValidUid() const { return mUid != 0; }
00075     void assignUid() { setUid( uidGen().generate() ); }
00076 
00077     virtual QString customField(const QString &) const;
00078     virtual void setCustomField(const QString &, const QString &);
00079     virtual void removeCustomField(const QString &);
00080 
00081     virtual bool operator == ( const Record &r ) const
00082 { return mUid == r.mUid; }
00083     virtual bool operator != ( const Record &r ) const
00084 { return mUid != r.mUid; }
00085 
00086     // convenience methods provided for loading and saving to xml
00087     static QString idsToString( const QArray<int> &ids );
00088     // convenience methods provided for loading and saving to xml
00089     static QArray<int> idsFromString( const QString &str );
00090 
00091     // for debugging
00092     static void dump( const QMap<int, QString> &map );
00093 
00094 protected:
00095     virtual UidGen &uidGen() = 0;
00096     virtual QString customToXml() const;
00097 private:
00098     int mUid;
00099     QArray<int> mCats;
00100     QMap<QString, QString> customMap;
00101     RecordPrivate *d;
00102 };
00103 
00104 }
00105 
00106 #endif
00107 
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:06 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001