Wt examples  3.7.1
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:
Inheritance graph
[legend]

Public Member Functions

 Composer (WContainerWidget *parent=0)
 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
 
- 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< void > send
 The message is ready to be sent... More...
 
Wt::Signal< void > 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 ( WContainerWidget parent = 0)

Construct a new Composer.

Definition at line 26 of file Composer.C.

27  : WCompositeWidget(parent),
28  saving_(false),
29  sending_(false)
30 {
32 
33  createUi();
34 }
void createUi()
Definition: Composer.C:94
WContainerWidget * layout_
Definition: Composer.h:100
void setImplementation(std::unique_ptr< WWidget > widget)
bool saving_
state when waiting asyncrhonously for attachments to be uploaded
Definition: Composer.h:140
bool sending_
Definition: Composer.h:140

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 332 of file Composer.C.

333 {
334  if (saving_) {
336  std::cerr << "Attachments still: " << attachmentsPending_ << std::endl;
337 
338  if (attachmentsPending_ == 0)
339  saved();
340  }
341 }
void saved()
All attachments have been processed, determine the result of saving the message.
Definition: Composer.C:349
bool saving_
state when waiting asyncrhonously for attachments to be uploaded
Definition: Composer.h:140
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 76 of file Composer.C.

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

◆ attachMore()

void Composer::attachMore ( )
private

Add an attachment edit.

Definition at line 250 of file Composer.C.

251 {
252  /*
253  * Create and append the next AttachmentEdit, that will be hidden.
254  */
255  AttachmentEdit *edit = new AttachmentEdit(this);
257  attachments_.push_back(edit);
258  attachments_.back()->hide();
259 
260  // Connect the attachOtherFile_ option to show this attachment.
262  .connect(attachments_.back(), &WWidget::show);
263 }
virtual void insertBefore(std::unique_ptr< WWidget > widget, WWidget *before)
WInteractWidget * item()
Returns the clickable part.
Definition: Option.h:44
WTable * edits_
Definition: Composer.h:106
EventSignal< WMouseEvent > & clicked()
Option * attachOtherFile_
Option for attaching another file.
Definition: Composer.h:131
An edit field for an email attachment.
std::vector< AttachmentEdit * > attachments_
Array which holds all the attachments, including one extra invisible one.
Definition: Composer.h:134
WTableCell * elementAt(int row, int column)
friend class AttachmentEdit
Definition: Composer.h:194

◆ bcc()

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

Get the Bc: contacts.

Definition at line 61 of file Composer.C.

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

◆ cc()

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

Get the Cc: contacts.

Definition at line 56 of file Composer.C.

57 {
58  return ccEdit_->addressees();
59 }
std::vector< Contact > addressees() const
Get a list of addressees.
Definition: AddresseeEdit.C:74
AddresseeEdit * ccEdit_
Cc: Addressees edit.
Definition: Composer.h:111

◆ createUi()

void Composer::createUi ( )
private

Definition at line 94 of file Composer.C.

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

◆ discardIt()

void Composer::discardIt ( )
private

Slot attached to the Discard button.

Discards the current message: emits the discard event.

Definition at line 379 of file Composer.C.

380 {
381  discard.emit();
382 }
void emit(A... args) const
Wt::Signal< void > discard
The message must be discarded.
Definition: Composer.h:97

◆ message()

const WString & Composer::message ( ) const

Get the message.

Definition at line 89 of file Composer.C.

90 {
91  return message_->text();
92 }
WTextArea * message_
WTextArea for the main message.
Definition: Composer.h:137
const WString & text() const

◆ removeAttachment()

void Composer::removeAttachment ( AttachmentEdit attachment)
private

Remove the given attachment edit.

Definition at line 265 of file Composer.C.

266 {
267  /*
268  * Remove the given attachment from the attachments list.
269  */
270  std::vector<AttachmentEdit *>::iterator i
271  = std::find(attachments_.begin(), attachments_.end(), attachment);
272 
273  if (i != attachments_.end()) {
274  attachments_.erase(i);
275  delete attachment;
276 
277  if (attachments_.size() == 1) {
278  /*
279  * This was the last visible attachment, thus, we should switch
280  * the option control again.
281  */
283  attachFile_->show();
284  attachFile_->item()->clicked()
285  .connect(attachments_.back(), &WWidget::show);
286  }
287  }
288 }
WInteractWidget * item()
Returns the clickable part.
Definition: Option.h:44
EventSignal< WMouseEvent > & clicked()
Option * attachOtherFile_
Option for attaching another file.
Definition: Composer.h:131
std::vector< AttachmentEdit * > attachments_
Array which holds all the attachments, including one extra invisible one.
Definition: Composer.h:134
Option * attachFile_
Option for attaching a file.
Definition: Composer.h:129

◆ saved()

void Composer::saved ( )
private

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

Definition at line 349 of file Composer.C.

