/*!
    Removes a QMailFolder with QMailFolderId \a id from the message store. Also removes any 
    sub-folders of the identified folder, and any messages contained in any of the 
    folders removed.  If \a option is QMailStore::CreateRemovalRecord then removal 
    records will be created for each removed message.
    Returns \c true if the operation completed successfully, \c false otherwise. 
*/
bool QMailStore::removeFolder(const QMailFolderId& id, QMailStore::MessageRemovalOption option)
{
    // Remove the identified folder and any sub-folders
    QMailFolderKey idKey(QMailFolderKey::id(id));
    QMailFolderKey subKey(QMailFolderKey::ancestorFolderIds(id, QMailDataComparator::Includes));

    return removeFolders(idKey | subKey, option);
}
Exemple #2
0
static QString msgSyntaxWarning(const QJsonObject &object, const QString &what)
{
    QString result;
    QTextStream(&result) << "Id " << object.value(idKey()).toInt()
        << " (\"" << object.value(descriptionKey()).toString()
        << "\"): " << what;
    return result;
}
bool QMailMessageListModelPrivate::addMessages(const QMailMessageIdList &ids)
{
    // Are any of these messages members of our display set?
    // Note - we must only consider messages in the set given by (those we currently know +
    // those we have now been informed of) because the database content may have changed between
    // when this event was recorded and when we're processing the signal.
    
    QMailMessageKey idKey(QMailMessageKey::id(_idList + ids));
    QMailMessageIdList newIds(QMailStore::instance()->queryMessages(_key & idKey, _sortKey));

    QList<int> insertIndices;
    QMap<QMailMessageId, int> newPositions;

    int index = 0;
    foreach (const QMailMessageId &id, newIds) {
        newPositions.insert(id, index);
        ++index;
    }
// ---------------------------------------------------------------------------
// Get next available key for ID.
// ---------------------------------------------------------------------------
//
TUint32 CCenRepDatabaseUtil::GetNewIdKeyL()
    {
    RKeyArray keys;
    CleanupClosePushL( keys );
    TUint32 idKey( 0 );

    // Reuse keys which value is KNoEntryId
    TInt err = iRepository->FindEqL( iStartKey, iColMask, KNoEntryId, keys );

    if ( KErrNone == err && 0 < keys.Count() )
        {
        // return id column key from first deleted row
        idKey = keys[0];
        }
    else if ( KErrNotFound == err )
        {
        keys.Close();
        TInt err1 = iRepository->FindL( iStartKey, iColMask, keys );

        if( KErrNone == err1  )
            {
            // return new
            TInt count( keys.Count() );
            idKey = keys[count-1] + 1;
            }
        else if ( KErrNotFound == err1 )
            {
            idKey = iStartKey;
            }
        else
            {
            User::Leave( err1 );
            }
        }
    else
    	{
    	User::Leave( err );
    	}

    CleanupStack::PopAndDestroy( &keys );

    return idKey;
    }