Ejemplo n.º 1
0
KArchive *ArchiveReader::create(const QString &fileName, QIODevice *data)
{
    QMimeDatabase dataBase;
    const QMimeType mimeType = dataBase.mimeTypeForFileNameAndData(fileName, data);

    return create(mimeType, data);
}
void ContactInfoDialog::slotButtonClicked(QAbstractButton *button)
{
    if (button == d->buttonBox->button(QDialogButtonBox::Save)) {
        if (d->avatarChanged) {
            Tp::Avatar avatar;
            if (!d->newAvatarFile.isEmpty()) {
                QFile file(d->newAvatarFile);
                file.open(QIODevice::ReadOnly);

                QFileInfo fi(file);

                avatar.avatarData = file.readAll();
                file.seek(0); // reset before passing to KMimeType

                QMimeDatabase db;
                avatar.MIMEType = db.mimeTypeForFileNameAndData(d->newAvatarFile, &file).name();
            }

            d->account->setAvatar(avatar);
        }

        if (d->infoDataChanged) {
            Tp::ContactInfoFieldList fieldList;

            for (InfoRowIndex index = (InfoRowIndex) 0; index < _InfoRowCount; index = (InfoRowIndex) (index + 1)) {
                InfoRow *row = &InfoRows[index];

                Tp::ContactInfoField field;
                field.fieldName = row->fieldName;

                if (index == Birthday) {
                    KDateComboBox *combo = qobject_cast<KDateComboBox*>(d->infoValueWidgets.value(index));
                    field.fieldValue << combo->date().toString();
                } else {
                    QLineEdit *lineEdit = qobject_cast<QLineEdit*>(d->infoValueWidgets.value(index));
                    field.fieldValue << lineEdit->text();
                }

                fieldList << field;
            }

#if 0   // This method does not exist in TpQt (yet)
            d->account->connection()->setContactInfo(fieldList);
#endif
        }

        accept();
        return;
    }
}
Ejemplo n.º 3
0
void QQuickQrcSchemeDelegate::readResourceAndSend()
{
    QFile file(m_fileName);
    QFileInfo fileInfo(file);
    if (fileInfo.isDir() || !file.open(QIODevice::ReadOnly | QIODevice::Unbuffered))
        return;

    QByteArray fileData(file.readAll());
    QMimeDatabase mimeDb;
    QMimeType mimeType = mimeDb.mimeTypeForFileNameAndData(m_fileName, fileData);
    file.close();

    reply()->setData(fileData);
    reply()->setContentType(mimeType.name());
    reply()->send();
}