Wt examples  4.10.4
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Composer Class Reference

An E-mail composer widget. More...

#include <Composer.h>

Inheritance diagram for Composer:
[legend]

Public Member Functions

 Composer ()
 Construct a new Composer. More...
 
void setTo (const std::vector< Contact > &to)
 Set message To: contacts. More...
 
void setSubject (const WString &subject)
 Set subject. More...
 
void setMessage (const WString &message)
 Set the message. More...
 
void setAddressBook (const std::vector< Contact > &addressBook)
 Set the address book, for autocomplete suggestions. More...
 
std::vector< Contactto () const
 Get the To: contacts. More...
 
std::vector< Contactcc () const
 Get the Cc: contacts. More...
 
std::vector< Contactbcc () const
 Get the Bc: contacts. More...
 
const WStringsubject () const
 Get the subject. More...
 
std::vector< Attachmentattachments () const
 Get the list of attachments. More...
 
const WStringmessage () const
 Get the message. More...
 
- Public Member Functions inherited from Wt::WCompositeWidget
 WCompositeWidget ()
 
 WCompositeWidget (std::unique_ptr< WWidget > implementation)
 
virtual std::vector< WWidget * > children () const override
 
virtual std::unique_ptr< WWidgetremoveWidget (WWidget *widget) override
 
virtual void setObjectName (const std::string &name) override
 
virtual std::string objectName () const override
 
virtual const std::string id () const override
 
virtual void setPositionScheme (PositionScheme scheme) override
 
virtual PositionScheme positionScheme () const override
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=AllSides) override
 
virtual WLength offset (Side s) const override
 
virtual void resize (const WLength &width, const WLength &height) override
 
virtual WLength width () const override
 
virtual WLength height () const override
 
virtual void setMinimumSize (const WLength &width, const WLength &height) override
 
virtual WLength minimumWidth () const override
 
virtual WLength minimumHeight () const override
 
virtual void setMaximumSize (const WLength &width, const WLength &height) override
 
virtual WLength maximumWidth () const override
 
virtual WLength maximumHeight () const override
 
virtual void setLineHeight (const WLength &height) override
 
virtual WLength lineHeight () const override
 
virtual void setFloatSide (Side s) override
 
virtual Side floatSide () const override
 
virtual void setClearSides (WFlags< Side > sides) override
 
virtual WFlags< SideclearSides () const override
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=AllSides) override
 
virtual WLength margin (Side side) const override
 
virtual void setHiddenKeepsGeometry (bool enabled) override
 
virtual bool hiddenKeepsGeometry () const override
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation()) override
 
virtual bool isHidden () const override
 
virtual bool isVisible () const override
 
virtual void setDisabled (bool disabled) override
 
virtual bool isDisabled () const override
 
virtual bool isEnabled () const override
 
virtual void setPopup (bool popup) override
 
virtual bool isPopup () const override
 
virtual void setInline (bool isInline) override
 
virtual bool isInline () const override
 
virtual void setDecorationStyle (const WCssDecorationStyle &style) override
 
virtual WCssDecorationStyledecorationStyle () override
 
virtual void setStyleClass (const WString &styleClass) override
 
virtual WString styleClass () const override
 
virtual void addStyleClass (const WString &styleClass, bool force=false) override
 
virtual void removeStyleClass (const WString &styleClass, bool force=false) override
 
virtual bool hasStyleClass (const WString &styleClass) const override
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto) override
 
virtual AlignmentFlag verticalAlignment () const override
 
virtual WLength verticalAlignmentLength () const override
 
virtual void setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override
 
virtual WString toolTip () const override
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override
 
virtual void refresh () override
 
virtual void setAttributeValue (const std::string &name, const WString &value) override
 
virtual WString attributeValue (const std::string &name) const override
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value) override
 
virtual std::string javaScriptMember (const std::string &name) const override
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args) override
 
virtual void load () override
 
virtual bool loaded () const override
 
virtual void setCanReceiveFocus (bool enabled) override
 
virtual bool canReceiveFocus () const override
 
virtual void setFocus (bool focus) override
 
