• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kalarm/lib

  • sources
  • kde-4.12
  • kdepim
  • kalarm
  • lib
stackedwidgets.h
Go to the documentation of this file.
1 /*
2  * stackedwidgets.h - group of stacked widgets
3  * Program: kalarm
4  * Copyright © 2008 by David Jarvie <djarvie@kde.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef STACKEDWIDGETS_H
22 #define STACKEDWIDGETS_H
23 
24 #include <QList>
25 #include <QScrollArea>
26 class KDialog;
27 
28 template <class T> class StackedGroupT;
29 
36 template <class T>
37 class StackedWidgetT : public T
38 {
39  public:
44  explicit StackedWidgetT(StackedGroupT<T>* group, QWidget* parent = 0)
45  : T(parent),
46  mGroup(group)
47  {
48  mGroup->addWidget(this);
49  }
50  ~StackedWidgetT() { mGroup->removeWidget(this); }
51  virtual QSize sizeHint() const { return minimumSizeHint(); }
52  virtual QSize minimumSizeHint() const { return mGroup->minimumSizeHint(); }
53 
54  private:
55  StackedGroupT<T>* mGroup;
56 };
57 
67 template <class T>
68 class StackedGroupT : public QObject
69 {
70  public:
71  explicit StackedGroupT(QObject* parent = 0) : QObject(parent) {}
72  void addWidget(StackedWidgetT<T>* w) { mWidgets += w; }
73  void removeWidget(StackedWidgetT<T>* w) { mWidgets.removeAll(w); }
74  virtual QSize minimumSizeHint() const;
75 
76  protected:
77  QList<StackedWidgetT<T>*> mWidgets;
78 };
79 
80 template <class T>
81 QSize StackedGroupT<T>::minimumSizeHint() const
82 {
83  QSize sz;
84  for (int i = 0, count = mWidgets.count(); i < count; ++i)
85  sz = sz.expandedTo(mWidgets[i]->T::minimumSizeHint());
86  return sz;
87 }
88 
90 typedef StackedWidgetT<QWidget> StackedWidget;
92 typedef StackedGroupT<QWidget> StackedGroup;
93 
94 
95 class StackedScrollGroup;
96 
103 class StackedScrollWidget : public StackedWidgetT<QScrollArea>
104 {
105  public:
106  explicit StackedScrollWidget(StackedScrollGroup* group, QWidget* parent = 0);
107  QWidget* widget() const { return viewport()->findChild<QWidget*>(); }
108 };
109 
116 class StackedScrollGroup : public StackedGroupT<QScrollArea>
117 {
118  public:
119  explicit StackedScrollGroup(KDialog*, QObject* tabParent);
120  virtual QSize minimumSizeHint() const;
121  int heightReduction() const { return mHeightReduction; }
122  QSize adjustSize(bool force = false);
123  void setSized() { mSized = true; }
124  bool sized() const { return mSized; }
125 
126  private:
127  QSize maxMinimumSizeHint() const;
128 
129  KDialog* mDialog;
130  int mMinHeight;
131  int mHeightReduction;
132  bool mSized;
133 };
134 
135 #endif // STACKEDWIDGETS_H
136 
137 // vim: et sw=4:
StackedScrollWidget::StackedScrollWidget
StackedScrollWidget(StackedScrollGroup *group, QWidget *parent=0)
Definition: stackedwidgets.cpp:30
StackedGroupT
A group of stacked widgets whose minimum size hints are all equal to the largest widget's minimum siz...
Definition: stackedwidgets.h:28
StackedScrollGroup::adjustSize
QSize adjustSize(bool force=false)
Definition: stackedwidgets.cpp:89
StackedWidgetT::~StackedWidgetT
~StackedWidgetT()
Definition: stackedwidgets.h:50
QWidget
StackedWidgetT::StackedWidgetT
StackedWidgetT(StackedGroupT< T > *group, QWidget *parent=0)
Constructor.
Definition: stackedwidgets.h:44
StackedGroupT::StackedGroupT
StackedGroupT(QObject *parent=0)
Definition: stackedwidgets.h:71
KDialog
QObject
StackedScrollGroup
A group of stacked widgets which individually become scrollable when necessary to fit the height of t...
Definition: stackedwidgets.h:116
StackedWidgetT::minimumSizeHint
virtual QSize minimumSizeHint() const
Definition: stackedwidgets.h:52
StackedScrollWidget::widget
QWidget * widget() const
Definition: stackedwidgets.h:107
StackedGroupT::addWidget
void addWidget(StackedWidgetT< T > *w)
Definition: stackedwidgets.h:72
StackedScrollGroup::sized
bool sized() const
Definition: stackedwidgets.h:124
StackedGroupT::minimumSizeHint
virtual QSize minimumSizeHint() const
Definition: stackedwidgets.h:81
StackedScrollGroup::minimumSizeHint
virtual QSize minimumSizeHint() const
Definition: stackedwidgets.cpp:57
StackedScrollGroup::setSized
void setSized()
Definition: stackedwidgets.h:123
StackedScrollGroup::StackedScrollGroup
StackedScrollGroup(KDialog *, QObject *tabParent)
Definition: stackedwidgets.cpp:40
StackedGroupT::removeWidget
void removeWidget(StackedWidgetT< T > *w)
Definition: stackedwidgets.h:73
T
StackedGroup
StackedGroupT< QWidget > StackedGroup
A group of non-scrollable stacked widgets.
Definition: stackedwidgets.h:92
StackedScrollWidget
A stacked widget which becomes scrollable when necessary to fit the height of the screen...
Definition: stackedwidgets.h:103
StackedGroupT::mWidgets
QList< StackedWidgetT< T > * > mWidgets
Definition: stackedwidgets.h:77
StackedWidgetT::sizeHint
virtual QSize sizeHint() const
Definition: stackedwidgets.h:51
StackedWidget
StackedWidgetT< QWidget > StackedWidget
A non-scrollable stacked widget.
Definition: stackedwidgets.h:90
StackedScrollGroup::heightReduction
int heightReduction() const
Definition: stackedwidgets.h:121
StackedWidgetT
A widget contained in a stack, whose minimum size hint is that of the largest widget in the stack...
Definition: stackedwidgets.h:37
QList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:59:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalarm/lib

Skip menu "kalarm/lib"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal