Skip to content

Commit 7b836d9

Browse files
author
Koen Deforche
committed
Several changes:
- use WStandardItem::setItemPrototype() to accept numeric data in models (#2717) - install DomElement.h and EscapeOStream.h (#2684) - use rpath for macsox builds (#2705) - implemented WTextEdit::setEnabled() and setReadOnly() - Removed obsolete Safari workaround (#2701) - Sending mail: report success/failure as return value for send() - added WTemplate::renderTemplateText error reporting - Fixed bestMatch logic in RequestHandler (#2694) - Added automatic redirect following to HTTP client (#2605) - Fix Http client: Change empty path into / - WDoubleSpinBox: decimalPoint and groupSeparator support (#2363)
1 parent 88ef994 commit 7b836d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+523
-212
lines changed

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,19 @@ IF (DOXYGEN_FOUND)
497497
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/examples
498498
COMMENT "Doxygen for examples ...")
499499
ADD_DEPENDENCIES(doc doxygen-examples)
500-
ENDIF (DOXYGEN_FOUND)
500+
ENDIF (DOXYGEN_FOUND)
501+
502+
# we enable rpath support for APPLE, this probably goes against policy
503+
# linux distributions?
504+
IF(APPLE)
505+
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
506+
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
507+
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
508+
IF("${isSystemDir}" STREQUAL "-1")
509+
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
510+
ENDIF("${isSystemDir}" STREQUAL "-1")
511+
SET(CMAKE_MACOSX_RPATH TRUE)
512+
ENDIF(APPLE)
501513

502514
SUBDIRS(src)
503515

WConfig.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define WT_VERSION (((WT_SERIES & 0xff) << 24) | ((WT_MAJOR & 0xff) << 16) | ((WT_MINOR & 0xff) << 8))
1414
#define WT_VERSION_STR "${VERSION_SERIES}.${VERSION_MAJOR}.${VERSION_MINOR}"
1515
#define WT_CLASS "Wt${VERSION_SERIES}_${VERSION_MAJOR}_${VERSION_MINOR}"
16+
#define WT_INCLUDED_VERSION Wt_${VERSION_SERIES}_${VERSION_MAJOR}_${VERSION_MINOR}
1617

1718
#define RUNDIR "${RUNDIR}"
1819
#define WT_CONFIG_XML "${CONFIGURATION}"
@@ -43,5 +44,10 @@
4344
#cmakedefine WT_USE_BOOST_SIGNALS
4445
#cmakedefine WT_USE_BOOST_SIGNALS2
4546

47+
// our win32: WIN32 (gcc) or _WIN32 (MSC)
48+
#if defined(WIN32) || defined(_WIN32)
49+
#define WT_WIN32 1
50+
#endif
51+
4652
#endif
4753

