qcpix/src/qcpixsearcher.cpp
branchGCC_SURGE
changeset 12 e3bafe42f98a
parent 3 ae3f1779f6da
equal deleted inserted replaced
6:8b3b4d191198 12:e3bafe42f98a
    69     return searcher;
    69     return searcher;
    70     }
    70     }
    71 
    71 
    72 void QCPixSearcher::setDatabase( QString aBaseAppClass )
    72 void QCPixSearcher::setDatabase( QString aBaseAppClass )
    73     {
    73     {
       
    74     QT_TRAP_THROWING( 
    74     TBuf<KMaxStringLength> baseAppClass( aBaseAppClass.utf16() );
    75     TBuf<KMaxStringLength> baseAppClass( aBaseAppClass.utf16() );
    75     QT_TRAP_THROWING( iPvtImpl->iSearcher->OpenDatabaseL( baseAppClass ) );
    76     iPvtImpl->iSearcher->OpenDatabaseL( baseAppClass ) 
       
    77     ); //end of QT_TRAP_THROWING
    76     }
    78     }
    77 
    79 
    78 void QCPixSearcher::setDatabaseAsync( QString aBaseAppClass )
    80 void QCPixSearcher::setDatabaseAsync( QString aBaseAppClass )
    79     {
    81     {
       
    82     QT_TRAP_THROWING( 
    80     TBuf<KMaxStringLength> baseAppClass( aBaseAppClass.utf16() );
    83     TBuf<KMaxStringLength> baseAppClass( aBaseAppClass.utf16() );
    81     QT_TRAP_THROWING( iPvtImpl->iSearcher->OpenDatabaseL( *iPvtImpl, baseAppClass ) );
    84     iPvtImpl->iSearcher->OpenDatabaseL( *iPvtImpl, baseAppClass ) 
       
    85     ); //end of QT_TRAP_THROWING
    82     }
    86     }
       
    87 
       
    88 //The following bit of code is common to two functions - this helps to avoid duplication.
       
    89 //However, macros make debugging difficult - so, if you need to debug, copy the code below
       
    90 //and replace the macro, fix the code and bring the fix back to the macro.
       
    91 #define CREATE_SEARCH_VARS \
       
    92         HBufC* searchString = HBufC::NewL( aSearchString.length() + 1 );                    \
       
    93         TPtrC searchStringPtr( reinterpret_cast<const TUint16*>( aSearchString.utf16() ) ); \
       
    94         searchString->Des().Copy( searchStringPtr );                                        \
       
    95                                                                                             \
       
    96         HBufC* defaultSearchField = HBufC::NewL( aDefaultSearchField.length() + 1 );        \
       
    97         TPtrC aDefaultSearchFieldPtr( reinterpret_cast<const TUint16*>( aDefaultSearchField.utf16() ) );\
       
    98         defaultSearchField->Des().Copy( aDefaultSearchFieldPtr );                           
       
    99 
       
   100 #define DELETE_SEARCH_VARS  \
       
   101         delete searchString;\
       
   102         delete defaultSearchField;
    83 
   103 
    84 int QCPixSearcher::search( QString aSearchString, QString aDefaultSearchField )
   104 int QCPixSearcher::search( QString aSearchString, QString aDefaultSearchField )
    85     {
   105     {
    86     PERF_SEARCH_RESTART_TIMER
   106     PERF_SEARCH_RESTART_TIMER
    87     TBuf<KMaxStringLength> searchString( aSearchString.utf16() );
       
    88     TBuf<KMaxStringLength> defaultSearchField( aDefaultSearchField.utf16() );
       
    89     //ideally would have had just the following single line:
       
    90     //QT_TRAP_THROWING( return iPvtImpl->iSearcher->SearchL( searchString, defaultSearchField ) );
       
    91     //But the RCVT compiler throws up warnings. The following is just to suppress those warnings.
       
    92     int tmp = 0;
   107     int tmp = 0;
    93     QT_TRAP_THROWING( tmp = iPvtImpl->iSearcher->SearchL( searchString, defaultSearchField ) );
   108     QT_TRAP_THROWING(
       
   109         CREATE_SEARCH_VARS;
       
   110         //ideally would have had just the following single line:
       
   111         //QT_TRAP_THROWING( return iPvtImpl->iSearcher->SearchL( searchString, defaultSearchField ) );
       
   112         //But the RCVT compiler throws up warnings. The following is just to suppress those warnings.
       
   113         tmp = iPvtImpl->iSearcher->SearchL( *searchString, *defaultSearchField );
       
   114         DELETE_SEARCH_VARS;
       
   115     ); //QT_TRAP_THROWING
       
   116     
    94     PERF_SEARCH_ENDLOG
   117     PERF_SEARCH_ENDLOG
    95     return tmp;
   118     return tmp;
    96     }
   119     }
    97 
   120 
    98 void QCPixSearcher::searchAsync( QString aSearchString, QString aDefaultSearchField )
   121 void QCPixSearcher::searchAsync( QString aSearchString, QString aDefaultSearchField )
    99     {
   122     {
   100     PERF_TIME_NOW("Async search start")
   123     PERF_TIME_NOW("Async search start")
   101     TBuf<KMaxStringLength> searchString( aSearchString.utf16() );
   124     QT_TRAP_THROWING(
   102     TBuf<KMaxStringLength> defaultSearchField( aDefaultSearchField.utf16() );
   125         CREATE_SEARCH_VARS;
   103     QT_TRAP_THROWING( iPvtImpl->iSearcher->SearchL( *iPvtImpl, searchString, defaultSearchField ) );
   126         iPvtImpl->iSearcher->SearchL( *iPvtImpl, *searchString, *defaultSearchField );
       
   127         DELETE_SEARCH_VARS;
       
   128     ); //QT_TRAP_THROWING
   104     }
   129     }
   105 
   130 
   106 QCPixDocument* QCPixSearcher::getDocument( int aIndex )
   131 QCPixDocument* QCPixSearcher::getDocument( int aIndex )
   107     {
   132     {
   108     PERF_GETDOC_RESTART_TIMER
   133     PERF_GETDOC_RESTART_TIMER