1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
/*
* Copyright (C) 2005, Mart Kelder ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "account_input.h"
#include <kurlrequester.h>
#include <klineedit.h>
#include <tqcheckbox.h>
#include <tqcombobox.h>
#include <tqlabel.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqvalidator.h>
AccountInput::AccountInput( const TQString& configName )
: _configName( new TQString( configName ) )
{
}
AccountInput::~AccountInput()
{
delete _configName;
}
TQString AccountInput::configName() const
{
return *_configName;
}
TextInput::TextInput( TQWidget *parent, const TQString& title, Type type, const TQString& defaul, const TQString& configName )
: AccountInput( configName )
{
_left = new TQLabel( title, parent, "label" );
_right = new KLineEdit( "", parent, "edit" );
switch( type )
{
case text:
break;
case password:
_right->setEchoMode( TQLineEdit::Password );
break;
}
setValue( defaul );
}
TextInput::TextInput( TQWidget *parent, const TQString& title, int min, int max, const TQString& defaul, const TQString& configName )
: AccountInput( configName )
{
_left = new TQLabel( title, parent, "label" );
_right = new KLineEdit( "", parent, "edit" );
_right->setValidator( new TQIntValidator( min, max, TQT_TQOBJECT(_right), "validator" ) );
setValue( defaul );
}
TextInput::~TextInput()
{
delete _left;
delete _right;
}
TQString TextInput::value() const
{
return _right->text();
}
void TextInput::setValue( const TQString& value )
{
return _right->setText( value );
}
URLInput::URLInput( TQWidget *parent, const TQString& title, const TQString& defaul, const TQString& configName )
: AccountInput( configName )
{
_left = new TQLabel( title, parent, "label" );
_right = new KURLRequester( "", parent, "kurledit" );
setValue( defaul );
}
URLInput::~URLInput()
{
delete _left;
delete _right;
}
TQString URLInput::value() const
{
return _right->url();
}
void URLInput::setValue( const TQString& value )
{
_right->setURL( value );
}
ComboInput::ComboInput( TQWidget *parent, const TQString& title, const TQMap<TQString, TQString>& list,
const TQString& defaul, const TQString& configName )
: AccountInput( configName )
, _list( new TQMap< TQString, TQString >( list ) )
{
_left = new TQLabel( title, parent, "label" );
_right = new TQComboBox( false, parent, "combo" );
_right->insertStringList( TQStringList( _list->values() ) );
setValue( defaul );
}
ComboInput::~ComboInput()
{
delete _left;
delete _right;
}
TQString ComboInput::value() const
{
if( _right->currentItem() >= 0 )
return _list->keys()[ _right->currentItem() ];
else
return "";
}
void ComboInput::setValue( const TQString& value )
{
if( _list->contains( value ) )
_right->setCurrentItem( _list->keys().findIndex( value ) );
else
_right->setCurrentItem( -1 );
}
CheckboxInput::CheckboxInput( TQWidget *parent, const TQString& title, const TQString& defaul, const TQString& configName )
: AccountInput( configName )
{
_right = new TQCheckBox( title, parent, "checkbox" );
setValue( defaul );
}
CheckboxInput::~CheckboxInput()
{
delete _right;
}
TQString CheckboxInput::value() const
{
if( _right->isChecked() )
return "true";
else
return "false";
}
void CheckboxInput::setValue( const TQString& value )
{
if( value == "true" )
_right->setChecked( true );
else if( value == "false" )
_right->setChecked( false );
//Elsewise: do nothing
}
|