Ejemplo n.º 1
0
    /// Constructor to build item representing file name cell.
    TFileAttachmentItem(const QFileInfo& fileInfo, TFileAttachmentWidget* owner) :
      AAttachmentItem(fileInfo.fileName().toStdString().c_str(), owner, nullptr),
      FileInfo(fileInfo), 
      _contactCardData(nullptr)
      {
      owner->TotalAttachmentSize += fileInfo.size();

      QString path = fileInfo.absoluteFilePath();
      TImage image;
      
      image.load(path);
      if (image.isNull())
        setToolTip(path);
      else
        setToolTip(image.toHtml() );
      }
Ejemplo n.º 2
0
void TFileAttachmentWidget::LoadAttachedFiles(const TAttachmentContainer& attachedFiles)
  {
  bool sortEnabled = FreezeAttachmentTable();

  for(const TPhysicalAttachment& a : attachedFiles)
    {
    size_t size = a.body.size();
    uchar  *imageData = (uchar*)a.body.data ();
    TImage image;
    image.loadFromData(imageData, size);

    TScaledSize scaledSize = ScaleAttachmentSize(size);

    /// Allocate objects representing table items - name item automatically will register in the list.
    TVirtualAttachmentItem* fileNameItem = new TVirtualAttachmentItem(a, this);
    TVirtualAttachmentItem* fileSizeItem = new TVirtualAttachmentItem(fileNameItem, scaledSize);
    fileNameItem->setToolTip( image.toHtml() );
    AddAttachmentItems(fileNameItem, fileSizeItem);
    }

  UnFreezeAttachmentTable(sortEnabled);
  
  UpdateColumnHeaders();
  }