virtual bool setFirstFocus () override
 
virtual bool hasFocus () const override
 
virtual void setTabIndex (int index) override
 
virtual int tabIndex () const override
 
virtual void setId (const std::string &id) override
 
virtual WWidgetfind (const std::string &name) override
 
virtual WWidgetfindById (const std::string &name) override
 
virtual void setSelectable (bool selectable) override
 
virtual void doJavaScript (const std::string &js) override
 
virtual void propagateSetEnabled (bool enabled) override
 
virtual bool scrollVisibilityEnabled () const final override
 
virtual void setScrollVisibilityEnabled (bool enabled) final override
 
virtual int scrollVisibilityMargin () const final override
 
virtual void setScrollVisibilityMargin (int margin) final override
 
virtual Signal< bool > & scrollVisibilityChanged () final override
 
virtual bool isScrollVisible () const final override
 
virtual void setThemeStyleEnabled (bool enabled) final override
 
virtual bool isThemeStyleEnabled () const final override
 
virtual std::unique_ptr< WWidgetremoveWidget (WWidget *widget)
 
std::unique_ptr< Widget > removeWidget (Widget *widget)
 
void setFocus ()
 
virtual void setFocus (bool focus)=0
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
std::unique_ptr< Widget > removeWidget (Widget *widget)
 
std::unique_ptr< WWidgetremoveFromParent ()
 
void setWidth (const WLength &width)
 
void setHeight (const WLength &height)
 
virtual void positionAt (const WWidget *widget, Orientation orientation=Orientation::Vertical)
 
virtual void toggleStyleClass (const WString &styleClass, bool add, bool force=false)
 
std::string jsRef () const
 
void setFocus ()
 
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
 
virtual void stopAcceptDrops (const std::string &mimeType)
 
virtual void htmlText (std::ostream &out)
 
bool isRendered () const
 
void hide ()
 
void animateHide (const WAnimation &animation)
 
void show ()
 
void animateShow (const WAnimation &animation)
 
void enable ()
 
void disable ()
 
bool layoutSizeAware () const
 
- Public Member Functions inherited from Wt::WObject
void addChild (std::unique_ptr< WObject > child)
 
Child * addChild (std::unique_ptr< Child > child)
 
std::unique_ptr< WObjectremoveChild (WObject *child)
 
std::unique_ptr< Child > removeChild (Child *child)
 
void resetLearnedSlots ()
 
