File indexing completed on 2024-10-06 12:24:01

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 "ksycocautils_p.h"
0011 
0012 #include <ksycoca.h>
0013 
0014 KSycocaEntryPrivate::KSycocaEntryPrivate(QDataStream &_str, int iOffset)
0015     : offset(iOffset)
0016     , deleted(false)
0017 {
0018     _str >> path;
0019 }
0020 
0021 KSycocaEntry::KSycocaEntry()
0022     : d_ptr(nullptr)
0023 {
0024 }
0025 
0026 KSycocaEntry::KSycocaEntry(KSycocaEntryPrivate &d)
0027     : d_ptr(&d)
0028 {
0029 }
0030 
0031 KSycocaEntry::~KSycocaEntry() = default;
0032 
0033 bool KSycocaEntry::isType(KSycocaType t) const
0034 {
0035     return d_ptr->isType(t);
0036 }
0037 
0038 KSycocaType KSycocaEntry::sycocaType() const
0039 {
0040     return d_ptr->sycocaType();
0041 }
0042 
0043 QString KSycocaEntry::entryPath() const
0044 {
0045     Q_D(const KSycocaEntry);
0046     return d->path;
0047 }
0048 
0049 QString KSycocaEntry::storageId() const
0050 {
0051     Q_D(const KSycocaEntry);
0052     return d->storageId();
0053 }
0054 
0055 bool KSycocaEntry::isDeleted() const
0056 {
0057     Q_D(const KSycocaEntry);
0058     return d->deleted;
0059 }
0060 
0061 void KSycocaEntry::setDeleted(bool deleted)
0062 {
0063     Q_D(KSycocaEntry);
0064     d->deleted = deleted;
0065 }
0066 
0067 bool KSycocaEntry::isSeparator() const
0068 {
0069     return d_ptr == nullptr || isType(KST_KServiceSeparator);
0070 }
0071 
0072 int KSycocaEntry::offset() const
0073 {
0074     Q_D(const KSycocaEntry);
0075     return d->offset;
0076 }
0077 
0078 void KSycocaEntryPrivate::save(QDataStream &s)
0079 {
0080     offset = s.device()->pos(); // store position in member variable
0081     s << qint32(sycocaType()) << path;
0082 }
0083 
0084 bool KSycocaEntry::isValid() const
0085 {
0086     Q_D(const KSycocaEntry);
0087     return d && d->isValid();
0088 }
0089 
0090 QString KSycocaEntry::name() const
0091 {
0092     Q_D(const KSycocaEntry);
0093     return d->name();
0094 }
0095 
0096 QStringList KSycocaEntry::propertyNames() const
0097 {
0098     Q_D(const KSycocaEntry);
0099     return d->propertyNames();
0100 }
0101 
0102 QVariant KSycocaEntry::property(const QString &name) const
0103 {
0104     Q_D(const KSycocaEntry);
0105     return d->property(name);
0106 }