source: flair-src/trunk/tools/FlairGCS/src/FormLayout.cpp@ 9

Last change on this file since 9 was 9, checked in by Sanahuja Guillaume, 7 years ago

gcs

File size: 1.6 KB
Line 
1#include "FormLayout.h"
2#include "Layout.h"
3#include <QWidget>
4#include <QFormLayout>
5#include <QEvent>
6
7FormLayout::FormLayout(Layout* parent,int row, int col,QString name,QString type):XmlWidget(name,type,parent)
8{
9 visible_widget=new QWidget();
10
11 //create a grid to put label and object
12 visible_widget->setObjectName(name);
13
14 parent->addWidget(visible_widget,row,col);
15 object_layout = new QFormLayout(visible_widget);
16 object_layout->setHorizontalSpacing(2);
17 object_layout->setVerticalSpacing(2);
18 object_layout->setContentsMargins (2,2,2,2);
19
20 visible_widget->installEventFilter(this);
21}
22
23FormLayout::~FormLayout()
24{
25}
26
27bool FormLayout::IsUptodate(void)
28{
29 //si le widget n'est pas enabled, sa palette est differente de rouge (greyed) donc on renvoit true
30 //permet de ne pas envoyer les modifs d'un widget disabled
31 //if(label->palette()==red_pal) return false;
32 if(visible_widget->palette()==red_pal) return false;
33 return true;
34}
35
36bool FormLayout::eventFilter(QObject *o, QEvent *e)
37{
38 if ( o == visible_widget )
39 {
40 switch(e->type())
41 {
42 case QEvent::EnabledChange:
43 {
44 QPalette palette=visible_widget->palette();
45 QPalette result;
46
47 if(palette==red_pal) result=red_pal_greyed;
48 if(palette==red_pal_greyed) result=red_pal;
49 if(palette==black_pal) result=black_pal_greyed;
50 if(palette==black_pal_greyed) result=black_pal;
51
52 visible_widget->setPalette(result);
53 }
54
55 default:
56 break;
57 }
58
59 }
60 return QObject::eventFilter(o, e);
61}
Note: See TracBrowser for help on using the repository browser.