Home · All Classes · Main Classes · Deprecated
Public Member Functions

MDesktopEntry Class Reference

Inheritance diagram for MDesktopEntry:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 MDesktopEntry (const QString &fileName)
virtual ~MDesktopEntry ()
QString fileName () const
virtual bool isValid () const
virtual uint hash () const
QString type () const
QString version () const
QString name () const
QString nameUnlocalized () const
QString genericName () const
bool noDisplay () const
QString comment () const
QString icon () const
bool hidden () const
QStringList onlyShowIn () const
QStringList notShowIn () const
QString tryExec () const
QString exec () const
QString path () const
bool terminal () const
QStringList mimeType () const
QStringList categories () const
bool startupNotify () const
QString startupWMClass () const
QString url () const
QString xMaemoService () const
QString value (const QString &key) const
QString value (const QString &group, const QString &key) const
bool contains (const QString &key) const
bool contains (const QString &group, const QString &key) const

Detailed Description

MDesktopEntry provides the means to read freedesktop.org desktop entry files.

MDesktopEntry object reads desktop file data from the desktop file given as a construction parameter.

The isValid() method determines whether the input desktop file conforms to the standard defined by freedesktop.org.

For more information see: http://standards.freedesktop.org/desktop-entry-spec/latest/index.html

Definition at line 43 of file corelib/core/mdesktopentry.h.


Constructor & Destructor Documentation

MDesktopEntry::MDesktopEntry ( const QString fileName  ) 

Reads input desktop file and constructs new MDesktopEntry object of it.

Parameters:
fileName the name of the file to read the desktop entry from

Definition at line 175 of file mdesktopentry.cpp.

                                                    :
    d_ptr(new MDesktopEntryPrivate(fileName))
{
}

MDesktopEntry::~MDesktopEntry (  )  [virtual]

Destroys the MDesktopEntry.

Definition at line 185 of file mdesktopentry.cpp.

{
    delete d_ptr;
}


Member Function Documentation

QStringList MDesktopEntry::categories (  )  const

Returns the value of Categories key or an empty string list if it is not defined in the input desktop entry file.

Definition at line 366 of file mdesktopentry.cpp.

{
    return d_ptr->stringListValue(CategoriesKey);
}

QString MDesktopEntry::comment (  )  const

Returns the value of Comment key or an empty string if it is not defined in the input desktop entry file.

Definition at line 311 of file mdesktopentry.cpp.

{
    return value(CommentKey);
}

Here is the call graph for this function:

bool MDesktopEntry::contains ( const QString key  )  const

Indicates whether map contains key or not. Returns false if key is not present.

Definition at line 195 of file mdesktopentry.cpp.

{
    return d_ptr->desktopEntriesMap.contains(key);
}

bool MDesktopEntry::contains ( const QString group,
const QString key 
) const

Indicates whether map contains group/key or not. Returns false if key is not present.

Definition at line 200 of file mdesktopentry.cpp.

{
    return d_ptr->desktopEntriesMap.contains(group + '/' + key);
}

QString MDesktopEntry::exec (  )  const

Returns the value of Exec key or an empty string if it is not defined in the input desktop entry file.

Definition at line 341 of file mdesktopentry.cpp.

{
    return value(ExecKey);
}

Here is the call graph for this function:

QString MDesktopEntry::fileName (  )  const

Returns the name of the file where the information for this desktop entry was read from.

Returns:
The desktop entry file name.

Definition at line 190 of file mdesktopentry.cpp.

{
    return d_ptr->sourceFileName;
}

QString MDesktopEntry::genericName (  )  const

Returns the value of GenericName key or an empty string if it is not defined in the input desktop entry file.

Definition at line 301 of file mdesktopentry.cpp.

{
    return value(GenericNameKey);
}

Here is the call graph for this function:

uint MDesktopEntry::hash (  )  const [virtual]

Calculates a hash value based on the required type and name keys of the desktop definition.

