Example #1
0
void
AttachArea::undeleteLastDeletedAttachment(
    DtMailEnv &mail_error
)
{

    Attachment *tmpAttachment;
    Attachment **list;
    time_t time_deleted = 0, tmpTime = 0;
    int i;

    if (_deleteCount == 0) {
	return;
    }

    list = getList();

    tmpAttachment = list[0];
    time_deleted = tmpAttachment->getBodyPart()->getDeleteTime(mail_error);
    if (mail_error.isSet()) {
	// do something
    }

    for (i=1; i<getIconCount(); i++) {
	if (list[i]->isDeleted()) {
	    tmpTime = list[i]->getBodyPart()->getDeleteTime(mail_error);
	    if (mail_error.isSet()) {
		// do something
	    }
	    if ( tmpTime > time_deleted) {
		time_deleted = tmpTime;
		tmpAttachment = list[i];
	    }
	}
    }

    tmpAttachment->undeleteIt();
    _deleteCount--;

    // Unmanage all.
    // Their positions need to get recomputed and the deleted
    // ones get remanaged in manageList().

    for (i=0; i<getIconCount(); i++) {
	list[i]->unmanageIconWidget();
    }


    this->manageList();

}