23 #include "imitemdialog.h"
26 #include "improtocols.h"
28 #include <QFormLayout>
30 #include <kcombobox.h>
31 #include <klineedit.h>
32 #include <klocalizedstring.h>
35 IMItemDialog::IMItemDialog(
QWidget *parent)
38 setButtons(Ok | Cancel);
42 setMainWidget(widget);
46 mProtocolCombo =
new KComboBox;
47 mProtocolCombo->addItem(i18nc(
"@item:inlistbox select from a list of IM protocols",
49 layout->
addRow(i18nc(
"@label:listbox",
"Protocol:"), mProtocolCombo);
51 const QStringList protocols = IMProtocols::self()->protocols();
52 foreach (
const QString &protocol, protocols) {
53 mProtocolCombo->addItem(KIcon(IMProtocols::self()->
icon(protocol)),
54 IMProtocols::self()->
name(protocol),
58 mNameEdit =
new KLineEdit;
59 layout->
addRow(i18nc(
"@label:textbox IM address",
"Address:"), mNameEdit);
61 connect(mProtocolCombo, SIGNAL(currentIndexChanged(
int)), SLOT(slotUpdateButtons()));
62 connect(mNameEdit, SIGNAL(textChanged(
QString)), SLOT(slotUpdateButtons()));
67 void IMItemDialog::setAddress(
const IMAddress &address)
69 mProtocolCombo->setCurrentIndex(
70 IMProtocols::self()->protocols().indexOf(address.protocol()) + 1);
72 mNameEdit->setText(address.name());
76 IMAddress IMItemDialog::address()
const
78 return IMAddress(mProtocolCombo->itemData(mProtocolCombo->currentIndex()).
toString(),
79 mNameEdit->text(),
false);
82 void IMItemDialog::slotUpdateButtons()
84 enableButtonOk(mProtocolCombo->currentIndex() > 0 && !mNameEdit->text().trimmed().isEmpty());
const char * name() const
char * toString(const T &value)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)