summaryrefslogtreecommitdiffstats
path: root/kexi/formeditor/utils.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/formeditor/utils.h
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/formeditor/utils.h')
-rw-r--r--kexi/formeditor/utils.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/kexi/formeditor/utils.h b/kexi/formeditor/utils.h
new file mode 100644
index 00000000..d5384e45
--- /dev/null
+++ b/kexi/formeditor/utils.h
@@ -0,0 +1,113 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2007 Jaroslaw Staniek <js@iidea.pl>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef FORMEDITORUTILS_H
+#define FORMEDITORUTILS_H
+
+#include <qptrlist.h>
+#include <qtabbar.h>
+#include <qtabwidget.h>
+
+//! @todo replace QTabWidget by KTabWidget after the bug with & is fixed:
+#define TabWidgetBase QTabWidget
+//#define USE_KTabWidget //todo: uncomment
+
+namespace KFormDesigner {
+
+class Form;
+
+/*! \return parent object of \a o that inherits \a className or NULL if no such parent
+ If the parent is found, \a prevPrev is set to a child of child of the parent,
+ what for TabWidget means the page widget. */
+template<class type>
+type* findParent(QObject* o, const char* className, QObject* &prevPrev)
+{
+ if (!o || !className || className[0]=='\0')
+ return 0;
+ QObject *prev = o;
+ while ( ((o=o->parent())) && !o->inherits(className) ) {
+ prevPrev = prev;
+ prev = o;
+ }
+ return static_cast<type*>(o);
+}
+
+//! A tab widget providing information about height of the tab bar.
+class KFORMEDITOR_EXPORT TabWidget : public TabWidgetBase
+{
+ Q_OBJECT
+ public:
+ TabWidget(QWidget *parent, const char *name)
+ : TabWidgetBase(parent, name) {}
+ virtual ~TabWidget() {}
+ int tabBarHeight() const { return tabBar()->height(); }
+};
+
+//! @short A list of widget pointers.
+typedef QPtrList<QWidget> WidgetList;
+
+//! @short An iterator for WidgetList.
+typedef QPtrListIterator<QWidget> WidgetListIterator;
+
+//! @short A helper for sorting widgets horizontally
+class HorWidgetList : public WidgetList
+{
+ public:
+ HorWidgetList(QWidget *topLevelWidget);
+ virtual ~HorWidgetList();
+ protected:
+ virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2);
+ QWidget *m_topLevelWidget;
+};
+
+//! @short A helper for sorting widgets vertically
+class VerWidgetList : public WidgetList
+{
+ public:
+ VerWidgetList(QWidget *topLevelWidget);
+ virtual ~VerWidgetList();
+ protected:
+ virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2);
+ QWidget *m_topLevelWidget;
+};
+
+/*! This function is used to remove all the child widgets from a list, and
+ keep only the "toplevel" ones. */
+KFORMEDITOR_EXPORT void removeChildrenFromList(WidgetList &list);
+
+/*! This helper function install an event filter on \a object and all of its
+ children, directed to \a container.
+ This is necessary to filter events for composed widgets. */
+KFORMEDITOR_EXPORT void installRecursiveEventFilter(QObject *object, QObject *container);
+
+/*! This helper function removes an event filter installed before
+ on \a object and all of its children.
+ This is necessary to filter events for composed widgets. */
+KFORMEDITOR_EXPORT void removeRecursiveEventFilter(QObject *object, QObject *container);
+
+KFORMEDITOR_EXPORT void setRecursiveCursor(QWidget *w, Form *form);
+
+/*! \return the size of \a w children. This can be used eg to get widget's sizeHint. */
+KFORMEDITOR_EXPORT QSize getSizeFromChildren(QWidget *widget, const char *inheritClass="QWidget");
+
+}
+
+#endif
+