qcpix/tsrc/samplesearch/samplesearch.cpp
changeset 13 fcb2a58c181b
parent 0 671dee74050a
child 23 d4d56f5e7c55
equal deleted inserted replaced
11:7c6f43cd91cf 13:fcb2a58c181b
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "SampleSearch.h"
    18 #include "SampleSearch.h"
    19 #include "searchhandler.h"
    19 #include "searchhandler.h"
    20 #include <QCPixDocument.h>
    20 #include <cpixdocument.h>
    21 #include <xqservicerequest.h>
    21 #include <xqservicerequest.h>
    22 
    22 
    23 SampleSearch::SampleSearch(QWidget */*parent*/)
    23 SampleSearch::SampleSearch(QWidget */*parent*/)
    24 {
    24 {
    25     iSearchHandler = new CSearchHandler();
    25     iSearchHandler = new CSearchHandler();
    96     setWindowTitle(tr("Search"));
    96     setWindowTitle(tr("Search"));
    97     connect(btnSearch, SIGNAL(clicked()),this, SLOT(doSearch()));
    97     connect(btnSearch, SIGNAL(clicked()),this, SLOT(doSearch()));
    98     connect(btnSearchAsync, SIGNAL(clicked()),this, SLOT(doSearchAsync()));
    98     connect(btnSearchAsync, SIGNAL(clicked()),this, SLOT(doSearchAsync()));
    99     connect(iSearchHandler, SIGNAL(handleSearchResult(int,int)),this, SLOT(onSearchComplete(int,int)));
    99     connect(iSearchHandler, SIGNAL(handleSearchResult(int,int)),this, SLOT(onSearchComplete(int,int)));
   100     connect(iSearchHandler, SIGNAL(handleAsyncSearchResult(int,int)),this, SLOT(onAsyncSearchComplete(int,int)));
   100     connect(iSearchHandler, SIGNAL(handleAsyncSearchResult(int,int)),this, SLOT(onAsyncSearchComplete(int,int)));
   101     connect(iSearchHandler, SIGNAL(handleDocument(int,QCPixDocument*)),this, SLOT(onGetDocumentComplete(int,QCPixDocument*)));
   101     connect(iSearchHandler, SIGNAL(handleDocument(int,CpixDocument*)),this, SLOT(onGetDocumentComplete(int,CpixDocument*)));
   102 }
   102 }
   103 
   103 
   104 SampleSearch::~SampleSearch()
   104 SampleSearch::~SampleSearch()
   105 {
   105 {
   106     delete dataTable;
   106     delete dataTable;
   140     currentRow = 0;
   140     currentRow = 0;
   141     nextDocumentIndex = 0;
   141     nextDocumentIndex = 0;
   142     iSearchHandler->getDocumentAsyncAtIndex( nextDocumentIndex++ );
   142     iSearchHandler->getDocumentAsyncAtIndex( nextDocumentIndex++ );
   143     }
   143     }
   144 
   144 
   145 void SampleSearch::onGetDocumentComplete(int aError, QCPixDocument* aDoc)
   145 void SampleSearch::onGetDocumentComplete(int aError, CpixDocument* aDoc)
   146     {
   146     {
   147     if( aDoc == NULL ) return;
   147     if( aDoc == NULL ) return;
   148     addDocumentToResultsPage( aDoc, currentRow++ );
   148     addDocumentToResultsPage( aDoc, currentRow++ );
   149     if( currentRow < noOfItemsPerPage ) 
   149     if( currentRow < noOfItemsPerPage ) 
   150         iSearchHandler->getDocumentAsyncAtIndex( nextDocumentIndex++ );
   150         iSearchHandler->getDocumentAsyncAtIndex( nextDocumentIndex++ );
   291     int rowCount=0;
   291     int rowCount=0;
   292     for(int i =startIndex;i<endIndex;i++)
   292     for(int i =startIndex;i<endIndex;i++)
   293         {
   293         {
   294         if(rowCount<noOfItemsPerPage)
   294         if(rowCount<noOfItemsPerPage)
   295             {
   295             {
   296             QCPixDocument* aSearchDoc = iSearchHandler->getDocumentAtIndex(i);
   296             CpixDocument* aSearchDoc = iSearchHandler->getDocumentAtIndex(i);
   297             addDocumentToResultsPage( aSearchDoc, rowCount );
   297             addDocumentToResultsPage( aSearchDoc, rowCount );
   298             rowCount++;
   298             rowCount++;
   299             }
   299             }
   300         }
   300         }
   301     }
   301     }
   310 public:
   310 public:
   311     QString type;
   311     QString type;
   312     QString docId;
   312     QString docId;
   313 };
   313 };
   314 
   314 
   315 void SampleSearch::addDocumentToResultsPage( QCPixDocument* aSearchDoc, int rowCount )
   315 void SampleSearch::addDocumentToResultsPage( CpixDocument* aSearchDoc, int rowCount )
   316     {
   316     {
   317     QTableWidgetItem *appClassCol = new QTableWidgetItem("Col1");
   317     QTableWidgetItem *appClassCol = new QTableWidgetItem("Col1");
   318     appClassCol->setFlags(Qt::ItemIsEnabled);
   318     appClassCol->setFlags(Qt::ItemIsEnabled);
   319 
   319 
   320     QTableWidgetItem *docuidCol = new QTableWidgetItem("Col2");    
   320     QTableWidgetItem *docuidCol = new QTableWidgetItem("Col2");