コード例 #1
0
ファイル: ocompletion.cpp プロジェクト: opieproject/opie
QString OCompletion::makeCompletion( const QString& string )
{
    if ( myCompletionMode == OGlobalSettings::CompletionNone )
        return QString::null;

    //qDebug( "OCompletion: completing: %s", string );

    d->matches.clear();
    myRotationIndex = 0;
    myHasMultipleMatches = false;
    myLastMatch = myCurrentMatch;

    // in Shell-completion-mode, emit all matches when we get the same
    // complete-string twice
    if ( myCompletionMode == OGlobalSettings::CompletionShell &&
            string == myLastString ) {
        // Don't use d->matches since calling postProcessMatches()
        // on d->matches here would interfere with call to
        // postProcessMatch() during rotation

        findAllCompletions( string, &d->matches, myHasMultipleMatches );
        QStringList l = d->matches.list();
        postProcessMatches( &l );
        emit matches( l );

        if ( l.isEmpty() )
            doBeep( NoMatch );

        return QString::null;
    }

    QString completion;
    // in case-insensitive popup mode, we search all completions at once
    if ( myCompletionMode == OGlobalSettings::CompletionPopup ||
            myCompletionMode == OGlobalSettings::CompletionPopupAuto ) {
        findAllCompletions( string, &d->matches, myHasMultipleMatches );
        if ( !d->matches.isEmpty() )
            completion = d->matches.first();
    }
    else
        completion = findCompletion( string );

    if ( myHasMultipleMatches )
        emit multipleMatches();

    myLastString = string;
    myCurrentMatch = completion;

    postProcessMatch( &completion );

    if ( !string.isEmpty() ) { // only emit match when string != ""
        //qDebug( "OCompletion: Match: %s", completion );
        emit match( completion );
    }

    if ( completion.isNull() )
        doBeep( NoMatch );

    return completion;
}
コード例 #2
0
ファイル: main.c プロジェクト: AmmarkoV/RGBDAcquisition
int processData_ObstacleDetector()
{
  unsigned int DEPTH_RANGE = 10000;
  unsigned char * bev  =0;
  bev = birdsEyeView(colorFrame, depthFrame, colorWidth,colorHeight, 0,DEPTH_RANGE);
  memcpy(colorFrame,bev , colorWidth *colorHeight*3);


  if (bev!=0)
         {
           //if(VIEW_SITUATION) { viewImage("bevFrame",&bevImg);  }
           unsigned int fitScore = FitImageInMask(bev,mask->pixels,mask->width,mask->height);
           fprintf(stderr,"Got a fit of %u\n",fitScore);
           if (fitScore < 9000)
           {
             ++bleeps;
             if (bleeps%10==0) {  doBeep(); }
           }

           free(bev);
           return 1;
        } else
        { fprintf(stderr,"Could not perform a birdseyeview translation\n"); }


  return 0;
}
コード例 #3
0
ファイル: ocompletion.cpp プロジェクト: opieproject/opie
QString OCompletion::previousMatch()
{
    QString completion;
    myLastMatch = myCurrentMatch;

    if ( d->matches.isEmpty() ) {
        findAllCompletions( myLastString, &d->matches, myHasMultipleMatches );
        completion = d->matches.last();
        myCurrentMatch = completion;
        myRotationIndex = 0;
        postProcessMatch( &completion );
        emit match( completion );
        return completion;
    }

    QStringList matches = d->matches.list();
    myLastMatch = matches[ myRotationIndex ];
    if ( myRotationIndex == 1 )
        doBeep( Rotation ); // indicate first item -> rotating

    else if ( myRotationIndex == 0 )
        myRotationIndex = matches.count();

    myRotationIndex--;

    completion = matches[ myRotationIndex ];
    myCurrentMatch = completion;
    postProcessMatch( &completion );
    emit match( completion );
    return completion;
}
コード例 #4
0
ファイル: kcompletion.cpp プロジェクト: Fat-Zer/tdelibs
TQString TDECompletion::nextMatch()
{
    TQString completion;
    myLastMatch = myCurrentMatch;

    if ( d->matches.isEmpty() ) {
        findAllCompletions( myLastString, &d->matches, myHasMultipleMatches );
        completion = d->matches.first();
        myCurrentMatch = completion;
        myRotationIndex = 0;
        postProcessMatch( &completion );
        emit match( completion );
        return completion;
    }

    TQStringList matches = d->matches.list();
    myLastMatch = matches[ myRotationIndex++ ];

    if ( myRotationIndex == matches.count() -1 )
        doBeep( Rotation ); // indicate last matching item -> rotating

    else if ( myRotationIndex == matches.count() )
        myRotationIndex = 0;

    completion = matches[ myRotationIndex ];
    myCurrentMatch = completion;
    postProcessMatch( &completion );
    emit match( completion );
    return completion;
}
コード例 #5
0
QStringList KCompletion::substringCompletion( const QString& string ) const
{
    // get all items in the tree, possibly in sorted order
    bool sorted = (myOrder == Weighted);
    KCompletionMatchesWrapper allItems( sorted );
    extractStringsFromNode( myTreeRoot, QString::null, &allItems, false );

    QStringList list = allItems.list();

    // subStringMatches is invoked manually, via a shortcut, so we should
    // beep here, if necessary.
    if ( list.isEmpty() ) {
        doBeep( NoMatch );
        return list;
    }

    if ( string.isEmpty() ) { // shortcut
        postProcessMatches( &list );
        return list;
    }

    QStringList matches;
    QStringList::ConstIterator it = list.begin();

    for( ; it != list.end(); ++it ) {
        QString item = *it;
        if ( item.find( string, 0, false ) != -1 ) { // always case insensitive
            matches.append( item );
        }
    }

    postProcessMatches( &matches );

    if ( matches.isEmpty() )
        doBeep( NoMatch );

    return matches;
}
コード例 #6
0
ファイル: ocompletion.cpp プロジェクト: opieproject/opie
// tries to complete "string" from the tree-root
QString OCompletion::findCompletion( const QString& string )
{
    QChar ch;
    QString completion;
    const OCompTreeNode *node = myTreeRoot;

    // start at the tree-root and try to find the search-string
    for( uint i = 0; i < string.length(); i++ ) {
        ch = string.at( i );
        node = node->find( ch );

        if ( node )
            completion += ch;
        else
            return QString::null; // no completion
    }

    // Now we have the last node of the to be completed string.
    // Follow it as long as it has exactly one child (= longest possible
    // completion)

    while ( node->childrenCount() == 1 ) {
        node = node->firstChild();
        if ( !node->isNull() )
            completion += *node;
    }
    // if multiple matches and auto-completion mode
    // -> find the first complete match
    if ( node && node->childrenCount() > 1 ) {
        myHasMultipleMatches = true;

        if ( myCompletionMode == OGlobalSettings::CompletionAuto ) {
            myRotationIndex = 1;
            if (myOrder != Weighted) {
                while ( (node = node->firstChild()) ) {
                    if ( !node->isNull() )
                        completion += *node;
                    else
                        break;
                }
            }
            else {
                // don't just find the "first" match, but the one with the
                // highest priority

                const OCompTreeNode* temp_node = 0L;
                while(1) {
                    int count = node->childrenCount();
                    temp_node = node->firstChild();
                    uint weight = temp_node->weight();
                    const OCompTreeNode* hit = temp_node;
                    for( int i = 1; i < count; i++ ) {
                        temp_node = node->childAt(i);
                        if( temp_node->weight() > weight ) {
                            hit = temp_node;
                            weight = hit->weight();
                        }
                    }
                    // 0x0 has the highest priority -> we have the best match
                    if ( hit->isNull() )
                        break;

                    node = hit;
                    completion += *node;
                }
            }
        }

        else
            doBeep( PartialMatch ); // partial match -> beep
    }

    return completion;
}