emailuis/nmailuiwidgets/src/nmattachmentlistwidget.cpp
changeset 56 15bc1d5d6267
parent 48 10eaf342f539
child 66 084b5b1f02a7
equal deleted inserted replaced
51:d845db10c0d4 56:15bc1d5d6267
    17 
    17 
    18 #include "nmailuiwidgetsheaders.h"
    18 #include "nmailuiwidgetsheaders.h"
    19 
    19 
    20 static const QString FILE_PATH_DOCML = ":nmattachmentlistwidget.docml";
    20 static const QString FILE_PATH_DOCML = ":nmattachmentlistwidget.docml";
    21 static const QString ATTACHMENT_WIDGET = "nmattachmentlistwidget";
    21 static const QString ATTACHMENT_WIDGET = "nmattachmentlistwidget";
       
    22 static const QString NmAttachmentTextColor = "qtc_default_main_pane_normal";
    22 
    23 
    23 static const qreal NmItemLineOpacity = 0.4;
    24 static const qreal NmItemLineOpacity = 0.4;
    24 
    25 
    25 /*!
    26 /*!
    26  @nmailuiwidgets
    27  @nmailuiwidgets
   154     //connect to signals
   155     //connect to signals
   155     connect(item, SIGNAL(itemActivated()), this, SLOT(handleItemActivated()));
   156     connect(item, SIGNAL(itemActivated()), this, SLOT(handleItemActivated()));
   156     connect(item, SIGNAL(itemLongPressed(QPointF)), this, SLOT(handleLongPressed(QPointF)));
   157     connect(item, SIGNAL(itemLongPressed(QPointF)), this, SLOT(handleLongPressed(QPointF)));
   157 
   158 
   158     //set texts
   159     //set texts
   159     if (mTextColor.isValid()){
   160     item->setTextColor(checkColor());      
   160         item->setTextColor(mTextColor);    
       
   161     }
       
   162     item->setFileNameText(fileName);
   161     item->setFileNameText(fileName);
   163     item->setFileSizeText(fileSize);
   162     item->setFileSizeText(fileSize);
   164 
   163 
   165     //finally add item to item's list
   164     //finally add item to item's list
   166     mItemList.insert(index,item);
   165     mItemList.insert(index,item);
   262     if (painter&&mLayout){
   261     if (painter&&mLayout){
   263         painter->save();
   262         painter->save();
   264         
   263         
   265         // Use text color as a line color if set, otherwise use theme
   264         // Use text color as a line color if set, otherwise use theme
   266         // normal list content color.
   265         // normal list content color.
   267         if (mTextColor.isValid()){
   266         painter->setPen(checkColor());
   268             painter->setPen(mTextColor);
       
   269         }
       
   270         else{
       
   271             QColor col = HbColorScheme::color("list_item_content_normal");
       
   272             if (col.isValid()) {
       
   273                 painter->setPen(col);
       
   274             }
       
   275         }
       
   276         painter->setOpacity(NmItemLineOpacity);
   267         painter->setOpacity(NmItemLineOpacity);
   277         // Draw line after each item
   268         // Draw line after each item
   278         int rowCount = mLayout->rowCount();
   269         int rowCount = mLayout->rowCount();
   279         QRectF layoutRect = mLayout->geometry ();
   270         QRectF layoutRect = mLayout->geometry ();
   280         for (int i=0;i<rowCount;i++){
   271         for (int i=0;i<rowCount;i++){
   465     
   456     
   466     if(!mLayout) {
   457     if(!mLayout) {
   467         NM_ERROR(1,"NmAttachmentListWidget::rearrangeLayout: Layout loading failed!");
   458         NM_ERROR(1,"NmAttachmentListWidget::rearrangeLayout: Layout loading failed!");
   468         return;
   459         return;
   469     }
   460     }
   470 
   461     
   471     //remove all items from the layout
   462     //remove all items from the layout
   472     int count(mLayout->count());
   463     int count(mLayout->count());
   473     for(int i = count - 1; i >= 0; --i){
   464     for(int i = count - 1; i >= 0; --i){
   474         mLayout->removeAt(i);
   465         mLayout->removeAt(i);
   475     }
   466     }
   476 
   467 
   477     //then add them back
   468     //then add them back
       
   469     QColor textColor = checkColor();    
   478     foreach(NmAttachmentListItem *item, mItemList){
   470     foreach(NmAttachmentListItem *item, mItemList){
       
   471         item->setTextColor(textColor);
   479         insertItemToLayout(item);
   472         insertItemToLayout(item);
   480     }
   473     }
   481 }
   474 }
       
   475 
       
   476 /*!
       
   477     Helper function to set text color
       
   478 */
       
   479 QColor NmAttachmentListWidget::checkColor()
       
   480 {
       
   481     NM_FUNCTION;
       
   482     
       
   483     QColor retColor;
       
   484 
       
   485     if (mTextColor.isValid()){
       
   486         retColor = mTextColor;
       
   487     }
       
   488     else {    
       
   489         retColor =  HbColorScheme::color(NmAttachmentTextColor);
       
   490     }
       
   491     return retColor;
       
   492 }
       
   493 
       
   494 /*!
       
   495     \reimp
       
   496 */
       
   497 
       
   498 void NmAttachmentListWidget::changeEvent(QEvent *event)
       
   499 {
       
   500     NM_FUNCTION;
       
   501 
       
   502     if (event->type() == HbEvent::ThemeChanged) {
       
   503         rearrangeLayout();    
       
   504     }
       
   505     return HbWidgetBase::changeEvent(event);
       
   506 }