#include <AddresseeEdit.h>
Public Member Functions | |
AddresseeEdit (const WString &label, WContainerWidget *parent, WContainerWidget *labelParent) | |
Create a new addressee edit with the given label. | |
void | setAddressees (const std::vector< Contact > &contacts) |
Set a list of addressees. | |
std::vector< Contact > | addressees () const |
Get a list of addressees. | |
virtual void | setHidden (bool) |
Reimplement hide() and show() to also hide() and show() the label. | |
Private Member Functions | |
bool | parse (std::vector< Contact > &contacts) const |
Parse the addressees into a list of contacts. | |
Private Attributes | |
Label * | label_ |
The label associated with this edit. |
This widget is part of the Wt composer example.
Definition at line 31 of file AddresseeEdit.h.
AddresseeEdit::AddresseeEdit | ( | const WString & | label, | |
WContainerWidget * | parent, | |||
WContainerWidget * | labelParent | |||
) |
Create a new addressee edit with the given label.
Constructs also a widget to hold the label in the labelParent. The label will be hidden and shown together with this field.
Definition at line 15 of file AddresseeEdit.C.
00017 : WTextArea(parent) 00018 { 00019 label_ = new Label(label, labelParent); 00020 00021 setRows(3); setColumns(55); 00022 resize(WLength(99, WLength::Percentage), WLength::Auto); 00023 00024 setInline(false); // for IE to position the suggestions well 00025 }
void AddresseeEdit::setAddressees | ( | const std::vector< Contact > & | contacts | ) |
Set a list of addressees.
Definition at line 27 of file AddresseeEdit.C.
00028 { 00029 std::wstring text; 00030 00031 for (unsigned i = 0; i < contacts.size(); ++i) { 00032 if (i != 0) 00033 text += L", "; 00034 text += contacts[i].formatted(); 00035 } 00036 00037 setText(text); 00038 }
std::vector< Contact > AddresseeEdit::addressees | ( | ) | const |
Get a list of addressees.
Definition at line 74 of file AddresseeEdit.C.
00075 { 00076 std::vector<Contact> result; 00077 parse(result); 00078 00079 return result; 00080 }
void AddresseeEdit::setHidden | ( | bool | how | ) | [virtual] |
Reimplement hide() and show() to also hide() and show() the label.
Reimplemented from Wt::WFormWidget.
Definition at line 82 of file AddresseeEdit.C.
bool AddresseeEdit::parse | ( | std::vector< Contact > & | contacts | ) | const [private] |
Parse the addressees into a list of contacts.
Definition at line 40 of file AddresseeEdit.C.
00041 { 00042 typedef boost::tokenizer<boost::escaped_list_separator<wchar_t>, 00043 std::wstring::const_iterator, std::wstring> 00044 CsvTokenizer; 00045 00046 std::wstring t = text(); 00047 CsvTokenizer tok(t); 00048 00049 for (CsvTokenizer::iterator i = tok.begin(); i != tok.end(); ++i) { 00050 std::wstring addressee = *i; 00051 00052 boost::trim(addressee); 00053 std::wstring::size_type pos = addressee.find_last_of(' '); 00054 if (pos != std::string::npos) { 00055 std::wstring email = addressee.substr(pos + 1); 00056 std::wstring name = addressee.substr(0, pos); 00057 00058 boost::trim(email); 00059 boost::trim(name); 00060 if (email[0] == '<') 00061 email = email.substr(1); 00062 if (email[email.length() - 1] == '>') 00063 email = email.substr(0, email.length() - 1); 00064 00065 if (!email.empty()) 00066 contacts.push_back(Contact(name, email)); 00067 } else 00068 if (!addressee.empty()) 00069 contacts.push_back(Contact(L"", addressee)); 00070 } 00071 return true; 00072 }
Label* AddresseeEdit::label_ [private] |