examples/blog/asciidoc/asciidoc.C

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace {
1414

1515
std::string tempFileName()
1616
{
17-
#ifndef WIN32
17+
#ifndef WT_WIN32
1818
char spool[20];
1919
strcpy(spool, "/tmp/wtXXXXXX");
2020

@@ -64,7 +64,7 @@ WString asciidoc(const Wt::WString& src)
6464
#endif
6565
std::string command = cmd + " -o " + htmlFileName + " -s " + srcFileName;
6666

67-
#ifndef WIN32
67+
#ifndef WT_WIN32
6868
/*
6969
* So, asciidoc apparently sends a SIGINT which is caught by its parent
7070
* process.. So we have to temporarily ignore it.
@@ -76,7 +76,7 @@ WString asciidoc(const Wt::WString& src)
7676
sigaction(SIGINT, &newAction, &oldAction);
7777
#endif
7878
bool ok = system(command.c_str()) == 0;
79-
#ifndef WIN32
79+
#ifndef WT_WIN32
8080
sigaction(SIGINT, &oldAction, 0);
8181
#endif
8282

examples/blog/model/BlogSession.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
#include <Wt/Dbo/FixedSqlConnectionPool>
2424

25-
#ifndef WIN32
25+
#ifndef WT_WIN32
2626
#include <unistd.h>
2727
#endif
2828

29-
#if !defined(WIN32) && !defined(__CYGWIN__) && !defined(ANDROID)
29+
#if !defined(WT_WIN32) && !defined(__CYGWIN__) && !defined(ANDROID)
3030
#define HAVE_CRYPT
3131
#endif
3232

examples/blog/view/EditUsers.C

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ void EditUsers::limitList()
3535
dbo::Transaction t(session_);
3636
UserList users = session_.find<User>().where("name like ?").bind("%"+limitEdit_->text()+"%").orderBy("name");
3737

38-
WSignalMapper<dbo::dbo_traits<User>::IdType >* userLinkMap = new WSignalMapper<dbo::dbo_traits<User>::IdType >(this);
39-
userLinkMap->mapped().connect(this,&EditUsers::onUserClicked);
4038
for (UserList::const_iterator i = users.begin(); i != users.end(); ++i) {
4139
WText* t = new WText((*i)->name, list);
4240
t->setStyleClass("link");
4341
new WBreak(list);
44-
userLinkMap->mapConnect(t->clicked(), (*i).id());
42+
t->clicked().connect(boost::bind(&EditUsers::onUserClicked, this, (*i).id()));
4543
}
4644
if (!users.size())
4745
new WText(tr("no-users-found"),list);

examples/charts/ChartsExample.C

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,43 @@
2929

3030
using namespace Wt;
3131
using namespace Wt::Chart;
32+
3233
namespace {
3334

35+
/*
36+
* A standard item which converts text edits to numbers
37+
*/
38+
class NumericItem : public WStandardItem {
39+
public:
40+
virtual NumericItem *clone() const {
41+
return new NumericItem();
42+
}
43+
44+
virtual void setData(const boost::any &data, int role = UserRole) {
45+
boost::any dt;
46+
47+
if (role == EditRole) {
48+
std::string s = Wt::asString(data).toUTF8();
49+
char *endptr;
50+
double d = strtod(s.c_str(), &endptr);
51+
if (*endptr == 0)
52+
dt = boost::any(d);
53+
else
54+
dt = data;
55+
}
56+
57+
WStandardItem::setData(data, role);
58+
}
59+
};
60+
3461
/*
3562
* Reads a CSV file as an (editable) standard item model.
3663
*/
3764
WAbstractItemModel *readCsvFile(const std::string &fname,
3865
WContainerWidget *parent)
3966
{
4067
WStandardItemModel *model = new WStandardItemModel(0, 0, parent);
68+
model->setItemPrototype(new NumericItem());
4169
std::ifstream f(fname.c_str());
4270

4371
if (f) {
@@ -255,6 +283,7 @@ ScatterPlotExample::ScatterPlotExample(WContainerWidget *parent):
255283
new WText(WString::tr("scatter plot 2"), this);
256284

257285
WStandardItemModel *model = new WStandardItemModel(40, 2, this);
286+
model->setItemPrototype(new NumericItem());
258287
model->setHeaderData(0, WString("X"));
259288
model->setHeaderData(1, WString("Y = sin(X)"));
260289

@@ -304,6 +333,7 @@ PieExample::PieExample(WContainerWidget *parent):
304333
new WText(WString::tr("pie chart"), this);
305334

306335
WStandardItemModel *model = new WStandardItemModel(this);
336+
model->setItemPrototype(new NumericItem());
307337

308338
//headers
309339
model->insertColumns(model->columnCount(), 2);

examples/feature/socketnotifier/SocketNotifier.C

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <iostream>
1313
#include <boost/thread.hpp>
1414

15-
#if WIN32
15+
#if WT_WIN32
1616
#include <winsock2.h>
1717
#include <ws2tcpip.h>
1818
typedef int socklen_t;
@@ -120,7 +120,7 @@ private:
120120
writeNotifier_->activated().connect(this, &RssReader::write);
121121

122122
// Set sockets to non-blocking
123-
#ifndef WIN32
123+
#ifndef WT_WIN32
124124
int flags = ::fcntl(socket_, F_GETFL, 0);
125125
flags |= O_NONBLOCK;
126126
::fcntl(socket_, F_SETFL, flags);
@@ -131,7 +131,7 @@ private:
131131
// Perform a non-blocking connect. POSIX specifies that the socket
132132
// will be marked as ready for write when the connect call completes.
133133
int err = ::connect(socket_, info->ai_addr, info->ai_addrlen);
134-
#ifndef WIN32
134+
#ifndef WT_WIN32
135135
int err2 = errno;
136136
#else
137137
int err2 = GetLastError();
@@ -146,7 +146,7 @@ private:
146146
state_ = WRITE;
147147
// write() will be invoked automatically by the notifier.
148148
} else if (err == -1) {
149-
#ifndef WIN32
149+
#ifndef WT_WIN32
150150
if (err2 == EINPROGRESS) {
151151
#else
152152
if (err2 == WSAEWOULDBLOCK) {
@@ -202,7 +202,7 @@ private:
202202
readNotifier_->setEnabled(true);
203203
}
204204
} else {
205-
#ifndef WIN32
205+
#ifndef WT_WIN32
206206
if (errno != EAGAIN) {
207207
#else
208208
if (GetLastError() == WSAEWOULDBLOCK) {
@@ -228,7 +228,7 @@ private:
228228
addText(" Done! (Remote end closed connection)<br/>");
229229
cleanup();
230230
} else if (retval < 0) {
231-
#ifndef WIN32
231+
#ifndef WT_WIN32
232232
if (errno != EAGAIN) {
233233
#else
234234
if (GetLastError() == WSAEWOULDBLOCK) {
@@ -252,7 +252,7 @@ private:
252252
delete readNotifier_;
253253
delete writeNotifier_;
254254
readNotifier_ = writeNotifier_ = 0;
255-
#ifdef WIN32
255+
#ifdef WT_WIN32
256256
closesocket(socket_);
257257
#else
258258
close(socket_);

examples/hangman/Session.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#include <Wt/WApplication>
1919
#include <Wt/WLogger>
2020

21-
#ifndef WIN32
21+
#ifndef WT_WIN32
2222
#include <unistd.h>
2323
#endif
2424

25-
#if !defined(WIN32) && !defined(__CYGWIN__) && !defined(ANDROID)
25+
#if !defined(WT_WIN32) && !defined(__CYGWIN__) && !defined(ANDROID)
2626
#define HAVE_CRYPT
2727
#endif
2828

examples/treeview-dragdrop/CsvUtil.C

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,38 @@
55

66
#include <Wt/WAbstractItemModel>
77
#include <Wt/WStandardItemModel>
8+
#include <Wt/WStandardItem>
89
#include <Wt/WString>
910

1011
#include "CsvUtil.h"
1112

13+
/*
14+
* A standard item which converts text edits to numbers
15+
*/
16+
class NumericItem : public Wt::WStandardItem {
17+
public:
18+
virtual NumericItem *clone() const {
19+
return new NumericItem();
20+
}
21+
22+
virtual void setData(const boost::any &data, int role = Wt::UserRole) {
23+
boost::any dt;
24+
25+
if (role == Wt::EditRole) {
26+
std::string s = Wt::asString(data).toUTF8();
27+
28+
char *end;
29+
double d = std::strtod(s.c_str(), &end);
30+
if (*end == 0)
31+
dt = boost::any(d);
32+
else
33+
dt = data;
34+
}
35+
36+
Wt::WStandardItem::setData(dt, role);
37+
}
38+
};
39+
1240
Wt::WStandardItemModel *csvToModel(const std::string& csvFile,
1341
Wt::WObject *parent,
1442
bool firstLineIsHeaders)
@@ -17,6 +45,7 @@ Wt::WStandardItemModel *csvToModel(const std::string& csvFile,
1745

1846
if (f) {
1947
Wt::WStandardItemModel *result = new Wt::WStandardItemModel(0, 0, parent);
48+
result->setItemPrototype(new NumericItem());
2049
readFromCsv(f, result, -1, firstLineIsHeaders);
2150
return result;
2251
} else
@@ -57,22 +86,7 @@ void readFromCsv(std::istream& f, Wt::WAbstractItemModel *model,
5786
model->insertRows(model->rowCount(),
5887
dataRow + 1 - model->rowCount());
5988

60-
std::string s = *i;
61-
62-
boost::any data;
63-
64-
char *end;
65-
int i = std::strtol(s.c_str(), &end, 10);
66-
if (*end == 0)
67-
data = boost::any(i);
68-
else {
69-
double d = std::strtod(s.c_str(), &end);
70-
if (*end == 0)
71-
data = boost::any(d);
72-
else
73-
data = boost::any(Wt::WString::fromUTF8(s));
74-
}
75-
89+
boost::any data(Wt::WString::fromUTF8(*i));
7690
model->setData(dataRow, col, data);
7791
}
7892
}

examples/widgetgallery/Services.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#if defined(WT_THREADED) || defined(WT_TARGET_JAVA)
2222
#include <boost/thread.hpp>
2323
#else
24-
#if defined(WIN32)
24+
#if WT_WIN32
2525
#include <windows.h>
2626
#endif
2727
#endif
@@ -85,7 +85,7 @@ void StyleLayout::load(Wt::WMouseEvent) {
8585
#if defined(WT_THREADED) || defined(WT_TARGET_JAVA)
8686
boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
8787
#else
88-
#ifdef WIN32
88+
#ifdef WT_WIN32
8989
Sleep(2000);
9090
#else
9191
sleep(2);

0 commit comments

Comments
 (0)