Home · All Namespaces · All Classes
Signals | Public Member Functions

LauncherDataStore Class Reference

LauncherDataStore provides a way to store .desktop entry file related data such as the location of the .desktop entry in the user interface. More...

#include <launcherdatastore.h>

Inheritance diagram for LauncherDataStore:
Inheritance graph
[legend]
Collaboration diagram for LauncherDataStore:
Collaboration graph
[legend]

List of all members.

Signals

void dataStoreChanged ()
 A signal for informing that the contents of the data store have changed.
void desktopEntryChanged (const QString &)
 A signal for informing that the contents of a desktop entry have changed.
void desktopEntryAdded (const QString &)
void desktopEntryRemoved (const QString &)

Public Member Functions

 LauncherDataStore (MDataStore *dataStore, const QString &directoryPath=APPLICATIONS_DIRECTORY)
virtual ~LauncherDataStore ()
QHash< QString, QVariant > dataForAllDesktopEntries ()
void updateDataForDesktopEntry (const QString &entryPath, const QVariant &data)
void removeDataForDesktopEntry (const QString &entryPath)

Detailed Description

LauncherDataStore provides a way to store .desktop entry file related data such as the location of the .desktop entry in the user interface.

The data is stored as key-value pairs. Key is entry file path relative to root. (eg. "usr/share/applications/deskentry.desktop"). The value is user specific data.

The LauncherDataStore uses a MDataStore as a backend to actually store the the data. The ownership of the MDataStore is transferred to the LauncherDataStore.

Definition at line 51 of file launcherdatastore.h.


Constructor & Destructor Documentation

LauncherDataStore::LauncherDataStore ( MDataStore *  dataStore,
const QString &  directoryPath = APPLICATIONS_DIRECTORY 
)

Constructs LauncherDataStore. The ownership of the MDataStore is transferred to this LauncherDataStore.

Parameters:
dataStore The backend data store.
directoryPath The directory to watch.

Definition at line 32 of file launcherdatastore.cpp.

                                                                                        :
        store(dataStore),
        updatePending(false),
        directoryPath(directoryPath)
{
    connect(&processUpdateQueueTimer, SIGNAL(timeout()), this, SLOT(processUpdateQueue()));
    processUpdateQueueTimer.setSingleShot(true);
    processUpdateQueueTimer.setInterval(0);

    supportedDesktopEntryFileTypes << "Application";
    updateDataFromDesktopEntryFiles();

    // Start watching the applications directory for changes
    connect(&watcher, SIGNAL(directoryChanged(const QString)), this, SLOT(updateDataFromDesktopEntryFiles()));
    connect(&watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateDesktopEntry(QString)));
    watcher.addPath(directoryPath);
}

LauncherDataStore::~LauncherDataStore (  )  [virtual]

Destroys LauncherDataStore

Definition at line 50 of file launcherdatastore.cpp.

{
    delete store;
}


Member Function Documentation

QHash< QString, QVariant > LauncherDataStore::dataForAllDesktopEntries (  ) 

Returns the data for all desktop entries stored in the data store.

Definition at line 55 of file launcherdatastore.cpp.

{
    QHash<QString, QVariant> data;
    foreach (const QString &key, store->allKeys()) {
        // Ignore any entries not withing the "DesktopEntries" section
        if (key.indexOf(KEY_PREFIX) != 0)
            continue;
        data.insert(keyToEntryPath(key), store->value(key));
    }
    return data;
}

void LauncherDataStore::dataStoreChanged (  )  [signal]

A signal for informing that the contents of the data store have changed.

void LauncherDataStore::desktopEntryAdded ( const QString &   )  [signal]

A signal for informing that the a new entry has been added.

Added desktop entry path as parameter.

void LauncherDataStore::desktopEntryChanged ( const QString &   )  [signal]

A signal for informing that the contents of a desktop entry have changed.

void LauncherDataStore::desktopEntryRemoved ( const QString &   )  [signal]

A signal for informing that the a entry has been removed.

Removed desktop entry path as parameter.

void LauncherDataStore::removeDataForDesktopEntry ( const QString &  entryPath  ) 

Removes the data for a desktop entry in the data store.

Parameters:
entryPath the path of the desktop entry to remove

Definition at line 79 of file launcherdatastore.cpp.

{
    // Disconnect listening store changes during the store is updated.
    disconnect(store, SIGNAL(valueChanged(QString, QVariant)), this, SIGNAL(dataStoreChanged()));

    // Remove value from the data store
    store->remove(entryPathToKey(entryPath));

    // Emit a dataStoreChanged() signal if something changes in the data store
    connect(store, SIGNAL(valueChanged(QString, QVariant)), this, SIGNAL(dataStoreChanged()));
}

Here is the call graph for this function:

void LauncherDataStore::updateDataForDesktopEntry ( const QString &  entryPath,
const QVariant &  data 
)

Updates the data for a desktop entry in the data store.

Parameters:
entryPath the path of the desktop entry to update
data the data to update the desktop entry with

Definition at line 67 of file launcherdatastore.cpp.

{
    // Disconnect listening store changes during the store is updated.
    disconnect(store, SIGNAL(valueChanged(QString, QVariant)), this, SIGNAL(dataStoreChanged()));

    // Update the data store
    store->createValue(entryPathToKey(entryPath), data);

    // Emit a dataStoreChanged() signal if something changes in the data store
    connect(store, SIGNAL(valueChanged(QString, QVariant)), this, SIGNAL(dataStoreChanged()));
}

Here is the call graph for this function:


The documentation for this class was generated from the following files:

Copyright © 2010 Nokia Corporation Generated on Thu Nov 4 2010 18:20:42
Doxygen 1.7.1
MeeGo Touch