messagingapp/msgui/unifiededitor/src/msgunieditorattachmentcontainer.cpp
changeset 76 60a8a215b0ec
parent 37 518b245aa84c
equal deleted inserted replaced
73:ecf6a73a9186 76:60a8a215b0ec
    33 //---------------------------------------------------------------
    33 //---------------------------------------------------------------
    34 // MsgAttachmentContainer::MsgAttachmentContainer
    34 // MsgAttachmentContainer::MsgAttachmentContainer
    35 // @see header file
    35 // @see header file
    36 //---------------------------------------------------------------
    36 //---------------------------------------------------------------
    37 MsgAttachmentContainer::MsgAttachmentContainer( QGraphicsItem *parent ) :
    37 MsgAttachmentContainer::MsgAttachmentContainer( QGraphicsItem *parent ) :
    38 HbWidget(parent),
    38 MsgUnifiedEditorBaseWidget(parent),
    39 mIsMMContent(false)
    39 mIsMMContent(false)
    40 {
    40 {
       
    41     this->setObjectName("attachmentContainer");
       
    42     
    41     mLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
    43     mLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
    42     mLayout->setContentsMargins(0,0,0,0);
    44     mLayout->setContentsMargins(0,0,0,0);
    43     mLayout->setSpacing(0);
    45     mLayout->setSpacing(0);
    44     mMmsConformanceCheck = new MmsConformanceCheck;
    46     mMmsConformanceCheck = new MmsConformanceCheck;   
    45 }
    47 }
    46 
    48 
    47 //---------------------------------------------------------------
    49 //---------------------------------------------------------------
    48 // MsgAttachmentContainer::~MsgAttachmentContainer
    50 // MsgAttachmentContainer::~MsgAttachmentContainer
    49 // @see header file
    51 // @see header file
    62 {
    64 {
    63     //check for insert conformance
    65     //check for insert conformance
    64     if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(filepath))
    66     if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(filepath))
    65         return EAddNotSupported;
    67         return EAddNotSupported;
    66 
    68 
    67     int msgSize = messageSize();
    69     int msgSize = MsgUnifiedEditorMonitor::messageSize();
       
    70     
    68     QFileInfo fileinfo(filepath);
    71     QFileInfo fileinfo(filepath);
    69     int fileSize = fileinfo.size() + KEstimatedMimeHeaderSize;
    72     int fileSize = fileinfo.size() + KEstimatedMimeHeaderSize;
    70     
    73     
    71     if( (fileSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize())
    74     if( (fileSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize())
    72     {
    75     {
    79         }
    82         }
    80         mAttachmentList << att;
    83         mAttachmentList << att;
    81         int index = mLayout->count();
    84         int index = mLayout->count();
    82         mLayout->insertItem(index,att);
    85         mLayout->insertItem(index,att);
    83         connect(att, SIGNAL(deleteMe(MsgUnifiedEditorAttachment*)),
    86         connect(att, SIGNAL(deleteMe(MsgUnifiedEditorAttachment*)),
    84             this, SLOT(deleteAttachment(MsgUnifiedEditorAttachment*)));
    87                 this, SLOT(deleteAttachment(MsgUnifiedEditorAttachment*)));
    85 
    88 
    86         // emit to signal that container content & size changed
    89         // emit to signal that container content & size changed
    87         emit contentChanged();
    90         QVariantList data;
       
    91         data << containerSize() << mIsMMContent;        
       
    92         emit contentsChanged(data);
    88     }
    93     }
    89     else
    94     else
    90     {
    95     {
    91         return EAddSizeExceed;
    96         return EAddSizeExceed;
    92     }
    97     }
   109     {
   114     {
   110         mIsMMContent = false;
   115         mIsMMContent = false;
   111     }
   116     }
   112 
   117 
   113     // emit to indicate change in container content & size
   118     // emit to indicate change in container content & size
   114     emit contentChanged();
   119     QVariantList data;
       
   120     data << containerSize() << mIsMMContent;
       
   121     emit contentsChanged(data);
       
   122     
   115     if(mAttachmentList.count() == 0)
   123     if(mAttachmentList.count() == 0)
   116     {
   124     {
   117         emit emptyAttachmentContainer();
   125         emit emptyAttachmentContainer();
   118     }
   126     }
   119 }
   127 }
   151     }
   159     }
   152     return containerSize;
   160     return containerSize;
   153 }
   161 }
   154 
   162 
   155 //---------------------------------------------------------------
   163 //---------------------------------------------------------------
   156 // MsgAttachmentContainer::messageSize
       
   157 // @see header file
       
   158 //---------------------------------------------------------------
       
   159 int MsgAttachmentContainer::messageSize()
       
   160 {
       
   161     return containerSize() + MsgUnifiedEditorMonitor::bodySize() + MsgUnifiedEditorMonitor::subjectSize();
       
   162 }
       
   163 
       
   164 //---------------------------------------------------------------
       
   165 // MsgAttachmentContainer::hasMMContent
   164 // MsgAttachmentContainer::hasMMContent
   166 // @see header file
   165 // @see header file
   167 //---------------------------------------------------------------
   166 //---------------------------------------------------------------
   168 bool MsgAttachmentContainer::hasMMContent()
   167 bool MsgAttachmentContainer::hasMMContent()
   169 {
   168 {
   170     return mIsMMContent;
   169     return mIsMMContent;
   171 }
   170 }
   172 
   171 
       
   172 //---------------------------------------------------------------
       
   173 // MsgAttachmentContainer::fileNameInUse
       
   174 // @see header file
       
   175 //---------------------------------------------------------------
       
   176 bool MsgAttachmentContainer::fileNameInUse(const QString& fileName)
       
   177 {
       
   178     bool alreadyExists = false;
       
   179     
       
   180     for(int i=0; i<mAttachmentList.count(); i++)
       
   181     {
       
   182         QFileInfo fileinfo(mAttachmentList.at(i)->path());
       
   183         if(fileName == fileinfo.fileName())
       
   184         {
       
   185             alreadyExists = true;
       
   186             break;
       
   187         }
       
   188     } 
       
   189     
       
   190     return alreadyExists;
       
   191 }
       
   192 
   173 //EOF
   193 //EOF
   174 
   194