formeditor/utils.h
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef FORMEDITORUTILS_H 00021 #define FORMEDITORUTILS_H 00022 00023 #include <qptrlist.h> 00024 #include <qwidget.h> 00025 00026 namespace KFormDesigner { 00027 00028 class Form; 00029 00031 typedef QPtrList<QWidget> WidgetList; 00032 00034 typedef QPtrListIterator<QWidget> WidgetListIterator; 00035 00037 class HorWidgetList : public WidgetList 00038 { 00039 public: 00040 HorWidgetList() {;} 00041 virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2) 00042 { 00043 QWidget *w1 = static_cast<QWidget*>(item1); 00044 QWidget *w2 = static_cast<QWidget*>(item2); 00045 00046 if(w1->x() < w2->x()) 00047 return -1; 00048 if(w1->x() > w2->x()) 00049 return 1; 00050 return 0; // item1 == item2 00051 } 00052 }; 00053 00055 class VerWidgetList : public WidgetList 00056 { 00057 public: 00058 VerWidgetList() {;} 00059 virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2) 00060 { 00061 QWidget *w1 = static_cast<QWidget*>(item1); 00062 QWidget *w2 = static_cast<QWidget*>(item2); 00063 00064 if(w1->y() < w2->y()) 00065 return -10; 00066 if(w1->y() > w2->y()) 00067 return 1; 00068 return 0; // item1 == item2 00069 } 00070 }; 00071 00074 KFORMEDITOR_EXPORT void removeChildrenFromList(WidgetList &list); 00075 00079 KFORMEDITOR_EXPORT void installRecursiveEventFilter(QObject *object, QObject *container); 00080 00084 KFORMEDITOR_EXPORT void removeRecursiveEventFilter(QObject *object, QObject *container); 00085 00086 KFORMEDITOR_EXPORT void setRecursiveCursor(QWidget *w, Form *form); 00087 00089 KFORMEDITOR_EXPORT QSize getSizeFromChildren(QWidget *widget, const char *inheritClass="QWidget"); 00090 00091 } 00092 00093 #endif 00094
