kalarm/lib
packedlayout.h
Go to the documentation of this file.00001 /* 00002 * packedlayout.h - layout to pack items into rows 00003 * Program: kalarm 00004 * Copyright © 2007 by David Jarvie <djarvie@kde.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 #ifndef PACKEDLAYOUT_H 00021 #define PACKEDLAYOUT_H 00022 00023 #include <QLayout> 00024 #include <QList> 00025 00026 00033 class PackedLayout : public QLayout 00034 { 00035 public: 00040 PackedLayout(QWidget* parent, Qt::Alignment alignment); 00041 explicit PackedLayout(Qt::Alignment alignment); 00042 ~PackedLayout(); 00043 // Override QLayout methods 00044 virtual bool hasHeightForWidth() const { return true; } 00045 virtual int heightForWidth(int w) const; 00046 virtual int count() const { return mItems.count(); } 00047 virtual void addItem(QLayoutItem* item); 00048 virtual QLayoutItem* itemAt(int index) const; 00049 virtual QLayoutItem* takeAt(int index); 00050 virtual void setGeometry(const QRect& r); 00051 virtual QSize sizeHint() const { return minimumSize(); } 00052 virtual QSize minimumSize() const; 00053 virtual Qt::Orientations expandingDirections() const { return Qt::Vertical | Qt::Horizontal; } 00054 virtual void invalidate() { mWidthCached = mHeightCached = false; } 00055 00056 private: 00057 int arrange(const QRect&, bool set) const; 00058 QList<QLayoutItem*> mItems; 00059 Qt::Alignment mAlignment; 00060 mutable int mWidthCached; 00061 mutable int mHeightCached; 00062 }; 00063 00064 #endif // PACKEDLAYOUT_H
KDE 4.2 API Reference