Skip to content

Commit 8adeb19

Browse files
committed
Several changes:
- UpdatePasswordWidget does not delete itself when done but emit a signal. (It is useful when the widget is not in a dialog) - int role was still used in some places (instead of ItemDataRole) - refactorings and changes for JWt 4 - Fixing access modifiers that Java is stricter about
1 parent 21cae5a commit 8adeb19

Some content is hidden

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

65 files changed

+283
-164
lines changed

examples/treeview-dragdrop/CsvUtil.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public:
1818
return std::unique_ptr<NumericItem>(cpp14::make_unique<NumericItem>());
1919
}
2020

21-
virtual void setData(const cpp17::any &data, int role = ItemDataRole::User) {
21+
virtual void setData(const cpp17::any &data, ItemDataRole role = ItemDataRole::User) {
2222
cpp17::any dt;
2323

2424
if (role == ItemDataRole::Edit) {

examples/widgetgallery/examples/GitModel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ class GitModel : public Wt::WAbstractItemModel
88
/*
99
* A custom role for the file contents of a Git BLOB object.
1010
*/
11+
#ifndef WT_TARGET_JAVA
1112
static constexpr Wt::ItemDataRole ContentsRole = Wt::ItemDataRole::User + 1;
13+
#else
14+
static constexpr Wt::ItemDataRole ContentsRole = Wt::ItemDataRole::User.value() + 1;
15+
#endif
1216

1317
GitModel(const std::string& repository)
1418
: WAbstractItemModel()

examples/widgetgallery/examples/PieChart.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace {
2121
return cpp14::make_unique<NumericItem>();
2222
}
2323

24-
virtual void setData(const cpp17::any &data, int role = ItemDataRole::User) {
24+
virtual void setData(const cpp17::any &data, ItemDataRole role = ItemDataRole::User) {
2525
if (role == ItemDataRole::Edit) {
2626
cpp17::any dt;
2727

examples/widgetgallery/examples/VirtualModel.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ class VirtualModel : public Wt::WAbstractTableModel
2727

2828
virtual Wt::cpp17::any data(const Wt::WModelIndex& index, Wt::ItemDataRole role = Wt::ItemDataRole::Display) const
2929
{
30-
switch (role.value()) {
31-
case Wt::ItemDataRole::Display:
30+
if (role == Wt::ItemDataRole::Display) {
3231
if (index.column() == 0)
3332
return Wt::WString("Row {1}").arg(index.row());
3433
else
3534
return Wt::WString("Item row {1}, col {2}")
3635
.arg(index.row()).arg(index.column());
37-
default:
36+
} else {
3837
return Wt::cpp17::any();
3938
}
4039
}
@@ -44,10 +43,9 @@ class VirtualModel : public Wt::WAbstractTableModel
4443
Wt::ItemDataRole role = Wt::ItemDataRole::Display) const
4544
{
4645
if (orientation == Wt::Orientation::Horizontal) {
47-
switch (role.value()) {
48-
case Wt::ItemDataRole::Display:
46+
if (role == Wt::ItemDataRole::Display) {
4947
return Wt::WString("Column {1}").arg(section);
50-
default:
48+
} else {
5149
return Wt::cpp17::any();
5250
}
5351
} else

src/Wt/Auth/LostPasswordWidget.C

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#include "Wt/WPushButton.h"
1414

1515
namespace {
16-
void deleteBox(Wt::WMessageBox *box) {
17-
Wt::WApplication::instance()->removeChild(box);
18-
}
1916
}
2017

2118
namespace Wt {
@@ -59,7 +56,8 @@ void LostPasswordWidget::send()
5956
Icon::None, StandardButton::Ok));
6057
box->show();
6158

62-
box->buttonClicked().connect(std::bind(&deleteBox, box.get()));
59+
WMessageBox *const boxPtr = box.get();
60+
box->buttonClicked().connect(this, std::bind(&LostPasswordWidget::deleteBox, this, boxPtr));
6361
WApplication::instance()->addChild(std::move(box));
6462
}
6563

@@ -68,5 +66,10 @@ void LostPasswordWidget::cancel()
6866
removeFromParent();
6967
}
7068

69+
void LostPasswordWidget::deleteBox(Wt::WMessageBox *box) const
70+
{
71+
Wt::WApplication::instance()->removeChild(box);
72+
}
73+
7174
}
7275
}

src/Wt/Auth/LostPasswordWidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class WT_API LostPasswordWidget : public WTemplate
4141
private:
4242
AbstractUserDatabase& users_;
4343
const AuthService& baseAuth_;
44+
45+
void deleteBox(Wt::WMessageBox *box) const;
4446
};
4547

4648
}

src/Wt/Auth/OidcService.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ LOGGER("Auth.OidcService");
3535
httpClient_->setTimeout(std::chrono::seconds(15));
3636
httpClient_->setMaximumResponseSize(10 * 1024);
3737

38-
httpClient_->done().connect(std::bind(&OidcProcess::handleResponse,
38+
httpClient_->done().connect(this, std::bind(&OidcProcess::handleResponse,
3939
this, std::placeholders::_1, std::placeholders::_2));
4040

4141
std::vector<Http::Message::Header> headers;

src/Wt/Auth/UpdatePasswordWidget.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ UpdatePasswordWidget
8484
password->setFocus(true);
8585

8686
okButton->clicked().connect(this, &UpdatePasswordWidget::doUpdate);
87-
cancelButton->clicked().connect(this, &UpdatePasswordWidget::close);
87+
cancelButton->clicked().connect(this, &UpdatePasswordWidget::cancel);
8888
}
8989

9090
std::unique_ptr<WWidget> UpdatePasswordWidget
@@ -165,13 +165,13 @@ void UpdatePasswordWidget::doUpdate()
165165
registrationModel_->passwordAuth()->updatePassword(user_, password);
166166
registrationModel_->login().login(user_);
167167

168-
close();
168+
updated_.emit();
169169
}
170170
}
171171

