Example #1
0
QByteArray FullMessageCombiner::data() const
{
    if (loaded())
        return *(headerPartPtr()->dataPtr()) + *(bodyPartPtr()->dataPtr());

    return QByteArray();
}
Example #2
0
void FullMessageCombiner::load()
{
    Imap::Mailbox::TreeItemPart *headerPart = headerPartPtr();
    headerPart->fetch(const_cast<Mailbox::Model *>(m_model));
    Imap::Mailbox::TreeItemPart *bodyPart = bodyPartPtr();
    bodyPart->fetch(const_cast<Mailbox::Model *>(m_model));
    slotDataChanged(QModelIndex(), QModelIndex());
}
void FullMessageCombiner::slotDataChanged(const QModelIndex &left, const QModelIndex &right)
{
    Q_UNUSED(left);
    Q_UNUSED(right);

    if (headerPartPtr()->fetched() && bodyPartPtr()->fetched()) {
       emit completed();
       // Disconnect this slot from its connected signal to prevent emitting completed() many times
       // when dataChanged() is emitted and the parts are already fetched.
       disconnect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(slotDataChanged(QModelIndex,QModelIndex)));
    }
}
Example #4
0
void FullMessageCombiner::slotDataChanged(const QModelIndex &left, const QModelIndex &right)
{
    Q_UNUSED(left);
    Q_UNUSED(right);

    if (headerPartPtr()->fetched() && bodyPartPtr()->fetched()) {
       emit completed();
       // Disconnect this slot from its connected signal to prevent emitting completed() many times
       // when dataChanged() is emitted and the parts are already fetched.
       disconnect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(slotDataChanged(QModelIndex,QModelIndex)));
    }

    Imap::Mailbox::Model *model = const_cast<Imap::Mailbox::Model*>(m_model);
    bool headerOffline = headerPartPtr()->isUnavailable(model);
    bool bodyOffline = bodyPartPtr()->isUnavailable(model);
    if (headerOffline && bodyOffline) {
        emit failed(tr("Offline mode: uncached message data not available"));
    } else if (headerOffline) {
        emit failed(tr("Offline mode: uncached header data not available"));
    } else if (bodyOffline) {
        emit failed(tr("Offline mode: uncached body data not available"));
    }
}
void FullMessageCombiner::load()
{
    Imap::Mailbox::TreeItemPart *headerPart = headerPartPtr();
    Imap::Mailbox::TreeItemPart *bodyPart = bodyPartPtr();


    headerPart->fetch(const_cast<Mailbox::Model *>(m_model));
    bodyPart->fetch(const_cast<Mailbox::Model *>(m_model));

    if (headerPart->fetched() && bodyPart->fetched()) {
        emit completed();
    }

}
Example #6
0
FullMessageCombiner::FullMessageCombiner(const QModelIndex &messageIndex, QObject *parent) :
    QObject(parent), m_model(0), m_messageIndex(messageIndex)
{
    Imap::Mailbox::Model::realTreeItem(messageIndex, &m_model);
    Q_ASSERT(m_model);
    Imap::Mailbox::TreeItemPart *headerPart = headerPartPtr();
    Imap::Mailbox::TreeItemPart *bodyPart = bodyPartPtr();

    Q_ASSERT(headerPart);
    Q_ASSERT(bodyPart);

    m_headerPartIndex = headerPart->toIndex(const_cast<Mailbox::Model *>(m_model));
    Q_ASSERT(m_headerPartIndex.isValid());

    m_bodyPartIndex = bodyPart->toIndex(const_cast<Mailbox::Model *>(m_model));
    Q_ASSERT(m_bodyPartIndex.isValid());

    connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(slotDataChanged(QModelIndex,QModelIndex)));
}
Example #7
0
bool FullMessageCombiner::loaded() const
{
    return headerPartPtr()->fetched() && bodyPartPtr()->fetched();
}