bluetoothengine/btnotif/btdevicedialogplugin/src/btsenddialogwidget.cpp
branchRCL_3
changeset 22 613943a21004
equal deleted inserted replaced
21:0ba996a9b75d 22:613943a21004
       
     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 "btsenddialogwidget.h"
       
    19 #include <hblabel.h>
       
    20 #include <hblistview.h>
       
    21 #include <hbtoolbar.h>
       
    22 #include <hblistwidget.h>
       
    23 #include <qstandarditemmodel.h>
       
    24 #include <hbaction.h>
       
    25 
       
    26 
       
    27 #define LOC_SENDING_FILES_TO_DEVICE hbTrId("txt_bt_title_sending_file_l1l2_to_3")
       
    28 
       
    29 const char* DOCML_BT_SEND_DIALOG = ":/docml/bt-send-dialog.docml";
       
    30 
       
    31 BTSendDialogWidget::BTSendDialogWidget(const QVariantMap &parameters)
       
    32     {
       
    33     mLoader = 0;
       
    34     constructDialog(parameters);
       
    35     }
       
    36 
       
    37 BTSendDialogWidget::~BTSendDialogWidget()
       
    38     {
       
    39     delete mLoader;
       
    40  /*   if(mContentItemModel)
       
    41         {
       
    42         delete mContentItemModel;
       
    43         mContentItemModel = NULL;
       
    44         }*/
       
    45     }
       
    46 
       
    47 bool BTSendDialogWidget::setDeviceDialogParameters(const QVariantMap &parameters)
       
    48     {
       
    49     if(mFileIndex != parameters.value("currentFileIdx").toString().toInt() )
       
    50         {
       
    51         mDialogHeading->setTextWrapping(Hb::TextWordWrap);
       
    52         mDialogHeading->setAlignment(Qt::AlignHCenter);
       
    53         //Todo - replace this with the actual text from parameters
       
    54     
       
    55         QString headLabel = QString(LOC_SENDING_FILES_TO_DEVICE).arg(parameters.value("currentFileIdx").toInt())
       
    56                                         .arg(parameters.value("totalFilesCnt").toInt())
       
    57                                         .arg(parameters.value("destinationName").toString());
       
    58       /*  headLabel.append(QString("Sending file "));
       
    59         headLabel.append(parameters.value("currentFileIdx").toString());
       
    60         headLabel.append('/');
       
    61         headLabel.append(parameters.value("totalFilesCnt").toString());
       
    62         headLabel.append(QString(" to "));
       
    63         headLabel.append(parameters.value("destinationName").toString());*/
       
    64         mDialogHeading->setPlainText(headLabel);
       
    65         
       
    66  /*       QStringList info;
       
    67         info.append(parameters.value("fileName").toString());
       
    68         info.append(parameters.value("fileSzTxt").toString());
       
    69                     
       
    70         QStandardItem* listitem = new QStandardItem();
       
    71         // parameters.
       
    72         listitem->setData(info, Qt::DisplayRole);
       
    73     
       
    74         //Todo - Insert file icons here thumbnail icon        
       
    75         QIcon icon(QString(":/icons/qtg_large_bluetooth.svg"));
       
    76         listitem->setIcon(icon);
       
    77     
       
    78         delete mContentItemModel;
       
    79         mContentItemModel = new QStandardItemModel(this);
       
    80         mListView->setModel(mContentItemModel);//, prototype);
       
    81     
       
    82         mContentItemModel->appendRow(listitem);*/
       
    83         //Todo - Insert file icons here thumbnail icon        
       
    84         QIcon icon(QString(":/icons/qtg_large_bluetooth.svg"));        
       
    85         mFileIconLabel->setIcon(icon);
       
    86         mFileNameLabel->setPlainText(parameters.value("fileName").toString());
       
    87         mFileSizeLabel->setPlainText(parameters.value("fileSzTxt").toString());
       
    88         mProgressBar->setMinimum(0);
       
    89         mProgressBar->setProgressValue(0);
       
    90         mProgressBar->setMaximum(parameters.value("fileSz").toInt());
       
    91         mFileIndex = parameters.value("currentFileIdx").toString().toInt();
       
    92         }
       
    93     else
       
    94         {
       
    95         mProgressBar->setProgressValue(parameters.value("progressValue").toInt());
       
    96         }
       
    97     return true;
       
    98     }
       
    99 
       
   100 int BTSendDialogWidget::deviceDialogError() const
       
   101     {
       
   102     return 0;
       
   103     }
       
   104 
       
   105 void BTSendDialogWidget::closeDeviceDialog(bool byClient)
       
   106     {
       
   107     Q_UNUSED(byClient);
       
   108     mSendDialog->close();
       
   109 // below redundant call is required because of the api documentation. 
       
   110     emit deviceDialogClosed();
       
   111     }
       
   112 
       
   113 HbPopup* BTSendDialogWidget::deviceDialogWidget() const
       
   114     {
       
   115     return mSendDialog;
       
   116     }
       
   117 
       
   118 QObject *BTSendDialogWidget::signalSender() const
       
   119 {
       
   120     return const_cast<BTSendDialogWidget*>(this);
       
   121 }  
       
   122 
       
   123 bool BTSendDialogWidget::constructDialog(const QVariantMap&/*parameters*/)
       
   124     {
       
   125     mLoader = new HbDocumentLoader();
       
   126     bool ok = false;
       
   127     
       
   128     mLoader->load(DOCML_BT_SEND_DIALOG, &ok);
       
   129     if(ok)
       
   130         {
       
   131         mSendDialog = qobject_cast<HbDialog*>(mLoader->findWidget("senddialog"));
       
   132         mDialogHeading = qobject_cast<HbLabel*>(mLoader->findWidget("heading"));
       
   133         mFileIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileiconlabel"));
       
   134         mFileNameLabel = qobject_cast<HbLabel*>(mLoader->findWidget("filenamelabel"));
       
   135         mFileSizeLabel = qobject_cast<HbLabel*>(mLoader->findWidget("filesizelabel"));
       
   136  //       mSendDialog->setHeadingWidget(mLabel);
       
   137    /*     mListView = qobject_cast<HbListView*>(mLoader->findWidget("listView"));
       
   138         if(mListView)
       
   139             {
       
   140             mContentItemModel = new QStandardItemModel(this);
       
   141             mListView->setModel(mContentItemModel);//, prototype);
       
   142             }*/
       
   143          
       
   144         mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("horizontalProgressBar"));
       
   145                 
       
   146    //     HbAction* hide = new HbAction("Hide");
       
   147      //   HbAction* cancel = new HbAction("Cancel");
       
   148         
       
   149     //    this->addAction(hide);
       
   150   //      this->addAction(cancel);
       
   151         
       
   152   //      QGraphicsWidget *widget = mLoader->findWidget(QString("container"));
       
   153    //     this->setContentWidget(widget);
       
   154         }
       
   155 
       
   156     mSendDialog->setBackgroundFaded(false);
       
   157     mSendDialog->setDismissPolicy(HbPopup::NoDismiss);
       
   158     mSendDialog->setTimeout(HbPopup::NoTimeout);
       
   159     mSendDialog->setAttribute(Qt::WA_DeleteOnClose);
       
   160     
       
   161     mHideAction = static_cast<HbAction*>( mLoader->findObject( "hideaction" ) );
       
   162     mHideAction->disconnect(mSendDialog);
       
   163     
       
   164     mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelaction" ) );
       
   165     mCancelAction->disconnect(mSendDialog);
       
   166     
       
   167     connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked()));
       
   168 
       
   169     return true;
       
   170     }
       
   171 
       
   172 /*void BTSendDialogWidget::hideEvent(QHideEvent *event)
       
   173     {
       
   174     HbDialog::hideEvent(event);
       
   175     emit deviceDialogClosed();
       
   176     }
       
   177 
       
   178 void BTSendDialogWidget::showEvent(QShowEvent *event)
       
   179     {
       
   180     HbDialog::showEvent(event);
       
   181     }*/
       
   182 
       
   183 /*void BTSendDialogWidget::hideClicked()
       
   184     {
       
   185     // TODO
       
   186     this->close();
       
   187     emit deviceDialogClosed();
       
   188     }*/
       
   189 
       
   190 void BTSendDialogWidget::cancelClicked()
       
   191     {
       
   192     mSendDialog->close();
       
   193     emit deviceDialogClosed();
       
   194     }
       
   195 
       
   196 /*void BTSendDialogWidget::inputClosed(HbAction* action)
       
   197     {
       
   198     QVariantMap data;
       
   199      
       
   200     HbDialog *dlg=static_cast<HbDialog*>(sender());
       
   201     if(dlg->actions().first() == action) {
       
   202     } 
       
   203     else if(dlg->actions().at(1) == action) {
       
   204       }
       
   205     }*/
       
   206