24 #include <tqcheckbox.h>
27 #include <tqpainter.h>
28 #include <tqpushbutton.h>
30 #include <tqtoolbutton.h>
31 #include <tqtooltip.h>
33 #include <tdeaccelmanager.h>
34 #include <tdeconfig.h>
35 #include <kcombobox.h>
38 #include <kiconloader.h>
39 #include <klineedit.h>
40 #include <tdelocale.h>
41 #include <tdemessagebox.h>
43 #include "imeditwidget.h"
44 #include "imeditorwidget.h"
46 IMEditWidget::IMEditWidget( TQWidget *parent, TDEABC::Addressee &addr,
const char *name )
47 : TQWidget( parent, name ), mAddressee(addr)
49 TQGridLayout *topLayout =
new TQGridLayout(
this, 2, 2, KDialog::marginHint(),
50 KDialog::spacingHint() );
52 TQLabel *label =
new TQLabel( i18n(
"IM address:" ),
this );
53 topLayout->addWidget( label, 0, 0 );
55 mIMEdit =
new KLineEdit(
this );
56 connect( mIMEdit, TQ_SIGNAL( textChanged(
const TQString& ) ),
57 TQ_SLOT( textChanged(
const TQString& ) ) );
58 connect( mIMEdit, TQ_SIGNAL( textChanged(
const TQString& ) ),
59 TQ_SIGNAL( modified() ) );
60 label->setBuddy( mIMEdit );
61 topLayout->addWidget( mIMEdit, 0, 1 );
63 mEditButton =
new TQPushButton( i18n(
"Edit IM Addresses..." ),
this);
64 connect( mEditButton, TQ_SIGNAL( clicked() ), TQ_SLOT( edit() ) );
65 topLayout->addMultiCellWidget( mEditButton, 1, 1, 0, 1 );
67 topLayout->activate();
70 IMEditWidget::~IMEditWidget()
74 void IMEditWidget::setReadOnly(
bool readOnly )
76 mIMEdit->setReadOnly( readOnly );
80 void IMEditWidget::setPreferredIM(
const TQString &addr )
82 bool blocked = mIMEdit->signalsBlocked();
83 mIMEdit->blockSignals(
true );
84 mIMEdit->setText( addr );
85 mIMEdit->blockSignals( blocked );
87 void IMEditWidget::setIMs(
const TQStringList &list )
91 bool blocked = mIMEdit->signalsBlocked();
92 mIMEdit->blockSignals(
true );
93 if ( list.count() > 0 )
94 mIMEdit->setText( list[ 0 ] );
96 mIMEdit->setText(
"" );
97 mIMEdit->blockSignals( blocked );
100 TQStringList IMEditWidget::ims()
102 if ( mIMEdit->text().isEmpty() ) {
103 if ( mIMList.count() > 0 )
104 mIMList.remove( mIMList.begin() );
106 if ( mIMList.count() > 0 )
107 mIMList.remove( mIMList.begin() );
109 mIMList.prepend( mIMEdit->text() );
114 TQString IMEditWidget::preferredIM()
116 return mIMEdit->text();
118 void IMEditWidget::edit()
121 dlg.loadContact(&mAddressee);
122 dlg.setReadOnly(mReadOnly);
125 if ( dlg.isModified() ) {
128 dlg.storeContact(&mAddressee);
129 mIMEdit->setText( dlg.preferred() );
135 void IMEditWidget::textChanged(
const TQString &text )
137 if ( mIMList.count() > 0 )
138 mIMList.remove( mIMList.begin() );
140 mIMList.prepend( text );
144 #include "imeditwidget.moc"