void resetLearnedSlot (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 
void isNotStateless ()
 
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 
- Public Member Functions inherited from Wt::Core::observable
 observable () noexcept
 
virtual ~observable ()
 
auto bindSafe (void(C::*method)(Args...)) noexcept
 
auto bindSafe (void(C::*method)(Args...) const) const noexcept
 
auto bindSafe (const Function &function) noexcept
 

Public Attributes

Wt::Signal send
 The message is ready to be sent... More...
 
Wt::Signal discard
 The message must be discarded. More...
 

Private Member Functions

void attachMore ()
 Add an attachment edit. More...
 
void removeAttachment (AttachmentEdit *attachment)
 Remove the given attachment edit. More...
 
void sendIt ()
 Slot attached to the Send button. More...
 
void saveNow ()
 Slot attached to the Save now button. More...
 
void discardIt ()
 Slot attached to the Discard button. More...
 
void attachmentDone ()
 Slotcalled when an attachment has been uploaded. More...
 
void createUi ()
 
void saved ()
 All attachments have been processed, determine the result of saving the message. More...
 
void setStatus (const WString &text, const WString &style)
 Set the status, and apply the given style. More...
 

Private Attributes

WContainerWidgetlayout_
 
WPushButtontopSendButton_
 
WPushButtontopSaveNowButton_
 
WPushButtontopDiscardButton_
 
WPushButtonbotSendButton_
 
WPushButtonbotSaveNowButton_
 
WPushButtonbotDiscardButton_
 
WTextstatusMsg_
 
WTableedits_
 
AddresseeEdittoEdit_
 To: Addressees edit. More...
 
AddresseeEditccEdit_
 Cc: Addressees edit. More...
 
AddresseeEditbccEdit_
 Bcc: Addressees edit. More...
 
ContactSuggestionscontactSuggestions_
 The suggestions popup for the addressee edits. More...
 
WLineEditsubject_
 The subject line edit. More...
 
OptionListoptions_
 OptionsList for editing Cc or Bcc. More...
 
Optionaddcc_
 Option for editing Cc: More...
 
Optionaddbcc_
 Option for editing Bcc: More...
 
OptionattachFile_
 Option for attaching a file. More...
 
OptionattachOtherFile_
 Option for attaching another file. More...
 
std::vector< AttachmentEdit * > attachments_
 Array which holds all the attachments, including one extra invisible one. More...
 
WTextAreamessage_
 WTextArea for the main message. More...
 
bool saving_
 state when waiting asyncrhonously for attachments to be uploaded More...
 
bool sending_
 
int attachmentsPending_
 number of attachments waiting to be uploaded during saving More...
 

Friends

class AttachmentEdit
 

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 
- Protected Member Functions inherited from Wt::WCompositeWidget
virtual void enableAjax () override
 
void setImplementation (std::unique_ptr< WWidget > widget)
 
Widget * setImplementation (std::unique_ptr< Widget > widget)
 
W * setNewImplementation (Args &&... args)
 
WWidgetimplementation ()
 
virtual int boxPadding (Orientation orientation) const override
 
virtual int boxBorder (Orientation orientation) const override
 
virtual void render (WFlags< RenderFlag > flags) override
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 
virtual void layoutSizeChanged (int width, int height)
 
 WWidget ()
 
virtual void dropEvent (WDropEvent dropEvent)
 
void scheduleRender (WFlags< RepaintFlag > flags=None)
 
virtual WStatelessSlot * getStateless (Method method) override
 

Detailed Description

An E-mail composer widget.

This widget is part of the Wt composer example.

Definition at line 40 of file Composer.h.

Constructor & Destructor Documentation

◆ Composer()

Composer::Composer ( )

Construct a new Composer.

Definition at line 27 of file Composer.C.

28  : WCompositeWidget(),
29  saving_(false),
30  sending_(false)
31 {
32  std::unique_ptr<WContainerWidget> layout
33  = std::make_unique<WContainerWidget>();
34  layout_ = layout.get();
35  setImplementation(std::move(layout));
36 
37  createUi();
38 }
bool saving_
state when waiting asyncrhonously for attachments to be uploaded
Definition: Composer.h:140
bool sending_
Definition: Composer.h:140
WContainerWidget * layout_
Definition: Composer.h:100
void createUi()
Definition: Composer.C:98
void setImplementation(std::unique_ptr< WWidget > widget)

Member Function Documentation

◆ attachmentDone()

void Composer::attachmentDone ( )
private

Slotcalled when an attachment has been uploaded.

This used during while saving the email and waiting for remaining attachments to be uploaded. It is connected to the AttachmentEdit control signals that are emitted when an attachment has been processed.

Definition at line 338 of file Composer.C.

339 {
340  if (saving_) {
342  std::cerr << "Attachments still: " << attachmentsPending_ << std::endl;
343 
344  if (attachmentsPending_ == 0)
345  saved();
346  }
347 }
void saved()
All attachments have been processed, determine the result of saving the message.
Definition: Composer.C:355
int attachmentsPending_
number of attachments waiting to be uploaded during saving
Definition: Composer.h:143

◆ attachments()

std::vector< Attachment > Composer::attachments ( ) const

Get the list of attachments.

The ownership of the attachment spool files is transferred to the caller as well, be sure to delete them !

Definition at line 80 of file Composer.C.

81 {
82  std::vector<Attachment> attachments;
83 
84  for (unsigned i = 0; i < attachments_.size() - 1; ++i) {
85  std::vector<Attachment> toadd = attachments_[i]->attachments();
86 
87  attachments.insert(attachments.end(), toadd.begin(), toadd.end());
88  }
89 
90  return attachments;
91 }
std::vector< AttachmentEdit * > attachments_
Array which holds all the attachments, including one extra invisible one.
Definition: Composer.h:134
std::vector< Attachment > attachments() const
Get the list of attachments.
Definition: Composer.C:80

◆ attachMore()

void Composer::attachMore ( )
private

Add an attachment edit.

Definition at line 254 of file Composer.C.

255 {
256  /*
257  * Create and append the next AttachmentEdit, that will be hidden.
258  */
259  std::unique_ptr<AttachmentEdit> edit
260  = std::make_unique<AttachmentEdit>(this);
261  AttachmentEdit *editPtr = edit.get();
262  edits_->elementAt(5, 1)->insertBefore(std::move(edit), attachOtherFile_);
263  attachments_.push_back(editPtr);
264  attachments_.back()->hide();
265 
266  // Connect the attachOtherFile_ option to show this attachment.
268  .connect(attachments_.back(), &WWidget::show);
269 }
An edit field for an email attachment.
Option * attachOtherFile_
Option for attaching another file.
Definition: Composer.h:131
WTable * edits_
Definition: Composer.h:106
WInteractWidget * item()
Returns the clickable part.
Definition: Option.h:44
Wt::Signals::connection connect(F function)
virtual void insertBefore(std::unique_ptr< WWidget > widget, WWidget *before)
EventSignal< WMouseEvent > & clicked()
WTableCell * elementAt(int row, int column)

◆ bcc()

std::vector< Contact > Composer::bcc ( ) const

Get the Bc: contacts.

Definition at line 65 of file Composer.C.

66 {
67  return bccEdit_->addressees();
68 }
std::vector< Contact > addressees() const
Get a list of addressees.
Definition: AddresseeEdit.C:74
AddresseeEdit * bccEdit_
Bcc: Addressees edit.
Definition: Composer.h:113

◆ cc()

std::vector< Contact > Composer::cc ( ) const

Get the Cc: contacts.

Definition at line 60 of file Composer.C.

61 {
62  return ccEdit_->addressees();
63 }
AddresseeEdit * ccEdit_
Cc: Addressees edit.
Definition: Composer.h:111

◆ createUi()

void Composer::createUi ( )
private

Definition at line 98 of file Composer.C.

99 {
100  setStyleClass("darker");
101 
102  // horizontal layout container, used for top and bottom buttons.
103  WContainerWidget *horiz;
104 
105  /*
106  * Top buttons
107  */
108  horiz = layout_->addWidget(std::make_unique<WContainerWidget>());
109  horiz->setPadding(5);
110  topSendButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr("msg.send")));
111  topSendButton_->setStyleClass("default"); // default action
112  topSaveNowButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr("msg.savenow")));
113  topDiscardButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr("msg.discard")));
114 
115  // Text widget which shows status messages, next to the top buttons.
116  statusMsg_ = horiz->addWidget(std::make_unique<WText>());
117  statusMsg_->setMargin(15, Side::Left);
118 
119  /*
120  * To, Cc, Bcc, Subject, Attachments
121  *
122  * They are organized in a two-column table: left column for
123  * labels, and right column for the edit.
124  */
125  edits_ = layout_->addWidget(std::make_unique<WTable>());
126  edits_->setStyleClass("lighter");
127  edits_->resize(WLength(100, LengthUnit::Percentage), WLength::Auto);
128  edits_->elementAt(0, 0)->resize(WLength(1, LengthUnit::Percentage),
129  WLength::Auto);
130 
131  /*
132  * To, Cc, Bcc
133  */
134  toEdit_ = edits_->elementAt(0,1)->addWidget(std::make_unique<AddresseeEdit>(tr("msg.to"), edits_->elementAt(0, 0)));
135  // add some space above To:
136  edits_->elementAt(0, 1)->setMargin(5, Side::Top);
137  ccEdit_ = edits_->elementAt(1,1)->addWidget(std::make_unique<AddresseeEdit>(tr("msg.cc"), edits_->elementAt(1, 0)));
138  bccEdit_ = edits_->elementAt(2,1)->addWidget(std::make_unique<AddresseeEdit>(tr("msg.bcc"), edits_->elementAt(2, 0)));
139 
140  ccEdit_->hide();
141  bccEdit_->hide();
142 
143  /*
144  * Addressbook suggestions popup
145  */
146  contactSuggestions_ = layout_->addChild(std::make_unique<ContactSuggestions>());
147 
151 
152  /*
153  * We use an OptionList widget to show the expand options for
154  * ccEdit_ and bccEdit_ nicely next to each other, separated
155  * by pipe characters.
156  */
157  options_ = edits_->elementAt(3, 1)->addWidget(std::make_unique<OptionList>());
158  std::unique_ptr<Option> addcc(new Option(tr("msg.addcc")));
159  addcc_ = addcc.get();
160  std::unique_ptr<Option> addbcc(new Option(tr("msg.addbcc")));
161  addbcc_ = addbcc.get();
162 
163  options_->add(std::move(addcc));
164  options_->add(std::move(addbcc));
165 
166  /*
167  * Subject
168  */
169  edits_->elementAt(4, 0)->addWidget(std::make_unique<Label>(tr("msg.subject"), edits_->elementAt(4, 0)));
170  subject_ = edits_->elementAt(4, 1)->addWidget(std::make_unique<WLineEdit>());
171  subject_->resize(WLength(99, LengthUnit::Percentage), WLength::Auto);
172 
173  /*
174  * Attachments
175  */
176  edits_->elementAt(5, 0)->addWidget(std::make_unique<WImage>("icons/paperclip.png"));
177  edits_->elementAt(5, 0)->setContentAlignment(AlignmentFlag::Right | AlignmentFlag::Top);
178  edits_->elementAt(5, 0)->setPadding(3);
179 
180  // Attachment edits: we always have the next attachmentedit ready
181  // but hidden. This improves the response time, since the show()
182  // and hide() slots are stateless.
183  AttachmentEdit *attachmentEdit = edits_->elementAt(5, 1)->addWidget(std::make_unique<AttachmentEdit>(this));
184  attachments_.push_back(attachmentEdit);
185  attachments_.back()->hide();
186 
187  /*
188  * Two options for attaching files. The first does not say 'another'.
189  */
190  attachFile_ = edits_->elementAt(5, 1)->addWidget(std::make_unique<Option>(tr("msg.attachfile")));
191  attachOtherFile_ = edits_->elementAt(5, 1)->addWidget(std::make_unique<Option>(tr("msg.attachanother")));
193 
194  /*
195  * Message
196  */
197  message_ = layout_->addWidget(std::make_unique<WTextArea>());
198  message_->setColumns(80);
199  message_->setRows(10); // should be 20, but let's keep it smaller
200  message_->setMargin(10);
201 
202  /*
203  * Bottom buttons
204  */
205  horiz = layout_->addWidget(std::make_unique<WContainerWidget>());
206  horiz->setPadding(5);
207  botSendButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr("msg.send")));
208  botSendButton_->setStyleClass("default");
209  botSaveNowButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr("msg.savenow")));
210  botDiscardButton_ = horiz->addWidget(std::make_unique<WPushButton>(tr("msg.discard")));
211 
212  /*
213  * Button events.
214  */
221 
222  /*
223  * Option events to show the cc or Bcc edit.
224  *
225  * Clicking on the option should both show the corresponding edit, and
226  * hide the option itself.
227  */
228  addcc_->item()->clicked().connect(ccEdit_, &WWidget::show);
229  addcc_->item()->clicked().connect(addcc_, &WWidget::hide);
231  addcc_->item()->clicked().connect(ccEdit_, &WWidget::setFocus);
232 
233  addbcc_->item()->clicked().connect(bccEdit_, &WWidget::show);
234  addbcc_->item()->clicked().connect(addbcc_, &WWidget::hide);
236  addbcc_->item()->clicked().connect(bccEdit_, &WWidget::setFocus);
237 
238  /*
239  * Option event to attach the first attachment.
240  *
241  * We show the first attachment, and call attachMore() to prepare the
242  * next attachment edit that will be hidden.
243  *
244  * In addition, we need to show the 'attach More' option, and hide the
245  * 'attach' option.
246  */
247  attachFile_->item()->clicked().connect(attachments_.back(), &WWidget::show);
248  attachFile_->item()->clicked().connect(attachOtherFile_, &WWidget::show);
249  attachFile_->item()->clicked().connect(attachFile_, &WWidget::hide);
252 }
WPushButton * botSaveNowButton_
Definition: Composer.h:103
void sendIt()
Slot attached to the Send button.
Definition: Composer.C:296
WText * statusMsg_
Definition: Composer.h:104
WTextArea * message_
WTextArea for the main message.
Definition: Composer.h:137
WPushButton * topSaveNowButton_
Definition: Composer.h:102
WPushButton * topSendButton_
Definition: Composer.h:102
AddresseeEdit * toEdit_
To: Addressees edit.
Definition: Composer.h:109
void discardIt()
Slot attached to the Discard button.
Definition: Composer.C:385
void attachMore()
Add an attachment edit.
Definition: Composer.C:254
void saveNow()
Slot attached to the Save now button.
Definition: Composer.C:309
WPushButton * botSendButton_
Definition: Composer.h:103
WLineEdit * subject_
The subject line edit.
Definition: Composer.h:119
WPushButton * topDiscardButton_
Definition: Composer.h:102
ContactSuggestions * contactSuggestions_
The suggestions popup for the addressee edits.
Definition: Composer.h:116
Option * attachFile_
Option for attaching a file.
Definition: Composer.h:129
WPushButton * botDiscardButton_
Definition: Composer.h:103
Option * addbcc_
Option for editing Bcc:
Definition: Composer.h:127
Option * addcc_
Option for editing Cc:
Definition: Composer.h:125
OptionList * options_
OptionsList for editing Cc or Bcc.
Definition: Composer.h:122
void update()
Updates the stateless implementations after an Option has been hidden or shown.
Definition: OptionList.C:31
void add(std::unique_ptr< Option > option)
Add an Option to the list.
Definition: OptionList.C:18
A clickable option.
Definition: Option.h:32
virtual void setStyleClass(const WString &styleClass) override
void setContentAlignment(WFlags< AlignmentFlag > contentAlignment)
void setPadding(const WLength &padding, WFlags< Side > sides=AllSides)
virtual void addWidget(std::unique_ptr< WWidget > widget)
void addChild(std::unique_ptr< WObject > child)
void forEdit(WFormWidget *edit, WFlags< PopupTrigger > popupTriggers=PopupTrigger::Editing)
void setRows(int rows)
void setColumns(int cols)
virtual void setMargin(const WLength &margin, WFlags< Side > sides=AllSides) override
virtual void resize(const WLength &width, const WLength &height) override
virtual void setStyleClass(const WString &styleClass) override
static WString tr(const char *key)

