Qtopia library API Documentation

AppLnk Class Reference

The AppLnk class represents an application available on the system. More...

#include <applnk.h>

Inheritance diagram for AppLnk:

Inheritance graph
[legend]
Collaboration diagram for AppLnk:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AppLnk ()
 AppLnk (const QString &file)
 AppLnk (const AppLnk &copy)
virtual ~AppLnk ()
bool isValid () const
QString name () const
const QPixmappixmap () const
const QPixmapbigPixmap () const
QString icon () const
virtual QString exec () const
QString type () const
QString rotation () const
QString comment () const
QString file () const
QString linkFile () const
QStringList mimeTypes () const
QStringList mimeTypeIcons () const
const QArray< int > & categories () const
int id () const
bool fileKnown () const
bool linkFileKnown () const
void execute () const
void execute (const QStringList &args) const
void removeFiles ()
void removeLinkFile ()
void setName (const QString &docname)
void setExec (const QString &exec)
void setFile (const QString &filename)
void setLinkFile (const QString &filename)
void setComment (const QString &comment)
void setType (const QString &mimetype)
void setRotation (const QString &rot)
void setIcon (const QString &iconname)
void setCategories (const QArray< int > &v)
bool writeLink () const
void setProperty (const QString &key, const QString &value)
QString property (const QString &key) const
AppLnkoperator= (const AppLnk &other)

Static Public Member Functions

void setSmallIconSize (int)
void setBigIconSize (int)
int smallIconSize ()
int bigIconSize ()

Protected Member Functions

virtual void invoke (const QStringList &args) const
bool ensureLinkExists () const
void storeLink () const

Protected Attributes

QString mName
QPixmap mPixmap
QPixmap mBigPixmap
QString mExec
QString mType
QString mRotation
QString mComment
QString mFile
QString mLinkFile
QString mIconFile
QStringList mMimeTypes
QStringList mMimeTypeIcons
int mId
AppLnkPrivate * d

Static Protected Attributes

int lastId = 5000

Friends

class AppLnkSet

Detailed Description

The AppLnk class represents an application available on the system.

Every Qtopia application app has a corresponding app.desktop file. When one of these files is read its data is stored as an AppLnk object.

The AppLnk class introduces some Qtopia-specific concepts, and provides a variety of functions, as described in the following sections.

Types Types

Every AppLnk object has a type. For applications, games and settings the type is Application; for documents the type is the document's MIME type.

files-and-links Files and Links

When you create an AppLnk (or more likely, a DocLnk), you don't deal directly with filenames in the filesystem. Instead you do this:

    DocLnk d;
    d.setType("text/plain");
    d.setName("My Nicely Named Document / Whatever"); // Yes, "/" is legal.
At this point, the file() and linkFile() are unknown. Normally this is uninteresting, and the names become automatically known, and more importantly, becomes reserved, when you ask what they are:

    QString fn = d.file();
This invents a filename, and creates the file on disk (an empty reservation file) to prevent the name being used by another application.

In some circumstances, you don't want to create the file if it doesn't already exist (e.g. in the Document tab, some of the DocLnk objects represented by icons are DocLnk's created just for that view - they don't have corresponding .desktop files. To avoid littering empty reservation files around, we check in a few places to see whether the file really needs to exist).

Functionality

AppLnk objects are created by calling the constructor with the name of a .desktop file. The object can be checked for validity using isValid().

The following functions are used to set or retrieve information about the application: Get Function Set Function Short Description name() setName() application's name pixmap() none application's icon bigPixmap() none application's large icon none setIcon() sets the icon's filename type() setType() see Types above rotation() none 0, 90, 180 or 270 degrees comment() setComment() text for the Details dialog exec() setExec() executable's filename file() none document's filename linkFile() setLinkFile() .desktop filename mimeTypes() none the mime types the application can view or edit categories() setCategories() {see the function descriptions} fileKnown() none see Files and Links above linkFileKnown() none see Files and Links above property() setProperty() any AppLnk property can be retrieved or set (if writeable) using these

