emailuis/nmailui/src/nmattachmentlist.cpp
changeset 44 c2d07d913565
parent 43 99bcbff212ad
child 47 f83bd4ae1fe3
equal deleted inserted replaced
43:99bcbff212ad 44:c2d07d913565
    27 */
    27 */
    28 NmAttachmentList::NmAttachmentList(NmAttachmentListWidget &listWidget)
    28 NmAttachmentList::NmAttachmentList(NmAttachmentListWidget &listWidget)
    29 : mListWidget(listWidget)
    29 : mListWidget(listWidget)
    30 {
    30 {
    31     NM_FUNCTION;
    31     NM_FUNCTION;
    32     
       
    33     updateLayout();
       
    34 }
    32 }
    35 
    33 
    36 /*!
    34 /*!
    37     Destructor
    35     Destructor
    38 */
    36 */
    60     mFileSize.append(fileSize);
    58     mFileSize.append(fileSize);
    61     mListWidget.insertAttachment(
    59     mListWidget.insertAttachment(
    62         count() - 1,
    60         count() - 1,
    63         displayName, 
    61         displayName, 
    64         NmUtilities::attachmentSizeString(fileSize.toDouble()));  
    62         NmUtilities::attachmentSizeString(fileSize.toDouble()));  
    65     updateLayout();
       
    66     return count() - 1;
    63     return count() - 1;
    67 }
    64 }
    68 
    65 
    69 /*!
    66 /*!
    70     Set attachmentPartId of the list item. Because there can be several attachments with
    67     Set attachmentPartId of the list item. Because there can be several attachments with
   109         mListWidget.removeAttachment(arrayIndex);
   106         mListWidget.removeAttachment(arrayIndex);
   110         // Remove from data structure
   107         // Remove from data structure
   111         mFullFileName.removeAt(arrayIndex);
   108         mFullFileName.removeAt(arrayIndex);
   112         mDisplayFileName.removeAt(arrayIndex);
   109         mDisplayFileName.removeAt(arrayIndex);
   113         mAttachmentPartId.removeAt(arrayIndex);
   110         mAttachmentPartId.removeAt(arrayIndex);
   114         updateLayout();
       
   115     }
   111     }
   116 }
   112 }
   117 
   113 
   118 /*!
   114 /*!
   119     Return full filename of the list item
   115     Return full filename of the list item
   170         mListWidget.removeAttachment(i);
   166         mListWidget.removeAttachment(i);
   171         // Remove from data structure
   167         // Remove from data structure
   172         mFullFileName.removeAt(i);
   168         mFullFileName.removeAt(i);
   173         mDisplayFileName.removeAt(i);
   169         mDisplayFileName.removeAt(i);
   174         mAttachmentPartId.removeAt(i);
   170         mAttachmentPartId.removeAt(i);
   175         updateLayout();
       
   176     }
   171     }
   177 }
   172 }
   178 
   173 
   179 /*!
   174 /*!
   180     Return attachment list widget
   175     Return attachment list widget
   228 {
   223 {
   229     NM_FUNCTION;
   224     NM_FUNCTION;
   230     
   225     
   231     return fullName.section('\\', -1);
   226     return fullName.section('\\', -1);
   232 }
   227 }
   233 
       
   234 /*!
       
   235     Update the list layout height
       
   236 */
       
   237 void NmAttachmentList::updateLayout()
       
   238 {
       
   239     NM_FUNCTION;
       
   240     
       
   241     // Fix this when progress bar is used
       
   242     mListWidget.setMaximumHeight(count() * 56); 
       
   243     QTimer::singleShot(1, this, SLOT(delayedLayoutChangeInfo()));
       
   244 }
       
   245 
       
   246 /*!
       
   247     Send delayed signal about attachment list layout change
       
   248 */
       
   249 void NmAttachmentList::delayedLayoutChangeInfo()
       
   250 {
       
   251     NM_FUNCTION;
       
   252     
       
   253     emit attachmentListLayoutChanged();
       
   254 }
       
   255