Upgrade from Wt3 to Wt4

This commit is contained in:
emeric
2018-04-16 16:56:51 +02:00
parent b743127076
commit 9cb4918f44
87 changed files with 954 additions and 2057 deletions
-56
View File
@@ -1,56 +0,0 @@
/*
* Copyright (C) 2015 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wt/WConfig.h>
#if WT_VERSION < 0X03030500
#include <Wt/WTemplate>
#include <Wt/WText>
#endif
#include "InputRange.hpp"
#if WT_VERSION >= 0X03030500
InputRange::InputRange(Wt::WContainerWidget *parent)
: Wt::WWebWidget(parent)
{
setHtmlTagName("input");
setAttributeValue("type", "range");
}
std::string
InputRange::jsRef(void) const
{
return Wt::WWebWidget::jsRef();
}
#else
InputRange::InputRange(Wt::WContainerWidget *parent)
: Wt::WContainerWidget(parent)
{
addWidget(new Wt::WTemplate("<input type=\"range\"></input>"));
}
std::string
InputRange::jsRef(void) const
{
return Wt::WWebWidget::jsRef() + ".getElementsByTagName(\"input\")[0]";
}
#endif
-51
View File
@@ -1,51 +0,0 @@
/*
* Copyright (C) 2015 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Wt/WContainerWidget>
#include <Wt/WWebWidget>
#include <Wt/WConfig.h>
#if WT_VERSION >= 0X03030500
class InputRange : public Wt::WWebWidget
{
public:
InputRange(Wt::WContainerWidget *parent = 0);
Wt::DomElementType domElementType() const
{
return Wt::DomElement_INPUT;
}
std::string jsRef() const;
};
#else
class InputRange : public Wt::WContainerWidget
{
public:
InputRange(Wt::WContainerWidget *parent = 0);
std::string jsRef() const;
};
#endif
-55
View File
@@ -1,55 +0,0 @@
/*
* Copyright (C) 2015 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wt/WTimer>
#include "LineEdit.hpp"
namespace UserInterface {
LineEdit::LineEdit(std::size_t ms, Wt::WContainerWidget* parent)
: Wt::WLineEdit(parent)
{
Wt::WTimer *timer = new Wt::WTimer(this);
timer->setSingleShot(true);
timer->setInterval(ms);
this->keyWentUp().connect(std::bind([=] (Wt::WKeyEvent keyEvent)
{
if (timer->isActive())
timer->stop();
if (keyEvent.key() == Wt::Key_Enter)
_sigTimedChanged.emit(this->text());
else
timer->start();
}, std::placeholders::_1));
timer->timeout().connect(std::bind([=] ()
{
_sigTimedChanged.emit(this->text());
}));
}
} // namespace UserInterface
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright (C) 2015 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UI_LINE_EDIT_HPP
#define UI_LINE_EDIT_HPP
#include <Wt/WLineEdit>
#include <Wt/WContainerWidget>
#include <Wt/WSignal>
namespace UserInterface {
class LineEdit : public Wt::WLineEdit
{
public:
LineEdit(std::size_t ms, Wt::WContainerWidget* parent = 0);
Wt::Signal<Wt::WString>& timedChanged() { return _sigTimedChanged; }
private:
Wt::Signal<Wt::WString> _sigTimedChanged;
};
} // namespace UserInterface
#endif
+12 -9
View File
@@ -19,28 +19,31 @@
#include <boost/filesystem.hpp>
#include <Wt/WLengthValidator.h>
#include "Validators.hpp"
namespace UserInterface {
Wt::WValidator* createNameValidator()
std::shared_ptr<Wt::WValidator>
createNameValidator()
{
Wt::WLengthValidator *v = new Wt::WLengthValidator();
auto v = std::make_shared<Wt::WLengthValidator>();
v->setMandatory(true);
v->setMinimumLength(::Database::User::MinNameLength);
v->setMaximumLength(::Database::User::MaxNameLength);
return v;
}
Wt::WValidator* createMandatoryValidator()
std::shared_ptr<Wt::WValidator>
createMandatoryValidator()
{
auto v = new Wt::WValidator();
auto v = std::make_shared<Wt::WValidator>();
v->setMandatory(true);
return v;
}
DirectoryValidator::DirectoryValidator(Wt::WObject *parent)
: Wt::WValidator(parent)
DirectoryValidator::DirectoryValidator() : Wt::WValidator()
{
}
@@ -56,11 +59,11 @@ DirectoryValidator::validate(const Wt::WString& input) const
// TODO check rights
bool res = boost::filesystem::is_directory(p, ec);
if (ec)
return Wt::WValidator::Result(Wt::WValidator::Invalid, ec.message()); // TODO translate common errors
return Wt::WValidator::Result(Wt::ValidationState::Invalid, ec.message()); // TODO translate common errors
else if (res)
return Wt::WValidator::Result(Wt::WValidator::Valid);
return Wt::WValidator::Result(Wt::ValidationState::Valid);
else
return Wt::WValidator::Result(Wt::WValidator::Invalid, Wt::WString::tr("Lms.not-a-directory"));
return Wt::WValidator::Result(Wt::ValidationState::Invalid, Wt::WString::tr("Lms.not-a-directory"));
}
+4 -4
View File
@@ -19,19 +19,19 @@
#pragma once
#include <Wt/WLengthValidator>
#include <Wt/WValidator.h>
#include "database/User.hpp"
namespace UserInterface {
Wt::WValidator* createNameValidator();
Wt::WValidator* createMandatoryValidator();
std::shared_ptr<Wt::WValidator> createNameValidator();
std::shared_ptr<Wt::WValidator> createMandatoryValidator();
class DirectoryValidator : public Wt::WValidator
{
public:
DirectoryValidator(Wt::WObject *parent = 0);
DirectoryValidator();
Wt::WValidator::Result validate(const Wt::WString& input) const override;