Wt examples  4.0.0
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 ()
 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 finaloverride
 
virtual void setScrollVisibilityEnabled (bool enabled) finaloverride
 
virtual int scrollVisibilityMargin () const finaloverride
 
virtual void setScrollVisibilityMargin (int margin) finaloverride
 
virtual Signal< bool > & scrollVisibilityChanged () finaloverride
 
virtual bool isScrollVisible () const finaloverride
 
virtual void setThemeStyleEnabled (bool enabled) finaloverride
 
virtual bool isThemeStyleEnabled () const finaloverride
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
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)
 
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 ()
 
virtual ~observable ()
 
auto bindSafe (void(C::*method)(Args...))
 
auto bindSafe (void(C::*method)(Args...) const) const
 
auto bindSafe (const Function &function)
 

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)
 
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 ( )

Construct a new Composer.

Definition at line 26 of file Composer.C.

27  : WCompositeWidget(),
28  saving_(false),
29  sending_(false)
30 {
31  std::unique_ptr<WContainerWidget> layout
32  = cpp14::make_unique<WContainerWidget>();
33  layout_ = layout.get();
34  setImplementation(std::move(layout));
35 
36  createUi();
37 }
void createUi()
Definition: Composer.C:97
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

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

338 {
339  if (saving_) {
341  std::cerr << "Attachments still: " << attachmentsPending_ << std::endl;
342 
343  if (attachmentsPending_ == 0)
344  saved();
345  }
346 }
void saved()
All attachments have been processed, determine the result of saving the message.
Definition: Composer.C:354
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
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 79 of file Composer.C.

80 {
81  std::vector<Attachment> attachments;
82 
83  for (unsigned i = 0; i < attachments_.size() - 1; ++i) {
84  std::vector<Attachment> toadd = attachments_[i]->attachments();
85 
86  attachments.insert(attachments.end(), toadd.begin(), toadd.end());
87  }
88 
89  return attachments;
90 }
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:79
void Composer::attachMore ( )
private

Add an attachment edit.

Definition at line 253 of file Composer.C.

254 {
255  /*
256  * Create and append the next AttachmentEdit, that will be hidden.
257  */
258  std::unique_ptr<AttachmentEdit> edit
259  = cpp14::make_unique<AttachmentEdit>(this);
260  AttachmentEdit *editPtr = edit.get();
261  edits_->elementAt(5, 1)->insertBefore(std::move(edit), attachOtherFile_);
262  attachments_.push_back(editPtr);
263  attachments_.back()->hide();
264 
265  // Connect the attachOtherFile_ option to show this attachment.
267  .connect(attachments_.back(), &WWidget::show);
268 }
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
Wt::Signals::connection connect(const F &function)
WTableCell * elementAt(int row, int column)
std::vector< Contact > Composer::bcc ( ) const

Get the Bc: contacts.

Definition at line 64 of file Composer.C.

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

Get the Cc: contacts.

Definition at line 59 of file Composer.C.

60 {
61  return ccEdit_->addressees();
62 }
AddresseeEdit * ccEdit_
Cc: Addressees edit.
Definition: Composer.h:111
std::vector< Contact > addressees() const
Get a list of addressees.
Definition: AddresseeEdit.C:74
void Composer::createUi ( )
private

Definition at line 97 of file Composer.C.

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

Slot attached to the Discard button.

Discards the current message: emits the discard event.

Definition at line 392 of file Composer.C.

393 {
394  discard.emit();
395 }
void emit(A...args) const
Wt::Signal discard
The message must be discarded.
Definition: Composer.h:97
const WString & Composer::message ( ) const

Get the message.

Definition at line 92 of file Composer.C.

93 {
94  return message_->text();
95 }
WTextArea * message_
WTextArea for the main message.
Definition: Composer.h:137
const WString & text() const
void Composer::removeAttachment ( AttachmentEdit attachment)
private

Remove the given attachment edit.

Definition at line 270 of file Composer.C.

271 {
272  /*
273  * Remove the given attachment from the attachments list.
274  */
275  std::vector<AttachmentEdit *>::iterator i
276  = std::find(attachments_.begin(), attachments_.end(), attachment);
277 
278  if (i != attachments_.end()) {
279  attachments_.erase(i);
280  attachment->removeFromParent();
281 
282  if (attachments_.size() == 1) {
283  /*
284  * This was the last visible attachment, thus, we should switch
285  * the option control again.
286  */
288  attachFile_->show();
289  attachFile_->item()->clicked()
290  .connect(attachments_.back(), &WWidget::show);
291  }
292  }
293 }
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
Wt::Signals::connection connect(const F &function)
Option * attachFile_
Option for attaching a file.
Definition: Composer.h:129
std::unique_ptr< WWidget > removeFromParent()
void Composer::saved ( )
private

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

Definition at line 354 of file Composer.C.

355 {
356  /*
357  * All attachments have been processed.
358  */
359 
360  bool attachmentsFailed = false;
361  for (unsigned i = 0; i < attachments_.size() - 1; ++i)
362  if (attachments_[i]->uploadFailed()) {
363  attachmentsFailed = true;
364  break;
365  }
366 
367  if (attachmentsFailed) {
368  setStatus(tr("msg.attachment.failed"), "error");
369  } else {
370 #ifndef WIN32
371  time_t t = time(0);
372  struct tm td;
373  gmtime_r(&t, &td);
374  char buffer[100];
375  strftime(buffer, 100, "%H:%M", &td);
376 #else
377  char buffer[] = "server"; // Should fix this; for now just make sense
378 #endif
379  setStatus(tr("msg.ok"), "status");
380  statusMsg_->setText(std::string("Draft saved at ") + buffer);
381 
382  if (sending_) {
383  send.emit();
384  return;
385  }
386  }
387 
388  saving_ = false;
389  sending_ = false;
390 }
static WString tr(const char *key)
void emit(A...args) const
std::vector< AttachmentEdit * > attachments_
Array which holds all the attachments, including one extra invisible one.
Definition: Composer.h:134
Wt::Signal send
The message is ready to be sent...
Definition: Composer.h:93
bool setText(const WString &text)
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:348
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 308 of file Composer.C.

309 {
310  if (!saving_) {
311  saving_ = true;
312 
313  /*
314  * Check if any attachments still need to be uploaded.
315  * This may be the case when fileupload change events could not
316  * be caught (for example in Konqueror).
317  */
319 
320  for (unsigned i = 0; i < attachments_.size() - 1; ++i) {
321  if (attachments_[i]->uploadNow()) {
323 
324  // this will trigger attachmentDone() when done, see
325  // the AttachmentEdit constructor.
326  }
327  }
328 
329  std::cerr << "Attachments pending: " << attachmentsPending_ << std::endl;
331  setStatus(tr("msg.uploading"), "status");
332  else
333  saved();
334  }
335 }
static WString tr(const char *key)
void saved()
All attachments have been processed, determine the result of saving the message.
Definition: Composer.C:354
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:348
void Composer::sendIt ( )
private

Slot attached to the Send button.

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

Definition at line 295 of file Composer.C.

296 {
297  if (!sending_) {
298  sending_ = true;
299 
300  /*
301  * First save -- this will check for the sending_ state
302  * signal if successfull.
303  */
304  saveNow();
305  }
306 }
void saveNow()
Slot attached to the Save now button.
Definition: Composer.C:308
bool sending_
Definition: Composer.h:140
void Composer::setAddressBook ( const std::vector< Contact > &  addressBook)

Set the address book, for autocomplete suggestions.

Definition at line 69 of file Composer.C.

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

Set the message.

Definition at line 49 of file Composer.C.

50 {
51  message_->setText(message);
52 }
WTextArea * message_
WTextArea for the main message.
Definition: Composer.h:137
virtual void setText(const WString &text)
void Composer::setStatus ( const WString text,
const WString style 
)
private

