CGoogleSearcher Class Reference

#include <GoogleSearcher.h>

List of all members.

Public Slots

void search (QString searchString=QString())

Signals

void parsedResult (QHash< QString, QString >)
void doParsing (QString rawData)

Public Member Functions

 CGoogleSearcher (QObject *parent=0)
 ~CGoogleSearcher ()
void setSearchString (const QString &searchString)

Private Slots

void searchComplete ()
void parse (QString rawData)

Private Member Functions

bool isImageData (const QString &imageData)
QString fetchDataFromRawChunk (const QString &key, const QString &rawData)

Private Attributes

QWebView * m_pGoogleAJAXapiMedia
int searchResultLabel
QString searchString


Detailed Description

CGoogleSearcher class is responsible creating a query in google image searched API format, execute query, fetch result, parse result and extract only thubnail view URL and original image url.CGoogleSearcher class also does recursive search for the same query so that most of the results can be obtaied. So far 20 iterations are done i.e. 20 times the same query is requested on google image search.

CGoogleSearcher class emit signal for every single search result parsedResult. emited result contains thumbnail view URL and original image URL.

As google image search API is using AJAX. CGoogleSearcher class uses QWebView class object to query over google which fetches the result from it. This feature is available in Qt4.5.x onwards.

Author:
vishwajeet <vishwajeet.dusane@gmail.com>

Constructor & Destructor Documentation

CGoogleSearcher::CGoogleSearcher ( QObject *  parent = 0  ) 

CGoogleSearcher::~CGoogleSearcher (  ) 

References m_pGoogleAJAXapiMedia.


Member Function Documentation

void CGoogleSearcher::setSearchString ( const QString &  searchString  ) 

This function set the new query that will queried to google for images.

Parameters:
searchString query string that need to be queried to google for images

Referenced by CPictureWallMainWindow::startNewGoogleSearch().

void CGoogleSearcher::search ( QString  searchString = QString()  )  [slot]

If called from outside, it will start new search using the passes query string, if the passes parameter is empty then deafault query will be used to start the search

This slot iterate over 20 iteration once started and same query is queried to google image server for more results

Parameters:
searchString 
See also:
setSearchString

References m_pGoogleAJAXapiMedia, and searchResultLabel.

Referenced by searchComplete(), and CPictureWallMainWindow::startNewGoogleSearch().

void CGoogleSearcher::searchComplete (  )  [private, slot]

This slot is called internally when the query result is fetched from the google server.

References doParsing(), m_pGoogleAJAXapiMedia, and search().

Referenced by CGoogleSearcher().

void CGoogleSearcher::parse ( QString  rawData  )  [private, slot]

This slot is called when query result is fetched from the server and raw data need to be parsed. This slot only extracts thumbnail view URL and Original image URL from the raw data. Rest of the data is ignored.

Parameters:
rawData result query data from google server

References fetchDataFromRawChunk(), isImageData(), and parsedResult().

Referenced by CGoogleSearcher().

void CGoogleSearcher::parsedResult ( QHash< QString, QString >   )  [signal]

This signal is emiited for single record found in the searched query result. Record emited by this function is QHash which is key value pair based data. Emited data only contains thumbnail view URL and original image URL

For Example: To access original image URL key is "url" To access thumbnail view URL key is "tbUrl"

Parameters:
 

Referenced by parse().

void CGoogleSearcher::doParsing ( QString  rawData  )  [signal]

This signal is emited when google server has responded with query result.

Parameters:
rawData google server return response for the query

Referenced by CGoogleSearcher(), and searchComplete().

bool CGoogleSearcher::isImageData ( const QString &  imageData  )  [private]

Parameters:
imageData Query result from google server
Returns:
true if the data is valid response from the google server and it contains required information for the searched images

Referenced by parse().

QString CGoogleSearcher::fetchDataFromRawChunk ( const QString &  key,
const QString &  rawData 
) [private]

This function parsed the required key within the raw data or query result from google server

Parameters:
key Key that need to be searched withing raw data
rawData Query response from google server where key needs to be searched
Returns:
value of that key if found else return empty string

Referenced by parse().


Member Data Documentation

Referenced by CGoogleSearcher(), and search().

QString CGoogleSearcher::searchString [private]


The documentation for this class was generated from the following files:

Generated on Mon Apr 27 15:25:35 2009 for PictureWall by  doxygen 1.5.6