Пример #1
0
void OcFeedsModelNew::setFolderId(const int &nFolderId)
{
    if (nFolderId != m_folderId) {
        m_folderId = nFolderId;
        QLOG_DEBUG() << "Feeds model: setting folder ID to " << folderId();
        init();
        emit folderIdChanged(folderId());
    }
}
Пример #2
0
void OcFeedsModelNew::feedMoved(const int &feedId, const int &fId)
{
    int idx = findIndex(feedId, 0);

    if ((idx == -999) && (fId == folderId())) {

        // feed was added to this folder, so create it

        QLOG_INFO() << "Feeds model: add feed that was moved to this folder";

        QSqlQuery query;

        if (!query.exec(QString("SELECT id, title, localUnreadCount, iconSource, iconWidth, iconHeight, folderId FROM feeds WHERE id = %1").arg(feedId))) {
            QLOG_ERROR() << "Feeds model: failed to select feed data from database: " << query.lastError().text();
        }

        query.next();

        beginInsertRows(QModelIndex(), rowCount(), rowCount());

        OcFeedObject *fobj = new OcFeedObject(query.value(0).toInt(),
                                              0,
                                              query.value(1).toString(),
                                              query.value(2).toInt(),
                                              query.value(3).toString(),
                                              query.value(4).toInt(),
                                              query.value(5).toInt());
        m_items.append(fobj);

        endInsertRows();

        queryAndSetTotalUnread();

    } else if ((idx != -999) && (fId != folderId())) {

        // feed was removed from this folder, so delete it

        QLOG_INFO() << "Feeds model: remove feed at index " << idx << " that was moved to another folder";

        beginRemoveRows(QModelIndex(), idx, idx);

        delete m_items.takeAt(idx);

        endRemoveRows();

        queryAndSetTotalUnread();
    }
}
Пример #3
0
void OcFeedsModelNew::feedCreated(const QString &name, const int &id)
{
    QSqlQuery query;

    if (!query.exec(QString("SELECT id, localUnreadCount, iconSource, iconWidth, iconHeight, folderId FROM feeds WHERE id = %1").arg(id))) {
        QLOG_ERROR() << "Feeds model: failed to select data of newly created feed from database: " << query.lastError().text();
    }

    query.next();

    if (query.value(5).toInt() == folderId()) {

        QLOG_INFO() << "Feeds model: adding newly created feed";

        beginInsertRows(QModelIndex(), rowCount(), rowCount());

        OcFeedObject *fobj = new OcFeedObject(query.value(0).toInt(),
                                              0,
                                              name,
                                              query.value(1).toInt(),
                                              query.value(2).toString(),
                                              query.value(3).toInt(),
                                              query.value(4).toInt());

        m_items.append(fobj);

        endInsertRows();

        queryAndSetTotalUnread();
    }
}
Пример #4
0
void QMessagePrivate::setStandardFolder(QMessage& message, QMessage::StandardFolder sf)
{
    if (message.type() == QMessage::Email) {
	QMessageFolderId folderId(standardFolderId(sf));
	if (folderId.isValid()) {
	    message.d_ptr->_parentFolderId = folderId;
	}
    }
    message.d_ptr->_standardFolder = sf;
    message.d_ptr->_modified = true;
}
int EventEditor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 11)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 11;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = subject(); break;
        case 1: *reinterpret_cast< QString*>(_v) = location(); break;
        case 2: *reinterpret_cast< QDateTime*>(_v) = startTime(); break;
        case 3: *reinterpret_cast< QDateTime*>(_v) = endTime(); break;
        case 4: *reinterpret_cast< int*>(_v) = folderId(); break;
        case 5: *reinterpret_cast< int*>(_v) = accountId(); break;
        case 6: *reinterpret_cast< Mode*>(_v) = mode(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setSubject(*reinterpret_cast< QString*>(_v)); break;
        case 1: setLocation(*reinterpret_cast< QString*>(_v)); break;
        case 2: setStartTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 3: setEndTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 4: setFolderId(*reinterpret_cast< int*>(_v)); break;
        case 5: setAccountId(*reinterpret_cast< int*>(_v)); break;
        case 6: setMode(*reinterpret_cast< Mode*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
void FolderListModel::setCurrentFolderIdx(int folderIdx)
{
    if (folderIdx >= m_folderList.count()) {
        qCWarning(lcGeneral) << Q_FUNC_INFO << " Can't set Invalid Index: " << folderIdx;
    }

    if (folderIdx != m_currentFolderIdx) {
        m_currentFolderIdx = folderIdx;
        m_currentFolderType = static_cast<FolderListModel::FolderStandardType>(folderType(m_currentFolderIdx).toInt());
        m_currentFolderUnreadCount = folderUnreadCount(m_currentFolderIdx);
        m_currentFolderId = QMailFolderId(folderId(m_currentFolderIdx));
        emit currentFolderIdxChanged();
        emit currentFolderUnreadCountChanged();
    }
}
/*!
    Equal operator returns true if all values are same,
    function is case insensitive
 */
bool NmMessageEnvelope::operator==(const NmMessageEnvelope &envelope) const
{
    NM_FUNCTION;
    
    bool ret = false;
    if (0 == subject().compare(envelope.subject(), Qt::CaseInsensitive)
        && sender() == envelope.sender()
        && sentTime() == envelope.sentTime()
        && flags() == envelope.flags()
        && mailboxId() == envelope.mailboxId()
        && folderId() == envelope.folderId()) {
        ret = true;
    }
    return ret;
}
Пример #8
0
void OcFeedsModelNew::folderMarkedRead(const int &id)
{
    if (id == folderId()) {

        QLOG_INFO() << "Feeds model: marking whole folder as read";

        for (int i = 0; i < rowCount(); ++i) {

            m_items.at(i)->unreadCount = 0;
        }

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
        emit dataChanged(index(0), index(rowCount()-1), QVector<int>(1, UnreadCountRole));
#else
        emit dataChanged(index(0), index(rowCount()-1));
#endif
    }
}
Пример #9
0
QMessageFolderId QMessagePrivate::standardFolderId(QMessage::StandardFolder folder)
{
    StandardFolderMap::const_iterator it = standardFolderMap()->find(folder);
    if (it == standardFolderMap()->end()) {
        const char *path((folder == QMessage::InboxFolder ? "Inbox" : 
                         (folder == QMessage::OutboxFolder ? "Outbox" : 
                         (folder == QMessage::DraftsFolder ? "Drafts" : 
                         (folder == QMessage::SentFolder ? "Sent" : 
                         (folder == QMessage::TrashFolder ? "Trash" : ""))))));

        // Find the ID for this standard folder
        QMessageFolderFilter pathFilter(QMessageFolderFilter::byPath(path));
        QMessageFolderFilter accountFilter(QMessageFolderFilter::byParentAccountId(QMessageAccountId()));

        QMessageFolderId folderId(QMessageManager().queryFolders(pathFilter & accountFilter).first());
        it = standardFolderMap()->insert(folder, folderId);
    }

    return *it;
}
Пример #10
0
void OcFeedsModelNew::queryAndSetTotalUnread()
{
    int idx = findIndex(folderId(), 1);

    if (idx == -999)
        return;

    QSqlQuery query;

    if (!query.exec(QString("SELECT localUnreadCount FROM folders WHERE id = %1").arg(folderId()))) {
        QLOG_ERROR() << "Feeds model: failed to select folder unread count from database: " << query.lastError().text();
    }

    query.next();

    m_items.at(idx)->unreadCount = query.value(0).toInt();

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    emit dataChanged(index(idx), index(idx), QVector<int>(1, UnreadCountRole));
#else
    emit dataChanged(index(idx), index(idx));
#endif

}
Пример #11
0
QMailMessageKey ActionFolderMessageSet::messageKey() const
{
    return contentKey(folderId());
}
Пример #12
0
void QMessagePrivate::setStandardFolder(QMessage& message, QMessage::StandardFolder sf)
{
    QMessageFolderId folderId(standardFolderId(sf));
    message.d_ptr->_message.setParentFolderId(QmfHelpers::convert(folderId));
}
QMailMessageKey EmailFolderMessageSet::messageKey() const
{
    return contentKey(folderId(), false);
}
QMailMessageKey EmailFolderMessageSet::descendantsMessageKey() const
{
    return contentKey(folderId(), true);
}
Пример #15
0
void OcFeedsModelNew::feedsRequested(const QList<int> &updated, const QList<int> &newFeeds, const QList<int> &deleted)
{
    if (updated.isEmpty() && newFeeds.isEmpty() && deleted.isEmpty())
        return;

    QSqlQuery query;

    if (!updated.isEmpty()) {

        QLOG_INFO() << "Feeds model: updating changed feeds";

        for (int i = 0; i < updated.size(); ++i)
        {
            int idx = findIndex(updated.at(i), 0);

            if (!query.exec(QString("SELECT title, iconSource, iconWidth, iconHeight, folderId, localUnreadCount, FROM feeds WHERE id = %1").arg(updated.at(i)))) {
                QLOG_ERROR() << "Feeds model: failed to select data for changed feeds from database: " << query.lastError().text();
            }

            query.next();

            int fId = query.value(4).toInt();

            // check if updated feed is still child of these folder
            if ((idx != -999) && (fId == folderId())) {

                QLOG_DEBUG() << "Feeds model: updating feed at index " << idx;

                m_items.at(i)->title = query.value(0).toString();
                m_items.at(i)->iconSource = query.value(1).toString();
                m_items.at(i)->iconWidth = query.value(2).toInt();
                m_items.at(i)->iconHeight = query.value(3).toInt();

                QVector<int> roles(1, TitleRole);
                roles.append(IconSourceRole);
                roles.append(IconWidthRole);
                roles.append(IconHeightRole);

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
                emit dataChanged(index(idx), index(idx), roles);
#else
                emit dataChanged(index(idx), index(idx));
#endif
            } else if ((idx != -999) && (fId != folderId())) {

                // the updated feed is no longer child of these folder

                QLOG_DEBUG() << "Feeds model: removing feed at index " << idx << " because it is no longer child of this folder";

                beginRemoveRows(QModelIndex(), idx, idx);

                delete m_items.takeAt(i);

                endRemoveRows();
            } else if ((idx == -999) && (fId == folderId())) {

                // the feed has been moved to this folder

                QLOG_DEBUG() << "Feeds model: adding feed that has been moved to this folder";

                beginInsertRows(QModelIndex(), rowCount(), rowCount());

                OcFeedObject *fobj = new OcFeedObject(updated.at(i),
                                                      0,
                                                      query.value(0).toString(),
                                                      query.value(5).toInt(),
                                                      query.value(1).toString(),
                                                      query.value(2).toInt(),
                                                      query.value(3).toInt());
                m_items.append(fobj);

                endInsertRows();
            }
        }
    }


    if (!newFeeds.isEmpty()) {

        QString feedList("(");
        for (int i = 0; i < newFeeds.size(); ++i) {
            feedList.append(QString::number(newFeeds.at(i)));
            feedList.append(", ");
        }
        feedList.chop(2);
        feedList.append(")");

        int length = 0;

        if (!query.exec(QString("SELECT COUNT(id) FROM feeds WHERE folderId = %1 AND id IN %2").arg(folderId()).arg(feedList))) {
            QLOG_ERROR() << "Feeds model: failed to select count of new feeds in this folder from database: " << query.lastError().text();
        }

        query.next();

        length = query.value(0).toInt();

        if (length > 0) {

            QLOG_INFO() << "Feeds model: adding new feeds";

            if (!query.exec(QString("SELECT id, title, localUnreadCount, iconSource, iconWidth, iconHeight WHERE folderId = %1 AND id IN %2").arg(folderId()).arg(feedList))) {
                QLOG_ERROR() << "Feeds model: failed to select data for newly added feeds from database: " << query.lastError().text();
            }

            beginInsertRows(QModelIndex(), rowCount(), (rowCount() + length - 1));

            while(query.next()) {

                OcFeedObject *fobj = new OcFeedObject(query.value(0).toInt(),
                                                      0,
                                                      query.value(1).toString(),
                                                      query.value(2).toInt(),
                                                      query.value(3).toString(),
                                                      query.value(4).toInt(),
                                                      query.value(5).toInt());
                m_items.append(fobj);
            }

            endInsertRows();

            endInsertRows();
        }
    }


    if (!deleted.isEmpty()) {

        for (int i = 0; i < deleted.size(); ++i) {

            int idx = findIndex(deleted.at(i), 0);

            if (idx != -999) {

                QLOG_INFO() << "Feeds model: removing deleted feed at index " << idx;

                beginRemoveRows(QModelIndex(), idx, idx);

                delete m_items.takeAt(idx);

                endRemoveRows();
            }
        }
    }

    queryAndSetTotalUnread();
}
Пример #16
0
void OcFeedsModelNew::init()
{
    QLOG_INFO() << "Initializing feeds model";

    if (!m_items.isEmpty())
        clear(false);

    QSqlQuery query;

    int length = 1;

    QString querystring(QString("SELECT COUNT(id) FROM feeds WHERE folderId = %1").arg(folderId()));

    if (!query.exec(querystring)) {
        QLOG_ERROR() << "Feeds mode: failed to select feeds count from database: " << query.lastError().text();
    }

    query.next();

    length += query.value(0).toInt();

    querystring = QString("SELECT %1 AS id, 1 AS type, '%2' AS title, (SELECT localUnreadCount FROM folders WHERE id = %1) AS unreadCount, '' AS iconSource, '' AS iconWidth, '' AS iconHeight ").arg(folderId()).arg(tr("All posts"));

    if (length > 1) {

        querystring.append("UNION ");

        querystring.append(QString("SELECT id, 0 AS type, title, localUnreadCount AS unreadCount, iconSource, iconWidth, iconHeight FROM feeds WHERE folderId = %1 ").arg(folderId()));

    }

    querystring.append("ORDER BY type DESC");

    if (!query.exec(querystring)) {
        QLOG_ERROR() << "Feeds mode: failed to select feeds from database: " << query.lastError().text();
    }

    beginInsertRows(QModelIndex(), 0, length-1);

    while(query.next())
    {
        OcFeedObject *fobj = new OcFeedObject(query.value(0).toInt(),
                                              query.value(1).toInt(),
                                              query.value(2).toString(),
                                              query.value(3).toInt(),
                                              query.value(4).toString(),
                                              query.value(5).toInt(),
                                              query.value(6).toInt());
        m_items.append(fobj);
    }

    endInsertRows();
}
Пример #17
0
void OcFeedsModelNew::itemsMarked()
{
    if (rowCount() < 2)
        return;

    QLOG_INFO() << "Feeds model: update unread count";

    QHash<int, int> idsAndUnread;

    QSqlQuery query;

    if (!query.exec(QString("SELECT id, localUnreadCount FROM feeds WHERE folderId = %1").arg(folderId()))) {
        QLOG_ERROR() << "Feeds model: failed to select feeds data from database: " << query.lastError().text();
    }

    while(query.next()) {
        idsAndUnread[query.value(0).toInt()] = query.value(1).toInt();
    }

    for (int i = 0; i < rowCount(); ++i) {

        if (m_items.at(i)->type == 0) {
            if (m_items.at(i)->unreadCount != idsAndUnread[m_items.at(i)->id]) {

                m_items.at(i)->unreadCount = idsAndUnread[m_items.at(i)->id];

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
                emit dataChanged(index(i), index(i), QVector<int>(1, UnreadCountRole));
#else
                emit dataChanged(index(i), index(i));
#endif
            }
        }
    }

    queryAndSetTotalUnread();
}