◆ discardIt()

void Composer::discardIt ( )
private

Slot attached to the Discard button.

Discards the current message: emits the discard event.

Definition at line 385 of file Composer.C.

386 {
387  discard.emit();
388 }
Wt::Signal discard
The message must be discarded.
Definition: Composer.h:97
void emit(A... args) const

◆ message()

const WString & Composer::message ( ) const

Get the message.

Definition at line 93 of file Composer.C.

94 {
95  return message_->text();
96 }
const WString & text() const

◆ removeAttachment()

void Composer::removeAttachment ( AttachmentEdit attachment)
private

Remove the given attachment edit.

Definition at line 271 of file Composer.C.

272 {
273  /*
274  * Remove the given attachment from the attachments list.
275  */
276  std::vector<AttachmentEdit *>::iterator i
277  = std::find(attachments_.begin(), attachments_.end(), attachment);
278 
279  if (i != attachments_.end()) {
280  attachments_.erase(i);
281  attachment->removeFromParent();
282 
283  if (attachments_.size() == 1) {
284  /*
285  * This was the last visible attachment, thus, we should switch
286  * the option control again.
287  */
289  attachFile_->show();
290  attachFile_->item()->clicked()
291  .connect(attachments_.back(), &WWidget::show);
292  }
293  }
294 }
std::unique_ptr< WWidget > removeFromParent()

