kexi
utils.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KEXIUTILS_UTILS_H
00021 #define KEXIUTILS_UTILS_H
00022
00023 #include "kexiutils_export.h"
00024
00025 #include <qguardedptr.h>
00026 #include <qobjectlist.h>
00027 #include <kmimetype.h>
00028 class QColor;
00029
00030
00031
00032 namespace KexiUtils
00033 {
00035 inline bool hasParent(QObject* par, QObject* o)
00036 {
00037 if (!o || !par)
00038 return false;
00039 while (o && o!=par)
00040 o = o->parent();
00041 return o==par;
00042 }
00043
00045 template<class type>
00046 inline type* findParent(QObject* o, const char* className)
00047 {
00048 if (!o || !className || className[0]=='\0')
00049 return 0;
00050 while ( ((o=o->parent())) && !o->inherits(className) )
00051 ;
00052 return static_cast<type*>(o);
00053 }
00054
00057 template<class type>
00058 type* findFirstChild(QObject *o, const char* className)
00059 {
00060 if (!o || !className || className[0]=='\0')
00061 return 0;
00062 QObjectList *l = o->queryList( className );
00063 QObjectListIt it( *l );
00064 return static_cast<type*>(it.current());
00065 }
00066
00068 inline QDateTime stringToHackedQTime(const QString& s)
00069 {
00070 if (s.isEmpty())
00071 return QDateTime();
00072
00073 return QDateTime( QDate(0,1,2), QTime::fromString( s, Qt::ISODate ) );
00074 }
00075
00078 KEXIUTILS_EXPORT void setWaitCursor(bool noDelay = false);
00079
00083 KEXIUTILS_EXPORT void removeWaitCursor();
00084
00092 class KEXIUTILS_EXPORT WaitCursor
00093 {
00094 public:
00095 WaitCursor(bool noDelay = false);
00096 ~WaitCursor();
00097 };
00098
00104 KEXIUTILS_EXPORT QString fileDialogFilterString(const KMimeType::Ptr& mime, bool kdeFormat = true);
00105
00107 KEXIUTILS_EXPORT QString fileDialogFilterString(const QString& mimeString, bool kdeFormat = true);
00108
00111 KEXIUTILS_EXPORT QString fileDialogFilterStrings(const QStringList& mimeStrings, bool kdeFormat);
00112
00115 KEXIUTILS_EXPORT QColor blendedColors(const QColor& c1, const QColor& c2, int factor1 = 1, int factor2 = 1);
00116
00120 KEXIUTILS_EXPORT QColor contrastColor(const QColor& c);
00121
00126 KEXIUTILS_EXPORT QColor bleachedColor(const QColor& c, int factor);
00127
00130 KEXIUTILS_EXPORT void serializeMap(const QMap<QString,QString>& map, QByteArray& array);
00131 KEXIUTILS_EXPORT void serializeMap(const QMap<QString,QString>& map, QString& string);
00132
00135 KEXIUTILS_EXPORT QMap<QString,QString> deserializeMap(const QByteArray& array);
00136
00139 KEXIUTILS_EXPORT QMap<QString,QString> deserializeMap(const QString& string);
00140
00145 KEXIUTILS_EXPORT QString stringToFileName(const QString& string);
00146
00151 KEXIUTILS_EXPORT void simpleCrypt(QString& string);
00152
00155 KEXIUTILS_EXPORT void simpleDecrypt(QString& string);
00156 }
00157
00158
00162 #define GLUE_WIDGET(what, where) \
00163 { QVBoxLayout *lyr = new QVBoxLayout(where); \
00164 lyr->addWidget(what); }
00165
00166
00167 #endif //KEXIUTILS_UTILS_H
|