kpilot Library API Documentation

pilotAppCategory.h

00001 #ifndef _KPILOT_PILOTAPPCATEGORY_H
00002 #define _KPILOT_PILOTAPPCATEGORY_H
00003 /* pilotAppCategory.h           KPilot
00004 **
00005 ** Copyright (C) 1998-2001 by Dan Pilone
00006 **
00007 ** The class PilotAppCategory is the base class for "interpretations"
00008 ** of a PilotRecord. This is where the records change from a collction
00009 ** of bits to something with meaning. Subclasses of PilotAppCategory
00010 ** give specific meaning to records from specific databases.
00011 **
00012 ** Almost everything is inline; as a crufty hack, the non-inline
00013 ** part of this class lives in pilotRecord.cc.
00014 */
00015 
00016 /*
00017 ** This program is free software; you can redistribute it and/or modify
00018 ** it under the terms of the GNU Lesser General Public License as published by
00019 ** the Free Software Foundation; either version 2.1 of the License, or
00020 ** (at your option) any later version.
00021 **
00022 ** This program is distributed in the hope that it will be useful,
00023 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00025 ** GNU Lesser General Public License for more details.
00026 **
00027 ** You should have received a copy of the GNU Lesser General Public License
00028 ** along with this program in a file called COPYING; if not, write to
00029 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00030 ** MA 02111-1307, USA.
00031 */
00032 
00033 /*
00034 ** Bug reports and questions can be sent to kde-pim@kde.org
00035 */
00036 
00037 // #include <pi-macros.h>
00038 
00039 #include <qstring.h>
00040 
00041 #include "pilotRecord.h"
00042 
00043 class QTextCodec;
00044 
00045 class PilotAppCategory
00046 {
00047 protected:          // Use protected since we will be subclassed
00048     int fAttrs;         // Attributes on this record
00049     recordid_t fId;     // The unique ID this record was assigned
00050 
00059     int fCategory;      // The category ID this record belongs to
00060 
00061     virtual void *pack(void *, int *) = 0;
00062     virtual void unpack(const void *, int = 0) = 0;
00063 
00064 
00065 public:
00066     PilotAppCategory(void) :
00067         fAttrs(0),
00068         fId(0),
00069         fCategory(0)
00070     {} ;
00071 
00072     PilotAppCategory(int a, recordid_t i, int c) :
00073         fAttrs(a),
00074         fId(i),
00075         fCategory(c)
00076     {} ;
00077 
00078     PilotAppCategory(PilotRecord* rec) :
00079         fAttrs((rec)?rec->getAttrib():0),
00080         fId((rec)?rec->getID():0),
00081         fCategory((rec)?rec->getCat():0)
00082     {} ;
00083 
00084     PilotAppCategory(const PilotAppCategory &copyFrom) :
00085         fAttrs(copyFrom.fAttrs),
00086         fId(copyFrom.fId),
00087         fCategory(copyFrom.fCategory)
00088     {} ;
00089 
00090     PilotAppCategory& operator=( const PilotAppCategory &r )
00091     {
00092         fAttrs = r.fAttrs;
00093         fId = r.fId;
00094         fCategory = r.fCategory;
00095         return *this;
00096     } ;
00097 
00098     bool operator==(const PilotAppCategory &compareTo)
00099     {
00100         return (fAttrs==compareTo.fAttrs && fId==compareTo.fId && fCategory==compareTo.fCategory);
00101     } ;
00102 
00103     virtual ~PilotAppCategory(void) {};
00104 
00108     virtual PilotRecord* pack()
00109     {
00110         int len = 0xffff;
00111         void* buff = new unsigned char[len];
00112         pack(buff, &len);
00113         PilotRecord* rec =  new PilotRecord(buff, len, getAttrib(), getCat(), id());
00114         delete [] (unsigned char*)buff;
00115         return rec;
00116     }
00117 
00118     int getAttrib(void) const { return fAttrs; }
00119     int getCat(void) const { return fCategory; }
00120     void setCat(int cat) { fCategory = cat; }
00121     recordid_t id(void) const { return fId; }
00122     recordid_t getID() { return id(); } // Just for compatability's sake
00123     recordid_t getID() const { return id(); } // Just for compatability's sake
00124     void setID(recordid_t id) { fId = id; }
00125     void setAttrib(int attrib) { fAttrs = attrib; }
00126 
00127     virtual QString getTextRepresentation(bool=false) {return i18n("Unknown record type");};
00128 
00129 public:
00130     bool isSecret() const { return fAttrs & dlpRecAttrSecret ; } ;
00131     bool isDeleted() const { return fAttrs & dlpRecAttrDeleted ; } ;
00132     bool isArchived() const { return fAttrs & dlpRecAttrArchived ; } ;
00133     void makeSecret() { fAttrs |= dlpRecAttrSecret; } ;
00134     void makeDeleted() { fAttrs |= dlpRecAttrDeleted ; } ;
00135     void makeArchived() { fAttrs |= dlpRecAttrArchived ; } ;
00136     bool isModified() const { return fAttrs & dlpRecAttrDirty; }
00137 
00138 protected:
00139     static QTextCodec *pilotCodec;
00140 public:
00141     static QTextCodec *codec()
00142         { if (pilotCodec) return pilotCodec; else return createCodec(0L); } ;
00143     static QTextCodec *createCodec(const char *);
00144     static QTextCodec *setupPilotCodec(const QString &);
00145     static QString codecName();
00146 };
00147 
00148 #endif
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:48 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003