bluetoothengine/btnotif/btdevicedialogplugin/src/btsenddialogwidget.cpp
changeset 67 16e4b9007960
parent 57 5ebadcda06cb
child 70 f5508c13dfe0
equal deleted inserted replaced
65:001a94c71129 67:16e4b9007960
     1 /*
     1 /*
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of "Eclipse Public License v1.0""
     5  * under the terms of "Eclipse Public License v1.0""
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14  * Description:  
    14  * Description:  
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 #include "btsenddialogwidget.h"
    18 #include "btsenddialogwidget.h"
    19 #include <hblabel.h>
    19 #include "btdevicedialogpluginerrors.h"
    20 #include <hblistview.h>
       
    21 #include <hbtoolbar.h>
       
    22 #include <hblistwidget.h>
       
    23 #include <qstandarditemmodel.h>
       
    24 #include <hbaction.h>
       
    25 
    20 
    26 
    21 
    27 #define LOC_SENDING_FILES_TO_DEVICE hbTrId("txt_bt_title_sending_file_l1l2_to_3")
    22 #define LOC_SENDING_FILES_TO_DEVICE hbTrId("txt_bt_title_sending_file_l1l2_to_3")
    28 
    23 
    29 const char* DOCML_BT_SEND_DIALOG = ":/docml/bt-send-dialog.docml";
    24 const char* DOCML_BT_SEND_DIALOG = ":/docml/bt-send-dialog.docml";
    30 
    25 
    31 BTSendDialogWidget::BTSendDialogWidget(const QVariantMap &parameters)
    26 BTSendDialogWidget::BTSendDialogWidget(const QVariantMap &parameters)
    32 {
    27 {
    33     mLoader = 0;
    28     mLoader = 0;
       
    29     mLastError = NoError;
    34     constructDialog(parameters);
    30     constructDialog(parameters);
    35 }
    31 }
    36 
    32 
    37 BTSendDialogWidget::~BTSendDialogWidget()
    33 BTSendDialogWidget::~BTSendDialogWidget()
    38 {
    34 {
    39     delete mLoader;
    35     delete mLoader;
    40  /*   if(mContentItemModel)
       
    41         {
       
    42         delete mContentItemModel;
       
    43         mContentItemModel = NULL;
       
    44         }*/
       
    45 }
    36 }
    46 
    37 
    47 bool BTSendDialogWidget::setDeviceDialogParameters(const QVariantMap &parameters)
    38 bool BTSendDialogWidget::setDeviceDialogParameters(const QVariantMap &parameters)
    48 {
    39 {
       
    40 	mLastError = NoError;
    49     if(mFileIndex != parameters.value("currentFileIdx").toString().toInt() )
    41     if(mFileIndex != parameters.value("currentFileIdx").toString().toInt() )
    50     {
    42     {
    51         mDialogHeading->setTextWrapping(Hb::TextWordWrap);
    43         mDialogHeading->setTextWrapping(Hb::TextWordWrap);
    52         mDialogHeading->setAlignment(Qt::AlignHCenter);
    44         mDialogHeading->setAlignment(Qt::AlignHCenter);
    53         //Todo - replace this with the actual text from parameters
       
    54     
    45     
    55         QString headLabel = QString(LOC_SENDING_FILES_TO_DEVICE).arg(parameters.value("currentFileIdx").toInt())
    46         QString headLabel = QString(LOC_SENDING_FILES_TO_DEVICE).arg(parameters.value("currentFileIdx").toInt())
    56                                         .arg(parameters.value("totalFilesCnt").toInt())
    47                                         .arg(parameters.value("totalFilesCnt").toInt())
    57                                         .arg(parameters.value("destinationName").toString());
    48                                         .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);
    49         mDialogHeading->setPlainText(headLabel);
    65         
    50         
    66  /*       QStringList info;
    51         //Todo - Insert file icons here instead of bluetooth image        
    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"));        
    52         QIcon icon(QString(":/icons/qtg_large_bluetooth.svg"));        
    85         mFileIconLabel->setIcon(icon);
    53         mFileIconLabel->setIcon(icon);
    86         mFileNameLabel->setPlainText(parameters.value("fileName").toString());
    54         mFileNameLabel->setPlainText(parameters.value("fileName").toString());
    87         mFileSizeLabel->setPlainText(parameters.value("fileSzTxt").toString());
    55         mFileSizeLabel->setPlainText(parameters.value("fileSzTxt").toString());
    88         mProgressBar->setMinimum(0);
    56         mProgressBar->setMinimum(0);
    97     return true;
    65     return true;
    98 }
    66 }
    99 
    67 
   100 int BTSendDialogWidget::deviceDialogError() const
    68 int BTSendDialogWidget::deviceDialogError() const
   101 {
    69 {
   102     return 0;
    70     return mLastError;
   103 }
    71 }
   104 
    72 
   105 void BTSendDialogWidget::closeDeviceDialog(bool byClient)
    73 void BTSendDialogWidget::closeDeviceDialog(bool byClient)
   106 {
    74 {
   107     Q_UNUSED(byClient);
    75     Q_UNUSED(byClient);
   118 QObject *BTSendDialogWidget::signalSender() const
    86 QObject *BTSendDialogWidget::signalSender() const
   119 {
    87 {
   120     return const_cast<BTSendDialogWidget*>(this);
    88     return const_cast<BTSendDialogWidget*>(this);
   121 }  
    89 }  
   122 
    90 
   123 bool BTSendDialogWidget::constructDialog(const QVariantMap&/*parameters*/)
    91 void BTSendDialogWidget::constructDialog(const QVariantMap& parameters)
   124 {
    92 {
       
    93 		Q_UNUSED(parameters);
   125     mLoader = new HbDocumentLoader();
    94     mLoader = new HbDocumentLoader();
   126     bool ok = false;
    95     bool ok = false;
   127     
    96     
   128     mLoader->load(DOCML_BT_SEND_DIALOG, &ok);
    97     mLoader->load(DOCML_BT_SEND_DIALOG, &ok);
   129     if(ok)
    98     if(ok)
   131         mSendDialog = qobject_cast<HbDialog*>(mLoader->findWidget("sendProgressDialog"));
   100         mSendDialog = qobject_cast<HbDialog*>(mLoader->findWidget("sendProgressDialog"));
   132         mDialogHeading = qobject_cast<HbLabel*>(mLoader->findWidget("sendDialogHeading"));
   101         mDialogHeading = qobject_cast<HbLabel*>(mLoader->findWidget("sendDialogHeading"));
   133         mFileIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileIcon"));
   102         mFileIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileIcon"));
   134         mFileNameLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileName"));
   103         mFileNameLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileName"));
   135         mFileSizeLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileSize"));
   104         mFileSizeLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileSize"));
   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          
   105          
   144         mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("sendProgressBar"));
   106         mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("sendProgressBar"));
   145                 
   107 		    mSendDialog->setBackgroundFaded(false);
   146    //     HbAction* hide = new HbAction("Hide");
   108 		    mSendDialog->setDismissPolicy(HbPopup::NoDismiss);
   147      //   HbAction* cancel = new HbAction("Cancel");
   109 		    mSendDialog->setTimeout(HbPopup::NoTimeout);
   148         
   110 		    mSendDialog->setAttribute(Qt::WA_DeleteOnClose);
   149     //    this->addAction(hide);
   111 		    
   150   //      this->addAction(cancel);
   112 		    mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelAction" ) );
   151         
   113 		    
   152   //      QGraphicsWidget *widget = mLoader->findWidget(QString("container"));
   114 		    connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked()));
   153    //     this->setContentWidget(widget);
       
   154     }
   115     }
   155 
   116     else
   156     mSendDialog->setBackgroundFaded(false);
   117     	{
   157     mSendDialog->setDismissPolicy(HbPopup::NoDismiss);
   118 			mLastError = DocMLLoadingError;    		
   158     mSendDialog->setTimeout(HbPopup::NoTimeout);
   119     	}
   159     mSendDialog->setAttribute(Qt::WA_DeleteOnClose);
       
   160     
       
   161     mHideAction = static_cast<HbAction*>( mLoader->findObject( "hideAction" ) );
       
   162     mHideAction->disconnect(mSendDialog);  // Todo:  needed?
       
   163     
       
   164     mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelAction" ) );
       
   165     mCancelAction->disconnect(mSendDialog); // Todo:  needed?
       
   166     
       
   167     connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked()));
       
   168 
       
   169     return true;
       
   170 }
   120 }
   171 
   121 
   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 
   122 
   190 void BTSendDialogWidget::cancelClicked()
   123 void BTSendDialogWidget::cancelClicked()
   191 {
   124 {
   192     mSendDialog->close();
   125     mSendDialog->close();
   193     emit deviceDialogClosed();
   126     emit deviceDialogClosed();
   194 }
   127 }
   195 
   128 
   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 
   129