Qtopia Home - Classes - Hierachy - Annotated - Functions - Qt Embedded |

# Global Class Reference

The Global class provides application-wide global functions. More...

`#include <qtopia/global.h>`

List of all member functions.

## Static Public Members

- QUuid generateUuid ()
- QStringList qtopiaPaths ()
- QString defaultButtonsFile ()
- QString homeDirPath ()
- bool renameFile ( QString from, QString to )
- QString tempName ( const QString & fname )
- QString applicationFileName ( const QString & appname, const QString & filename )
- void findDocuments ( DocLnkSet * folder, const QString & mimefilter = QString::null )
- bool isDocumentFileName ( const QString & file )
- bool isAppLnkFileName ( const QString & file )
- void statusMessage ( const QString & message )
- QString shellQuote ( const QString & s )
- QString stringQuote ( const QString & s )
- QByteArray encodeBase64 ( const QByteArray & origData )
- QByteArray decodeBase64 ( const QByteArray & encoded )
- bool weekStartsOnMonday ()
- void setWeekStartsMonday ( bool v )
- bool mousePreferred ()
- bool hasKey ( int key )
- void sleep ( unsigned long secs )
- void msleep ( unsigned long msecs )
- void usleep ( unsigned long usecs )
- const QDawg & fixedDawg ()
- const QDawg & addedDawg ()
- const QDawg & dawg ( const QString & name )
- void addWords ( const QStringList & wordlist )
- void addWords ( const QString & dictname, const QStringList & wordlist )
- void removeWords ( const QStringList & wordlist )
- void removeWords ( const QString & dictname, const QStringList & wordlist )
- QString version ()
- QString architecture ()
- QString deviceId ()
- QString ownerName ()
- void execute ( const QString & c, const QString & document = QString::null )
- void hideInputMethod ()
- void showInputMethod ()
- void writeHWClock ()

## Detailed Description

The Global class provides application-wide global functions.

The Global functions are grouped as follows:

- User Interface
- Document related
- Filesystem related
- Word list related
- Quoting
- Hardware

### User Interface

The statusMessage() function provides short-duration messages to the user. The showInputMethod() function shows the current input method, and hideInputMethod() hides the input method.

### Document related

The findDocuments() function creates a set of DocLnk objects in a particular folder.

### Filesystem related

Global provides an applicationFileName() function that returns the full path of an application-specific file.

The execute() function runs an application.

### Word list related

A list of words relevant to the current locale is maintained by the system. The list is held in a DAWG (implemented by the QDawg class). This list is used, for example, by the pickboard input method.

The global QDawg is returned by fixedDawg(); this cannot be updated. An updatable copy of the global QDawg is returned by addedDawg(). Applications may have their own word lists stored in QDawgs which are returned by dawg(). Use addWords() to add words to the updateable copy of the global QDawg or to named application QDawgs.

### Quoting

The shellQuote() function quotes a string suitable for passing to a shell. The stringQuote() function backslash escapes '\' and '"' characters.

### Hardware

The writeHWClock() function sets the hardware clock to the system clock's date and time.

See also Qtopia Classes.

## Member Function Documentation

### void Global::addWords ( const QStringList & wordlist )`[static]`

Adds wordlist to the addedDawg(). Words that are already there are not added. Words that are in the 'deleted' dictionary are removed from there.

Note that the addition of words persists between program executions (they are saved in the dictionary files), so you should confirm the words with the user before adding them.

This is a slow operation. Call it once with a large list rather than multiple times with a small list.

### void Global::addWords ( const QString & dictname, const QStringList & wordlist )`[static]`

Adds wordlist to the dawg() named dictname.

Note that the addition of words persists between program executions (they are saved in the dictionary files), so you should confirm the words with the user before adding them.

This is a slow operation. Call it once with a large list rather than multiple times with a small list.

### const QDawg & Global::addedDawg ()`[static]`

Returns the changeable QDawg that contains general words for the current locale.

See also fixedDawg().

### QString Global::applicationFileName ( const QString & appname, const QString & filename )`[static]`

Returns the full path for the application called appname, with the given filename. Returns QString::null if there was a problem creating the directory tree for appname. If filename contains "/", it is the caller's responsibility to ensure that those directories exist.

### QString Global::architecture ()`[static]`

Returns the device architecture string. This is a sequence of identifiers separated by "/", from most general to most specific (eg. "IBM/PC").

First availability: Qtopia 1.6

### const QDawg & Global::dawg ( const QString & name )`[static]`

Returns the QDawg with the given name. This is an application-specific word list.

name should not contain "/". If name starts with "_", it is a read-only system word list.

### QByteArray Global::decodeBase64 ( const QByteArray & encoded )`[static]`

Decodes base64 encoded encoded and returns a QByteArray containing the decoded data.

First availability: Qtopia 1.6

### QString Global::defaultButtonsFile ()`[static]`

Return the name of the defaultbuttons.conf file. This allows Qtopia to use a QVFb-supplied defaultbuttons.conf file (if one exists).

First availability: Qtopia 2.1

### QString Global::deviceId ()`[static]`

Returns a unique ID for this device. The value can change, if for example, the device is reset.