Definition at line 246 of file mdesktopentry.cpp.

{
    return qHash(type() + name());
}

Here is the call graph for this function:

bool MDesktopEntry::hidden (  )  const

Indicates whether value of Hidden key is true or false. Returns false if Hidden key is undefined.

Definition at line 321 of file mdesktopentry.cpp.

{
    return d_ptr->boolValue(HiddenKey);
}

QString MDesktopEntry::icon (  )  const

Returns the value of Icon key or an empty string if it is not defined in the input desktop entry file.

Definition at line 316 of file mdesktopentry.cpp.

{
    return value(IconKey);
}

Here is the call graph for this function:

bool MDesktopEntry::isValid (  )  const [virtual]

Indicates whether desktop entry information adheres to the requirements set in the freedesktop.org standard. Freedesktop.org defines required keys that one has to fill to have a valid desktop file. This checks whether those keys are defined.

Reimplemented in MApplicationExtensionMetaData, and MAppletMetaData.

Definition at line 215 of file mdesktopentry.cpp.

{
    // The Type and Name keys always have to be present
    if (!contains(TypeKey)) {
        return false;
    }

    if (!contains(NameKey)) {
        return false;
    }

    // In case of an application the Exec key needs to be present
    if (type() == "Application" && !contains(ExecKey)) {
        return false;
    }

    // In case of a link the URL key needs to be present
    if (type() == "Link" && !contains(URLKey)) {
        return false;
    }

    // In case the desktop entry is invalid for some explicit reason
    // Some cases are:
    // 1. Group name defined multiple times
    // 2. Desktop entry's first group should be "Desktop Entry"
    if (!d_ptr->valid) {
        return false;
    }
    return true;
}

Here is the call graph for this function:

QStringList MDesktopEntry::mimeType (  )  const

Returns the value of MimeTypes key or an empty string list if it is not defined in the input desktop entry file.

Definition at line 361 of file mdesktopentry.cpp.

{
    return d_ptr->stringListValue(MimeTypeKey);
}

QString MDesktopEntry::name (  )  const

Returns the localized value of Name key or an empty string if it is not defined in the input desktop entry file. The localization requires either a X-MeeGo-Logical-Id attribute with optional X-MeeGo-Translation-Catalog attribute or freedesktop.org standard style localized name attribute. Returns the name as unlocalized if the logical id cannot be found from the catalog.

See also:
nameUnlocalized

Definition at line 261 of file mdesktopentry.cpp.

{
    QString name = value(NameKey);

    if (contains(LogicalIdKey)) {
        // Get the name from the translation catalog;
        // if it does not exist use the unlocalized name prefixed
        // by the engineering English marker "!! ":
        QString translation = qtTrId(value(LogicalIdKey).toAscii().data());
        if (translation == value(LogicalIdKey))
            name = "!! " + name;
        else
            name = translation;
    } else {
        MLocale locale;
        QString lang(locale.language());
        QString country(locale.country());
        QString variant(locale.variant());
        QString postfixKey;
        if (contains(postfixKey = NameKey + '[' + lang + '_' +
                                  country  + '@' +
                                  variant  + ']') ||
                contains(postfixKey = NameKey + '[' + lang + '_' +
                                      country  + ']') ||
                contains(postfixKey = NameKey + '[' + lang + '@' +
                                      variant  + ']') ||
                contains(postfixKey = NameKey + '[' + lang + ']')) {
            // Use the freedesktop.org standard localization style
            name = value(postfixKey);
        }
    }

    return name;
}

Here is the call graph for this function:

QString MDesktopEntry::nameUnlocalized (  )  const

Returns the unlocalized value of Name key or an empty string if it is not defined in the input desktop entry file.

Definition at line 296 of file mdesktopentry.cpp.

{
    return value(NameKey);
}

Here is the call graph for this function:

bool MDesktopEntry::noDisplay (  )  const

