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

Last change on this file since 10 was 10, checked in by Sanahuja Guillaume, 5 years ago

lic

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