emailuis/nmailuiwidgets/src/nmattachmentlistitem.cpp
changeset 20 ecc8def7944a
parent 18 578830873419
child 23 2dc6caa42ec3
equal deleted inserted replaced
18:578830873419 20:ecc8def7944a
    20 static const QString FILE_PATH_WIDGETML = ":nmattachmentlistitem.widgetml";
    20 static const QString FILE_PATH_WIDGETML = ":nmattachmentlistitem.widgetml";
    21 static const QString FILE_PATH_CSS = ":nmattachmentlistitem.css";
    21 static const QString FILE_PATH_CSS = ":nmattachmentlistitem.css";
    22 
    22 
    23 static const int PROGRESSBAR_MIN = 0; 
    23 static const int PROGRESSBAR_MIN = 0; 
    24 static const int PROGRESSBAR_MAX = 100;
    24 static const int PROGRESSBAR_MAX = 100;
    25 static const int PROGRESSBAR_HIDE_COUNTDOWN = 5000;
    25 static const int PROGRESSBAR_HIDE_COUNTDOWN = 500;
    26 static const int LONGPRESS_TIMER = 2000;
    26 static const int LONGPRESS_TIMER = 2000;
    27 
    27 
    28 
    28 
    29 /*!
    29 /*!
    30  @nmailuiwidgets
    30  @nmailuiwidgets
    51       mLongPressedPoint(0,0)
    51       mLongPressedPoint(0,0)
    52 {
    52 {
    53     init( );
    53     init( );
    54 }
    54 }
    55 
    55 
       
    56 /*!
       
    57     Setter for items text color override. This fucntion can be used
       
    58     if theme background is not used and text needs to be shown in diferent color.
       
    59  */
       
    60 void NmAttachmentListItem::setTextColor(const QColor color)
       
    61 {
       
    62     mTextColor=color;
       
    63 }
    56 
    64 
    57 /*!
    65 /*!
    58     Destructor.
    66     Destructor.
    59  */
    67  */
    60 NmAttachmentListItem::~NmAttachmentListItem( )
    68 NmAttachmentListItem::~NmAttachmentListItem( )
    61 {
    69 {
    62     HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML);
    70     HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML);
    63     HbStyleLoader::unregisterFilePath(FILE_PATH_CSS);
    71     HbStyleLoader::unregisterFilePath(FILE_PATH_CSS);
    64 }
       
    65 
       
    66 /*!
       
    67     Set the texts to be displayed in the file name and file size items
       
    68     
    72     
    69  */
    73     delete mTimer;
    70 void NmAttachmentListItem::setTextItems(const QString &fileName, const QString &fileSize)
    74     mTimer = NULL; 
    71 {
    75 }
    72     mFileNameText->setText(fileName);
    76 
    73     mFileSizeText->setText(fileSize);    
    77 /*!
    74 }
    78     Set the text to be displayed in the file name item.
    75 
    79  */
       
    80 void NmAttachmentListItem::setFileNameText(const QString &fileName)
       
    81 {
       
    82     if (mFileNameText){
       
    83         if (mTextColor.isValid()){
       
    84             mFileNameText->setTextColor(mTextColor);
       
    85         }
       
    86         mFileNameText->setTextWrapping(Hb::TextNoWrap);
       
    87         mFileNameText->setText(fileName);    
       
    88     }
       
    89 }
       
    90 
       
    91 /*!
       
    92     Set the text to be displayed in the file size item
       
    93  */
       
    94 void NmAttachmentListItem::setFileSizeText(const QString &fileSize)
       
    95 {
       
    96     if (mFileSizeText){
       
    97         if (mTextColor.isValid()){
       
    98             mFileSizeText->setTextColor(mTextColor);
       
    99         }
       
   100         mFileSizeText->setTextWrapping(Hb::TextNoWrap);
       
   101         mFileSizeText->setText(fileSize);  
       
   102     } 
       
   103 }
    76 
   104 
    77 /*!
   105 /*!
    78     Set the download progress bar value (0-100)%, if value is 0 progress bar is hidden
   106     Set the download progress bar value (0-100)%, if value is 0 progress bar is hidden
    79  */
   107  */
    80 void NmAttachmentListItem::setProgressBarValue(const int value)
   108 void NmAttachmentListItem::setProgressBarValue(const int value)
   157 {
   185 {
   158     NMLOG("NmAttachmentListItem::mousePressEvent");
   186     NMLOG("NmAttachmentListItem::mousePressEvent");
   159 
   187 
   160     mButtonPressed = true;
   188     mButtonPressed = true;
   161     mLongPressedPoint = event->scenePos();
   189     mLongPressedPoint = event->scenePos();
   162     mTimer->start(LONGPRESS_TIMER);
   190     if(mTimer){
       
   191         mTimer->start(LONGPRESS_TIMER);        
       
   192     }
   163 }
   193 }
   164 
   194 
   165 /*!
   195 /*!
   166     \reimp
   196     \reimp
   167  */
   197  */
   168 void NmAttachmentListItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   198 void NmAttachmentListItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   169 {
   199 {
   170     Q_UNUSED(event);
   200     Q_UNUSED(event);
   171     NMLOG("NmAttachmentListItem::mouseReleasedEvent");
   201     NMLOG("NmAttachmentListItem::mouseReleasedEvent");
   172     if ( mButtonPressed ){
   202     if ( mTimer && mButtonPressed ){
   173         emit itemActivated();
   203         emit itemActivated();
   174         mButtonPressed = false;
   204         mButtonPressed = false;
   175         mTimer->stop();
   205         mTimer->stop();
   176     }
   206     }
   177 }
   207 }
   197     //check first if button is not released already
   227     //check first if button is not released already
   198     if ( mButtonPressed ){
   228     if ( mButtonPressed ){
   199         NMLOG("NmAttachmentListItem::longPressedActivated");
   229         NMLOG("NmAttachmentListItem::longPressedActivated");
   200         emit itemLongPressed(mLongPressedPoint);
   230         emit itemLongPressed(mLongPressedPoint);
   201         mButtonPressed = false;
   231         mButtonPressed = false;
   202         mTimer->stop();
   232     }
   203     }
   233 }
   204 }
   234 
   205