First availability: Qtopia 1.6

### QByteArray Global::encodeBase64 ( const QByteArray & origData )`[static]`

Encodes origData using base64 mapping and returns a QString containing the encoded form.

First availability: Qtopia 1.6

### void Global::execute ( const QString & c, const QString & document = QString::null )`[static]`

Executes the application identfied by c, passing document if it isn't null.

Note that a better approach might be to send a QCop message to the application's QPE/Application/appname channel.

### void Global::findDocuments ( DocLnkSet * folder, const QString & mimefilter = QString::null )`[static]`

Finds all documents in the system's document directories which match the filter mimefilter, and appends the resulting DocLnk objects to folder.

### const QDawg & Global::fixedDawg ()`[static]`

Returns the unchangeable QDawg that contains general words for the current locale.

See also addedDawg().

### QUuid Global::generateUuid ()`[static]`

Returns a Uuid with system-wide uniqueness.

First availability: Qtopia 1.6

### bool Global::hasKey ( int key )`[static]`

Returns TRUE if key is available on the device. The buttons may be either fixed function buttons, such as Key_Menu, or user mappable buttons, such as Key_F1.

First availability: Qtopia 2.0

See also ContextBar and DeviceButtonManager.

### void Global::hideInputMethod ()`[static]`

Explicitly hide the current input method.

The current input method is still indicated in the taskbar, but no longer takes up screen space, and can no longer be interacted with.

See also showInputMethod().

### QString Global::homeDirPath ()`[static]`

Returns the name of the directory to be used as the current users home directory.

First availability: Qtopia 1.6

### bool Global::isAppLnkFileName ( const QString & file )`[static]`

Returns TRUE if file is the filename of an application.

First availability: Qtopia 1.6

### bool Global::isDocumentFileName ( const QString & file )`[static]`

Returns TRUE if file is the filename of a document.

First availability: Qtopia 1.6

### void Global::msleep ( unsigned long msecs )`[static]`

System independant sleep. Sleep for msecs milliseconds.

First availability: Qtopia 2.0

### QString Global::ownerName ()`[static]`

Returns the name of the owner of the device.

First availability: Qtopia 1.6

### QStringList Global::qtopiaPaths ()`[static]`

List of base directories containing Qtopia files. This is like QPEApplication::qpeDir(), but allows multiple directories to be specified.

The value is set by the colon-seperated environment variable QPEDIRS. The default is just $QPEDIR.

First availability: Qtopia 2.1

### void Global::removeWords ( const QStringList & wordlist )`[static]`

Removes wordlist from the addedDawg(). If the words are in the fixed dictionary, they are added to the "deleted" dictionary.

This is a slow operation. Call it once with a large list rather than multiple times with a small list.

### void Global::removeWords ( const QString & dictname, const QStringList & wordlist )`[static]`

Removes wordlist from the dawg() named dictname.

This is a slow operation. Call it once with a large list rather than multiple times with a small list.

### bool Global::renameFile ( QString from, QString to )`[static]`

Renames the file from to to. Returns TRUE if the operation is successful.

First availability: Qtopia 1.6

### void Global::setWeekStartsMonday ( bool v )`[static]`

Sets the day the user regards their week starting on. If v is TRUE, then the week begins on Monday. If v is FALSE, then the week begins on Sunday.

First availability: Qtopia 1.6

### QString Global::shellQuote ( const QString & s )`[static]`

Returns the string s with the characters '\', '"', and '$' quoted by a preceeding '\', and enclosed by double-quotes (").

See also stringQuote().

### void Global::showInputMethod ()`[static]`

Explicitly show the current input method.

Input methods are indicated in the taskbar by a small icon. If the input method is activated (shown) then it takes up some proportion of the bottom of the screen, to allow the user to interact (input characters) with it.

See also hideInputMethod().

### void Global::sleep ( unsigned long secs )`[static]`

System independant sleep. Sleep for secs seconds.

First availability: Qtopia 2.0

### void Global::statusMessage ( const QString & message )`[static]`

Displays a status message to the user. This usually appears in the taskbar for a short amount of time, then disappears.

### QString Global::stringQuote ( const QString & s )`[static]`

Returns the string s with the characters '\' and '"' quoted by a preceeding '\'.

See also shellQuote().

### QString Global::tempName ( const QString & fname )`[static]`

Returns a filename suitable for use as a temporary file using fname as a base.

First availability: Qtopia 1.6

### void Global::usleep ( unsigned long usecs )`[static]`

System independant sleep. Sleep for usecs microseconds.

First availability: Qtopia 2.0

### QString Global::version ()`[static]`

Returns the Qtopia version string. This is of the form: major.minor.patchlevel (eg. "1.2.3"), possibly followed by a space and special information (eg. "1.2.3 beta4").

First availability: Qtopia 1.6

### bool Global::weekStartsOnMonday ()`[static]`

Returns TRUE if the user regards their week as starting on Monday. Returns FALSE if the user regards their week as starting on Sunday.

First availability: Qtopia 1.6

### void Global::writeHWClock ()`[static]`

Writes the system clock to the hardware clock.

This file is part of the Qtopia platform, copyright © 1995-2004 Trolltech, all rights reserved.