172-
void UpdatePasswordWidget::close()
172+
void UpdatePasswordWidget::cancel()
173173
{
174-
removeFromParent();
174+
canceled_.emit();
175175
}
176176

177177
}

src/Wt/Auth/UpdatePasswordWidget.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ class WT_API UpdatePasswordWidget : public WTemplateFormView
4141
std::unique_ptr<RegistrationModel> registrationModel,
4242
const std::shared_ptr<AuthModel>& authModel);
4343

44+
/*! \brief Signal emitted when the password was updated.
45+
*/
46+
Signal<>& updated() { return updated_; }
47+
48+
/*! \brief Signal emitted when cancel clicked.
49+
*/
50+
Signal<>& canceled() { return canceled_; }
51+
4452
protected:
4553
virtual std::unique_ptr<WWidget> createFormWidget(WFormModel::Field field)
4654
override;
@@ -50,12 +58,14 @@ class WT_API UpdatePasswordWidget : public WTemplateFormView
5058

5159
std::unique_ptr<RegistrationModel> registrationModel_;
5260
std::shared_ptr<AuthModel> authModel_;
61+
Signal<> updated_;
62+
Signal<> canceled_;
5363

5464
void checkPassword();
5565
void checkPassword2();
5666
bool validate();
5767
void doUpdate();
58-
void close();
68+
void cancel();
5969
};
6070

6171
}

src/Wt/Chart/WAbstractDataSeries3D.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void WAbstractDataSeries3D::setHidden(bool enabled)
158158
WGLWidget::Texture WAbstractDataSeries3D::colorTexture()
159159
{
160160
std::unique_ptr<WPaintDevice> cpd;
161-
if (colormap_ == 0) {
161+
if (!colormap_) {
162162
cpd = chart_->createPaintDevice(WLength(1),WLength(1));
163163
WColor seriesColor = chartpaletteColor();
164164
WPainter painter(cpd.get());

0 commit comments

Comments
 (0)