23 #include "configguisyncmlobex.h"
25 #include <kcombobox.h>
27 #include <klineedit.h>
28 #include <tdelocale.h>
29 #include <kurlrequester.h>
32 #include <tqcheckbox.h>
33 #include <tqcombobox.h>
36 #include <tqspinbox.h>
37 #include <tqtabwidget.h>
40 ConfigGuiSyncmlObex::ConfigGuiSyncmlObex(
const QSync::Member &member, TQWidget *parent )
41 : ConfigGui( member, parent )
43 TQTabWidget *tabWidget =
new TQTabWidget(
this );
44 topLayout()->addWidget( tabWidget );
47 TQVBox *connectionWidget =
new TQVBox(
this );
48 connectionWidget->setMargin( KDialog::marginHint() );
49 connectionWidget->setSpacing( 5 );
51 tabWidget->addTab( connectionWidget, i18n(
"Connection" ) );
53 mConnection =
new KComboBox( connectionWidget );
55 connect( mConnection, TQT_SIGNAL (activated(
int ) ),
56 this, TQT_SLOT( slotConnectionChanged (
int ) ) );
58 mConnectionTypes.append( ConnectionType( 2, i18n(
"Bluetooth" ) ) );
59 mConnectionTypes.append( ConnectionType( 5, i18n(
"USB" ) ) );
61 ConnectionTypeList::ConstIterator it;
62 for ( it = mConnectionTypes.begin(); it != mConnectionTypes.end(); it++ )
63 mConnection->insertItem( (*it).second );
65 mBluetooth =
new BluetoothWidget( connectionWidget );
68 mUsb =
new UsbWidget( connectionWidget );
71 connectionWidget->setStretchFactor( mBluetooth, 1 );
72 connectionWidget->setStretchFactor( mUsb, 1 );
75 TQWidget *databaseWidget =
new TQWidget( tabWidget );
76 TQVBoxLayout *databaseLayout =
new TQVBoxLayout( databaseWidget,
77 KDialog::marginHint(), KDialog::spacingHint() );
79 tabWidget->addTab( databaseWidget, i18n(
"Databases" ) );
81 mGridLayout =
new TQGridLayout( databaseLayout );
82 addLineEdit( databaseWidget, i18n(
"Contact Database:"), &mContactDb, 0 );
83 addLineEdit( databaseWidget, i18n(
"Calendar Database:"), &mCalendarDb, 1 );
84 addLineEdit( databaseWidget, i18n(
"Note Database:"), &mNoteDb, 2 );
86 mContactDb->insertItem(
"addressbook" );
87 mContactDb->insertItem(
"contacts" );
89 mCalendarDb->insertItem(
"agenda" );
90 mCalendarDb->insertItem(
"calendar" );
92 mNoteDb->insertItem(
"notes" );
95 TQWidget *optionsWidget =
new TQWidget( tabWidget );
96 TQVBoxLayout *optionsLayout =
new TQVBoxLayout( optionsWidget,
97 KDialog::marginHint(), KDialog::spacingHint() );
99 tabWidget->addTab( optionsWidget, i18n(
"Options" ) );
101 mGridLayout =
new TQGridLayout( optionsLayout );
103 TQLabel *label =
new TQLabel( i18n(
"User name:"), optionsWidget );
104 mGridLayout->addWidget( label, 0, 0 );
106 mUsername =
new KLineEdit( optionsWidget );
107 mGridLayout->addWidget( mUsername, 0, 1 );
109 label =
new TQLabel( i18n(
"Password:"), optionsWidget );
110 mGridLayout->addWidget( label, 1, 0 );
112 mPassword =
new KLineEdit( optionsWidget );
113 mPassword->setEchoMode( TQLineEdit::Password );
114 mGridLayout->addWidget( mPassword, 1, 1 );
116 mUseStringTable =
new TQCheckBox( i18n(
"Use String Table"), optionsWidget );
117 mGridLayout->addMultiCellWidget( mUseStringTable, 2, 2, 0, 1 );
119 mOnlyReplace =
new TQCheckBox( i18n(
"Only Replace Entries"), optionsWidget );
120 mGridLayout->addMultiCellWidget( mOnlyReplace, 3, 3, 0, 1 );
123 label =
new TQLabel( i18n(
"SyncML Version:"), optionsWidget );
124 mGridLayout->addWidget( label, 4, 0 );
126 mSyncmlVersion =
new TQComboBox( optionsWidget );
127 mGridLayout->addWidget( mSyncmlVersion, 4, 1 );
129 mSyncmlVersions.append( SyncmlVersion( 0, i18n(
"1.0" ) ) );
130 mSyncmlVersions.append( SyncmlVersion( 1, i18n(
"1.1" ) ) );
131 mSyncmlVersions.append( SyncmlVersion( 2, i18n(
"1.2" ) ) );
133 SyncmlVersionList::ConstIterator itVersion;
134 for ( itVersion = mSyncmlVersions.begin(); itVersion != mSyncmlVersions.end(); itVersion++ )
135 mSyncmlVersion->insertItem( (*itVersion).second );
138 mWbxml =
new TQCheckBox( i18n(
"WAP Binary XML"), optionsWidget );
139 mGridLayout->addMultiCellWidget( mWbxml, 12, 12, 0, 1 );
142 label =
new TQLabel( i18n(
"Software Identifier:"), optionsWidget );
143 mGridLayout->addWidget( label, 13, 0 );
145 mIdentifier =
new KComboBox(
true, optionsWidget );
146 mGridLayout->addWidget( mIdentifier, 13, 1 );
148 mIdentifier->insertItem(
"" );
149 mIdentifier->insertItem(
"PC Suite" );
152 label =
new TQLabel( i18n(
"Receive Limit:"), optionsWidget );
153 mGridLayout->addWidget( label, 14, 0 );
155 mRecvLimit =
new TQSpinBox( optionsWidget );
156 mRecvLimit->setMinValue( 1 );
157 mRecvLimit->setMaxValue( 65536 );
158 mGridLayout->addWidget( mRecvLimit, 14, 1 );
161 label =
new TQLabel( i18n(
"Maximum Object Size"), optionsWidget );
162 mGridLayout->addWidget( label, 15, 0 );
164 mMaxObjSize =
new TQSpinBox( optionsWidget );
165 mMaxObjSize->setMinValue( 1 );
166 mMaxObjSize->setMaxValue( 65536 );
167 mGridLayout->addWidget( mMaxObjSize, 15, 1 );
169 topLayout()->addStretch( 1 );
172 void ConfigGuiSyncmlObex::slotConnectionChanged(
int pos )
183 void ConfigGuiSyncmlObex::load(
const TQString &xml )
185 TQDomDocument document;
186 document.setContent( xml );
188 TQDomElement docElement = document.documentElement();
191 for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
192 TQDomElement element = node.toElement();
193 if ( element.tagName() ==
"username" ) {
194 mUsername->setText( element.text() );
195 }
else if ( element.tagName() ==
"password" ) {
196 mPassword->setText( element.text() );
197 }
else if ( element.tagName() ==
"type" ) {
198 for ( uint i = 0; i < mConnectionTypes.count(); i++ ) {
199 if ( mConnectionTypes[i].first == element.text().toInt() ) {
200 mConnection->setCurrentItem( i );
201 slotConnectionChanged( i );
205 }
else if ( element.tagName() ==
"version" ) {
206 for ( uint i = 0; i < mSyncmlVersions.count(); i++ ) {
207 if ( mSyncmlVersions[i].first == element.text().toInt() ) {
208 mSyncmlVersion->setCurrentItem( i );
212 }
else if ( element.tagName() ==
"bluetooth_address" ) {
213 if ( mBluetooth ) mBluetooth->setAddress( element.text() );
214 }
else if ( element.tagName() ==
"bluetooth_channel" ) {
215 if ( mBluetooth ) mBluetooth->setChannel( element.text() );
216 }
else if ( element.tagName() ==
"identifier" ) {
217 if ( mIdentifier ) mIdentifier->setCurrentText( element.text() );
218 }
else if ( element.tagName() ==
"interface" ) {
219 if ( mUsb ) mUsb->setInterface( element.text().toInt() );
220 }
else if ( element.tagName() ==
"wbxml" ) {
221 if ( mWbxml) mWbxml->setChecked( element.text() ==
"1" );
222 }
else if ( element.tagName() ==
"recvLimit" ) {
223 if ( mRecvLimit ) mRecvLimit->setValue( element.text().toInt() );
224 }
else if ( element.tagName() ==
"maxObjSize" ) {
225 if ( mMaxObjSize ) mMaxObjSize->setValue( element.text().toInt() );
226 }
else if ( element.tagName() ==
"usestringtable" ) {
227 mUseStringTable->setChecked( element.text() ==
"1" );
228 }
else if ( element.tagName() ==
"onlyreplace" ) {
229 mOnlyReplace->setChecked( element.text() ==
"1" );
230 }
else if ( element.tagName() ==
"contact_db" ) {
231 mContactDb->setCurrentText( element.text() );
232 }
else if ( element.tagName() ==
"calendar_db" ) {
233 mCalendarDb->setCurrentText( element.text() );
234 }
else if ( element.tagName() ==
"note_db" ) {
235 mNoteDb->setCurrentText( element.text() );
240 TQString ConfigGuiSyncmlObex::save()
const
244 xml +=
"<username>" + mUsername->text() +
"</username>\n";
245 xml +=
"<password>" + mPassword->text() +
"</password>\n";
246 ConnectionTypeList::ConstIterator it;
247 for ( it = mConnectionTypes.begin(); it != mConnectionTypes.end(); it++ ) {
248 if ( mConnection->currentText() == (*it).second ) {
249 xml +=
"<type>" + TQString(
"%1").arg((*it).first) +
"</type>\n";
255 xml +=
"<bluetooth_address>" + mBluetooth->address() +
"</bluetooth_address>\n";
258 xml +=
"<bluetooth_channel>" + mBluetooth->channel() +
"</bluetooth_channel>\n";
261 xml +=
"<interface>" + TQString::number( mUsb->interface() ) +
"</interface>\n";
264 SyncmlVersionList::ConstIterator itVersion;
265 for ( itVersion = mSyncmlVersions.begin(); itVersion != mSyncmlVersions.end(); itVersion++ ) {
266 if ( mSyncmlVersion->currentText() == (*itVersion).second ) {
267 xml +=
"<version>" + TQString(
"%1").arg((*itVersion).first) +
"</version>\n";
273 xml +=
"<identifier>" + mIdentifier->currentText() +
"</identifier>\n";
277 if ( mWbxml->isChecked() )
284 xml +=
"<recvLimit>" + TQString::number( mRecvLimit->value() ) +
"</recvLimit>\n";
287 xml +=
"<maxObjSize>" + TQString::number( mMaxObjSize->value() ) +
"</maxObjSize>\n";
289 xml +=
"<usestringtable>";
290 if ( mUseStringTable->isChecked() )
294 xml +=
"</usestringtable>\n";
296 xml +=
"<onlyreplace>";
297 if ( mOnlyReplace->isChecked() )
301 xml +=
"</onlyreplace>\n";
303 xml +=
"<contact_db>" + mContactDb->currentText() +
"</contact_db>\n";
304 xml +=
"<calendar_db>" + mCalendarDb->currentText() +
"</calendar_db>\n";
305 xml +=
"<note_db>" + mNoteDb->currentText() +
"</note_db>\n";
311 void ConfigGuiSyncmlObex::addLineEdit( TQWidget *parent,
const TQString &text, KComboBox **edit,
int row )
313 TQLabel *label =
new TQLabel( text, parent );
314 mGridLayout->addWidget( label, row, 0 );
316 *edit =
new KComboBox(
true, parent );
317 mGridLayout->addWidget( *edit, row, 1 );
320 #include "configguisyncmlobex.moc"