To save an AppLnk to disk use writeLink(). To execute the application that the AppLnk object refers to, use execute().

AppLnk's can be deleted from disk using removeLinkFile(). To remove both the link and the application's executable use removeFiles().

Icon sizes can be globally changed (but only for AppLnk objects created after the calls) with setSmallIconSize() and setBigIconSize().

Definition at line 32 of file applnk.h.


Constructor & Destructor Documentation

AppLnk::AppLnk  ) 
 

Creates an invalid AppLnk.

See also:
isValid()

Definition at line 357 of file applnk.cpp.

AppLnk::AppLnk const QString file  ) 
 

Loads file (e.g. app.desktop) as an AppLnk.

See also:
writeLink()

Definition at line 368 of file applnk.cpp.

References Categories::addCategory(), QValueList::begin(), QValueList::end(), QString::findRev(), Categories::id(), id(), QString::isNull(), Config::isValid(), QString::left(), Categories::load(), Config::readEntry(), Config::readListEntry(), and Config::setGroup().

AppLnk::AppLnk const AppLnk copy  ) 
 

Copies copy.

Definition at line 631 of file applnk.cpp.

References d, mBigPixmap, mComment, mExec, mFile, mIconFile, mLinkFile, mMimeTypeIcons, mMimeTypes, mName, mPixmap, mRotation, and mType.

AppLnk::~AppLnk  )  [virtual]
 

Destroys the AppLnk. Note that if the AppLnk is currently a member of an AppLnkSet, this will produce a run-time warning.

See also:
AppLnkSet::add() AppLnkSet::remove()

Definition at line 658 of file applnk.cpp.


Member Function Documentation

bool AppLnk::isValid  )  const [inline]
 

Returns TRUE if this AppLnk is valid; otherwise returns FALSE.

Definition at line 40 of file applnk.h.

References QString::isNull().

Referenced by removeFiles(), and removeLinkFile().

void AppLnk::setSmallIconSize int  small  )  [static]
 

Sets the size used for small icons to small pixels. Only affects AppLnk objects created after the call.

See also:
smallIconSize() setIcon()

Definition at line 229 of file applnk.cpp.

Referenced by QPEApplication::QPEApplication().

void AppLnk::setBigIconSize int  big  )  [static]
 

Sets the size used for large icons to big pixels. Only affects AppLnk objects created after the call.

See also:
bigIconSize() setIcon()

Definition at line 251 of file applnk.cpp.

Referenced by QPEApplication::QPEApplication().

int AppLnk::smallIconSize  )  [static]
 

Returns the size used for small icons.

See also:
setSmallIconSize() setIcon()

Definition at line 239 of file applnk.cpp.

int AppLnk::bigIconSize  )  [static]
 

Returns the size used for large icons.

See also:
setBigIconSize() setIcon()

Definition at line 261 of file applnk.cpp.

QString AppLnk::name  )  const [inline]
 

Returns the Name property. This is the user-visible name for the document or application, not the filename.

See Files and Links.

See also:
setName()

Definition at line 47 of file applnk.h.

const QPixmap & AppLnk::pixmap  )  const
 

Returns a small pixmap associated with the application.

See also:
bigPixmap() setIcon()

Definition at line 496 of file applnk.cpp.

Referenced by bigPixmap().

const QPixmap & AppLnk::bigPixmap  )  const
 

Returns a large pixmap associated with the application.

See also:
pixmap() setIcon()

Definition at line 509 of file applnk.cpp.

References pixmap().

QString AppLnk::icon  )  const [inline]
 

Returns the Icon property.

See also:
setIcon()

Definition at line 50 of file applnk.h.

QString AppLnk::exec  )  const [inline, virtual]
 

Returns the Exec property. This is the name of the executable program associated with the AppLnk.

See also:
setExec()

Reimplemented in DocLnk.

