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

Last change on this file since 470 was 15, checked in by Bayard Gildas, 9 years ago

sources reformatted with flair-format-dir script

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