14 #include <Wt/WAnchor.h>
15 #include <Wt/WApplication.h>
16 #include <Wt/WCheckBox.h>
17 #include <Wt/WCssDecorationStyle.h>
18 #include <Wt/WFileResource.h>
20 #include <Wt/WFileUpload.h>
21 #include <Wt/WProgressBar.h>
42 std::streamsize fsize = 0;
45 theFile.seekg(0, std::ios_base::end);
46 fsize = theFile.tellg();
51 size =
WString(std::to_string(fsize)) +
U" bytes";
53 size =
WString(std::to_string((
int)(fsize / 1024)))
56 std::u32string fn =
static_cast<std::u32string
>
84 std::unique_ptr<WProgressBar> progress = std::make_unique<WProgressBar>();
85 progress->setFormat(WString::Empty);
86 progress->setVerticalAlignment(AlignmentFlag::Middle);
146 if (!files.empty()) {
156 for (
unsigned i = 0; i < files.size(); ++i) {
180 .arg(WApplication::instance()->maximumRequestSize() / 1024));
191 std::vector<Attachment> result;
193 for (
unsigned i = 0; i <
uploadInfo_.size(); ++i) {
WCheckBox * keep_
The check box to keep or discard the uploaded file.
WAnchor * downloadLink_
Anchor referencing the file.
UploadInfo(const Http::UploadedFile &f)
bool uploadNow()
Updates the file now.
void remove()
Slot triggered when the users wishes to remove this attachment edit.
WText * error_
The text box to display an error (empty or too big file)
Option * remove_
The option to cancel the file upload.
bool uploadFailed_
The state of the last upload process.
void uploaded()
Slot triggered when the WFileUpload completed an upload.
std::vector< Attachment > attachments()
Returns the attachment.
WFileUpload * upload_
The WFileUpload control.
std::vector< UploadInfo * > uploadInfo_
AttachmentEdit(Composer *composer)
Creates an attachment edit field.
void fileTooLarge(::int64_t size)
Slot triggered when the WFileUpload received an oversized file.
An E-mail composer widget.
void attachmentDone()
Slotcalled when an attachment has been uploaded.
void removeAttachment(AttachmentEdit *attachment)
Remove the given attachment edit.
WInteractWidget * item()
Returns the clickable part.
Wt::Signals::connection connect(F function)
const std::string & spoolFileName() const
const std::string & clientFileName() const
void stealSpoolFile() const
const std::string & contentType() const
Wt::Signals::connection connect(F function)
void emit(A... args) const
virtual Wt::Signals::connection connect(WObject *target, WObject::Method method) override
void setLink(const WLink &link)
void setMultiple(bool multiple)
void setProgressBar(WProgressBar *progressBar)
JSignal< ::int64_t > & fileTooLarge()
void setFileTextSize(int chars)
const std::vector< Http::UploadedFile > & uploadedFiles() const
void setSize(FontSize size)
bool setText(const WString &text)