◆ saved()

void Composer::saved ( )
private

All attachments have been processed, determine the result of saving the message.

Definition at line 355 of file Composer.C.

356 {
357  /*
358  * All attachments have been processed.
359  */
360 
361  bool attachmentsFailed = false;
362  for (unsigned i = 0; i < attachments_.size() - 1; ++i)
363  if (attachments_[i]->uploadFailed()) {
364  attachmentsFailed = true;
365  break;
366  }
367 
368  if (attachmentsFailed) {
369  setStatus(tr("msg.attachment.failed"), "error");
370  } else {
371  setStatus(tr("msg.ok"), "status");
373  statusMsg_->setText(Wt::utf8("Draft saved at {1}").arg(timeStr));
374 
375  if (sending_) {
376  send.emit();
377  return;
378  }
379  }
380 
381  saving_ = false;
382  sending_ = false;
383 }
Wt::Signal send
The message is ready to be sent...
Definition: Composer.h:93
void setStatus(const WString &text, const WString &style)
Set the status, and apply the given style.
Definition: Composer.C:349
static WLocalDateTime currentDateTime(const WLocale &locale=WLocale::currentLocale())
WString toString() const
bool setText(const WString &text)

◆ saveNow()

void Composer::saveNow ( )
private

Slot attached to the Save now button.

