AttachmentIconItem( KCal::Attachment *att, Q3IconView *parent )
   : K3IconViewItem( parent )
 {
   if ( att ) {
     mAttachment = new KCal::Attachment( *att );
   } else {
     mAttachment = new KCal::Attachment( QString() );
   }
   readAttachment();
 }
void AttachmentSeriesTest::attachmentTest()
{
    CPPUNIT_ASSERT(m_series);

    //Create Path
    const ::boost::filesystem::path path = ::fwTools::System::getTemporaryFolder() / "attachmenttest";
    ::boost::filesystem::create_directories(path);
    const std::string filename                     = "attach.ext";
    const ::boost::filesystem::path attachmentFile = path / filename;
    const std::string mediaType                    = "text";

    std::ofstream file;
    file.open(attachmentFile.string().c_str(), std::ofstream::out);
    file << "42";
    file.close();
    size_t fileSize = ::boost::filesystem::file_size(attachmentFile);

    //None
    CPPUNIT_ASSERT_EQUAL(::fwMedData::AttachmentSeries::NONE, m_series->getAttachmentAvailability());
    CPPUNIT_ASSERT(m_series->getBufferObject()->isEmpty());

    //Local
    m_series->setAttachmentPath(attachmentFile);
    m_series->setMediaType(mediaType);
    CPPUNIT_ASSERT_EQUAL(::fwMedData::AttachmentSeries::LOCAL, m_series->getAttachmentAvailability());
    CPPUNIT_ASSERT_EQUAL(attachmentFile, m_series->getAttachmentPath());
    CPPUNIT_ASSERT(!m_series->getBufferObject()->isEmpty());
    CPPUNIT_ASSERT_EQUAL(fileSize, m_series->getBufferObject()->getSize());
    CPPUNIT_ASSERT_EQUAL(mediaType, m_series->getMediaType());

    //Embedded
    const std::string jsonzFile = "AttachmentSeriesTest.jsonz";
    ::fwAtoms::Object::sptr atom1 = ::fwAtomConversion::convert(m_series);
    writeAttachment((path/jsonzFile), atom1);
    ::fwAtoms::Object::sptr atom2 = readAttachment(path/jsonzFile);

    ::fwData::Object::sptr object;
    ::fwMedData::AttachmentSeries::sptr attachmentSeries;

    object           = ::fwAtomConversion::convert(atom2, ::fwAtomConversion::AtomVisitor::ChangePolicy());
    attachmentSeries = ::fwMedData::AttachmentSeries::dynamicCast(object);

    CPPUNIT_ASSERT(attachmentSeries);
    CPPUNIT_ASSERT_EQUAL(::fwMedData::AttachmentSeries::EMBEDDED, attachmentSeries->getAttachmentAvailability());
    CPPUNIT_ASSERT_EQUAL(filename, attachmentSeries->getAttachmentPath().string());
    CPPUNIT_ASSERT_EQUAL(mediaType, attachmentSeries->getMediaType());

    ::fwMemory::BufferObject::sptr buff = attachmentSeries->getBufferObject();
    ::fwMemory::BufferObject::Lock lock = buff->lock();
    CPPUNIT_ASSERT_EQUAL(fileSize, buff->getSize());
    CPPUNIT_ASSERT( lock.getBuffer() != nullptr );
}
static spSkin *readSkin(spSkeletonBinary *self, const char *skinName)
{
    spSkin *skin;
    int slotCount = readVarint(self, true);
    
    if (slotCount == 0) {
        return NULL;
    }
    
    skin = spSkin_create(skinName);
    for (int i = 0; i < slotCount; i++) {
        int slotIndex = readVarint(self, true);
        int nn = readVarint(self, true);
        for (int ii = 0; ii < nn; ii++) {
            char *name = readString(self);
            spAttachment *attachment = readAttachment(self, skin, slotIndex, name);
            spSkin_addAttachment(skin, slotIndex, name, attachment);
        }
    }
    
    return skin;
}
 void setData( const QByteArray &data )
 {
   mAttachment->setDecodedData( data );
   readAttachment();
 }
 void setUri( const QString &uri )
 {
   mAttachment->setUri( uri );
   readAttachment();
 }
 void setLabel( const QString &description )
 {
   mAttachment->setLabel( description );
   readAttachment();
 }
 void setMimeType( const QString &mime )
 {
   mAttachment->setMimeType( mime );
   readAttachment();
 }