24#include <tqcheckbox.h>
25#include <tqcombobox.h>
26#include <tqlineedit.h>
30#include <kiconloader.h>
32#include <kplugininfo.h>
34#include "imaddresswidget.h"
36IMAddressWidget::IMAddressWidget( TQWidget *parent, TQValueList<KPluginInfo *> protocols )
37 : IMAddressBase( parent )
39 mProtocols = protocols;
44IMAddressWidget::IMAddressWidget( TQWidget *parent, TQValueList<KPluginInfo *> protocols,
45 KPluginInfo *protocol,
const TQString& address,
46 const IMContext& context )
47 : IMAddressBase( parent )
51 mProtocols = protocols;
53 cmbProtocol->setCurrentItem( mProtocols.findIndex( protocol ) );
55 edtAddress->setText( address.section( TQChar( 0xE120 ), 0, 0 ) );
56 edtNetwork->setText( address.section( TQChar( 0xE120 ), 1 ) );
61void IMAddressWidget::init()
63 connect( cmbProtocol, TQ_SIGNAL( activated(
const TQString& ) ),
64 this, TQ_SLOT( slotProtocolChanged() ) );
65 connect( edtAddress, TQ_SIGNAL( textChanged(
const TQString& ) ),
66 this, TQ_SLOT( slotAddressChanged(
const TQString& ) ) );
68 slotProtocolChanged();
71void IMAddressWidget::slotAddressChanged(
const TQString &text )
73 emit inValidState( !text.stripWhiteSpace().isEmpty() );
76KPluginInfo * IMAddressWidget::protocol()
const
78 int protocolIndex = cmbProtocol->currentItem();
80 return mProtocols[ protocolIndex ];
83IMContext IMAddressWidget::context()
const
85 IMContext context = Any;
108TQString IMAddressWidget::address()
const
112 if ( protocol()->name() ==
"IRC" && !edtNetwork->text().stripWhiteSpace().isEmpty() )
113 return edtAddress->text().stripWhiteSpace() + TQChar( 0xE120 ) + edtNetwork->text().stripWhiteSpace();
115 return edtAddress->text().stripWhiteSpace();
121 TQValueList<KPluginInfo *>::ConstIterator it;
122 for ( it = mProtocols.begin(); it != mProtocols.end(); ++it )
123 cmbProtocol->insertItem( SmallIcon( (*it)->icon() ), (*it)->name() );
126void IMAddressWidget::slotProtocolChanged()
128 if ( protocol()->name() ==
"IRC" ) {
130 labelNetwork->show();
133 labelNetwork->hide();
137#include "imaddresswidget.moc"