ksycocaentry.h

00001 /*  This file is part of the KDE libraries
00002  *  Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
00003  *
00004  *  This library is free software; you can redistribute it and/or
00005  *  modify it under the terms of the GNU Library General Public
00006  *  License version 2 as published by the Free Software Foundation;
00007  *
00008  *  This library is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  *  Library General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU Library General Public License
00014  *  along with this library; see the file COPYING.LIB.  If not, write to
00015  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016  *  Boston, MA 02110-1301, USA.
00017  **/
00018 
00019 #ifndef __ksycocaentry_h__
00020 #define __ksycocaentry_h__
00021 
00022 #include "ksycocatype.h"
00023 
00024 #include <qstringlist.h>
00025 #include <ksharedptr.h>
00026 class QDataStream;
00027 
00037 class KDECORE_EXPORT KSycocaEntry : public KShared
00038 {
00039  
00040 public:
00041    virtual bool isType(KSycocaType t) const { return (t == KST_KSycocaEntry); }
00042    virtual KSycocaType sycocaType() const { return KST_KSycocaEntry; }
00043 
00044 public:
00045   typedef KSharedPtr<KSycocaEntry> Ptr;
00046   typedef QValueList<Ptr> List;
00047 public: // KDoc seems to barf on those typedefs and generates no docs after them
00051    KSycocaEntry(const QString &path) : mOffset(0), m_bDeleted(false), mPath(path) { }
00052 
00056    static void read( QDataStream &s, QString &str );
00057    static void read( QDataStream &s, QStringList &list );
00058 
00063    KSycocaEntry( QDataStream &_str, int offset ) : 
00064               mOffset( offset ), m_bDeleted(false) 
00065    { 
00066      read(_str, mPath);
00067    }
00068 
00072    virtual QString name() const = 0;
00073 
00079    QString entryPath() const { return mPath; }
00080   
00084    virtual bool isValid() const = 0;
00085   
00089    virtual bool isDeleted() const { return m_bDeleted; }
00090 
00095    int offset() { return mOffset; }
00096 
00102    virtual void save(QDataStream &s)
00103      {
00104        mOffset = s.device()->at(); // store position in member variable
00105        s << (Q_INT32) sycocaType() << mPath;
00106      }
00107 
00112    virtual void load(QDataStream &) = 0;
00113 
00114 private:
00115    int mOffset;
00116 protected:
00117    bool m_bDeleted;
00118    QString mPath;   
00119 protected:
00120    virtual void virtual_hook( int id, void* data );
00121 };
00122 
00123 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys