]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQTimeField.cc
restart qt4 porting
[duncan/yast2-qt4.git] / src / YQTimeField.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:         YQTimeField.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 <qdatetimeedit.h>
24
25 #include "utf8.h"
26 #include "YQUI.h"
27 #include "YQTimeField.h"
28 #include "YQWidgetCaption.h"
29
30
31
32 YQTimeField::YQTimeField( YWidget * parent, const string & label )
33     : QVBox( (QWidget *) parent->widgetRep() )
34     , YTimeField( parent, label )
35 {
36     setWidgetRep( this );
37     setSpacing( YQWidgetSpacing );
38     setMargin ( YQWidgetMargin );
39
40     _caption = new YQWidgetCaption( this, fromUTF8( label ) );
41     YUI_CHECK_NEW( _caption );
42
43     _qt_timeEdit = new QTimeEdit( this );
44     YUI_CHECK_NEW( _qt_timeEdit );
45
46     _qt_timeEdit->setAutoAdvance( true );
47     _caption->setBuddy( _qt_timeEdit );
48 }
49
50
51 YQTimeField::~YQTimeField()
52 {
53     // NOP
54 }
55
56
57 string YQTimeField::value()
58 {
59     return toUTF8( _qt_timeEdit->time().toString( Qt::ISODate ) );
60 }
61
62
63 void YQTimeField::setValue( const string & newValue )
64 {
65     _qt_timeEdit->setTime(  QTime::fromString( fromUTF8( newValue ), Qt::ISODate ) );
66 }
67
68
69 void YQTimeField::setLabel( const string & newLabel )
70 {
71     _caption->setText( fromUTF8( newLabel ) );
72     YTimeField::setLabel( newLabel );
73 }
74
75
76 void YQTimeField::setEnabled( bool enabled )
77 {
78     QVBox::setEnabled( enabled );
79     YWidget::setEnabled( enabled );
80 }
81
82
83 int YQTimeField::preferredWidth()
84 {
85     return sizeHint().width();
86 }
87
88
89 int YQTimeField::preferredHeight()
90 {
91     return sizeHint().height();
92 }
93
94
95 void YQTimeField::setSize( int newWidth, int newHeight )
96 {
97     resize( newWidth, newHeight );
98 }
99
100
101 bool YQTimeField::setKeyboardFocus()
102 {
103     _qt_timeEdit->setFocus();
104
105     return true;
106 }
107
108
109 #include "YQTimeField.moc"