perfapps/piprofilerui/ui/hb/src/main.cpp
changeset 51 b048e15729d6
parent 26 41ebde60981f
equal deleted inserted replaced
44:5db69f4c3d06 51:b048e15729d6
       
     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 
       
    19 #include <hbapplication.h>
       
    20 #include <hblabel.h>
       
    21 #include <hbmainwindow.h>
       
    22 #include <hbdocumentloader.h>
       
    23 #include <hbview.h>
       
    24 #include "pimainview.h"
       
    25 #include "piprofilerengine.h"
       
    26 #include "notifications.h"
       
    27 #include "pimainwindow.h"
       
    28 
       
    29 // Create custom document loader to be able to use custom views in XML.
       
    30 class PIProfilerDocumentLoader: public HbDocumentLoader
       
    31 {
       
    32 public:
       
    33     virtual QObject *createObject(const QString& type, const QString &name);
       
    34 };
       
    35 
       
    36 int main(int argc, char *argv[])
       
    37 {
       
    38 
       
    39     // Create application and document loader.
       
    40     HbApplication app(argc, argv);
       
    41     PIProfilerDocumentLoader loader;
       
    42 
       
    43     // Create Engine and initialize it
       
    44     PIProfilerEngine engine;
       
    45     if (!engine.init()) {
       
    46         Notifications::showErrorNote(QString("Unable to start PI Profiler engine"));
       
    47         return EXIT_FAILURE;
       
    48     }
       
    49 
       
    50     // create and show main window
       
    51     PIMainWindow mainWindow(&engine, loader, &app);
       
    52     mainWindow.show();
       
    53 
       
    54     return app.exec();
       
    55 }
       
    56 
       
    57 QObject *PIProfilerDocumentLoader::createObject(const QString& type, const QString &name)
       
    58 {
       
    59     // Main view
       
    60     if (type == PIMainView::staticMetaObject.className()) {
       
    61         QObject *object = new PIMainView;
       
    62         object->setObjectName(name);
       
    63         return object;
       
    64     }
       
    65 
       
    66     return HbDocumentLoader::createObject(type, name);
       
    67 }
       
    68