qcpix/tsrc/orbitsearch/testci.cpp
changeset 1 6f2c1c46032b
equal deleted inserted replaced
0:671dee74050a 1:6f2c1c46032b
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtGui>
       
    19 #include <QGraphicsLayout>
       
    20 #include <hbmainwindow.h>
       
    21 #include <hbwidget.h>
       
    22 #include <hbtextedit.h>
       
    23 #include <qsql.h>
       
    24 #include <qsqldatabase.h>
       
    25 #include <qsqlquery.h>
       
    26 #include "testci.h"
       
    27 
       
    28 TestCI::TestCI( )
       
    29 {
       
    30 }
       
    31 
       
    32 TestCI::~TestCI()
       
    33 {
       
    34 
       
    35 }
       
    36 
       
    37 void TestCI::updatedbcontent( HbTextEdit* aHbTextEdit )
       
    38     {
       
    39     QString mConnectionName("cpixcontentinfo.sq");
       
    40     QString mDatabaseName("c:\\Private\\2001f6fb\\cpixcontentinfo.sq");
       
    41 
       
    42     QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", mConnectionName);
       
    43     db.setDatabaseName(mDatabaseName);
       
    44 
       
    45     QSqlQuery query(QSqlDatabase::database(mConnectionName));
       
    46     QString statement = "SELECT * FROM table1";
       
    47 
       
    48     query.prepare(statement);
       
    49     query.exec();
       
    50     QString resultinstring("Database View : \n");
       
    51     resultinstring.append( "ContentName   INS   BLS  \n" );
       
    52     resultinstring.append( "--------------------------------\n" );
       
    53     
       
    54     while (query.next())
       
    55        {
       
    56        QString category_name = query.value(0).toString();
       
    57        int ins = query.value(1).toInt ();
       
    58        int bls = query.value(2).toInt ( );
       
    59        resultinstring  += category_name + "   " +  QString().setNum( ins ) + "   " +QString().setNum( bls ) + "\n";
       
    60        aHbTextEdit->setPlainText ( resultinstring );  
       
    61        }
       
    62     
       
    63     db.close();
       
    64     return;   
       
    65     }
       
    66 
       
    67 void TestCI::doCITest()
       
    68 {
       
    69     //Declare controls
       
    70     HbTextEdit* resultsBox;
       
    71     
       
    72     HbMainWindow *BigScreen = new HbMainWindow();
       
    73     HbWidget *w = new HbWidget;
       
    74     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
       
    75     layout->setOrientation(Qt::Vertical);
       
    76         
       
    77     //Initialize controls    
       
    78     resultsBox = new HbTextEdit;
       
    79     layout->addItem( resultsBox );
       
    80     
       
    81     resultsBox->setReadOnly( true );    
       
    82     
       
    83     updatedbcontent ( resultsBox );
       
    84     
       
    85     w->setLayout( layout );
       
    86     BigScreen->addView ( w );
       
    87     BigScreen->show();    
       
    88 }