kexi

utils.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2007 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef FORMEDITORUTILS_H
00022 #define FORMEDITORUTILS_H
00023 
00024 #include <qptrlist.h>
00025 #include <qtabbar.h>
00026 #include <qtabwidget.h>
00027 
00029 #define TabWidgetBase QTabWidget
00030 //#define USE_KTabWidget //todo: uncomment
00031 
00032 namespace KFormDesigner {
00033 
00034 class Form;
00035 
00039 template<class type>
00040 type* findParent(QObject* o, const char* className, QObject* &prevPrev)
00041 {
00042     if (!o || !className || className[0]=='\0')
00043         return 0;
00044     QObject *prev = o;
00045     while ( ((o=o->parent())) && !o->inherits(className) ) {
00046         prevPrev = prev;
00047         prev = o;
00048     }
00049     return static_cast<type*>(o);
00050 }
00051 
00053 class KFORMEDITOR_EXPORT TabWidget : public TabWidgetBase
00054 {
00055     Q_OBJECT
00056     public:
00057         TabWidget(QWidget *parent, const char *name) 
00058          : TabWidgetBase(parent, name) {}
00059         virtual ~TabWidget() {}
00060         int tabBarHeight() const { return tabBar()->height(); }
00061 };
00062 
00064 typedef QPtrList<QWidget> WidgetList;
00065 
00067 typedef QPtrListIterator<QWidget> WidgetListIterator;
00068 
00070 class HorWidgetList : public WidgetList
00071 {
00072     public:
00073         HorWidgetList(QWidget *topLevelWidget);
00074         virtual ~HorWidgetList();
00075     protected:
00076         virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2);
00077         QWidget *m_topLevelWidget;
00078 };
00079 
00081 class VerWidgetList : public WidgetList
00082 {
00083     public:
00084         VerWidgetList(QWidget *topLevelWidget);
00085         virtual ~VerWidgetList();
00086     protected:
00087         virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2);
00088         QWidget *m_topLevelWidget;
00089 };
00090 
00093 KFORMEDITOR_EXPORT void removeChildrenFromList(WidgetList &list);
00094 
00098 KFORMEDITOR_EXPORT void installRecursiveEventFilter(QObject *object, QObject *container);
00099 
00103 KFORMEDITOR_EXPORT void removeRecursiveEventFilter(QObject *object, QObject *container);
00104 
00105 KFORMEDITOR_EXPORT void setRecursiveCursor(QWidget *w, Form *form);
00106 
00108 KFORMEDITOR_EXPORT QSize getSizeFromChildren(QWidget *widget, const char *inheritClass="QWidget");
00109 
00110 }
00111 
00112 #endif
00113 
KDE Home | KDE Accessibility Home | Description of Access Keys