Esempio n. 1
0
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();
    if (!m_bInit)
        fillEncoding();
}
Esempio n. 2
0
void YahooInfo::fill()
{
    YahooUserData *data = m_data;
    if (data == NULL) data = &m_client->data.owner;
    edtLogin->setText(QString::fromUtf8(data->Login.ptr));
    edtNick->setText(data->Nick.ptr ? QString::fromUtf8(data->Nick.ptr) : QString(""));
    edtFirst->setText(data->First.ptr ? QString::fromUtf8(data->First.ptr) : QString(""));
    edtLast->setText(data->Last.ptr ? QString::fromUtf8(data->Last.ptr) : QString(""));
    int current = 0;
    const char *text = NULL;
    unsigned long status = STATUS_OFFLINE;
    if (m_data == NULL){
        if (m_client->getState() == Client::Connected){
            const char *statusIcon = NULL;
            unsigned style  = 0;
            m_client->contactInfo(&m_client->data.owner, status, style, statusIcon);
        }
    }else{
        const char *statusIcon = NULL;
        unsigned style  = 0;
        m_client->contactInfo(data, status, style, statusIcon);
    }
    for (const CommandDef *cmd = m_client->protocol()->statusList(); cmd->id; cmd++){
        if (cmd->flags & COMMAND_CHECK_STATE)
            continue;
        if (status == cmd->id){
            current = cmbStatus->count();
            text = cmd->text;
        }
        cmbStatus->insertItem(Pict(cmd->icon), i18n(cmd->text));
    }
    cmbStatus->setCurrentItem(current);
    disableWidget(cmbStatus);
    if (status == STATUS_OFFLINE){
        if (data->StatusTime.value){
            lblOnline->setText(i18n("Last online") + ":");
            edtOnline->setText(formatDateTime(data->StatusTime.value));
            lblOnline->show();
            edtOnline->show();
        }else{
            lblOnline->hide();
            edtOnline->hide();
        }
        lblNA->hide();
        edtNA->hide();
    }else{
        if (data->OnlineTime.value){
            edtOnline->setText(formatDateTime(data->OnlineTime.value));
        }else{
            lblOnline->hide();
            edtOnline->hide();
        }
        if ((status == STATUS_ONLINE) || (text == NULL)){
            lblNA->hide();
            edtNA->hide();
        }else{
            lblNA->setText(i18n(text));
            edtNA->setText(formatDateTime(data->StatusTime.value));
        }
    }
    if (m_bInit)
        return;
    m_bInit = true;
    fillEncoding(data);
}