]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQWidgetCaption.cc
Qt3support--
[duncan/yast2-qt4.git] / src / YQWidgetCaption.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQWidgetCaption.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #define y2log_component "qt-ui"
21 #include <ycp/y2log.h>
22
23 #include "YQWidgetCaption.h"
24 #include "utf8.h"
25
26
27 YQWidgetCaption::YQWidgetCaption( QWidget * parent,
28                                   const string &  text )
29     : QLabel( fromUTF8( text ), parent )
30 {
31     setTextFormat( Qt::PlainText );
32     handleVisibility( text );
33 }
34
35
36 YQWidgetCaption::YQWidgetCaption( QWidget * parent, const QString & text )
37     : QLabel( text, parent )
38 {
39     setTextFormat( Qt::PlainText );
40     handleVisibility( text );
41 }
42
43
44 YQWidgetCaption::~YQWidgetCaption()
45 {
46     // NOP
47 }
48
49
50 void YQWidgetCaption::setText ( const string  & newText )
51 {
52     setText( fromUTF8( newText ) );
53 }
54
55
56 void YQWidgetCaption::setText ( const QString & newText )
57 {
58     QLabel::setText( newText );
59     handleVisibility( newText.isEmpty() );
60 }
61
62
63 void YQWidgetCaption::handleVisibility( const string  & text )
64 {
65     handleVisibility( text.empty() );
66 }
67
68
69 void YQWidgetCaption::handleVisibility( const QString & text )
70 {
71     handleVisibility( text.isEmpty() );
72 }
73
74
75 void YQWidgetCaption::handleVisibility( bool textIsEmpty )
76 {
77     if ( textIsEmpty )
78     {
79         if ( !isHidden() )
80             hide();
81     }
82     else
83     {
84         if ( isHidden() )
85             show();
86     }
87 }
88
89
90 #include "YQWidgetCaption.moc"