Esempio n. 1
0
// current strategy: Fetch 100 items per Account
// ATTENTION: This method is const and thus it is not possible to modify
// the _activityLists hash or so. Doesn't make it easier...
bool ActivityListModel::canFetchMore(const QModelIndex& ) const
{
    if( _activityLists.count() == 0 ) return true;

    for(auto i = _activityLists.begin() ; i != _activityLists.end(); ++i) {
        AccountState *ast = i.key();
        if( ast && ast->isConnected() ) {
            ActivityList activities = i.value();
            if( activities.count() == 0 &&
                    ! _currentlyFetching.contains(ast) ) {
                return true;
            }
        }
    }

    return false;
}
// current strategy: Fetch 100 items per Account
bool ActivityListModel::canFetchMore(const QModelIndex& ) const
{
    if( _activityLists.count() == 0 ) return true;

    QMap<AccountState*, ActivityList>::const_iterator i = _activityLists.begin();
    while (i != _activityLists.end()) {
        AccountState *ast = i.key();
        if( !ast->isConnected() ) {
            return false;
        }
        ActivityList activities = i.value();
        if( activities.count() == 0 &&
                ! _currentlyFetching.contains(ast) ) {
            return true;
        }
        ++i;
    }

    return false;
}
Esempio n. 3
0
void ActivityListModel::slotActivitiesReceived(const QVariantMap& json, int statusCode)
{
    auto activities = json.value("ocs").toMap().value("data").toList();

    ActivityList list;
    AccountState* ast = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
    _currentlyFetching.remove(ast);

    foreach( auto activ, activities ) {
        auto json = activ.toMap();

        Activity a;
        a._type = Activity::ActivityType;
        a._accName  = ast->account()->displayName();
        a._id       = json.value("id").toLongLong();
        a._subject  = json.value("subject").toString();
        a._message  = json.value("message").toString();
        a._file     = json.value("file").toString();
        a._link     = json.value("link").toUrl();
        a._dateTime = json.value("date").toDateTime();
        list.append(a);
    }