]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQTimeField.cc
remove one FIXME
[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 #include <QVBoxLayout>
30
31
32 YQTimeField::YQTimeField( YWidget * parent, const string & label )
33     : QFrame( (QWidget *) parent->widgetRep() )
34     , YTimeField( parent, label )
35 {
36     setWidgetRep( this );
37     QVBoxLayout* layout = new QVBoxLayout( this );
38     setLayout( layout );
39
40     layout->setSpacing( YQWidgetSpacing );
41     layout->setMargin ( YQWidgetMargin );
42
43     _caption = new YQWidgetCaption( this, fromUTF8( label ) );
44     YUI_CHECK_NEW( _caption );
45     layout->addWidget( _caption );
46
47     _qt_timeEdit = new QTimeEdit( this );
48     YUI_CHECK_NEW( _qt_timeEdit );
49     layout->addWidget( _qt_timeEdit );
50
51 #warning FIXME setAutoAdvance does?
52     //_qt_timeEdit->setAutoAdvance( true );
53     _caption->setBuddy( _qt_timeEdit );
54 }
55
56
57 YQTimeField::~YQTimeField()
58 {
59     // NOP
60 }
61
62
63 string YQTimeField::value()
64 {
65     return toUTF8( _qt_timeEdit->time().toString( Qt::ISODate ) );
66 }
67
68
69 void YQTimeField::setValue( const string & newValue )
70 {
71     _qt_timeEdit->setTime(  QTime::fromString( fromUTF8( newValue ), Qt::ISODate ) );
72 }
73
74
75 void YQTimeField::setLabel( const string & newLabel )
76 {
77     _caption->setText( fromUTF8( newLabel ) );
78     YTimeField::setLabel( newLabel );
79 }
80
81
82 void YQTimeField::setEnabled( bool enabled )
83 {
84     QFrame::setEnabled( enabled );
85     YWidget::setEnabled( enabled );
86 }
87
88
89 int YQTimeField::preferredWidth()
90 {
91     return sizeHint().width();
92 }
93
94
95 int YQTimeField::preferredHeight()
96 {
97     return sizeHint().height();
98 }
99
100
101 void YQTimeField::setSize( int newWidth, int newHeight )
102 {
103     resize( newWidth, newHeight );
104 }
105
106
107 bool YQTimeField::setKeyboardFocus()
108 {
109     _qt_timeEdit->setFocus();
110
111     return true;
112 }
113
114
115 #include "YQTimeField.moc"