Example #1
0
void HostipRunner::search( const QString &searchTerm, const GeoDataLatLonBox & )
{
    if( !searchTerm.contains('.') ) {
        // Simple IP/hostname heuristic to avoid requests not needed:
        // String must contain at least one dot.
        slotNoResults();
    }
    else {
        QEventLoop eventLoop;

        QTimer timer;
        timer.setSingleShot( true );
        timer.setInterval( 15000 );

        connect( &timer, SIGNAL(timeout()),
                 &eventLoop, SLOT(quit()));
        connect( this, SIGNAL(searchFinished(QVector<GeoDataPlacemark*>)),
                 &eventLoop, SLOT(quit()) );

        // Lookup the IP address for a hostname, or the hostname if an IP address was given
        QHostInfo ::lookupHost( searchTerm, this, SLOT(slotLookupFinished(QHostInfo)));
        timer.start();

        eventLoop.exec();
    }
}
Example #2
0
void HostipRunner::search( const QString &searchTerm )
{
    if( !searchTerm.contains('.') ) {
        // Simple IP/hostname heuristic to avoid requests not needed:
        // String must contain at least one dot.
        slotNoResults();
    }
    else {
        // Lookup the IP address for a hostname, or the hostname if an IP address was given
        QHostInfo ::lookupHost( searchTerm, this, SLOT(slotLookupFinished(QHostInfo)));
    }
}