File indexing completed on 2024-04-21 03:56:54

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 1999 Waldo Bastian <bastian@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #include "ksycocaentry.h"
0009 #include "ksycocaentry_p.h"
0010 #include <QIODevice>
0011 #include <ksycoca.h>
0012 
0013 KSycocaEntryPrivate::KSycocaEntryPrivate(QDataStream &_str, int iOffset)
0014     : offset(iOffset)
0015     , deleted(false)
0016 {
0017     _str >> path;
0018 }
0019 
0020 KSycocaEntry::KSycocaEntry()
0021     : d_ptr(nullptr)
0022 {
0023 }
0024 
0025 KSycocaEntry::KSycocaEntry(KSycocaEntryPrivate &d)
0026     : d_ptr(&d)
0027 {
0028 }
0029 
0030 KSycocaEntry::~KSycocaEntry() = default;
0031 
0032 bool KSycocaEntry::isType(KSycocaType t) const
0033 {
0034     return d_ptr->isType(t);
0035 }
0036 
0037 KSycocaType KSycocaEntry::sycocaType() const
0038 {
0039     return d_ptr->sycocaType();
0040 }
0041 
0042 QString KSycocaEntry::entryPath() const
0043 {
0044     Q_D(const KSycocaEntry);
0045     return d->path;
0046 }
0047 
0048 QString KSycocaEntry::storageId() const
0049 {
0050     Q_D(const KSycocaEntry);
0051     return d->storageId();
0052 }
0053 
0054 bool KSycocaEntry::isDeleted() const
0055 {
0056     Q_D(const KSycocaEntry);
0057     return d->deleted;
0058 }
0059 
0060 void KSycocaEntry::setDeleted(bool deleted)
0061 {
0062     Q_D(KSycocaEntry);
0063     d->deleted = deleted;
0064 }
0065 
0066 bool KSycocaEntry::isSeparator() const
0067 {
0068     return d_ptr == nullptr || isType(KST_KServiceSeparator);
0069 }
0070 
0071 int KSycocaEntry::offset() const
0072 {
0073     Q_D(const KSycocaEntry);
0074     return d->offset;
0075 }
0076 
0077 void KSycocaEntryPrivate::save(QDataStream &s)
0078 {
0079     offset = s.device()->pos(); // store position in member variable
0080     s << qint32(sycocaType()) << path;
0081 }
0082 
0083 bool KSycocaEntry::isValid() const
0084 {
0085     Q_D(const KSycocaEntry);
0086     return d && d->isValid();
0087 }
0088 
0089 QString KSycocaEntry::name() const
0090 {
0091     Q_D(const KSycocaEntry);
0092     return d->name();
0093 }