Definition at line 51 of file applnk.h.

Referenced by DocLnk::exec(), AppLnkSet::findExec(), and invoke().

QString AppLnk::type  )  const
 

Returns the type of the AppLnk. For applications, games and settings the type is Application; for documents the type is the document's MIME type.

Definition at line 522 of file applnk.cpp.

References file(), MimeType::id(), QString::isNull(), and mType.

Referenced by DocLnkSet::DocLnkSet(), DocLnk::exec(), DocLnk::invoke(), linkFile(), MimeType::MimeType(), and Ir::send().

QString AppLnk::rotation  )  const [inline]
 

Returns the Rotation property. The value is 0, 90, 180 or 270 degrees.

Definition at line 53 of file applnk.h.

QString AppLnk::comment  )  const [inline]
 

Returns the Comment property.

See also:
setComment()

Definition at line 54 of file applnk.h.

QString AppLnk::file  )  const
 

Returns the file associated with the AppLnk.

See also:
exec() name()

Definition at line 541 of file applnk.cpp.

References QString::contains(), QFile::exists(), QString::isEmpty(), QString::isNull(), QString::latin1(), QString::left(), QString::length(), mFile, mLinkFile, mName, QFile::open(), and QString::right().

Referenced by FileManager::copyFile(), FileManager::exists(), DocLnk::invoke(), linkFile(), FileManager::loadFile(), FileManager::openFile(), removeFiles(), FileManager::saveFile(), Ir::send(), and type().

QString AppLnk::linkFile  )  const
 

Returns the desktop file corresponding to this AppLnk.

See also:
file() exec() name()

Definition at line 586 of file applnk.cpp.

References QString::contains(), FileSystem::disk(), QFile::exists(), file(), StorageInfo::fileSystemOf(), QString::isNull(), FileSystem::isRemovable(), mFile, mLinkFile, mName, FileSystem::path(), and type().

Referenced by ensureLinkExists(), DocLnk::invoke(), property(), removeFiles(), removeLinkFile(), setProperty(), and writeLink().

QStringList AppLnk::mimeTypes  )  const [inline]
 

Returns the MimeTypes property. This is the list of MIME types that the application can view or edit.

Definition at line 57 of file applnk.h.

QStringList AppLnk::mimeTypeIcons  )  const [inline]
 

Returns the MimeTypeIcons property of the AppLnk.

Definition at line 58 of file applnk.h.

const QArray< int > & AppLnk::categories  )  const
 

Returns the Categories property.

See the CategoryWidget for more details.

See also:
setCategories()

Definition at line 314 of file applnk.cpp.

int AppLnk::id  )  const [inline]
 

Returns the id of the AppLnk. If the AppLnk is not in an AppLnkSet, this value is 0, otherwise it is a value that is unique for the duration of the current process.

See also:
AppLnkSet::find()

Definition at line 60 of file applnk.h.

Referenced by AppLnk(), and AppLnkSet::find().

bool AppLnk::fileKnown  )  const [inline]
 

If the with the AppLnk associated file is not equal to QString::null

Definition at line 62 of file applnk.h.

References QString::isNull().

bool AppLnk::linkFileKnown  )  const [inline]
 

The filename of the AppLnk

Definition at line 63 of file applnk.h.

References QString::isNull().

Referenced by DocLnk::invoke(), removeFiles(), and removeLinkFile().

void AppLnk::execute  )  const
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Executes the application associated with this AppLnk.

See also:
exec()

Definition at line 672 of file applnk.cpp.

Referenced by DocLnk::invoke().

void AppLnk::execute const QStringList args  )  const
 

Executes the application associated with this AppLnk, with args as arguments.

See also:
exec()

Definition at line 683 of file applnk.cpp.

References QByteArray::data(), invoke(), QString::isEmpty(), and QString::toInt().

void AppLnk::removeFiles  ) 
 

Deletes both the linkFile() and the file() associated with this AppLnk.

