emailuis/nmailuiwidgets/src/nmattachmentlistitem.cpp
changeset 44 c2d07d913565
parent 43 99bcbff212ad
child 56 15bc1d5d6267
equal deleted inserted replaced
43:99bcbff212ad 44:c2d07d913565
    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 = 500;
    25 static const int PROGRESSBAR_HIDE_COUNTDOWN = 500;
    26 
    26 
    27 // Hardcoded file size length. Maximum (999.9 Mb) fits into size field.
       
    28 static const int FILE_SIZE_FIELD_LENGTH = 120;
       
    29 
       
    30 /*!
    27 /*!
    31  @nmailuiwidgets
    28  @nmailuiwidgets
    32  \class NmAttachmentListItem
    29  \class NmAttachmentListItem
    33 
    30 
    34  \brief The NmAttachmentListItem widget provides for showing a single attachment with file size and
    31  \brief The NmAttachmentListItem widget provides for showing a single attachment with file size and
   110         mFileSizeText->setText(fileSize);
   107         mFileSizeText->setText(fileSize);
   111     }
   108     }
   112 }
   109 }
   113 
   110 
   114 /*!
   111 /*!
   115     Set the length of the filename field.
       
   116  */
       
   117 void NmAttachmentListItem::resetFileNameLength(Qt::Orientation orientation)
       
   118 {
       
   119     NM_FUNCTION;
       
   120     
       
   121 	QSizeF reso = screenSize(orientation);
       
   122 	
       
   123 	if (orientation == Qt::Horizontal) {
       
   124         mFileNameText->setPreferredWidth(reso.width() / 2 - FILE_SIZE_FIELD_LENGTH);
       
   125 	}
       
   126 	else {		
       
   127         mFileNameText->setPreferredWidth(reso.width() - FILE_SIZE_FIELD_LENGTH);
       
   128 	}
       
   129 }
       
   130 
       
   131 /*!
       
   132     Set the download progress bar value (0-100)%, if value is 0 progress bar is hidden
   112     Set the download progress bar value (0-100)%, if value is 0 progress bar is hidden
   133  */
   113  */
   134 void NmAttachmentListItem::setProgressBarValue(const int value)
   114 void NmAttachmentListItem::setProgressBarValue(const int value)
   135 {
   115 {
   136     NM_FUNCTION;
   116     NM_FUNCTION;
   231 	    mProgressBar = 0;
   211 	    mProgressBar = 0;
   232 	    repolish();
   212 	    repolish();
   233 	}
   213 	}
   234 }
   214 }
   235 
   215 
   236 
       
   237 /*!
       
   238     This function returns screen size depending on the orientation.
       
   239     Function is copied from NmApplication.
       
   240  */
       
   241 QSize NmAttachmentListItem::screenSize(Qt::Orientation orientation)
       
   242 {
       
   243     NM_FUNCTION;
       
   244     
       
   245     QSize ret(0,0);
       
   246     HbDeviceProfile currentP = HbDeviceProfile::current();
       
   247     HbDeviceProfile altP(currentP.alternateProfileName());
       
   248     QSize curPSize = currentP.logicalSize();
       
   249     QSize altPSize = altP.logicalSize();
       
   250     if (orientation == Qt::Horizontal) {
       
   251         // Get wide profile size in landscape
       
   252         if (curPSize.width() > altPSize.width()) {
       
   253             ret = curPSize;
       
   254         }
       
   255         else{
       
   256             ret = altPSize;
       
   257         }
       
   258     }
       
   259     else {
       
   260         // Get narrow profile size in portrait
       
   261         if (curPSize.width() < altPSize.width()) {
       
   262             ret = curPSize;
       
   263         }
       
   264         else{
       
   265             ret = altPSize;
       
   266         }
       
   267     }
       
   268     return ret;
       
   269 }
       
   270 
   216 
   271 /*!
   217 /*!
   272     This function handles gestures
   218     This function handles gestures
   273  */
   219  */
   274 void NmAttachmentListItem::gestureEvent(QGestureEvent *event)
   220 void NmAttachmentListItem::gestureEvent(QGestureEvent *event)