Exemple #1
0
QList<BookmarkMatch> Opera::match( const QString& term, bool addEverything )
{
    QList<BookmarkMatch> matches;

    QLatin1String nameStart("\tNAME=");
    QLatin1String urlStart("\tURL=");
    QLatin1String descriptionStart("\tDESCRIPTION=");

    // search
    foreach (const QString & entry, m_operaBookmarkEntries) {
        QStringList entryLines = entry.split(QStringLiteral("\n"));
        if (!entryLines.first().startsWith(QStringLiteral("#URL"))) {
            continue; // skip folder entries
        }
        entryLines.pop_front();

        QString name;
        QString url;
        QString description;

        foreach (const QString & line, entryLines) {
            if (line.startsWith(nameStart)) {
                name = line.mid( QString(nameStart).length() ).simplified();
            } else if (line.startsWith(urlStart)) {
                url = line.mid( QString(urlStart).length() ).simplified();
            } else if (line.startsWith(descriptionStart)) {
                description = line.mid(QString(descriptionStart).length())
                              .simplified();
            }
        }
        
        BookmarkMatch bookmarkMatch(m_favicon, term, name, url, description);
        bookmarkMatch.addTo(matches, addEverything);
    }
Exemple #2
0
fpPair readLine()
{
        fpPair pair;

        pair.fp = malloc( sizeof(pair.fp) );
        pair.name = malloc( sizeof(pair.name) ); 
        char *buffer = malloc( bufferSize * sizeof( char ) );      
        int fpEnd;



        fgets( buffer, bufferSize, stdin );

        if(feof(stdin))         // prevent the reading in of a blank line
        {
                free (pair.name);
                free (pair.fp);
                free (buffer);
                return pair;
        }

        fpEnd = Str_find( buffer, 1, 0 , " ");
        pair.fp = Str_dup( buffer, 1, fpEnd, 1 );
        pair.name = Str_dup( buffer, nameStart( buffer, fpEnd ), 0 , 1);

        free (buffer);
        return pair;



}