Пример #1
0
//Query online sources for images of the object
void ThumbnailPicker::slotFillList() {    
    //Query Google Image Search:

    QUrlQuery gURL( "http://images.google.com/images?" );
    //Search for the primary name, or longname and primary name
    QString sName = QString("%1 ").arg( Object->name() );
    if ( Object->longname() != Object->name() ) {
        sName = QString("%1 ").arg( Object->longname() ) + sName;
    }
    gURL.addQueryItem( "q", sName ); //add the Google-image query string

    parseGooglePage(gURL.query());
}
Пример #2
0
//Query online sources for images of the object
void ThumbnailPicker::slotFillList() {
    //Preload ImageList with the URLs in the object's ImageList:
    QStringList ImageList( Object->ImageList() );

    //Query Google Image Search:
    KUrl gURL( "http://images.google.com/images" );
    //Search for the primary name, or longname and primary name
    QString sName = QString("%1 ").arg( Object->name() );
    if ( Object->longname() != Object->name() ) {
        sName = QString("%1 ").arg( Object->longname() ) + sName;
    }
    gURL.addQueryItem( "q", sName ); //add the Google-image query string

    //Download the google page and parse it for image URLs
    parseGooglePage( ImageList, gURL.prettyUrl() );

    //Total Number of images to be loaded:
    int nImages = ImageList.count();
    if ( nImages ) {
        ui->SearchProgress->setMinimum( 0 );
        ui->SearchProgress->setMaximum( nImages-1 );
        ui->SearchLabel->setText( i18n( "Loading images..." ) );
    }

    //Add images from the ImageList
    for ( int i=0; i<ImageList.size(); ++i ) {
        QString s( ImageList[i] );
        KUrl u( ImageList[i] );

        if ( u.isValid() ) {
            KIO::StoredTransferJob *j = KIO::storedGet( u, KIO::NoReload, KIO::HideProgressInfo );
            j->setUiDelegate(0);
            connect( j, SIGNAL( result(KJob*) ), SLOT( slotJobResult(KJob*) ) );
        }
    }
}