MainInfo::MainInfo(QWidget *parent, Contact *contact) : MainInfoBase(parent) { m_contact = contact; m_bInit = false; cmbDisplay->setEditable(true); lstMails->addColumn(i18n("EMail")); lstPhones->addColumn(i18n("Type")); lstPhones->addColumn(i18n("Phone")); lstMails->setMenu(MenuMailList); lstPhones->setMenu(MenuPhoneList); if (m_contact == NULL) { lstMails->addColumn(i18n("Publish")); lstPhones->addColumn(i18n("Publish")); lblCurrent->setText(i18n("I'm currently available at:")); cmbStatus->insertItem(i18n("Don't show")); cmbStatus->insertItem(Pict("phone"), i18n("Available")); cmbStatus->insertItem(Pict("nophone"), i18n("Busy")); cmbStatus->setCurrentItem(getContacts()->owner()->getPhoneStatus()); } else { lblCurrent->setText(i18n("User is crrently available at:")); disableWidget(cmbCurrent); lblStatus->hide(); cmbStatus->hide(); } bool bHide = true; for (unsigned i = 0; i < getContacts()->nClients(); i++) { if (getContacts()->getClient(i)->protocol()->description()->flags & PROTOCOL_FOLLOWME) { bHide = false; break; } } if (bHide) { lblCurrent->hide(); cmbCurrent->hide(); lblStatus->hide(); cmbStatus->hide(); } lstMails->setExpandingColumn(0); lstPhones->setExpandingColumn(PHONE_NUMBER); if (m_contact == NULL) tabMain->removePage(tabNotes); fill(); connect(lstMails, SIGNAL(selectionChanged()), this, SLOT(mailSelectionChanged())); connect(lstPhones, SIGNAL(selectionChanged()), this, SLOT(phoneSelectionChanged())); connect(lstMails, SIGNAL(deleteItem(QListViewItem*)), this, SLOT(deleteMail(QListViewItem*))); connect(lstPhones, SIGNAL(deleteItem(QListViewItem*)), this, SLOT(deletePhone(QListViewItem*))); connect(btnMailAdd, SIGNAL(clicked()), this, SLOT(addMail())); connect(btnMailEdit, SIGNAL(clicked()), this, SLOT(editMail())); connect(btnMailDelete, SIGNAL(clicked()), this, SLOT(deleteMail())); connect(btnPhoneAdd, SIGNAL(clicked()), this, SLOT(addPhone())); connect(btnPhoneEdit, SIGNAL(clicked()), this, SLOT(editPhone())); connect(btnPhoneDelete, SIGNAL(clicked()), this, SLOT(deletePhone())); }
void MainInfo::fill() { Contact *contact = m_contact; if (contact == NULL) contact = getContacts()->owner(); QString firstName = contact->getFirstName(); firstName = getToken(firstName, '/'); edtFirstName->setText(firstName); QString lastName = contact->getLastName(); lastName = getToken(lastName, '/'); edtLastName->setText(lastName); cmbDisplay->clear(); QString name = contact->getName(); if (name.length()) cmbDisplay->insertItem(name); if (firstName.length() && lastName.length()){ cmbDisplay->insertItem(firstName + " " + lastName); cmbDisplay->insertItem(lastName + " " + firstName); } if (firstName.length()) cmbDisplay->insertItem(firstName); if (lastName.length()) cmbDisplay->insertItem(lastName); cmbDisplay->lineEdit()->setText(contact->getName()); edtNotes->setText(contact->getNotes()); QString mails = contact->getEMails(); lstMails->clear(); while (mails.length()){ QString mailItem = getToken(mails, ';', false); QString mail = getToken(mailItem, '/'); QListViewItem *item = new QListViewItem(lstMails); item->setText(MAIL_ADDRESS, mail); item->setText(MAIL_PROTO, mailItem); item->setPixmap(MAIL_ADDRESS, Pict("mail_generic")); if ((m_contact == NULL) && mailItem.isEmpty()) item->setText(MAIL_PUBLISH, i18n("Yes")); } mailSelectionChanged(); QString phones = contact->getPhones(); lstPhones->clear(); unsigned n = 1; cmbCurrent->clear(); cmbCurrent->insertItem(""); while (phones.length()){ QString number; QString type; unsigned icon = 0; QString proto; QString phone = getToken(phones, ';', false); QString phoneItem = getToken(phone, '/', false); proto = phone; number = getToken(phoneItem, ','); type = getToken(phoneItem, ','); if (!phoneItem.isEmpty()) icon = atol(getToken(phoneItem, ',').latin1()); QListViewItem *item = new QListViewItem(lstPhones); fillPhoneItem(item, number, type, icon, proto); cmbCurrent->insertItem(number); if (!phoneItem.isEmpty()){ item->setText(PHONE_ACTIVE, "1"); cmbCurrent->setCurrentItem(n); } n++; } connect(lstPhones, SIGNAL(selectionChanged()), this, SLOT(phoneSelectionChanged())); phoneSelectionChanged(); }