Wt examples  3.3.5
Public Member Functions | Public Attributes
AttachmentEdit::UploadInfo Class Reference

List of all members.

Public Member Functions

 UploadInfo (const Http::UploadedFile &f, WContainerWidget *parent=0)

Public Attributes

Http::UploadedFile info_
WAnchor * downloadLink_
 Anchor referencing the file.
WCheckBox * keep_
 The check box to keep or discard the uploaded file.

Detailed Description

Definition at line 73 of file AttachmentEdit.h.


Constructor & Destructor Documentation

AttachmentEdit::UploadInfo::UploadInfo ( const Http::UploadedFile &  f,
WContainerWidget *  parent = 0 
)

Definition at line 29 of file AttachmentEdit.C.

  : WContainerWidget(parent),
    info_(f)
{
  /*
   * Include the file ?
   */
  keep_ = new WCheckBox(this);
  keep_->setChecked();

  /*
   * Give information on the file uploaded.
   */
  std::streamsize fsize = 0;
  {
    std::ifstream theFile(info_.spoolFileName().c_str());
    theFile.seekg(0, std::ios_base::end);
    fsize = theFile.tellg();
    theFile.seekg(0);
  }
  std::wstring size;
  if (fsize < 1024)
    size = boost::lexical_cast<std::wstring>(fsize) + L" bytes";
  else
    size = boost::lexical_cast<std::wstring>((int)(fsize / 1024))
      + L"kb";

  std::wstring fn = static_cast<std::wstring>
    (escapeText(WString::fromUTF8(info_.clientFileName())));

  downloadLink_
    = new WAnchor("", fn + L" (<i>" + WString::fromUTF8(info_.contentType())
                  + L"</i>) " + size, this);

  WFileResource *res = new WFileResource(info_.contentType(),
                                         info_.spoolFileName(),
                                         this);
  res->suggestFileName(info_.clientFileName());
  downloadLink_->setLink(res);
}

Member Data Documentation

Anchor referencing the file.

Definition at line 81 of file AttachmentEdit.h.

Definition at line 78 of file AttachmentEdit.h.

The check box to keep or discard the uploaded file.

Definition at line 84 of file AttachmentEdit.h.


The documentation for this class was generated from the following files:

Generated on Wed Mar 23 2016 for the C++ Web Toolkit (Wt) by doxygen 1.7.6.1