File indexing completed on 2024-05-12 16:39:54

0001 /* This file is part of the KDE project
0002    Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
0003    Copyright (C) 2007-2012 Jarosław Staniek <staniek@kde.org>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This library is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this library; see the file COPYING.LIB.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef KEXIFLOWLAYOUT_H
0022 #define KEXIFLOWLAYOUT_H
0023 
0024 #include <QLayout>
0025 #include <QList>
0026 #include "kexiutils_export.h"
0027 
0028 //! @short a special "flow" layout
0029 //! @todo Vertical KexiFlowLayout ported to Qt4 but not tested.
0030 class KEXIUTILS_EXPORT KexiFlowLayout : public QLayout
0031 {
0032     Q_OBJECT
0033 public:
0034     explicit KexiFlowLayout(QWidget *parent, int margin = 0, int spacing = -1);
0035     explicit KexiFlowLayout(QLayout* parent, int margin = 0, int spacing = -1);
0036     explicit KexiFlowLayout(int margin = 0, int spacing = -1);
0037 
0038     virtual ~KexiFlowLayout();
0039 
0040     /*! \return the widgets in the order of the layout,
0041      ie as it is stored in m_list. You must delete the list after using it. */
0042     QList<QWidget*>* widgetList() const;
0043 
0044     /*! Sets layout's orientation to \a orientation. Default orientation is Vertical. */
0045     void  setOrientation(Qt::Orientation orientation);
0046 
0047 
0048     /*! \return layout's orientation. */
0049     Qt::Orientation orientation() const;
0050 
0051     void setJustified(bool justify);
0052     bool isJustified() const;
0053 
0054     virtual void addItem(QLayoutItem *item) override;
0055     virtual void addSpacing(int size);
0056     void insertWidget(int index, QWidget* widget, int stretch = 0, Qt::Alignment alignment = 0);
0057     virtual void invalidate() override;
0058 
0059     virtual bool hasHeightForWidth() const override;
0060     virtual int heightForWidth(int width) const override;
0061     virtual QSize sizeHint() const override;
0062     virtual QSize minimumSize() const override;
0063     virtual Qt::Orientations expandingDirections() const override;
0064     virtual int count() const override;
0065     virtual bool isEmpty() const override;
0066     virtual void setGeometry(const QRect&) override;
0067     virtual QLayoutItem *itemAt(int index) const override;
0068     virtual QLayoutItem *takeAt(int index) override;
0069 
0070 protected:
0071     int simulateLayout(const QRect &r);
0072     int doHorizontalLayout(const QRect&, bool testonly = false);
0073     int doVerticalLayout(const QRect&, bool testonly = false);
0074 
0075 private:
0076     class Private;
0077 
0078     Private* const d;
0079 };
0080 
0081 #endif