itom 2.2.1
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom and its software development toolkit (SDK). 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 In addition, as a special exception, the Institut fuer Technische 00015 Optik (ITO) gives you certain additional rights. 00016 These rights are described in the ITO LGPL Exception version 1.0, 00017 which can be found in the file LGPL_EXCEPTION.txt in this package. 00018 00019 itom is distributed in the hope that it will be useful, but 00020 WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00022 General Public Licence for more details. 00023 00024 You should have received a copy of the GNU Library General Public License 00025 along with itom. If not, see <http://www.gnu.org/licenses/>. 00026 00027 This file is a port and modified version of the 00028 Common framework (http://www.commontk.org) 00029 *********************************************************************** */ 00030 00031 #ifndef __CollapsibleGroupBox_h 00032 #define __CollapsibleGroupBox_h 00033 00034 // Qt includes 00035 #include <QGroupBox> 00036 00037 #include "commonWidgets.h" 00038 00039 class CollapsibleGroupBoxPrivate; 00040 00047 class ITOMWIDGETS_EXPORT CollapsibleGroupBox : public QGroupBox 00048 { 00049 Q_OBJECT 00050 Q_PROPERTY(bool collapsed READ collapsed WRITE setCollapsed) 00051 00052 00053 00054 00055 Q_PROPERTY(int collapsedHeight READ collapsedHeight WRITE setCollapsedHeight) 00056 00057 public: 00058 CollapsibleGroupBox(QWidget* parent = 0); 00059 CollapsibleGroupBox(const QString& title, QWidget* parent = 0); 00060 virtual ~CollapsibleGroupBox(); 00061 00066 inline void setCollapsed(bool collapse); 00067 00070 inline bool collapsed()const; 00071 00073 virtual void setCollapsedHeight(int heightInPixels); 00074 int collapsedHeight()const; 00075 00078 virtual bool eventFilter(QObject* child, QEvent* e); 00079 00081 virtual void setVisible(bool show); 00082 protected slots: 00085 virtual void expand(bool expand); 00086 00087 protected: 00088 QScopedPointer<CollapsibleGroupBoxPrivate> d_ptr; 00090 virtual void childEvent(QChildEvent*); 00091 00092 #if QT_VERSION < 0x040600 00093 virtual void paintEvent(QPaintEvent*); 00094 virtual void mousePressEvent(QMouseEvent*); 00095 virtual void mouseReleaseEvent(QMouseEvent*); 00096 #endif 00097 00098 private: 00099 Q_DECLARE_PRIVATE(CollapsibleGroupBox); 00100 Q_DISABLE_COPY(CollapsibleGroupBox); 00101 }; 00102 00103 //---------------------------------------------------------------------------- 00104 bool CollapsibleGroupBox::collapsed()const 00105 { 00106 return !this->isChecked(); 00107 } 00108 00109 //---------------------------------------------------------------------------- 00110 void CollapsibleGroupBox::setCollapsed(bool collapse) 00111 { 00112 this->setChecked(!collapse); 00113 } 00114 00115 #endif