Logo Search packages:      
Sourcecode: kchmviewer version File versions  Download package

void CHMFile::GetSearchResults ( const KCHMSearchProgressResults_t &  tempres,
KCHMSearchResults_t &  results,
unsigned int  limit_results = 500 
)

Finalize the search, resolves all the and generate the results.

Parameters:
tempres Temporary search results from SearchWord.
results A string-string hashmap that will hold the results in case of successful search. The keys are the URLs and the values are the page titles.

Definition at line 1245 of file xchmfile.cpp.

References encodeWithCurrentCodec(), m_chmSTRINGS, m_chmURLSTR, KCHMViewWindow::makeURLabsoluteIfNeeded(), and RetrieveObject().

{
      unsigned char combuf [COMMON_BUF_LEN];
      QMap<u_int32_t, u_int32_t> urlsmap;  // used to prevent duplicated urls
      
      for ( unsigned int i = 0; i < tempres.size(); i++ )
      {
            if ( urlsmap.find (tempres[i].urloff) != urlsmap.end() )
                  continue;
            
            urlsmap[tempres[i].urloff] = 1;
            
            KCHMSearchResult res;
            
            if ( RetrieveObject (&m_chmSTRINGS, combuf, tempres[i].titleoff, COMMON_BUF_LEN - 1) != 0 )
            {
                  combuf[COMMON_BUF_LEN - 1] = 0;
                  res.title = encodeWithCurrentCodec ((const char*)combuf);
            }
            else
                  res.title = "Untitled";

            if ( RetrieveObject (&m_chmURLSTR, combuf, tempres[i].urloff + 8, COMMON_BUF_LEN - 1) == 0 )
                  continue;

            combuf[COMMON_BUF_LEN - 1] = 0;
            res.url = KCHMViewWindow::makeURLabsoluteIfNeeded ((const char*) combuf);
            
            results.push_back (res);
            
            if ( --limit_results == 0 )
                  break;
      }
}


Generated by  Doxygen 1.6.0   Back to index