Set the status, and apply the given style.

Definition at line 348 of file Composer.C.

349 {
350  statusMsg_->setText(text);
351  statusMsg_->setStyleClass(style);
352 }
virtual void setStyleClass(const WString &styleClass) override
bool setText(const WString &text)
WText * statusMsg_
Definition: Composer.h:104
void Composer::setSubject ( const WString subject)

Set subject.

Definition at line 44 of file Composer.C.

45 {
46  subject_->setText(subject);
47 }
virtual void setText(const WString &text)
WLineEdit * subject_
The subject line edit.
Definition: Composer.h:119
void Composer::setTo ( const std::vector< Contact > &  to)

Set message To: contacts.

Definition at line 39 of file Composer.C.

40 {
42 }
std::vector< Contact > to() const
Get the To: contacts.
Definition: Composer.C:54
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
const WString & Composer::subject ( ) const

Get the subject.

Definition at line 74 of file Composer.C.

75 {
76  return subject_->text();
77 }
const WString & text() const
WLineEdit * subject_
The subject line edit.
Definition: Composer.h:119
std::vector< Contact > Composer::to ( ) const

Get the To: contacts.

Definition at line 54 of file Composer.C.

55 {
56  return toEdit_->addressees();
57 }
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

friend class AttachmentEdit
friend

Definition at line 194 of file Composer.h.

Member Data Documentation

Option* Composer::addbcc_
private

Option for editing Bcc:

Definition at line 127 of file Composer.h.

Option* Composer::addcc_
private

Option for editing Cc:

Definition at line 125 of file Composer.h.

Option* Composer::attachFile_
private

Option for attaching a file.

Definition at line 129 of file Composer.h.

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.

int Composer::attachmentsPending_
private

number of attachments waiting to be uploaded during saving

Definition at line 143 of file Composer.h.

Option* Composer::attachOtherFile_
private

Option for attaching another file.

Definition at line 131 of file Composer.h.

AddresseeEdit* Composer::bccEdit_
private

Bcc: Addressees edit.

Definition at line 113 of file Composer.h.

WPushButton * Composer::botDiscardButton_
private

Definition at line 103 of file Composer.h.

WPushButton * Composer::botSaveNowButton_
private

Definition at line 103 of file Composer.h.

WPushButton* Composer::botSendButton_
private

Definition at line 103 of file Composer.h.

AddresseeEdit* Composer::ccEdit_
private

Cc: Addressees edit.

Definition at line 111 of file Composer.h.

ContactSuggestions* Composer::contactSuggestions_
private

The suggestions popup for the addressee edits.

Definition at line 116 of file Composer.h.

Wt::Signal Composer::discard

The message must be discarded.

Definition at line 97 of file Composer.h.

WTable* Composer::edits_
private

Definition at line 106 of file Composer.h.

WContainerWidget* Composer::layout_
private

Definition at line 100 of file Composer.h.

WTextArea* Composer::message_
private

WTextArea for the main message.

Definition at line 137 of file Composer.h.

OptionList* Composer::options_
private

OptionsList for editing Cc or Bcc.

Definition at line 122 of file Composer.h.

bool Composer::saving_
private

state when waiting asyncrhonously for attachments to be uploaded

Definition at line 140 of file Composer.h.

Wt::Signal Composer::send

The message is ready to be sent...

Definition at line 93 of file Composer.h.

bool Composer::sending_
private

Definition at line 140 of file Composer.h.

WText* Composer::statusMsg_
private

Definition at line 104 of file Composer.h.

WLineEdit* Composer::subject_
private

The subject line edit.

Definition at line 119 of file Composer.h.

AddresseeEdit* Composer::toEdit_
private

To: Addressees edit.

Definition at line 109 of file Composer.h.

WPushButton * Composer::topDiscardButton_
private

Definition at line 102 of file Composer.h.

WPushButton * Composer::topSaveNowButton_
private

Definition at line 102 of file Composer.h.

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 Mon Sep 4 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11