350 {
351  /*
352  * All attachments have been processed.
353  */
354 
355  bool attachmentsFailed = false;
356  for (unsigned i = 0; i < attachments_.size() - 1; ++i)
357  if (attachments_[i]->uploadFailed()) {
358  attachmentsFailed = true;
359  break;
360  }
361 
362  if (attachmentsFailed) {
363  setStatus(tr("msg.attachment.failed"), "error");
364  } else {
365  setStatus(tr("msg.ok"), "status");
367  statusMsg_->setText(Wt::utf8("Draft saved at {1}").arg(timeStr));
368 
369  if (sending_) {
370  send.emit();
371  return;
372  }
373  }
374 
375  saving_ = false;
376  sending_ = false;
377 }
static WString tr(const char *key)
WString toString() const
std::vector< AttachmentEdit * > attachments_
Array which holds all the attachments, including one extra invisible one.
Definition: Composer.h:134
Wt::Signal< void > send
The message is ready to be sent...
Definition: Composer.h:93
void emit(A... args) const
bool setText(const WString &text)
static WLocalDateTime currentDateTime(const WLocale &locale=WLocale::currentLocale())
bool saving_
state when waiting asyncrhonously for attachments to be uploaded
Definition: Composer.h:140
WText * statusMsg_
Definition: Composer.h:104
bool sending_
Definition: Composer.h:140
void setStatus(const WString &text, const WString &style)
Set the status, and apply the given style.
Definition: Composer.C:343

◆ 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 303 of file Composer.C.

304 {
305  if (!saving_) {
306  saving_ = true;
307 
308  /*
309  * Check if any attachments still need to be uploaded.
310  * This may be the case when fileupload change events could not
311  * be caught (for example in Konqueror).
312  */
314 
315  for (unsigned i = 0; i < attachments_.size() - 1; ++i) {
316  if (attachments_[i]->uploadNow()) {
318 
319  // this will trigger attachmentDone() when done, see
320  // the AttachmentEdit constructor.
321  }
322  }
323 
324  std::cerr << "Attachments pending: " << attachmentsPending_ << std::endl;
326  setStatus(tr("msg.uploading"), "status");
327  else
328  saved();
329  }
330 }
static WString tr(const char *key)
void saved()
All attachments have been processed, determine the result of saving the message.
Definition: Composer.C:349
std::vector< AttachmentEdit * > attachments_
Array which holds all the attachments, including one extra invisible one.
Definition: Composer.h:134
bool saving_
state when waiting asyncrhonously for attachments to be uploaded
Definition: Composer.h:140
int attachmentsPending_
number of attachments waiting to be uploaded during saving
Definition: Composer.h:143
void setStatus(const WString &text, const WString &style)
Set the status, and apply the given style.
Definition: Composer.C:343

◆ 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 290 of file Composer.C.

291 {
292  if (!sending_) {
293  sending_ = true;
294 
295  /*
296  * First save -- this will check for the sending_ state
297  * signal if successfull.
298  */
299  saveNow();
300  }
301 }
void saveNow()
Slot attached to the Save now button.
Definition: Composer.C:303
bool sending_
Definition: Composer.h:140

◆ setAddressBook()

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

Set the address book, for autocomplete suggestions.

Definition at line 66 of file Composer.C.

67 {
69 }
void setAddressBook(const std::vector< Contact > &contacts)
Set the address book.
ContactSuggestions * contactSuggestions_
The suggestions popup for the addressee edits.
Definition: Composer.h:116

◆ setMessage()

void Composer::setMessage ( const WString message)

Set the message.

Definition at line 46 of file Composer.C.

47 {
48  message_->setText(message);
49 }
WTextArea * message_
WTextArea for the main message.
Definition: Composer.h:137
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 343 of file Composer.C.

344 {
345  statusMsg_->setText(text);
346  statusMsg_->setStyleClass(style);
347 }
virtual void setStyleClass(const WString &styleClass) override
bool setText(const WString &text)
WText * statusMsg_
Definition: Composer.h:104

◆ setSubject()

void Composer::setSubject ( const WString subject)

Set subject.

Definition at line 41 of file Composer.C.

42 {
43  subject_->setText(subject);
44 }
virtual void setText(const WString &text)
WLineEdit * subject_
The subject line edit.
Definition: Composer.h:119

◆ setTo()

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

Set message To: contacts.

Definition at line 36 of file Composer.C.

37 {
39 }
AddresseeEdit * toEdit_
To: Addressees edit.
Definition: Composer.h:109
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:51

◆ subject()

const WString & Composer::subject ( ) const

Get the subject.

Definition at line 71 of file Composer.C.

72 {
73  return subject_->text();
74 }
const WString & text() const
WLineEdit * subject_
The subject line edit.
Definition: Composer.h:119

◆ to()

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

Get the To: contacts.

Definition at line 51 of file Composer.C.

52 {
53  return toEdit_->addressees();
54 }
AddresseeEdit * toEdit_
To: Addressees edit.
Definition: Composer.h:109
std::vector< Contact > addressees() const
Get a list of addressees.
Definition: AddresseeEdit.C:74

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<void> 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<void> 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:

Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13