Indicates whether value of NoDisplay key is true or false. Returns false if NoDisplay key is undefined.

Definition at line 306 of file mdesktopentry.cpp.

{
    return d_ptr->boolValue(NoDisplayKey);
}

QStringList MDesktopEntry::notShowIn (  )  const

Returns the value of NotShowIn key or an empty string list if it is not defined in the input desktop entry file.

Definition at line 331 of file mdesktopentry.cpp.

{
    return d_ptr->stringListValue(NotShowInKey);
}

QStringList MDesktopEntry::onlyShowIn (  )  const

Returns the value of OnlyShowIn key or an empty string list if it is not defined in the input desktop entry file.

Definition at line 326 of file mdesktopentry.cpp.

{
    return d_ptr->stringListValue(OnlyShowInKey);
}

QString MDesktopEntry::path (  )  const

Returns the value of Path key or an empty string if it is not defined in the input desktop entry file.

Definition at line 351 of file mdesktopentry.cpp.

{
    return value(PathKey);
}

Here is the call graph for this function:

bool MDesktopEntry::startupNotify (  )  const

Indicates whether value of StartupNotify key is true or false. Returns false if StartupNotify key is undefined.

Definition at line 371 of file mdesktopentry.cpp.

{
    return d_ptr->boolValue(StartupNotifyKey);
}

QString MDesktopEntry::startupWMClass (  )  const

Returns the value of StartupWMClass key or an empty string if it is not defined in the input desktop entry file.

Definition at line 376 of file mdesktopentry.cpp.

{
    return value(StartupWMClassKey);
}

Here is the call graph for this function:

bool MDesktopEntry::terminal (  )  const

Indicates whether value of Terminal key is true or false. Returns false if Terminal key is undefined.

Definition at line 356 of file mdesktopentry.cpp.

{
    return d_ptr->boolValue(TerminalKey);
}

QString MDesktopEntry::tryExec (  )  const

Returns the value of TryExec key or an empty string if it is not defined in the input desktop entry file.

Definition at line 336 of file mdesktopentry.cpp.

{
    return value(TryExecKey);
}

Here is the call graph for this function:

QString MDesktopEntry::type (  )  const

Returns the value of Type key or an empty string if it is not defined in the input desktop entry file.

Definition at line 251 of file mdesktopentry.cpp.

{
    return value(TypeKey);
}

Here is the call graph for this function:

QString MDesktopEntry::url (  )  const

Returns the value of URL key or an empty string if it is not defined in the input desktop entry file.

Definition at line 381 of file mdesktopentry.cpp.

{
    return value(URLKey);
}

Here is the call graph for this function:

QString MDesktopEntry::value ( const QString group,
const QString key 
) const

Returns the value of the group-key stored as "group/key" key or an empty string if it is not defined in the input desktop entry file.

Definition at line 210 of file mdesktopentry.cpp.

{
    return d_ptr->desktopEntriesMap.value(group + '/' + key);
}

QString MDesktopEntry::value ( const QString key  )  const

Returns the value of the key- key or an empty string if it is not defined in the input desktop entry file.

Definition at line 205 of file mdesktopentry.cpp.

{
    return d_ptr->desktopEntriesMap.value(key);
}

QString MDesktopEntry::version (  )  const

Returns the value of Version key or an empty string if it is not defined in the input desktop entry file.

Definition at line 256 of file mdesktopentry.cpp.

{
    return value(VersionKey);
}

Here is the call graph for this function:

QString MDesktopEntry::xMaemoService (  )  const

Returns the value of X-Osso-Service key or an empty string if it is not defined in the input desktop entry file.

Definition at line 346 of file mdesktopentry.cpp.

{
    return value(XMaemoServiceKey);
}

Here is the call graph for this function:


Copyright © 2010 Nokia Corporation Generated on Thu Nov 4 2010 18:14:24 (PDT)
Doxygen 1.7.1
MeeGo Touch