kpilot/lib

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 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 **
00008 */
00009 
00010 /*
00011 ** This program is free software; you can redistribute it and/or modify
00012 ** it under the terms of the GNU Lesser General Public License as published by
00013 ** the Free Software Foundation; either version 2.1 of the License, or
00014 ** (at your option) any later version.
00015 **
00016 ** This program is distributed in the hope that it will be useful,
00017 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 ** GNU Lesser General Public License for more details.
00020 **
00021 ** You should have received a copy of the GNU Lesser General Public License
00022 ** along with this program in a file called COPYING; if not, write to
00023 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00024 ** MA 02110-1301, USA.
00025 */
00026 
00027 /*
00028 ** Bug reports and questions can be sent to kde-pim@kde.org
00029 */
00030 
00041 #include <qstring.h>
00042 #include <klocale.h>
00043 
00044 #include <pi-appinfo.h>
00045 
00046 #include "pilotRecord.h"
00047 
00048 class QTextCodec;
00049 
00060 class KDE_EXPORT PilotAppCategory : public PilotRecordBase
00061 {
00062 protected:          // Use protected since we will be subclassed
00076     virtual void *pack_(void *buf, int *size) = 0;
00077 
00081     virtual void unpack(const void *buf, int size) = 0;
00082 
00083 
00084 public:
00089     PilotAppCategory(int a=0, recordid_t i=0, int c=0) :
00090         PilotRecordBase(a,c,i)
00091     {} ;
00092 
00096     PilotAppCategory(const PilotRecord* rec) :
00097         PilotRecordBase( ((rec)?rec->attributes():0),
00098             ((rec)?rec->category():0),
00099             ((rec)?rec->id():0)
00100             )
00101     {} ;
00102 
00104     PilotAppCategory(const PilotAppCategory &copyFrom) :
00105         PilotRecordBase(copyFrom.attributes(),
00106             copyFrom.id(),
00107             copyFrom.category() )
00108     {} ;
00109 
00111     PilotAppCategory& operator=( const PilotAppCategory &r )
00112     {
00113         setAttributes( r.attributes() );
00114         setID( r.id() );
00115         setCategory( r.category() );
00116         return *this;
00117     } ;
00118 
00122     bool operator==(const PilotAppCategory &compareTo)
00123     {
00124         return (attributes() ==compareTo.attributes() &&
00125             id() ==compareTo.id() &&
00126             category() ==compareTo.category() );
00127     } ;
00128 
00130     virtual ~PilotAppCategory(void) {};
00131 
00136     virtual PilotRecord* pack();
00137 
00144     virtual QString getTextRepresentation(bool rt=false)
00145         { Q_UNUSED(rt); return i18n("Unknown record type"); }
00146 
00151     void setCategory( int c ) { return PilotRecordBase::setCategory(c); }
00160     bool setCategory(struct CategoryAppInfo &info,const QString &label);
00161     bool KDE_DEPRECATED setCat(struct CategoryAppInfo &info,const QString &label)
00162         { return setCategory(info,label); }
00163 
00164 protected:
00165     static QTextCodec *pilotCodec;
00166 public:
00172     static QString fromPilot( const char *c, int len );
00173 
00179     static int toPilot( const QString &s, char *buf, int len);
00180 
00184     static QTextCodec *codec()
00185         { if (pilotCodec) return pilotCodec; else return setupPilotCodec(QString::null); } ;
00191     static QTextCodec *setupPilotCodec(const QString &name);
00193     static QString codecName();
00194 };
00195 
00196 
00197 
00198 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys