Kexi API Documentation (2.0 alpha)

KexiUtils Namespace Reference


Classes

class  IdentifierValidator
 Validates input for identifier name. More...
class  LongLongValidator
 A validator for longlong data type. More...
class  StyleProxy
 a QStyle proxy allowing to customizing the currently used style More...
class  WaitCursor
class  WaitCursorRemover
class  Validator
 A validator extending QValidator with offline-checking for value's validity. More...
class  MultiValidator
 A validator groupping multiple QValidators. More...

Functions

KEXIUTILS_EXPORT bool isIdentifier (const QString &s)
KEXIUTILS_EXPORT QString string2Identifier (const QString &s)
KEXIUTILS_EXPORT QString identifierExpectedMessage (const QString &valueName, const QVariant &v)
KEXIUTILS_EXPORT QString string2FileName (const QString &s)
bool hasParent (QObject *par, QObject *o)
template<class type>
type * findParent (QObject *o, const char *className)
template<class type>
type * findParentConst (const QObject *const o, const char *className)
 Const version of findParent().
template<class type>
type * findFirstChild (QObject *o, const char *className, const char *objName=0)
QDateTime stringToHackedQTime (const QString &s)
 QDateTime - a hack needed because QVariant(QTime) has broken isNull().
KEXIUTILS_EXPORT void setWaitCursor (bool noDelay=false)
KEXIUTILS_EXPORT void removeWaitCursor ()
KEXIUTILS_EXPORT QString fileDialogFilterString (const KMimeType::Ptr &mime, bool kdeFormat=true)
KEXIUTILS_EXPORT QString fileDialogFilterString (const QString &mimeString, bool kdeFormat=true)
KEXIUTILS_EXPORT QString fileDialogFilterStrings (const QStringList &mimeStrings, bool kdeFormat)
KEXIUTILS_EXPORT QColor blendedColors (const QColor &c1, const QColor &c2, int factor1=1, int factor2=1)
KEXIUTILS_EXPORT QColor contrastColor (const QColor &c)
KEXIUTILS_EXPORT QColor bleachedColor (const QColor &c, int factor)
KEXIUTILS_EXPORT QIconSet colorizeIconToTextColor (const QPixmap &icon, const QPalette &palette)
KEXIUTILS_EXPORT QPixmap emptyIcon (KIcon::Group iconGroup)
KEXIUTILS_EXPORT void serializeMap (const QMap< QString, QString > &map, const QByteArray &array)
KEXIUTILS_EXPORT void serializeMap (const QMap< QString, QString > &map, QString &string)
KEXIUTILS_EXPORT QMap< QString,
QString
deserializeMap (const QByteArray &array)
KEXIUTILS_EXPORT QMap< QString,
QString
deserializeMap (const QString &string)
KEXIUTILS_EXPORT QString stringToFileName (const QString &string)
KEXIUTILS_EXPORT void simpleCrypt (QString &string)
KEXIUTILS_EXPORT void simpleDecrypt (QString &string)
KEXIUTILS_EXPORT void drawPixmap (QPainter &p, int lineWidth, const QRect &rect, const QPixmap &pixmap, int alignment, bool scaledContents, bool keepAspectRatio)
 Draws pixmap on painter p using predefined parameters.
KEXIUTILS_EXPORT QString ptrToStringInternal (void *ptr, uint size)
KEXIUTILS_EXPORT void * stringToPtrInternal (const QString &str, uint size)
template<class type>
QString ptrToString (type *ptr)
template<class type>
type * stringToPtr (const QString &str)


Function Documentation

KEXIUTILS_EXPORT QColor KexiUtils::bleachedColor const QColor &  c,
int  factor
 

Returns:
a lighter color for a color c and a factor factor. For colors like Qt::red or Qt::green where hue and saturation are near to 255, hue is decreased so the result will be more bleached. For black color the result is dark gray rather than black.

KEXIUTILS_EXPORT QColor KexiUtils::blendedColors const QColor &  c1,
const QColor &  c2,
int  factor1 = 1,
int  factor2 = 1
 

Returns:
a color being a result of blending c1 with c2 with factor1 and factor1 factors: (c1*factor1+c2*factor2)/(factor1+factor2).

Referenced by KexiTableView::Appearance::Appearance(), KexiScrollView::KexiScrollView(), lighterGrayBackgroundColor(), KexiDBTextWidgetInterface::paint(), KexiRecordMarker::paintEvent(), and KexiTableViewHeader::paintSection().

KEXIUTILS_EXPORT QIconSet KexiUtils::colorizeIconToTextColor const QPixmap &  icon,
const QPalette &  palette
 

Returns:
icon set computed as a result of colorizing icon pixmap with "buttonText" color of palette palette. This function is useful for displaying monochromed icons on the list view or table view header, to avoid bloat, but still have the color compatible with accessibility settings.

Referenced by KexiTableDesignerView::KexiTableDesignerView().

KEXIUTILS_EXPORT QColor KexiUtils::contrastColor const QColor &  c  ) 
 

Returns:
a contrast color for a color c: If c is light color, darker color created using c.dark(200) is returned; otherwise lighter color created using c.light(200) is returned.

Referenced by KexiDBImageBox::paintEvent().

KEXIUTILS_EXPORT QMap<QString,QString> KexiUtils::deserializeMap const QString string  ) 
 

Returns:
a map deserialized from string. string need to contain data previously serialized using KexiUtils::serializeMap().

KEXIUTILS_EXPORT QMap<QString,QString> KexiUtils::deserializeMap const QByteArray &  array  ) 
 

Returns:
a map deserialized from a byte array array. array need to contain data previously serialized using KexiUtils::serializeMap().

KEXIUTILS_EXPORT void KexiUtils::drawPixmap QPainter &  p,
int  lineWidth,
const QRect &  rect,
const QPixmap &  pixmap,
int  alignment,
bool  scaledContents,
bool  keepAspectRatio
 

Draws pixmap on painter p using predefined parameters.

Used in KexiDBImageBox and KexiBlobTableEdit.

Referenced by KexiDBImageBox::paintEvent(), and KexiBlobTableEdit::setupContents().

KEXIUTILS_EXPORT QPixmap KexiUtils::emptyIcon KIcon::Group  iconGroup  ) 
 

Returns:
empty (fully transparent) pixmap that can be used as a place for icon of size iconGroup

Referenced by KActionsListViewBase::init().

KEXIUTILS_EXPORT QString KexiUtils::fileDialogFilterString const QString mimeString,
bool  kdeFormat = true
 

KEXIUTILS_EXPORT QString KexiUtils::fileDialogFilterString const KMimeType::Ptr &  mime,
bool  kdeFormat = true
 

Returns:
filter string in QFileDialog format for a mime type pointed by mime If kdeFormat is true, QFileDialog-compatible filter string is generated, eg. "Image files (*.png *.xpm *.jpg)", otherwise KFileDialog -compatible filter string is generated, eg. "*.png *.xpm *.jpg|Image files (*.png *.xpm *.jpg)". "\\n" is appended if kdeFormat is true, otherwise ";;" is appended.

Referenced by KexiUtils::fileDialogFilterString(), and KexiUtils::fileDialogFilterStrings().

KEXIUTILS_EXPORT QString KexiUtils::fileDialogFilterStrings const QStringList &  mimeStrings,
bool  kdeFormat
 

Like QString fileDialogFilterString(const KMimeType::Ptr& mime, bool kdeFormat = true) but returns a list of filter strings.

Referenced by KexiCSVImportDialog::KexiCSVImportDialog().

template<class type>
type* KexiUtils::findFirstChild QObject *  o,
const char *  className,
const char *  objName = 0
 

Returns:
first found child of o, that inherit className. If objName is 0 (the default), all object names match. Returned pointer type is casted.

Definition at line 75 of file kexiutils/utils.h.

template<class type>
type* KexiUtils::findParent QObject *  o,
const char *  className
[inline]
 

Returns:
parent object of o that inherits className or NULL if no such parent

Definition at line 46 of file kexiutils/utils.h.

template<class type>
type* KexiUtils::findParentConst const QObject *const   o,
const char *  className
[inline]
 

Const version of findParent().

Definition at line 57 of file kexiutils/utils.h.

bool KexiUtils::hasParent QObject *  par,
QObject *  o
[inline]
 

Returns:
true if o has parent par.

Definition at line 35 of file kexiutils/utils.h.

Referenced by KexiDialogBase::activate(), KexiViewBase::eventFilter(), KexiMainWindowImpl::eventFilter(), KexiDialogBase::eventFilter(), KexiFieldComboBox::focusOutEvent(), and KexiTableView::keyPressEvent().

KEXIUTILS_EXPORT QString KexiUtils::identifierExpectedMessage const QString valueName,
const QVariant &  v
 

Returns:
useful message "Value of "valueName" column must be an identifier. "v" is not a valid identifier.". It is also used by IdentifierValidator.

Referenced by KexiUtils::IdentifierValidator::internalCheck(), and KexiQueryDesignerGuiEditor::slotPropertyChanged().

KEXIUTILS_EXPORT bool KexiUtils::isIdentifier const QString s  ) 
 

Returns:
true if s is a valid identifier, ie. starts with a letter or '_' character and contains only letters, numbers and '_' character.

