Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

palmtoprecord.h

Go to the documentation of this file.
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) { }
00058     virtual ~Record() { }
00059 
00060     Record &operator=( const Record &c );
00061 
00062     virtual bool match( const QRegExp & ) const { return FALSE; }
00063 
00064     void setCategories( const QArray<int> &v ) { mCats = v; mCats.sort(); }
00065     void setCategories( int single );
00066     const QArray<int> &categories() const { return mCats; }
00067 
00068     void reassignCategoryId( int oldId, int newId )
00069     {
00070         int index = mCats.find( oldId );
00071         if ( index >= 0 )
00072             mCats[index] = newId;
00073     }
00074 
00075     int uid() const { return mUid; };
00076     virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); }
00077     bool isValidUid() const { return mUid != 0; }
00078     void assignUid() { setUid( uidGen().generate() ); }
00079 
00080     virtual QString customField(const QString &) const;
00081     virtual void setCustomField(const QString &, const QString &);
00082     virtual void removeCustomField(const QString &);
00083 
00084     virtual bool operator == ( const Record &r ) const
00085 { return mUid == r.mUid; }
00086     virtual bool operator != ( const Record &r ) const
00087 { return mUid != r.mUid; }
00088 
00089     // convenience methods provided for loading and saving to xml
00090     static QString idsToString( const QArray<int> &ids );
00091     // convenience methods provided for loading and saving to xml
00092     static QArray<int> idsFromString( const QString &str );
00093 
00094     // for debugging
00095     static void dump( const QMap<int, QString> &map );
00096 
00097 protected:
00098     virtual UidGen &uidGen() = 0;
00099     virtual QString customToXml() const;
00100 private:
00101     int mUid;
00102     QArray<int> mCats;
00103     QMap<QString, QString> customMap;
00104     RecordPrivate *d;
00105 };
00106 
00107 }
00108 
00109 #endif
00110 

Generated on Sat Nov 5 16:16:33 2005 for OPIE by  doxygen 1.4.2