KShared Class Reference
from PyKDE4.kdecore import *
Detailed Description
Enumerations | |
CopyCatalogs | { DoCopyCatalogs, DontCopyCatalogs } |
Errors | { NoError, BadQuoting, FoundMeta } |
KSycocaFactoryId | { KST_KServiceFactory, KST_KServiceTypeFactory, KST_KServiceGroupFactory, KST_KImageIO, KST_KProtocolInfoFactory, KST_KMimeTypeFactory, KST_CTimeInfo } |
KSycocaType | { KST_KSycocaEntry, KST_KService, KST_KServiceType, KST_KMimeType, KST_KFolderMimeType, KST_KDEDesktopMimeType, KST_KServiceGroup, KST_KImageIOFormat, KST_KProtocolInfo, KST_KServiceSeparator, KST_KCustom } |
MessageType | { Error, Information, Warning, Sorry, Fatal } |
Option | { NoOptions, TildeExpand, AbortOnMeta } Typesafe wrapper: Options |
Methods | |
KComponentData | activeComponent (self) |
allowUrlAction (self, QString action, KUrl baseUrl, KUrl _destUrl) | |
bool | authorize (self, QString genericAction) |
bool | authorizeControlModule (self, QString menuId) |
QStringList | authorizeControlModules (self, QStringList menuIds) |
bool | authorizeKAction (self, QString action) |
bool | authorizeUrlAction (self, QString action, KUrl baseUrl, KUrl destUrl) |
QString | caption (self) |
QString | capwords (self, QString text) |
QStringList | capwords (self, QStringList list) |
KCharsets | charsets (self) |
KCharsets | charsets (self) |
clearCache (self) | |
KSharedConfigPtr | config (self) |
bool | configurationMode (self) |
QTcpSocket | connectToHost (self, QString protocol, QString host, int port, QObject parent=0) |
QTcpSocket | connectToHost (self, QUrl url, QObject parent=0) |
connectToHost (self, QTcpSocket socket, QString protocol, QString host, int port) | |
connectToHost (self, QTcpSocket socket, QUrl url) | |
QString | csqueeze (self, QString str, int maxlen=40) |
QUdpSocket | datagramSocket (self, QString protocol, QString host, QObject parent=0) |
deleteServiceTypeProfile (self, QString serviceType) | |
deref (self) | |
KStandardDirs | dirs (self) |
QString | expandMacros (self, QString str, QHash |
QString | expandMacros (self, QString str, QHash |
QString | expandMacros (self, QString str, QHash |
QString | expandMacros (self, QString str, QHash |
QString | expandMacrosShellQuote (self, QString str, QHash |
QString | expandMacrosShellQuote (self, QString str, QHash |
QString | expandMacrosShellQuote (self, QString str, QHash |
QString | expandMacrosShellQuote (self, QString str, QHash |
QString | from8Bit (self, QString str) |
bool | hasLocale (self) |
bool | hasMainComponent (self) |
bool | hasProfile (self, QString serviceType) |
QString | i18n (self, QString text) |
QString | i18n (self, QString text, ... a0) |
QString | i18nc (self, QString ctxt, QString text) |
QString | i18nc (self, QString ctxt, QString text, ... a0) |
QString | i18ncp (self, QString ctxt, QString sing, QString plur, ... a0) |
QString | i18np (self, QString sing, QString plur, ... a0) |
bool | isUtf8 (self, QString str) |
QString | joinArgs (self, QStringList args) |
QString | kAsciiToLower (self, QString str) |
QString | kAsciiToUpper (self, QString str) |
int | kasciistricmp (self, QString str1, QString str2) |
KLocalizedString | ki18n (self, QString msg) |
KLocalizedString | ki18nc (self, QString ctxt, QString msg) |
KLocalizedString | ki18ncp (self, QString ctxt, QString singular, QString plural) |
KLocalizedString | ki18np (self, QString singular, QString plural) |
QTcpServer | listen (self, QString protocol, QHostAddress address=QHostAddress.Any, int port=0, QObject parent=0) |
KLocale | locale (self) |
QString | lsqueeze (self, QString str, int maxlen=40) |
KComponentData | mainComponent (self) |
message (self, KMessage.MessageType messageType, QString text, QString caption=QString()) | |
int | naturalCompare (self, QString a, QString b, Qt.CaseSensitivity caseSensitivity=Qt.CaseSensitive) |
QString | obscure (self, QString str) |
QStringList | perlSplit (self, QString sep, QString s, int max=0) |
QStringList | perlSplit (self, QChar sep, QString s, int max=0) |
QStringList | perlSplit (self, QRegExp sep, QString s, int max=0) |
QNetworkProxy | proxyForConnection (self, QString protocol, QString host) |
QNetworkProxy | proxyForDatagram (self, QString protocol, QString host) |
QNetworkProxy | proxyForListening (self, QString protocol) |
long | qHash (self, QString key) |
long | qHash (self, KUrl kurl) |
long | qHash (self, KPluginInfo a0) |
QString | quoteArg (self, QString arg) |
int | random (self) |
QString | randomString (self, int length) |
ref (self) | |
QString | rsqueeze (self, QString str, int maxlen=40) |
setActiveComponent (self, KComponentData d) | |
setConfigurationMode (self) | |
setLocale (self, KLocale a0, KGlobal.CopyCatalogs copy=KGlobal.DoCopyCatalogs) | |
setMessageHandler (self, KMessageHandler handler) | |
QStringList | splitArgs (self, QString cmd, KShell.Options flags=KShell.NoOptions, KShell.Errors err=0) |
QString | staticQString (self, QString str) |
QString | staticQString (self, QString str) |
QTcpSocket | synchronousConnectToHost (self, QString protocol, QString host, int port, int msecs=30000, QObject parent=0) |
QTcpSocket | synchronousConnectToHost (self, QUrl url, int msecs=30000, QObject parent=0) |
synchronousConnectToHost (self, QTcpSocket socket, QString protocol, QString host, int port, int msecs=30000) | |
synchronousConnectToHost (self, QTcpSocket socket, QUrl url, int msecs=30000) | |
QString | tagUrls (self, QString text) |
QString | tildeExpand (self, QString path) |
QString | tr2i18n (self, QString message, QString comment=0) |
mode_t | umask (self) |
bool | urlcmp (self, QString _url1, QString _url2) |
bool | urlcmp (self, QString _url1, QString _url2, KUrl.EqualsOptions options) |
writeServiceTypeProfile (self, QString serviceType, KService.List services, KService.List disabledServices=KService.List()) |
Method Documentation
KComponentData activeComponent | ( | self ) |
The component currently active (useful in a multi-component application, such as a KParts application). Don't use this - it's mainly for KAboutDialog and KBugReport.
- Internal:
Allow a certain URL action. This can be useful if your application needs to ensure access to an application specific directory that may otherwise be subject to KIOSK restrictions.
- Parameters:
-
action The name of the action. baseUrl The url where the action originates from _destUrl The object of the action
bool authorize | ( | self, | ||
QString | genericAction | |||
) |
Returns whether a certain action is authorized
- Parameters:
-
genericAction The name of a generic action
- Returns:
- true if the action is authorized
bool authorizeControlModule | ( | self, | ||
QString | menuId | |||
) |
Returns whether access to a certain control module is authorized.
- Parameters:
-
menuId identifying the control module, e.g. kde-mouse.desktop
- Returns:
- true if access to the module is authorized, false otherwise.
QStringList authorizeControlModules | ( | self, | ||
QStringList | menuIds | |||
) |
Returns which control modules from a given list are authorized for access.
- Parameters:
-
menuIds list of menu-ids of control modules; an example of a menu-id is kde-mouse.desktop.
- Returns:
- Those control modules for which access has been authorized.
bool authorizeKAction | ( | self, | ||
QString | action | |||
) |
Returns whether a certain KAction is authorized.
- Parameters:
-
action The name of a KAction action. The name is prepended with "action/" before being passed to authorize()
- Returns:
- true if the KAction is authorized
Returns whether a certain URL related action is authorized.
- Parameters:
-
action The name of the action. Known actions are - list (may be listed (e.g. in file selection dialog)), - link (may be linked to), - open (may open) and - redirect (may be redirected to) baseUrl The url where the action originates from destUrl The object of the action
- Returns:
- true when the action is authorized, false otherwise.
QString caption | ( | self ) |
Returns a text for the window caption.
This may be set by "-caption", otherwise it will be equivalent to the name of the executable.
- Returns:
- the text for the window caption
Capitalizes each word in the string "hello there" becomes "Hello There" (string)
- Parameters:
-
text the text to capitalize
- Returns:
- the resulting string
QStringList capwords | ( | self, | ||
QStringList | list | |||
) |
Capitalizes each word in the list [hello, there] becomes [Hello, There] (list)
- Parameters:
-
list the list to capitalize
- Returns:
- the resulting list
KCharsets charsets | ( | self ) |
The global charset manager.
- Returns:
- the global charset manager
KCharsets charsets | ( | self ) |
clearCache | ( | self ) |
Clear all cached information @internal, for KServiceTypeFactory
KSharedConfigPtr config | ( | self ) |
Returns the general config object.
- Returns:
- the global configuration object.
bool configurationMode | ( | self ) |
- Internal:
QTcpSocket connectToHost | ( | self, | ||
QString | protocol, | |||
QString | host, | |||
int | port, | |||
QObject | parent=0 | |||
) |
Initiates a TCP/IP socket connection to remote node (host) @p host, using the protocol. Returns a QTcpSocket that is connecting (i.e., in a state before QAbstractSocket.Connected) in most cases, even if the target service doesn't exist or if a connection failure happens.
This function never returns 0. If the returned socket cannot connect, it will emit the QAbstractSocket.error() signal. Otherwise, the QAbstractSocket.connected() signal will be emitted eventually.
The protocol parameter must be a string representation of the protocol being attempted, like "http", "ftp" or "xmpp". It might be used to determine the proxy type -- for instance, the proxy for HTTP connections might be different from the proxy for other connections. Pass an empty QString if the connection is of no established protocol.
The port parameter can be used to specify the port number lookup if the service is not a well-known service.
- Parameters:
-
protocol the protocol this socket will use host the remote node (host) to connect to port the port number to connect to parent the parent object to be passed to the QTcpSocket constructor
@threadsafe
QTcpSocket connectToHost | ( | self, | ||
QUrl | url, | |||
QObject | parent=0 | |||
) |
connectToHost | ( | self, | ||
QTcpSocket | socket, | |||
QString | protocol, | |||
QString | host, | |||
int | port | |||
) |
connectToHost | ( | self, | ||
QTcpSocket | socket, | |||
QUrl | url | |||
) |
Substitute characters at the middle of a string by "...".
- Parameters:
-
str is the string to modify maxlen is the maximum length the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
- Returns:
- the modified string
QUdpSocket datagramSocket | ( | self, | ||
QString | protocol, | |||
QString | host, | |||
QObject | parent=0 | |||
) |
deleteServiceTypeProfile | ( | self, | ||
QString | serviceType | |||
) |
Delete the complete profile for a given servicetype, reverting to the default preference order (the one specified by InitialPreference in the .desktop files).
Do not use this for mimetypes.
- Parameters:
-
serviceType The name of the servicetype.
deref | ( | self ) |
Tells KGlobal that one operation such as those described in ref() just finished. This call makes the QApplication quit if the counter is back to 0.
KStandardDirs dirs | ( | self ) |
Returns the application standard dirs object.
- Returns:
- the global standard dir object
Perform safe macro expansion (substitution) on a string. The escape char must be quoted with itself to obtain its literal representation in the resulting string.
- Parameters:
-
str The string to expand map map with substitutions c escape char indicating start of macro, or QChar.null if none
- Returns:
- the string with all valid macros expanded
// Code example QHash<QChar,QString> map; map.insert('u', "/tmp/myfile.txt"); map.insert('n', "My File"); QString s = "%% Title: %u:%n"; s = KMacroExpander.expandMacros(s, map); // s is now "% Title: /tmp/myfile.txt:My File";
Perform safe macro expansion (substitution) on a string. The escape char must be quoted with itself to obtain its literal representation in the resulting string. Macro names can consist of chars in the range [A-Za-z0-9_]; use braces to delimit macros from following words starting with these chars, or to use other chars for macro names.
- Parameters:
-
str The string to expand map map with substitutions c escape char indicating start of macro, or QChar.null if none
- Returns:
- the string with all valid macros expanded
// Code example QHash<QString,QString> map; map.insert("url", "/tmp/myfile.txt"); map.insert("name", "My File"); QString s = "Title: %{url}-%name"; s = KMacroExpander.expandMacros(s, map); // s is now "Title: /tmp/myfile.txt-My File";
Same as above, except that the macros expand to string lists that are simply join(" ")ed together.
Perform safe macro expansion (substitution) on a string for use in shell commands. The escape char must be quoted with itself to obtain its literal representation in the resulting string.
- Parameters:
-
str The string to expand map map with substitutions c escape char indicating start of macro, or QChar.null if none
- Returns:
- the string with all valid macros expanded, or a null string if a shell syntax error was detected in the command
// Code example QHash<QChar,QString> map; map.insert('u', "/tmp/myfile.txt"); map.insert('n', "My File"); QString s = "kedit --caption %n %u"; s = KMacroExpander.expandMacrosShellQuote(s, map); // s is now "kedit --caption 'My File' '/tmp/myfile.txt'"; system(QFile.encodeName(s));
Perform safe macro expansion (substitution) on a string for use in shell commands. See KMacroExpanderBase.expandMacrosShellQuote() for the exact semantics. The escape char must be quoted with itself to obtain its literal representation in the resulting string. Macro names can consist of chars in the range [A-Za-z0-9_]; use braces to delimit macros from following words starting with these chars, or to use other chars for macro names.
- Parameters:
-
str The string to expand map map with substitutions c escape char indicating start of macro, or QChar.null if none
- Returns:
- the string with all valid macros expanded, or a null string if a shell syntax error was detected in the command
// Code example QHash<QString,QString> map; map.insert("url", "/tmp/myfile.txt"); map.insert("name", "My File"); QString s = "kedit --caption %name %{url}"; s = KMacroExpander.expandMacrosShellQuote(s, map); // s is now "kedit --caption 'My File' '/tmp/myfile.txt'"; system(QFile.encodeName(s));
Same as above, except that the macros expand to string lists. If the macro appears inside a quoted string, the list is simply join(" ")ed together; otherwise every element expands to a separate quoted string.
Construct QString from a c string, guessing whether it is UTF8- or Local8Bit-encoded.
- Parameters:
-
str the input string
- Returns:
- the (hopefully correctly guessed) QString representation of str
- See also:
- KEncodingDetector
bool hasLocale | ( | self ) |
- Internal:
- Returns whether KGlobal has a valid KLocale object
bool hasMainComponent | ( | self ) |
- Internal:
- Returns whether a main KComponentData is available.
bool hasProfile | ( | self, | ||
QString | serviceType | |||
) |
@internal, for KServiceTypeTrader
Returns a localized version of a string and a context.
- Parameters:
-
ctxt context of the string text string to be localized
- Returns:
- localized string
bool isUtf8 | ( | self, | ||
QString | str | |||
) |
Guess whether a string is UTF8 encoded.
- Parameters:
-
str the string to check
- Returns:
- true if UTF8. If false, the string is probably in Local8Bit.
QString joinArgs | ( | self, | ||
QStringList | args | |||
) |
Quotes and joins args together according to system shell rules.
If the output is fed back into splitArgs(), the AbortOnMeta flag needs to be used on Windows. On *NIX, no such requirement exists.
See quoteArg() for more info.
- Parameters:
-
args a list of strings to quote and join
- Returns:
- a command suitable for shell execution
Locale-independent function to convert ASCII strings to lower case ASCII strings. This means that it affects only the ASCII characters A-Z.
- Parameters:
-
str pointer to the string which should be converted to lower case
- Returns:
- pointer to the converted string (same as str)
Locale-independent function to convert ASCII strings to upper case ASCII strings. This means that it affects only the ASCII characters a-z.
- Parameters:
-
str pointer to the string which should be converted to upper case
- Returns:
- pointer to the converted string (same as str)
Locale-independent qstricmp. Use this for comparing ascii keywords in a case-insensitive way. qstricmp fails with e.g. the Turkish locale where 'I'.toLower() != 'i'
KLocalizedString ki18n | ( | self, | ||
QString | msg | |||
) |
KLocalizedString ki18nc | ( | self, | ||
QString | ctxt, | |||
QString | msg | |||
) |
Creates localized string from a given message, with added context. Context is only for disambiguation purposes (both for lookup and for translators), it is not part of the message. Normaly you should use i18nc() templates instead, as you need real KLocalizedString object only in special cases. All text arguments must be UTF-8 encoded and must not be empty or NULL.
- Parameters:
-
ctxt context text msg message text
- Returns:
- created KLocalizedString
KLocalizedString ki18ncp | ( | self, | ||
QString | ctxt, | |||
QString | singular, | |||
QString | plural | |||
) |
Creates localized string from a given plural and singular form, with added context. Context is only for disambiguation purposes (both for lookup and for translators), it is not part of the message. Normaly you should use i18ncp() templates instead, as you need real KLocalizedString object only in special cases. All text arguments must be UTF-8 encoded and must not be empty or NULL.
- Parameters:
-
ctxt context text singular message text in singular plural message text in plural
- Returns:
- created KLocalizedString
KLocalizedString ki18np | ( | self, | ||
QString | singular, | |||
QString | plural | |||
) |
Creates localized string from a given plural and singular form. Normaly you should use i18np() templates instead, as you need real KLocalizedString object only in special cases. All text arguments must be UTF-8 encoded and must not be empty or NULL.
- Parameters:
-
singular message text in singular plural message text in plural
- Returns:
- created KLocalizedString
QTcpServer listen | ( | self, | ||
QString | protocol, | |||
QHostAddress | address=QHostAddress.Any, | |||
int | port=0, | |||
QObject | parent=0 | |||
) |
Opens a TCP/IP socket for listening protocol protocol, binding only at address address. The port parameter indicates the port to be opened.
This function does not return 0. If the opening of the socket failed for some reason, it will return a QTcpServer object that is not listening (QTcpServer.isListening() returns false), with a properly set error string indicating the reason).
Note that passing 0 as the default port number will cause the operating system to automatically allocate a free port for the socket.
- Parameters:
-
protocol the protocol this socket will accept address the address to listen at port the default port for the service parent the parent object to be passed to the QTcpServer constructor
KLocale locale | ( | self ) |
Returns the global locale object.
- Returns:
- the global locale object
Substitute characters at the beginning of a string by "...".
- Parameters:
-
str is the string to modify maxlen is the maximum length the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
- Returns:
- the modified string
KComponentData mainComponent | ( | self ) |
Returns the global component data. There is always at least one instance of a component in one application (in most cases the application itself).
- Returns:
- the global component data
Display a long message of a certain type. A long message span on multiple lines and can have a caption.
- Parameters:
-
messageType Currrent type of message. See MessageType enum. text Long message to be displayed. caption Caption to be used. This is optional.
int naturalCompare | ( | self, | ||
QString | a, | |||
QString | b, | |||
Qt.CaseSensitivity | caseSensitivity=Qt.CaseSensitive | |||
) |
Does a natural comparing of the strings. A negative value is returned if a is smaller than b. A positive value is returned if a is greater than b. 0 is returned if both values are equal.
- Parameters:
-
a first string to compare b second string to compare caseSensitivity whether to use case sensitive compare or not
- Since:
- 4.1
Obscure string by using a simple symmetric encryption. Applying the function to a string obscured by this function will result in the original string.
The function can be used to obscure passwords stored to configuration files. Note that this won't give you any more security than preventing that the password is directly copied and pasted.
- Parameters:
-
str string to be obscured
- Returns:
- obscured string
QStringList perlSplit | ( | self, | ||
QString | sep, | |||
QString | s, | |||
int | max=0 | |||
) |
Split a QString into a QStringList in a similar fashion to the static QStringList function in Qt, except you can specify a maximum number of tokens. If max is specified (!= 0) then only that number of tokens will be extracted. The final token will be the remainder of the string.
Example:
perlSplit("__", "some__string__for__you__here", 4) QStringList contains: "some", "string", "for", "you__here"
- Parameters:
-
sep is the string to use to delimit s. s is the input string max is the maximum number of extractions to perform, or 0.
- Returns:
- A QStringList containing tokens extracted from s.
QStringList perlSplit | ( | self, | ||
QChar | sep, | |||
QString | s, | |||
int | max=0 | |||
) |
Split a QString into a QStringList in a similar fashion to the static QStringList function in Qt, except you can specify a maximum number of tokens. If max is specified (!= 0) then only that number of tokens will be extracted. The final token will be the remainder of the string.
Example:
perlSplit(' ', "kparts reaches the parts other parts can't", 3) QStringList contains: "kparts", "reaches", "the parts other parts can't"
- Parameters:
-
sep is the character to use to delimit s. s is the input string max is the maximum number of extractions to perform, or 0.
- Returns:
- A QStringList containing tokens extracted from s.
QStringList perlSplit | ( | self, | ||
QRegExp | sep, | |||
QString | s, | |||
int | max=0 | |||
) |
Split a QString into a QStringList in a similar fashion to the static QStringList function in Qt, except you can specify a maximum number of tokens. If max is specified (!= 0) then only that number of tokens will be extracted. The final token will be the remainder of the string.
Example:
perlSplit(QRegExp("[! ]"), "Split me up ! I'm bored ! OK ?", 3) QStringList contains: "Split", "me", "up ! I'm bored ! OK ?"
- Parameters:
-
sep is the regular expression to use to delimit s. s is the input string max is the maximum number of extractions to perform, or 0.
- Returns:
- A QStringList containing tokens extracted from s.
QNetworkProxy proxyForConnection | ( | self, | ||
QString | protocol, | |||
QString | host | |||
) |
QNetworkProxy proxyForDatagram | ( | self, | ||
QString | protocol, | |||
QString | host | |||
) |
QNetworkProxy proxyForListening | ( | self, | ||
QString | protocol | |||
) |
long qHash | ( | self, | ||
QString | key | |||
) |
long qHash | ( | self, | ||
KUrl | kurl | |||
) |
long qHash | ( | self, | ||
KPluginInfo | a0 | |||
) |
Quotes arg according to system shell rules.
This function can be used to quote an argument string such that the shell processes it properly. This is e.g. necessary for user-provided file names which may contain spaces or quotes. It also prevents expansion of wild cards and environment variables.
On *NIX, the output is POSIX shell compliant. On Windows, it is compliant with the argument splitting code of the Microsoft C runtime and the cmd shell used together. Occurrences of the percent sign are replaced with \%PERCENT_SIGN% to prevent spurious variable expansion; related KDE functions are prepared for this.
- Parameters:
-
arg the argument to quote
- Returns:
- the quoted argument
int random | ( | self ) |
Generates a uniform random number.
- Returns:
- A random number in the range [0, RAND_MAX). The RNG is seeded on first use.
QString randomString | ( | self, | ||
int | length | |||
) |
Generates a random string. It operates in the range [A-Za-z0-9]
- Parameters:
-
length Generate a string of this length.
- Returns:
- the random string
ref | ( | self ) |
Tells KGlobal about one more operations that should be finished before the application exits. The standard behavior is to exit on the "last window closed" event, but some events should outlive the last window closed (e.g. a file copy for a file manager, or 'compacting folders on exit' for a mail client).
Note that for this to happen you must call qApp->setQuitOnLastWindowClosed(false), in main() for instance.
Substitute characters at the end of a string by "...".
- Parameters:
-
str is the string to modify maxlen is the maximum length the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
- Returns:
- the modified string
setActiveComponent | ( | self, | ||
KComponentData | d | |||
) |
Set the active component for use by KAboutDialog and KBugReport. To be used only by a multi-component (KParts) application.
- See also:
- activeComponent()
setConfigurationMode | ( | self ) |
This method activates a special mode of KServiceTypeProfile, in which all/all and all/allfiles are excluded from the results of the queries. It is meant for the configuration module _only_.
- Internal:
setLocale | ( | self, | ||
KLocale | a0, | |||
KGlobal.CopyCatalogs | copy=KGlobal.DoCopyCatalogs | |||
) |
- Internal:
setMessageHandler | ( | self, | ||
KMessageHandler | handler | |||
) |
Set the current KMessageHandler Note that this method take ownership of the KMessageHandler.
- Parameters:
-
handler Instance of a real KMessageHandler.
- Warning:
- This function isn't thread-safe. You don't want to change the message handler during the program's execution anyways. Do so only at start-up.
QStringList splitArgs | ( | self, | ||
QString | cmd, | |||
KShell.Options | flags=KShell.NoOptions, | |||
KShell.Errors | err=0 | |||
) |
Splits cmd according to system shell word splitting and quoting rules. Can optionally perform tilde expansion and/or abort if it finds shell meta characters it cannot process.
On *NIX the behavior is based on the POSIX shell and bash: - Whitespace splits tokens - The backslash quotes the following character - A string enclosed in single quotes is not split. No shell meta characters are interpreted. - A string enclosed in double quotes is not split. Within the string, the backslash quotes shell meta characters - if it is followed by a "meaningless" character, the backslash is output verbatim. - A string enclosed in $'' is not split. Within the string, the backslash has a similar meaning to the one in C strings. Consult the bash manual for more information.
On Windows, the behavior is defined by the Microsoft C runtime. Qt and many other implementations comply with this standard, but many do not. - Whitespace splits tokens - A string enclosed in double quotes is not split - 2N double quotes within a quoted string yield N literal quotes. This is not documented on MSDN. - Backslashes have special semantics iff they are followed by a double quote: - 2N backslashes + double quote => N backslashes and begin/end quoting - 2N+1 backslashes + double quote => N backslashes + literal quote
If AbortOnMeta is used on Windows, this function applies cmd shell semantics before proceeding with word splitting: - Cmd ignores all special chars between double quotes. Note that the quotes are not removed at this stage - the tokenization rules described above still apply. - The circumflex is the escape char for everything including itself.
- Parameters:
-
cmd the command to split flags operation flags, see Option err if not NULL, a status code will be stored at the pointer target, see Errors
- Returns:
- a list of unquoted words or an empty list if an error occurred
Creates a static QString.
To be used inside functions(!) like:
static const QString &myString = KGlobal.staticQString("myText");
Do NOT use code such as:
static QString myString = KGlobal.staticQString("myText");This creates a static object (instead of a static reference) and as you know static objects are EVIL.
- Parameters:
-
str the string to create
- Returns:
- the static string
Creates a static QString.
To be used inside functions(!) like:
static const QString &myString = KGlobal.staticQString(i18n("My Text"));
Do NOT use code such as:
static QString myString = KGlobal.staticQString(i18n("myText"));This creates a static object (instead of a static reference) and as you know static objects are EVIL.
- Parameters:
-
str the string to create
- Returns:
- the static string
QTcpSocket synchronousConnectToHost | ( | self, | ||
QString | protocol, | |||
QString | host, | |||
int | port, | |||
int | msecs=30000, | |||
QObject | parent=0 | |||
) |
This function behaves exactly like connectToHost() above, except that the socket it returns is either in QAbstractSocket.Connected state, or it has failed connecting altogether.
This function should be used if a synchronous connection is necessary instead of calling QAbstractSocket.waitForConnected(), since that may not work on all objects returned from connectToHost().
This function does not return 0. If the connection attempt failed for some reason, the socket state will be QAbstractSocket.UnconnectedState and QAbstractSocket.isValid will return false. The socket error state and string will contain more information. @warning: This function may block.
- Parameters:
-
protocol the protocol this socket will use host the remote node (host) to connect to port the port number to connect to msecs the time (in milliseconds) to wait while attempting to connect parent the parent object to be passed to the QTcpSocket constructor
@threadsafe
QTcpSocket synchronousConnectToHost | ( | self, | ||
QUrl | url, | |||
int | msecs=30000, | |||
QObject | parent=0 | |||
) |
synchronousConnectToHost | ( | self, | ||
QTcpSocket | socket, | |||
QString | protocol, | |||
QString | host, | |||
int | port, | |||
int | msecs=30000 | |||
) |
synchronousConnectToHost | ( | self, | ||
QTcpSocket | socket, | |||
QUrl | url, | |||
int | msecs=30000 | |||
) |
This method auto-detects URLs in strings, and adds HTML markup to them so that richtext or HTML-enabled widgets will display the URL correctly.
- Parameters:
-
text the string which may contain URLs
- Returns:
- the resulting text
Performs tilde expansion on path. Interprets "~/path" and "~user/path". If the path starts with an escaped tilde ("\~" on UNIX, "^~" on Windows), the escape char is removed and the path is returned as is.
- Parameters:
-
path the path to tilde-expand
- Returns:
- the expanded path
Qt's uic generated translation calls go through numerous indirections unnecessary in our case. So we use uic -tr tr2i18n to redirect them to our i18n API.
mode_t umask | ( | self ) |
Returns the umask of the process.
- Returns:
- the umask of the process
\relates KUrl Compares URLs. They are parsed, split and compared. Two malformed URLs with the same string representation are nevertheless considered to be unequal. That means no malformed URL equals anything else.
\relates KUrl Compares URLs. They are parsed, split and compared. Two malformed URLs with the same string representation are nevertheless considered to be unequal. That means no malformed URL equals anything else.
- Parameters:
-
_url1 A reference URL _url2 A URL that will be compared with the reference URL options a set of KUrl.EqualsOption flags
writeServiceTypeProfile | ( | self, | ||
QString | serviceType, | |||
KService.List | services, | |||
KService.List | disabledServices=KService.List() | |||
) |
Write the complete profile for a given servicetype. Do not use this for mimetypes.
- Parameters:
-
serviceType The name of the servicetype. services Ordered list of services, from the preferred one to the least preferred one. disabledServices List of services which are normally associated with this serviceType, but which should be disabled, i.e. trader queries will not return them.
Enumeration Documentation
CopyCatalogs |
For setLocale
- Enumerator:
-
DoCopyCatalogs DontCopyCatalogs
Errors |
Success.
- Enumerator:
-
NoError = 0 BadQuoting FoundMeta
KSycocaFactoryId |
\relates KSycocaFactory A KSycocaFactoryId is a code (out of the KSycocaFactoryId enum) assigned to each class type derived from KSycocaFactory. To use it, call the macro K_SYCOCAFACTORY( your_factory_id ) at the top of your class definition.
- Enumerator:
-
KST_KServiceFactory = 1 KST_KServiceTypeFactory = 2 KST_KServiceGroupFactory = 3 KST_KImageIO = 4 KST_KProtocolInfoFactory = 5 KST_KMimeTypeFactory = 6 KST_CTimeInfo = 100
KSycocaType |
\relates KSycocaEntry A KSycocaType is a code (out of the KSycocaType enum) assigned to each class type derived from KSycocaEntry . To use it, call the macro K_SYCOCATYPE( your_typecode, parent_class ) at the top of your class definition.
- Enumerator:
-
KST_KSycocaEntry = 0 KST_KService = 1 KST_KServiceType = 2 KST_KMimeType = 3 KST_KFolderMimeType = 4 KST_KDEDesktopMimeType = 5 KST_KServiceGroup = 7 KST_KImageIOFormat = 8 KST_KProtocolInfo = 9 KST_KServiceSeparator = 10 KST_KCustom = 1000
MessageType |
Error message. Display critical information that affect the behavior of the application.
- Enumerator:
-
Error Error message. Display critical information that affect the behavior of the application. < p>
Information Warning Sorry Fatal
Option |
Flags for splitArgs().
- Note:
- It is necessary to wrap members of this enumeration in a
Options
instance when passing them to a method as group of flags. For example:Options( NoOptions | TildeExpand)
- Enumerator:
-
NoOptions = 0 TildeExpand = 1 AbortOnMeta = 2