Referenced by KexiDB::Connection::alterTableName(), KexiUtils::IdentifierValidator::internalCheck(), KFormDesigner::WidgetPropertySet::isNameValid(), KexiProject::items(), KexiDB::Connection::objectIds(), KexiDB::Connection::objectNames(), KexiQueryDesignerGuiEditor::parseExpressionString(), KexiDB::Connection::setupField(), KexiDB::Connection::setupObjectSchemaData(), KexiQueryDesignerGuiEditor::slotBeforeCellChanged(), and KexiQueryDesignerGuiEditor::slotPropertyChanged().

template<class type>
QString KexiUtils::ptrToString type *  ptr  ) 
 

Returns:
a pointer ptr safely serialized to string

Definition at line 228 of file kexiutils/utils.h.

References ptrToStringInternal().

KEXIUTILS_EXPORT QString KexiUtils::ptrToStringInternal void *  ptr,
uint  size
 

Referenced by ptrToString().

KEXIUTILS_EXPORT void KexiUtils::removeWaitCursor  ) 
 

Remove "wait" cursor previously set with setWaitCursor(), even if it's not yet visible. Does nothing if the application has no GUI enabled. (see KApplication::guiEnabled())

Referenced by KexiTextMessageHandler::showMessage(), KexiGUIMessageHandler::showMessage(), KexiDialogBase::switchToViewMode(), and KexiUtils::WaitCursor::~WaitCursor().

KEXIUTILS_EXPORT void KexiUtils::serializeMap const QMap< QString, QString > &  map,
QString string
 

KEXIUTILS_EXPORT void KexiUtils::serializeMap const QMap< QString, QString > &  map,
const QByteArray &  array
 

Serializes map to array. KexiUtils::deserializeMap() can be used to deserialize this array back to map.

Referenced by KexiMainWindowImpl::showProjectMigrationWizard().

KEXIUTILS_EXPORT void KexiUtils::setWaitCursor bool  noDelay = false  ) 
 

Sets "wait" cursor with 1 second delay (or 0 seconds if noDelay is true). Does nothing if the application has no GUI enabled. (see KApplication::guiEnabled())

Referenced by KexiDialogBase::switchToViewMode(), and KexiUtils::WaitCursor::WaitCursor().

KEXIUTILS_EXPORT void KexiUtils::simpleCrypt QString string  ) 
 

Performs a simple string encryption using rot47-like algorithm. Each character's unicode value is increased by 47 + i (where i is index of the character). The resulting string still contains redable characters. Do not use this for data that can be accessed by attackers!

Referenced by KexiDBShortcutFile::saveProjectData().

KEXIUTILS_EXPORT void KexiUtils::simpleDecrypt QString string  ) 
 

Performs a simple string decryption using rot47-like algorithm, using opposite operations to KexiUtils::simpleCrypt().

Referenced by KexiDBShortcutFile::loadProjectData().

KEXIUTILS_EXPORT QString KexiUtils::string2FileName const QString s  ) 
 

Returns:
Valid filename based on s

Referenced by KexiNewProjectWizard::showPage().

KEXIUTILS_EXPORT QString KexiUtils::string2Identifier const QString s  ) 
 

Returns:
valid identifier based on s. Non-alphanumeric characters (or spaces) are replaced with '_'. If a number is at the beginning, '_' is added at start. Empty strings are not changed. Case remains unchanged.

Referenced by KexiCSVImportDialog::accept(), KexiProject::createPartItem(), KexiMigration::PqxxMigrate::drv_readTableSchema(), KexiMigration::MySQLMigrate::drv_readTableSchema(), KexiPart::Part::instanceName(), KexiMigration::KexiMigrate::performImport(), KexiIdentifierPropertyEdit::setValue(), KexiNameWidget::slotCaptionTxtChanged(), KexiTableDesignerView::slotRowUpdated(), KexiNewProjectWizard::slotServerDBCaptionTxtChanged(), and KexiUtils::IdentifierValidator::validate().

KEXIUTILS_EXPORT QString KexiUtils::stringToFileName const QString string  ) 
 

Returns:
a valid filename converted from string by:
  • replacing \, /, :, *, ?, ", <, >, |,
    \t characters with a space
  • simplifing whitespace by removing redundant space characters using QString::simplifyWhiteSpace() Do not pass full paths here, but only filename strings.

Referenced by KexiCSVExportWizard::KexiCSVExportWizard().

QDateTime KexiUtils::stringToHackedQTime const QString s  )  [inline]
 

QDateTime - a hack needed because QVariant(QTime) has broken isNull().

Definition at line 85 of file kexiutils/utils.h.

Referenced by KexiDB::SQLiteCursor::storeCurrentRow().

template<class type>
type* KexiUtils::stringToPtr const QString str  ) 
 

Returns:
a pointer of type type safely deserialized from str

Definition at line 235 of file kexiutils/utils.h.

References stringToPtrInternal().

KEXIUTILS_EXPORT void* KexiUtils::stringToPtrInternal const QString str,
uint  size
 

Referenced by stringToPtr().

KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:50:55 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003