homescreenapp/hsdomainmodel/src/hsdbupdatethread.cpp
changeset 101 ba1b7e218624
equal deleted inserted replaced
98:e6f74eb7f69f 101:ba1b7e218624
       
     1 /*
       
     2 * Copyright (c) 2009 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 "hsdbupdatethread.h"
       
    19 #include "hsdatabase.h"
       
    20 #include "hsdomainmodeldatastructures.h"
       
    21 
       
    22 
       
    23 HsDbUpdateThread *HsDbUpdateThread::mInstance = 0;
       
    24 
       
    25 /*!
       
    26     \class HsDbUpdateThread
       
    27     \ingroup group_hsdomainmodel
       
    28     \brief 
       
    29 */
       
    30 
       
    31 /*!
       
    32     Constructs a new asynchronous database object with the given \a connectionName, 
       
    33     \a databaseName and a \a parent object.
       
    34 */
       
    35 HsDbUpdateThread::HsDbUpdateThread(
       
    36     const QString &connectionName, 
       
    37     const QString &databaseName, 
       
    38     QObject *parent):
       
    39     QThread(parent),mConnectionName(connectionName),mDatabaseName(databaseName)
       
    40 {
       
    41     
       
    42 }
       
    43 /*!
       
    44     Destructor
       
    45 */
       
    46 HsDbUpdateThread::~HsDbUpdateThread()
       
    47 {
       
    48     quit();
       
    49 }
       
    50 /*!
       
    51     Destructor
       
    52 */
       
    53 HsDbUpdateThread *HsDbUpdateThread::instance()
       
    54 {
       
    55     return mInstance;
       
    56 }
       
    57 /*!
       
    58     Set \a instance in place.
       
    59 */
       
    60 void HsDbUpdateThread::setInstance(HsDbUpdateThread *instance)
       
    61 {
       
    62     delete mInstance;
       
    63     mInstance = instance;
       
    64 }
       
    65 /*!
       
    66     Update given \a data widgets zvalues for passed \a orientation
       
    67 */
       
    68 void HsDbUpdateThread::slotUpdateWidgetZValues(const QHash<int, qreal> &data, Qt::Orientation orientation)
       
    69 {
       
    70     emit updateWidgetZValues(data,orientation);
       
    71 }
       
    72 #ifdef COVERAGE_MEASUREMENT
       
    73 #pragma CTC SKIP
       
    74 #endif //COVERAGE_MEASUREMENT
       
    75 /*!
       
    76     Initialize database
       
    77 */
       
    78 void HsDbUpdateThread::run()
       
    79 {
       
    80     HsDatabase db;
       
    81     db.setConnectionName(mConnectionName);
       
    82     db.setDatabaseName(mDatabaseName);
       
    83     db.open();
       
    84     qRegisterMetaType< QHash<int, qreal> >("QHash<int, qreal>");
       
    85     qRegisterMetaType< Qt::Orientation >("Qt::Orientation");
       
    86     connect(this, SIGNAL(updateWidgetZValues(QHash<int, qreal>, Qt::Orientation)),
       
    87         &db, SLOT(updateWidgetZValues(QHash<int, qreal>, Qt::Orientation)));
       
    88     
       
    89     exec();
       
    90 }
       
    91 #ifdef COVERAGE_MEASUREMENT
       
    92 #pragma CTC ENDSKIP
       
    93 #endif //COVERAGE_MEASUREMENT
       
    94 
       
    95