Ejemplo n.º 1
0
/** @short Find a message body part through its slash-separated string path */
Imap::Mailbox::TreeItemPart *MsgPartNetAccessManager::pathToPart(const QModelIndex &message, const QString &path)
{
    QStringList items = path.split('/', QString::SkipEmptyParts);
    const Mailbox::Model *model = 0;
    Imap::Mailbox::TreeItem *target = Mailbox::Model::realTreeItem(message, &model);
    Q_ASSERT(model);
    Q_ASSERT(target);
    bool ok = ! items.isEmpty(); // if it's empty, it's a bogous URL

    for (QStringList::const_iterator it = items.constBegin(); it != items.constEnd(); ++it) {
        uint offset = it->toUInt(&ok);
        if (!ok) {
            // special case, we have to dive into that funny, irregular special parts now
            if (*it == QLatin1String("HEADER"))
                target = target->specialColumnPtr(0, Imap::Mailbox::TreeItem::OFFSET_HEADER);
            else if (*it == QLatin1String("TEXT"))
                target = target->specialColumnPtr(0, Imap::Mailbox::TreeItem::OFFSET_TEXT);
            else if (*it == QLatin1String("MIME"))
                target = target->specialColumnPtr(0, Imap::Mailbox::TreeItem::OFFSET_MIME);
            else
                return 0;
            continue;
        }
        if (offset >= target->childrenCount(const_cast<Mailbox::Model *>(model))) {
            return 0;
        }
        target = target->child(offset, const_cast<Mailbox::Model *>(model));
    }
    return dynamic_cast<Imap::Mailbox::TreeItemPart *>(target);
}
Ejemplo n.º 2
0
TreeItemPart *FullMessageCombiner::bodyPartPtr() const
{
    Imap::Mailbox::TreeItem *target = m_model->realTreeItem(m_messageIndex);
    return dynamic_cast<Imap::Mailbox::TreeItemPart *>(target->specialColumnPtr(0, Imap::Mailbox::TreeItem::OFFSET_TEXT));
}