Tries to save the mail message, and gives feedback on failure and on success.

Definition at line 309 of file Composer.C.

310 {
311  if (!saving_) {
312  saving_ = true;
313 
314  /*
315  * Check if any attachments still need to be uploaded.
316  * This may be the case when fileupload change events could not
317  * be caught (for example in Konqueror).
318  */
320 
321  for (unsigned i = 0; i < attachments_.size() - 1; ++i) {
322  if (attachments_[i]->uploadNow()) {
324 
325  // this will trigger attachmentDone() when done, see
326  // the AttachmentEdit constructor.
327  }
328  }
329 
330  std::cerr << "Attachments pending: " << attachmentsPending_ << std::endl;
332  setStatus(tr("msg.uploading"), "status");
333  else
334  saved();
335  }
336 }

◆ sendIt()

void Composer::sendIt ( )
private

Slot attached to the Send button.

Tries to save the mail message, and if succesfull, sends it.

Definition at line 296 of file Composer.C.

297 {
298  if (!sending_) {
299  sending_ = true;
300 
301  /*
302  * First save -- this will check for the sending_ state
303  * signal if successfull.
304  */
305  saveNow();
306  }
307 }

◆ setAddressBook()

void Composer::setAddressBook ( const std::vector< Contact > &  addressBook)