See also:
removeLinkFile()

Definition at line 950 of file applnk.cpp.

References file(), isValid(), linkFile(), linkFileKnown(), QFile::remove(), and writeLink().

void AppLnk::removeLinkFile  ) 
 

Deletes the linkFile(), leaving any file() untouched.

See also:
removeFiles()

Definition at line 974 of file applnk.cpp.

References isValid(), linkFile(), linkFileKnown(), and QFile::remove().

void AppLnk::setName const QString docname  ) 
 

Sets the Name property to docname.

See also:
name()

Definition at line 738 of file applnk.cpp.

Referenced by DocLnkSet::DocLnkSet().

void AppLnk::setExec const QString exec  ) 
 

Sets the Exec property to exec.

See also:
exec() name()

Definition at line 716 of file applnk.cpp.

void AppLnk::setFile const QString filename  ) 
 

Sets the File property to filename.

See also:
file() name()

Definition at line 748 of file applnk.cpp.

Referenced by DocLnkSet::DocLnkSet().

void AppLnk::setLinkFile const QString filename  ) 
 

Sets the LinkFile property to filename.

See also:
linkFile()

Definition at line 758 of file applnk.cpp.

void AppLnk::setComment const QString comment  ) 
 

Sets the Comment property to comment.

This text is displayed in the 'Details Dialog', for example if the user uses the 'press-and-hold' gesture.

See also:
comment()

Definition at line 771 of file applnk.cpp.

void AppLnk::setType const QString type  ) 
 

Sets the Type property to type.

For applications, games and settings the type should be Application; for documents the type should be the document's MIME type.

See also:
type()

Definition at line 785 of file applnk.cpp.

void AppLnk::setRotation const QString rot  )  [inline]
 

The default rotation of the associated application. This function is included inline for binary compatible issues

Definition at line 76 of file applnk.h.

void AppLnk::setIcon const QString iconname  ) 
 

Sets the Icon property to iconname. This is the filename from which the pixmap() and bigPixmap() are obtained.

See also:
icon() setSmallIconSize() setBigIconSize()

Definition at line 804 of file applnk.cpp.

References Resource::loadImage(), and QImage::smoothScale().

void AppLnk::setCategories const QArray< int > &  c  ) 
 

Sets the Categories property to c.

See the CategoryWidget for more details.

See also:
categories()

Definition at line 819 of file applnk.cpp.

bool AppLnk::writeLink  )  const
 

Commits the AppLnk to disk. Returns TRUE if the operation succeeded; otherwise returns FALSE.

In addition, the "linkChanged(QString)" message is sent to the "QPE/System" QCop channel.

Definition at line 851 of file applnk.cpp.

References ensureLinkExists(), and linkFile().

Referenced by FileManager::copyFile(), removeFiles(), and FileManager::saveFile().

void AppLnk::setProperty const QString key,
const QString value
 

Sets the property named key to value.

See also:
property()

Definition at line 900 of file applnk.cpp.

References ensureLinkExists(), linkFile(), and Config::writeEntry().

QString AppLnk::property const QString key  )  const
 

Returns the property named key.

See also:
setProperty()

Definition at line 913 of file applnk.cpp.

References QFile::exists(), linkFile(), and Config::readEntry().

void AppLnk::invoke const QStringList args  )  const [protected, virtual]
 

Invokes the application associated with this AppLnk, with args as arguments. Rotation is not taken into account by this function, so you should not call it directly.

See also:
execute()

Reimplemented in DocLnk.

Definition at line 706 of file applnk.cpp.

References exec(), and Global::execute().

Referenced by execute().

bool AppLnk::ensureLinkExists  )  const [protected]
 

Attempts to ensure that the link file for this AppLnk exists, including creating any required directories. Returns TRUE if successful; otherwise returns FALSE.

You should not need to use this function.

Definition at line 838 of file applnk.cpp.

References linkFile().

Referenced by setProperty(), and writeLink().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:11 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001