|         |      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 "fbpropertiesdialog.h" | 
|         |     19  | 
|         |     20 #include <HbListWidget> | 
|         |     21 #include <HbAction> | 
|         |     22 #include <HbLabel> | 
|         |     23 #include <HbMarqueeItem> | 
|         |     24 #include <HbColorScheme> | 
|         |     25  | 
|         |     26 #include <QSizePolicy> | 
|         |     27 #include <QGraphicsGridLayout> | 
|         |     28  | 
|         |     29 /** | 
|         |     30   * Constructor | 
|         |     31   */ | 
|         |     32 FbPropertiesDialog::FbPropertiesDialog(QGraphicsItem *parent) : | 
|         |     33         HbDialog(parent), | 
|         |     34         mTitle(0), | 
|         |     35         mGridLayout(0) | 
|         |     36 { | 
|         |     37     setAttribute(Qt::WA_DeleteOnClose); | 
|         |     38     setDismissPolicy(HbPopup::TapOutside); | 
|         |     39     setTimeout(HbPopup::NoTimeout); | 
|         |     40  | 
|         |     41     createHeading(); | 
|         |     42     createContentWidget(); | 
|         |     43     createToolBar(); | 
|         |     44 } | 
|         |     45  | 
|         |     46 /** | 
|         |     47   * Destructor | 
|         |     48   */ | 
|         |     49 FbPropertiesDialog::~FbPropertiesDialog() | 
|         |     50 { | 
|         |     51 } | 
|         |     52  | 
|         |     53 /** | 
|         |     54   * Set \a title into heading widget label | 
|         |     55   */ | 
|         |     56 void FbPropertiesDialog::setTitle(const QString &title) | 
|         |     57 { | 
|         |     58     mTitle->setText(title); | 
|         |     59 } | 
|         |     60  | 
|         |     61 /** | 
|         |     62   * Fill content list with property list \a propertyList | 
|         |     63   */ | 
|         |     64 void FbPropertiesDialog::setProperties(const QVector<QPair<QString, QString> > &properties) | 
|         |     65 { | 
|         |     66     QString previousProperty(""); | 
|         |     67     QPair<QString, QString> propertyPair; | 
|         |     68     HbLabel *propertyNameLabel; | 
|         |     69     HbLabel *propertyValueLabel; | 
|         |     70     for (int i(0), ie(properties.count()); i < ie; ++i) | 
|         |     71     { | 
|         |     72         propertyPair = properties.at(i); | 
|         |     73         propertyNameLabel = new HbLabel(); | 
|         |     74         if (propertyPair.first != previousProperty) { | 
|         |     75             propertyNameLabel->setPlainText(propertyPair.first); | 
|         |     76             propertyNameLabel->setElideMode(Qt::ElideNone); | 
|         |     77             propertyNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); | 
|         |     78         } | 
|         |     79         mGridLayout->addItem(propertyNameLabel, i, 0); | 
|         |     80         previousProperty = propertyPair.first; | 
|         |     81  | 
|         |     82         propertyValueLabel = new HbLabel(); | 
|         |     83         propertyValueLabel->setPlainText(propertyPair.second); | 
|         |     84         propertyValueLabel->setTextWrapping(Hb::TextWrapAnywhere); | 
|         |     85         mGridLayout->addItem(propertyValueLabel, i, 1); | 
|         |     86     } | 
|         |     87 } | 
|         |     88  | 
|         |     89 /** | 
|         |     90   * Create dialog heading widget | 
|         |     91   */ | 
|         |     92 void FbPropertiesDialog::createHeading() | 
|         |     93 { | 
|         |     94     mTitle = new HbMarqueeItem(this); | 
|         |     95     mTitle->setLoopCount(1); | 
|         |     96     connect(this, SIGNAL(aboutToShow()), mTitle, SLOT(startAnimation())); | 
|         |     97  | 
|         |     98     // TODO later check if this is needed, default color is magenta, even if black theme used | 
|         |     99     QColor col = HbColorScheme::color("qtc_textedit_normal"); | 
|         |    100     if (col.isValid()) { | 
|         |    101        mTitle->setTextColor(col); | 
|         |    102     } | 
|         |    103  | 
|         |    104     setHeadingWidget(mTitle); | 
|         |    105 } | 
|         |    106  | 
|         |    107 /** | 
|         |    108   * Create dialog content widget as a grid | 
|         |    109   */ | 
|         |    110 void FbPropertiesDialog::createContentWidget() | 
|         |    111 { | 
|         |    112     mGridLayout = new QGraphicsGridLayout(); | 
|         |    113  | 
|         |    114     QGraphicsWidget *contentWidget = new QGraphicsWidget; | 
|         |    115     contentWidget->setLayout(mGridLayout); | 
|         |    116     setContentWidget(contentWidget); | 
|         |    117 } | 
|         |    118  | 
|         |    119 /** | 
|         |    120   * Create dialog toolbar | 
|         |    121   */ | 
|         |    122 void FbPropertiesDialog::createToolBar() | 
|         |    123 { | 
|         |    124     HbAction *rejectAction = new HbAction(QString("Cancel"), this); | 
|         |    125     addAction(rejectAction); | 
|         |    126 } | 
|         |    127  | 
|         |    128 // End of file |