HAL
expanding_list_item.cpp
Go to the documentation of this file.
2 
4 
5 #include <QStyle>
6 
7 namespace hal
8 {
10  : QFrame(parent), mButton(but), mCollapsedHeight(0), mExpandedHeight(0),
11  mExpanded(false), mFixedHeight(mButton->minimumHeight())
12  {
13  mButton->setParent(this);
14  mButton->show();
16  setMinimumHeight(mButton->minimumHeight());
17  }
18 
20  {
21  return minimumSize();
22  }
23 
25  {
26  return size();
27  }
28 
30  {
31  int width = event->size().width();
32 
33  mButton->resize(width, mButton->height());
34  }
35 
37  {
38  return mExpanded;
39  }
40 
42  {
43  return mFixedHeight;
44  }
45 
46 
48  {
49  return mButton;
50  }
51 
53  {
54  QStyle* s = style();
55 
56  s->unpolish(this);
57  s->polish(this);
58 
59  mButton->repolish();
60  mButton->move(0, 0);
61  mCollapsedHeight = mButton->height();
62  int offset = mCollapsedHeight;
63 
64  mExpandedHeight = offset;
65 
66  setFixedHeight(mCollapsedHeight);
67  }
68 
70  {
71  mExpanded = false;
72  hide();
73  }
74 
76  {
77  mExpanded = true;
78  show();
79  repolish();
80  }
81 
83  {
84  mFixedHeight = height;
85 
88  }
89 }
One button of the ExpandingListWidget.
void setFixedHeight(int height)
ExpandingListButton * button() const
virtual QSize minimumSizeHint() const override
virtual void resizeEvent(QResizeEvent *event) override
ExpandingListItem(ExpandingListButton *but, QWidget *parent=nullptr)
virtual QSize sizeHint() const override
virtual void polish(QWidget *widget)
virtual void unpolish(QWidget *widget)
void hide()
void setMaximumHeight(int maxh)
void setMinimumHeight(int minh)
void move(int x, int y)
void resize(int w, int h)
void setParent(QWidget *parent)
void show()
void setSizePolicy(QSizePolicy)
QStyle * style() const const