Wt examples  3.3.8
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 (WContainerWidget *parent=0)
 
 WCompositeWidget (WWidget *implementation, WContainerWidget *parent)
 
virtual void setObjectName (const std::string &name)
 
virtual std::string objectName () const
 
virtual const std::string id () const
 
virtual void setPositionScheme (PositionScheme scheme)
 
virtual PositionScheme positionScheme () const
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)
 
virtual WLength offset (Side s) const
 
virtual void resize (const WLength &width, const WLength &height)
 
virtual WLength width () const
 
virtual WLength height () const
 
virtual void setMinimumSize (const WLength &width, const WLength &height)
 
virtual WLength minimumWidth () const
 
virtual WLength minimumHeight () const
 
virtual void setMaximumSize (const WLength &width, const WLength &height)
 
virtual WLength maximumWidth () const
 
virtual WLength maximumHeight () const
 
virtual void setLineHeight (const WLength &height)
 
virtual WLength lineHeight () const
 
virtual void setFloatSide (Side s)
 
virtual Side floatSide () const
 
virtual void setClearSides (WFlags< Side > sides)
 
virtual WFlags< SideclearSides () const
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)
 
virtual WLength margin (Side side) const
 
virtual void setHiddenKeepsGeometry (bool enabled)
 
virtual bool hiddenKeepsGeometry () const
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 
virtual bool isHidden () const
 
virtual bool isVisible () const
 
virtual void setDisabled (bool disabled)
 
virtual bool isDisabled () const
 
virtual bool isEnabled () const
 
virtual void setPopup (bool popup)
 
virtual bool isPopup () const
 
virtual void setInline (bool isInline)
 
virtual bool isInline () const
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)
 
virtual WCssDecorationStyledecorationStyle ()
 
virtual void setStyleClass (const WString &styleClass)
 
virtual WString styleClass () const
 
virtual void addStyleClass (const WString &styleClass, bool force=false)
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)
 
virtual bool hasStyleClass (const WString &styleClass) const
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)
 
virtual AlignmentFlag verticalAlignment () const
 
virtual WLength verticalAlignmentLength () const
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 
virtual WString toolTip () const
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=PlainText)
 
virtual void refresh ()
 
virtual void setAttributeValue (const std::string &name, const WString &value)
 
virtual WString attributeValue (const std::string &name) const
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)
 
virtual std::string javaScriptMember (const std::string &name) const
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)
 
virtual void load ()
 
virtual bool loaded () const
 
virtual void setCanReceiveFocus (bool enabled)
 
virtual bool canReceiveFocus () const
 
virtual void setFocus (bool focus)
 
virtual bool setFirstFocus ()
 
virtual bool hasFocus () const
 
virtual void setTabIndex (int index)
 
virtual int tabIndex () const
 
virtual void setId (const std::string &id)
 
virtual WWidgetfind (const std::string &name)
 
virtual WWidgetfindById (const std::string &name)
 
virtual void setSelectable (bool selectable)
 
virtual void doJavaScript (const std::string &js)
 
virtual void propagateSetEnabled (bool enabled)
 
virtual bool scrollVisibilityEnabled () const WT_CXX11ONLY(finaloverride)
 
virtual void setScrollVisibilityEnabled (bool enabled) WT_CXX11ONLY(finaloverride)
 
virtual int scrollVisibilityMargin () const WT_CXX11ONLY(finaloverride)
 
virtual void setScrollVisibilityMargin (int margin) WT_CXX11ONLY(finaloverride)
 
virtual Signal< bool > & scrollVisibilityChanged () WT_CXX11ONLY(finaloverride)
 
virtual bool isScrollVisible () const WT_CXX11ONLY(finaloverride)
 
virtual void setThemeStyleEnabled (bool enabled)
 
virtual bool isThemeStyleEnabled () const
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
virtual void removeChild (WObject *child)
 
void setWidth (const WLength &width)
 
void setHeight (const WLength &height)
 
virtual void positionAt (const WWidget *widget, 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
 WObject (WObject *parent=0)
 
virtual ~WObject ()
 
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)
 
void addChild (WObject *child)
 
const std::vector< WObject * > & children () const
 
WObjectparent () const
 

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 ()
 
void setImplementation (WWidget *widget)
 
WWidgetimplementation ()
 
virtual int boxPadding (Orientation orientation) const
 
virtual int boxBorder (Orientation orientation) const
 
virtual void render (WFlags< RenderFlag > flags)
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 
virtual void layoutSizeChanged (int width, int height)
 
 WWidget (WContainerWidget *parent=0)
 
virtual void dropEvent (WDropEvent dropEvent)
 
void scheduleRender (WFlags< RepaintFlag > flags=0)
 
virtual WStatelessSlot * getStateless (Method method)
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 

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 ( WContainerWidget parent = 0)

Construct a new Composer.

Definition at line 25 of file Composer.C.

