KSycoca

#include <ksycoca.h>

Inheritance diagram for KSycoca:

Public Types

enum  DatabaseType { LocalDatabase, GlobalDatabase }
 

Signals

void databaseChanged ()
 
void databaseChanged (const QStringList &changedResources)
 

Public Member Functions

 KSycoca ()
 
void addFactory (KSycocaFactory *)
 
QStringList allResourceDirs ()
 
void ensureCacheValid ()
 
QDataStreamfindEntry (int offset, KSycocaType &type)
 
QDataStreamfindFactory (KSycocaFactoryId id)
 
virtual bool isBuilding ()
 
QString language ()
 
quint32 timeStamp ()
 
quint32 updateSignature ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static QString absoluteFilePath (DatabaseType type=LocalDatabase)
 
static void disableAutoRebuild ()
 
static void flagError ()
 
static bool isAvailable ()
 
static bool isChanged (const char *type)
 
static KSycocaself ()
 
static int version ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

 KSycoca (bool)
 
void connectNotify (const QMetaMethod &signal) override
 
KSycocaFactoryList * factories ()
 
QDataStream *& stream ()
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

Read-only SYstem COnfiguration CAche

Definition at line 33 of file ksycoca.h.

Member Enumeration Documentation

type of database

See also
absoluteFilePath()

Definition at line 50 of file ksycoca.h.

Constructor & Destructor Documentation

KSycoca::KSycoca ( bool  )
explicitprotected

Building database

Definition at line 350 of file ksycoca.cpp.

KSycoca::KSycoca ( )

Read-only database.

Definition at line 208 of file ksycoca.cpp.

Member Function Documentation

QString KSycoca::absoluteFilePath ( DatabaseType  type = LocalDatabase)
static

- returns absolute file path of the database

For the global database type, the database is searched under the 'share/ksycoca' install path. Otherwise, the value from the environment variable KDESYCOCA is returned if set. If not set the path is built based on QStandardPaths cache save location, typically ~/.cache on Unix.

Since 5.15, the filename includes language and a sha1 of the directories in GenericDataLocation, i.e. the directories with the desktop files. This allows to have one database per setup, when using different install prefixes or when switching languages.

Definition at line 673 of file ksycoca.cpp.

void KSycoca::addFactory ( KSycocaFactory *  factory)

- add a factory

Definition at line 408 of file ksycoca.cpp.

QStringList KSycoca::allResourceDirs ( )

- returns all directories with information stored inside sycoca.

Definition at line 704 of file ksycoca.cpp.

void KSycoca::databaseChanged ( )
signal

Connect to this to get notified when the database changes.

Example: after creating a .desktop file in KOpenWithDialog, it must wait until kbuildsycoca5 finishes until the KService::Ptr is available. Other examples: anything that displays a list of apps or plugins to the user and which is always visible (otherwise querying sycoca before showing could be enough).

void KSycoca::databaseChanged ( const QStringList changedResources)
signal

Connect to this to get notified when the database changes Example: when MIME type definitions have changed, applications showing files as icons refresh icons to take into account the new MIME types.

Another example: after creating a .desktop file in KOpenWithDialog, it must wait until kbuildsycoca5 finishes until the KService::Ptr is available.

Parameters
changedResourcesList of resources where changes were detected. This can include the following resources (as defined in KStandardDirs) : apps, xdgdata-apps, services, servicetypes, xdgdata-mime.
void KSycoca::disableAutoRebuild ( )
static

Disables automatic rebuilding of the cache on service file changes.

Be extremely careful when using this. Only threads that definitely have no use for automatic reloading should use this. Specifically shared runner threads (as seen in the threadweaver framework) can avoid claiming persistent resources this way (e.g. inotify instances on Linux).

Definition at line 732 of file ksycoca.cpp.

void KSycoca::ensureCacheValid ( )

Ensures the ksycoca database is up to date.

If the database was modified by another process, close it, so the next use reopens it. If the desktop files have been modified more recently than the database, update it.

Update the sycoca file from the files on disk (e.g. desktop files or mimeapps.list). You don't normally have to call this because the next use of KSycoca (e.g. via KMimeTypeTrader, KService etc.) will notice that the sycoca database is out of date, by looking a directory modification times. In addition, in a full KDE session, kded monitors directories to detect changes.

This is however useful for GUIs that allow to create a new desktop file and then want to ensure it is available immediately in KSycoca. This is also useful after modifying a mimeapps.list file.

KBuildSycocaProgressDialog can also be used instead of this method, in GUI apps.

Since
5.15

Definition at line 763 of file ksycoca.cpp.

QDataStream * KSycoca::findEntry ( int  offset,
KSycocaType &  type 
)

- called by factories in read-only mode This is how factories get a stream to an entry

Definition at line 420 of file ksycoca.cpp.

QDataStream * KSycoca::findFactory ( KSycocaFactoryId  id)

- called by factories in read-only mode Returns stream(), but positioned for reading this factory, 0 on error.

Definition at line 495 of file ksycoca.cpp.

void KSycoca::flagError ( )
static

A read error occurs.

Definition at line 712 of file ksycoca.cpp.

bool KSycoca::isAvailable ( )
static
Returns
true if the ksycoca database is available This is usually the case, except if KDE isn't installed yet, or before kded is started.

Definition at line 371 of file ksycoca.cpp.

bool KSycoca::isBuilding ( )
virtual
Returns
true if building (i.e. if a KBuildSycoca);

Definition at line 727 of file ksycoca.cpp.

bool KSycoca::isChanged ( const char *  type)
static

When you receive a "databaseChanged" signal, you can query here if a change has occurred in a specific resource type.

See also
KStandardDirs for the various resource types.

This method is meant to be called from the GUI thread only.

Deprecated:
Since 5.0, use the signal databaseChanged(QStringList) instead.

Definition at line 414 of file ksycoca.cpp.

QString KSycoca::language ( )

- returns language stored inside database

Definition at line 695 of file ksycoca.cpp.

KSycoca * KSycoca::self ( )
static

Get or create the only instance of KSycoca (read-only)

Definition at line 355 of file ksycoca.cpp.

quint32 KSycoca::timeStamp ( )

- returns timestamp of database

The database contains all changes made before this time and might contain changes made after that.

Definition at line 654 of file ksycoca.cpp.

quint32 KSycoca::updateSignature ( )

- returns update signature of database

Signature that keeps track of changes to $KDEDIR/share/services/update_ksycoca

Touching this file causes the database to be recreated from scratch.

Definition at line 664 of file ksycoca.cpp.

int KSycoca::version ( )
static
Returns
the compiled-in version, i.e. the one used when writing a new ksycoca

Definition at line 154 of file ksycoca.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Sep 17 2020 22:47:35 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.