Wt examples 3.3.12
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ComposeExample Class Reference

Main widget of the Composer example. More...

#include <ComposeExample.h>

Inheritance diagram for ComposeExample:
Inheritance graph
[legend]

Public Member Functions

 ComposeExample (WContainerWidget *parent=0)
 create a new Composer example.
 

Private Member Functions

void send ()
 
void discard ()
 

Private Attributes

Composercomposer_
 
WContainerWidget * details_
 

Detailed Description

Main widget of the Composer example.

Definition at line 25 of file ComposeExample.h.

Constructor & Destructor Documentation

◆ ComposeExample()

ComposeExample::ComposeExample ( WContainerWidget parent = 0)

create a new Composer example.

Definition at line 21 of file ComposeExample.C.

22 : WContainerWidget(parent)
23{
24 composer_ = new Composer(this);
25
26 std::vector<Contact> addressBook;
27 addressBook.push_back(Contact(L"Koen Deforche",
28 L"koen.deforche@gmail.com"));
29 addressBook.push_back(Contact(L"Koen alias1",
30 L"koen.alias1@yahoo.com"));
31 addressBook.push_back(Contact(L"Koen alias2",
32 L"koen.alias2@yahoo.com"));
33 addressBook.push_back(Contact(L"Koen alias3",
34 L"koen.alias3@yahoo.com"));
35 addressBook.push_back(Contact(L"Bartje",
36 L"jafar@hotmail.com"));
37 composer_->setAddressBook(addressBook);
38
39 std::vector<Contact> contacts;
40 contacts.push_back(Contact(L"Koen Deforche", L"koen.deforche@gmail.com"));
41
42 composer_->setTo(contacts);
43 composer_->setSubject("That's cool! Want to start your own google?");
44
47
48 details_ = new WContainerWidget(this);
49
50 new WText(tr("example.info"), details_);
51}
WContainerWidget * details_
Composer * composer_
An E-mail composer widget.
Definition Composer.h:41
Wt::Signal< void > send
The message is ready to be sent...
Definition Composer.h:93
void setTo(const std::vector< Contact > &to)
Set message To: contacts.
Definition Composer.C:35
Wt::Signal< void > discard
The message must be discarded.
Definition Composer.h:97
void setSubject(const WString &subject)
Set subject.
Definition Composer.C:40
void setAddressBook(const std::vector< Contact > &addressBook)
Set the address book, for autocomplete suggestions.
Definition Composer.C:65
virtual Wt::Signals::connection connect(WObject *target, WObject::Method method)
An email contact.
Definition Contact.h:20

Member Function Documentation

◆ discard()

void ComposeExample::discard ( )
private

Definition at line 125 of file ComposeExample.C.

126{
127 WContainerWidget *feedback = new WContainerWidget(this);
128 feedback->setStyleClass("feedback");
129
130 WContainerWidget *horiz = new WContainerWidget(feedback);
131 new WText("<p>Wise decision! Everyone's mailbox is already full anyway.</p>",
132 horiz);
133
134 delete composer_;
135 delete details_;
136
137 wApp->quit();
138}
virtual void setStyleClass(const WString &styleClass)

◆ send()

void ComposeExample::send ( )
private

Definition at line 53 of file ComposeExample.C.

54{
55 WContainerWidget *feedback = new WContainerWidget(this);
56 feedback->setStyleClass(L"feedback");
57
58 WContainerWidget *horiz = new WContainerWidget(feedback);
59 new WText(L"<p>We could have, but did not send the following email:</p>",
60 horiz);
61
62 std::vector<Contact> contacts = composer_->to();
63 if (!contacts.empty())
64 horiz = new WContainerWidget(feedback);
65 for (unsigned i = 0; i < contacts.size(); ++i) {
66 new WText(L"To: \"" + contacts[i].name + L"\" <"
67 + contacts[i].email + L">", PlainText, horiz);
68 new WBreak(horiz);
69 }
70
71 contacts = composer_->cc();
72 if (!contacts.empty())
73 horiz = new WContainerWidget(feedback);
74 for (unsigned i = 0; i < contacts.size(); ++i) {
75 new WText(L"Cc: \"" + contacts[i].name + L"\" <"
76 + contacts[i].email + L">", PlainText, horiz);
77 new WBreak(horiz);
78 }
79
80 contacts = composer_->bcc();
81 if (!contacts.empty())
82 horiz = new WContainerWidget(feedback);
83 for (unsigned i = 0; i < contacts.size(); ++i) {
84 new WText(L"Bcc: \"" + contacts[i].name + L"\" <"
85 + contacts[i].email + L">", PlainText, horiz);
86 new WBreak(horiz);
87 }
88
89 horiz = new WContainerWidget(feedback);
90 new WText("Subject: \"" + composer_->subject() + "\"", PlainText, horiz);
91
92 std::vector<Attachment> attachments = composer_->attachments();
93 if (!attachments.empty())
94 horiz = new WContainerWidget(feedback);
95 for (unsigned i = 0; i < attachments.size(); ++i) {
96 new WText(L"Attachment: \""
97 + attachments[i].fileName
98 + L"\" (" + attachments[i].contentDescription
99 + L")", PlainText, horiz);
100
101 unlink(attachments[i].spoolFileName.c_str());
102
103 new WText(", was in spool file: "
104 + attachments[i].spoolFileName, horiz);
105 new WBreak(horiz);
106 }
107
108 std::wstring message = composer_->message();
109
110 horiz = new WContainerWidget(feedback);
111 new WText("Message body: ", horiz);
112 new WBreak(horiz);
113
114 if (!message.empty()) {
115 new WText(message, PlainText, horiz);
116 } else
117 new WText("<i>(empty)</i>", horiz);
118
119 delete composer_;
120 delete details_;
121
122 wApp->quit();
123}
std::vector< Contact > bcc() const
Get the Bc: contacts.
Definition Composer.C:60
const WString & message() const
Get the message.
Definition Composer.C:88
std::vector< Contact > to() const
Get the To: contacts.
Definition Composer.C:50
const WString & subject() const
Get the subject.
Definition Composer.C:70
std::vector< Contact > cc() const
Get the Cc: contacts.
Definition Composer.C:55
std::vector< Attachment > attachments() const
Get the list of attachments.
Definition Composer.C:75
PlainText

Member Data Documentation

◆ composer_

Composer* ComposeExample::composer_
private

Definition at line 33 of file ComposeExample.h.

◆ details_

WContainerWidget* ComposeExample::details_
private

Definition at line 34 of file ComposeExample.h.


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

Generated on Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8