コード例 #1
0
bool CommentFilterInterface::performLoadRequestImpl(QObject *item,
        SocialNetworkInterface *socialNetwork,
        LoadType loadType)
{
    Q_D(CommentFilterInterface);
    FacebookInterface *facebook = qobject_cast<FacebookInterface *>(socialNetwork);
    if (!facebook) {
        return false;
    }

    SocialNetworkModelInterface *model = qobject_cast<SocialNetworkModelInterface *>(item);
    if (!model) {
        return false;
    }

    QMap<QString, QString> arguments;
    QString query (QUERY);
    bool isPost = model->extraData().value(ISPOST_KEY, d->isPost).toBool();
    int limit = model->extraData().value(LIMIT_KEY, d->limit).toInt();
    QString previousOffset = model->extraData().value(PREVIOUS_OFFSET_CURSOR_KEY, 0).toString();
    QString nextTimestamp = model->extraData().value(NEXT_TIMESTAMP_KEY).toString();

    QString idKey = isPost ? POST_ID_KEY : OBJECT_ID_KEY;

    switch (loadType) {
    case FilterInterface::Load:
        query = query.arg(idKey, d->identifier, QString(), QString::number(limit));
        break;
    case FilterInterface::LoadNext:
        query = query.arg(idKey, d->identifier, QString("AND time > %1 ").arg(nextTimestamp),
                          QString::number(limit));
        break;
    case FilterInterface::LoadPrevious:
        query = query.arg(idKey, d->identifier, QString(),
                          QString("%1,%2").arg(previousOffset, QString::number(limit)));
        break;
    }
    arguments.insert("q", query);

    QVariantMap properties;
    properties.insert(LIMIT_KEY, limit);

    QObject *handle = facebook->get(this, QLatin1String("fql"), QString(), QString(), arguments);
    d->addHandleProperties(handle, properties);
    return d->addHandle(handle, item, socialNetwork, loadType);
}
コード例 #2
0
bool NewsFeedFilterInterface::performLoadRequestImpl(QObject *item,
                                                     SocialNetworkInterface *socialNetwork,
                                                     LoadType loadType)
{
    Q_D(NewsFeedFilterInterface);
    FacebookInterface *facebook = qobject_cast<FacebookInterface *>(socialNetwork);
    if (!facebook) {
        return false;
    }

    SocialNetworkModelInterface *model = qobject_cast<SocialNetworkModelInterface *>(item);
    if (!model) {
        return false;
    }

    QString where;
    switch(d->type) {
    case Home:
        where = WALL_WHERE;
        break;
    case Feed:
        where = QString(FEED_WHERE).arg(d->identifier);
        break;
    }


    QMap<QString, QString> arguments;
    QString query (QUERY);
    if (model->extraData().contains(LAST_TIMESTAMP_KEY)) {
        QString lastTimestamp = model->extraData().value(LAST_TIMESTAMP_KEY).toString();
        query = query.arg(where, QString("AND created_time < %1").arg(lastTimestamp));
    } else {
        query = query.arg(where, QString());
    }

    arguments.insert("q", query);

    QObject *handle = facebook->get(this, QLatin1String("fql"), QString(), QString(), arguments);
    return d->addHandle(handle, item, socialNetwork, loadType);
}