logsui/tsrc/logscenrepeditor/src/logscenrepeditorview.cpp
changeset 0 4a5361db8937
child 18 acd4e87b24b4
equal deleted inserted replaced
-1:000000000000 0:4a5361db8937
       
     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 #include <QGraphicsLinearLayout>
       
    18 #include <QDebug>
       
    19 #include <centralrepository.h>
       
    20 #include <hbradiobuttonlist.h>
       
    21 #include <hbpushbutton.h>
       
    22 #include <hbaction.h>
       
    23 #include <hblabel.h>
       
    24 #include <hbapplication.h>
       
    25 #include <LogsDomainCRKeys.h>
       
    26 #include "logscenrepeditorview.h"
       
    27 
       
    28 const QStringList KPredictiveSearchList = (QStringList() 
       
    29         << "Permanently Off" 
       
    30         << "On" 
       
    31         << "Temporarily Off"
       
    32         << "Not defined");
       
    33 
       
    34 LogsCenrepEditorView::LogsCenrepEditorView() 
       
    35     : HbView(0),
       
    36       mList(0),
       
    37       mRepository(0)
       
    38 {
       
    39     qDebug() << "[LOGS_CENREP]-> LogsCenrepEditorView::LogsCenrepEditorView()";
       
    40     this->setTitle("Logs cenrep editor");
       
    41 
       
    42     QT_TRAP_THROWING( mRepository = CRepository::NewL( KCRUidLogs ) );
       
    43 
       
    44     TInt value(-1);
       
    45     TInt err = mRepository->Get( KLogsPredictiveSearch, value );
       
    46     qDebug() << "[LOGS_CENREP]-> mRepository->Get(KLogsPredictiveSearch) value: " << value
       
    47             << ", err: " << err;
       
    48     
       
    49     mList = new HbRadioButtonList(this);    
       
    50     mList->setItems(KPredictiveSearchList);
       
    51     int listCurrentIndex = (err == 0) ? value : KPredictiveSearchList.count()-1;
       
    52     mList->setSelected(listCurrentIndex);
       
    53 
       
    54     HbPushButton* buttonSave = new HbPushButton("Save and Exit", this);
       
    55     buttonSave->setMinimumHeight(60);
       
    56     connect(buttonSave, SIGNAL(clicked()), this, SLOT(saveSettings()));
       
    57     connect(buttonSave, SIGNAL(clicked()), qApp, SLOT(quit()));
       
    58 
       
    59     HbPushButton* buttonExit = new HbPushButton("Exit without saving", this);
       
    60     buttonExit->setMinimumHeight(60);
       
    61     connect(buttonExit, SIGNAL(clicked()), qApp, SLOT(quit()));
       
    62 
       
    63     HbLabel* label = new HbLabel("Predictive search feature", this); 
       
    64     
       
    65     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
       
    66     layout->addItem(label);
       
    67     layout->addItem(mList);
       
    68     layout->addItem(buttonSave);
       
    69     layout->addItem(buttonExit);
       
    70     setLayout(layout);
       
    71 }
       
    72 
       
    73 
       
    74 LogsCenrepEditorView::~LogsCenrepEditorView()
       
    75 {
       
    76     qDebug() << "[LOGS_CENREP]-> LogsCenrepEditorView::~LogsCenrepEditorView()";
       
    77     delete mRepository;
       
    78     qDebug() << "[LOGS_CENREP]<- LogsCenrepEditorView::~LogsCenrepEditorView()";
       
    79 }
       
    80 
       
    81 void LogsCenrepEditorView::saveSettings()
       
    82 {
       
    83     qDebug() << "[LOGS_CENREP]-> LogsCenrepEditorView::saveSettings()";
       
    84     if (mList->selected() < KPredictiveSearchList.count()) {
       
    85         int err = mRepository->Set( KLogsPredictiveSearch, mList->selected() );
       
    86         qDebug() << "[LOGS_CENREP]-> mRepository->Set(KLogsPredictiveSearch), value:"
       
    87                 << mList->selected() << ", err: " << err;
       
    88     } else {
       
    89         qDebug() << "[LOGS_CENREP]-> not saving!!";
       
    90     }
       
    91 
       
    92     qDebug() << "[LOGS_CENREP]<- LogsCenrepEditorView::saveSettings()";
       
    93 }