26  : WCompositeWidget(parent),
27  saving_(false),
28  sending_(false)
29 {
31 
32  createUi();
33 }
void createUi()
Definition: Composer.C:93
WContainerWidget * layout_
Definition: Composer.h:100
void setImplementation(WWidget *widget)
bool saving_
state when waiting asyncrhonously for attachments to be uploaded
Definition: Composer.h:140
WCompositeWidget(WContainerWidget *parent=0)
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 331 of file Composer.C.

332 {
333  if (saving_) {
335  std::cerr << "Attachments still: " << attachmentsPending_ << std::endl;
336 
337  if (attachmentsPending_ == 0)
338  saved();
339  }
340 }
void saved()
All attachments have been processed, determine the result of saving the message.
Definition: Composer.C:348
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 75 of file Composer.C.

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

Add an attachment edit.

Definition at line 249 of file Composer.C.

250 {
251  /*
252  * Create and append the next AttachmentEdit, that will be hidden.
253  */
254  AttachmentEdit *edit = new AttachmentEdit(this);
256  attachments_.push_back(edit);
257  attachments_.back()->hide();
258 
259  // Connect the attachOtherFile_ option to show this attachment.
261  .connect(attachments_.back(), &WWidget::show);
262 }
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
virtual void insertBefore(WWidget *widget, WWidget *before)
WTableCell * elementAt(int row, int column)
friend class AttachmentEdit
Definition: Composer.h:194
std::vector< Contact > Composer::bcc ( ) const

Get the Bc: contacts.

Definition at line 60 of file Composer.C.

61 {
62  return bccEdit_->addressees();
63 }
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 55 of file Composer.C.

56 {
57  return ccEdit_->addressees();
58 }
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 93 of file Composer.C.

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

Slot attached to the Discard button.

Discards the current message: emits the discard event.

Definition at line 386 of file Composer.C.

387 {
388  discard.emit();
389 }
void emit(A1 a1=NoClass::none, A2 a2=NoClass::none, A3 a3=NoClass::none, A4 a4=NoClass::none, A5 a5=NoClass::none, A6 a6=NoClass::none) const
Wt::Signal< void > discard
The message must be discarded.
Definition: Composer.h:97
const WString & Composer::message ( ) const

Get the message.

Definition at line 88 of file Composer.C.

89 {
90  return message_->text();
91 }
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 264 of file Composer.C.

265 {
266  /*
267  * Remove the given attachment from the attachments list.
268  */
269  std::vector<AttachmentEdit *>::iterator i
270  = std::find(attachments_.begin(), attachments_.end(), attachment);
271 
272  if (i != attachments_.end()) {
273  attachments_.erase(i);
274  delete attachment;
275 
276  if (attachments_.size() == 1) {
277  /*
278  * This was the last visible attachment, thus, we should switch
279  * the option control again.
280  */
282  attachFile_->show();
283  attachFile_->item()->clicked()
284  .connect(attachments_.back(), &WWidget::show);
285  }
286  }
287 }
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
void Composer::saved ( )
private

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

Definition at line 348 of file Composer.C.

349 {
350  /*
351  * All attachments have been processed.
352  */
353 
354  bool attachmentsFailed = false;
355  for (unsigned i = 0; i < attachments_.size() - 1; ++i)
356  if (attachments_[i]->uploadFailed()) {
357  attachmentsFailed = true;
358  break;
359  }
360 
361  if (attachmentsFailed) {
362  setStatus(tr("msg.attachment.failed"), "error");
363  } else {
364 #ifndef WIN32
365  time_t t = time(0);
366  struct tm td;
367  gmtime_r(&t, &td);
368  char buffer[100];
369  strftime(buffer, 100, "%H:%M", &td);
370 #else
371  char buffer[] = "server"; // Should fix this; for now just make sense
372 #endif
373  setStatus(tr("msg.ok"), "status");
374  statusMsg_->setText(std::string("Draft saved at ") + buffer);
375 
376  if (sending_) {
377  send.emit();
378  return;
379  }
380  }
381 
382  saving_ = false;
383  sending_ = false;
384 }
void emit(A1 a1=NoClass::none, A2 a2=NoClass::none, A3 a3=NoClass::none, A4 a4=NoClass::none, A5 a5=NoClass::none, A6 a6=NoClass::none) const
static WString tr(const char *key)
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
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:342
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 302 of file Composer.C.

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

Slot attached to the Send button.

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

Definition at line 289 of file Composer.C.

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

Set the address book, for autocomplete suggestions.

Definition at line 65 of file Composer.C.

66 {
68 }
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 45 of file Composer.C.

46 {
47  message_->setText(message);
48 }
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 342 of file Composer.C.

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

Set subject.

Definition at line 40 of file Composer.C.

41 {
42  subject_->setText(subject);
43 }
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 35 of file Composer.C.

36 {
38 }
std::vector< Contact > to() const
Get the To: contacts.
Definition: Composer.C:50
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 70 of file Composer.C.

71 {
72  return subject_->text();
73 }
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 50 of file Composer.C.

51 {
52  return toEdit_->addressees();
53 }
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<void> 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<void> 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