Set the address book, for autocomplete suggestions.

Definition at line 70 of file Composer.C.

71 {
73 }
void setAddressBook(const std::vector< Contact > &contacts)
Set the address book.

◆ setMessage()

void Composer::setMessage ( const WString message)

Set the message.

Definition at line 50 of file Composer.C.

51 {
53 }
const WString & message() const
Get the message.
Definition: Composer.C:93
virtual void setText(const WString &text)

◆ setStatus()

void Composer::setStatus ( const WString text,
const WString style 
)
private

Set the status, and apply the given style.

Definition at line 349 of file Composer.C.

350 {
351  statusMsg_->setText(text);
352  statusMsg_->setStyleClass(style);
353 }

◆ setSubject()

void Composer::setSubject ( const WString subject)

Set subject.

Definition at line 45 of file Composer.C.

46 {
48 }
const WString & subject() const
Get the subject.
Definition: Composer.C:75
virtual void setText(const WString &text)

◆ setTo()

void Composer::setTo ( const std::vector< Contact > &  to)

Set message To: contacts.

Definition at line 40 of file Composer.C.

41 {
43 }
void setAddressees(const std::vector< Contact > &contacts)
Set a list of addressees.
Definition: AddresseeEdit.C:27
std::vector< Contact > to() const
Get the To: contacts.
Definition: Composer.C:55

◆ subject()

const WString & Composer::subject ( ) const

Get the subject.

Definition at line 75 of file Composer.C.

76 {
77  return subject_->text();
78 }
const WString & text() const

◆ to()

std::vector< Contact > Composer::to ( ) const

Get the To: contacts.

Definition at line 55 of file Composer.C.

56 {
57  return toEdit_->addressees();
58 }

Friends And Related Function Documentation

◆ AttachmentEdit

friend class AttachmentEdit
friend

Definition at line 194 of file Composer.h.

Member Data Documentation

◆ addbcc_

Option* Composer::addbcc_
private

Option for editing Bcc:

Definition at line 127 of file Composer.h.

◆ addcc_

Option* Composer::addcc_
private

Option for editing Cc:

Definition at line 125 of file Composer.h.

◆ attachFile_

Option* Composer::attachFile_
private

Option for attaching a file.

Definition at line 129 of file Composer.h.

◆ attachments_

std::vector<AttachmentEdit *> Composer::attachments_
private

Array which holds all the attachments, including one extra invisible one.

Definition at line 134 of file Composer.h.

◆ attachmentsPending_

int Composer::attachmentsPending_
private

number of attachments waiting to be uploaded during saving

Definition at line 143 of file Composer.h.

◆ attachOtherFile_

Option* Composer::attachOtherFile_
private

Option for attaching another file.

Definition at line 131 of file Composer.h.

◆ bccEdit_

AddresseeEdit* Composer::bccEdit_
private

Bcc: Addressees edit.

Definition at line 113 of file Composer.h.

◆ botDiscardButton_

WPushButton * Composer::botDiscardButton_
private

Definition at line 103 of file Composer.h.

◆ botSaveNowButton_

WPushButton * Composer::botSaveNowButton_
private

Definition at line 103 of file Composer.h.

◆ botSendButton_

WPushButton* Composer::botSendButton_
private

Definition at line 103 of file Composer.h.

◆ ccEdit_

AddresseeEdit* Composer::ccEdit_
private

Cc: Addressees edit.

Definition at line 111 of file Composer.h.

◆ contactSuggestions_

ContactSuggestions* Composer::contactSuggestions_
private

The suggestions popup for the addressee edits.

Definition at line 116 of file Composer.h.

◆ discard

Wt::Signal Composer::discard

The message must be discarded.

Definition at line 97 of file Composer.h.

◆ edits_

WTable* Composer::edits_
private

Definition at line 106 of file Composer.h.

◆ layout_

WContainerWidget* Composer::layout_
private

Definition at line 100 of file Composer.h.

◆ message_

WTextArea* Composer::message_
private

WTextArea for the main message.

Definition at line 137 of file Composer.h.

◆ options_

OptionList* Composer::options_
private

OptionsList for editing Cc or Bcc.

Definition at line 122 of file Composer.h.

◆ saving_

bool Composer::saving_
private

state when waiting asyncrhonously for attachments to be uploaded

Definition at line 140 of file Composer.h.

◆ send

Wt::Signal Composer::send

The message is ready to be sent...

Definition at line 93 of file Composer.h.

◆ sending_

bool Composer::sending_
private

Definition at line 140 of file Composer.h.

◆ statusMsg_

WText* Composer::statusMsg_
private

Definition at line 104 of file Composer.h.

◆ subject_

WLineEdit* Composer::subject_
private

The subject line edit.

Definition at line 119 of file Composer.h.

◆ toEdit_

AddresseeEdit* Composer::toEdit_
private

To: Addressees edit.

Definition at line 109 of file Composer.h.

◆ topDiscardButton_

WPushButton * Composer::topDiscardButton_
private

Definition at line 102 of file Composer.h.

◆ topSaveNowButton_

WPushButton * Composer::topSaveNowButton_
private

Definition at line 102 of file Composer.h.

◆ topSendButton_

WPushButton* Composer::topSendButton_
private

Definition at line 102 of file Composer.h.


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