fixed warnings

This commit is contained in:
Bartosz Wieczorek 2018-01-25 11:10:53 +01:00
parent 73f4b636fb
commit db8809a87e
38 changed files with 114 additions and 130 deletions

View File

@ -9,6 +9,7 @@ HunterGate(
project(eedb) project(eedb)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(HUNTER_BUILD_SHARED_LIBS TRUE) set(HUNTER_BUILD_SHARED_LIBS TRUE)
include(cmake/Compiler.cmake) include(cmake/Compiler.cmake)

View File

@ -1 +1 @@
add_definitions( -std=c++1z ) add_definitions( -std=c++17 )

View File

@ -20,7 +20,7 @@ Wt::WApplication * createApplication(const Wt::WEnvironment & env) {
using std::unique_ptr; using std::unique_ptr;
auto dbConfig = make_unique< eedb::db::PgConfig >(env); auto dbConfig = make_unique< eedb::db::PgConfig >(env);
// auto dbConnection = make_unique< eedb::db::PgConnection >(move(dbConfig)); auto dbConnection = make_unique< eedb::db::PgConnection >(move(dbConfig));
// auto session = unique_ptr< eedb::Session >(make_unique< eedb::WebSession >(move(dbConnection), env)); // auto session = unique_ptr< eedb::Session >(make_unique< eedb::WebSession >(move(dbConnection), env));
// auto authPageFactory = [_session = session.get()]()->std::unique_ptr< eedb::AuthPage > { // auto authPageFactory = [_session = session.get()]()->std::unique_ptr< eedb::AuthPage > {

View File

@ -67,4 +67,4 @@ void EEDB::authEventLogout() {
redirect(url()); redirect(url());
quit(); quit();
} }
} } // namespace eedb

View File

@ -35,4 +35,4 @@ class EEDB : public Wt::WApplication {
HomePageFactory _homePageFactory; HomePageFactory _homePageFactory;
std::unique_ptr< eedb::HomePage > _homePage; std::unique_ptr< eedb::HomePage > _homePage;
}; };
} } // namespace eedb

View File

@ -4,8 +4,7 @@
#include <eedb/db/connection.hpp> #include <eedb/db/connection.hpp>
namespace eedb { namespace eedb {
WebSession::WebSession(std::unique_ptr< eedb::db::PgConnection > dbConnection, WebSession::WebSession(std::unique_ptr< eedb::db::PgConnection > dbConnection, const Wt::WEnvironment & env)
const Wt::WEnvironment & env)
: _dbConnection(std::move(dbConnection)), _env(env) {} : _dbConnection(std::move(dbConnection)), _env(env) {}
db::PgConnection & WebSession::db() { db::PgConnection & WebSession::db() {
@ -19,4 +18,4 @@ const Wt::WEnvironment & WebSession::enviroment() const {
Wt::Auth::Login & WebSession::login() { Wt::Auth::Login & WebSession::login() {
return _login; return _login;
} }
} } // namespace eedb

View File

@ -38,4 +38,4 @@ class WebSession final : public Session {
Wt::Auth::Login _login; Wt::Auth::Login _login;
const Wt::WEnvironment & _env; const Wt::WEnvironment & _env;
}; };
} } // namespace eedb

View File

@ -17,6 +17,7 @@
#include <iostream> #include <iostream>
#include <random> #include <random>
#include <string> #include <string>
#include <experimental/string_view>
#include <Wt/Auth/AuthService.h> #include <Wt/Auth/AuthService.h>
#include <Wt/Auth/Dbo/AuthInfo.h> #include <Wt/Auth/Dbo/AuthInfo.h>
@ -30,15 +31,15 @@ using namespace Wt::Auth;
// enum LoginActions { Login, Logout }; // enum LoginActions { Login, Logout };
// static std::array< std::string_view, 2 > UserActionNames = {{"login", "logout"}}; // static std::array< std::string_view, 2 > UserActionNames = {{"login", "logout"}};
std::string RandomString(int len) { std::string RandomString(uint len) {
using namespace std; using namespace std;
srand(time(0)); srand(static_cast< unsigned int >(time(nullptr)));
string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; experimental::string_view str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
string newstr; string newstr;
int pos; std::size_t pos;
while(newstr.size() != len) { while(newstr.size() != len) {
pos = ((rand() % (str.size() - 1))); pos = ((rand() % (static_cast< int >(str.size()) - 1)));
newstr += str.substr(pos, 1); newstr += str.substr(pos, 1).to_string();
} }
return newstr; return newstr;
} }
@ -53,8 +54,7 @@ struct TransactionGuard : public Wt::Auth::AbstractUserDatabase::Transaction {
_c.native()->commit_transaction(); _c.native()->commit_transaction();
} }
void rollback() override { void rollback() override {
///FIXME _c.native()->rollback_transaction(false);
// _c.native()->rollback_transaction();
} }
private: private:
@ -85,8 +85,6 @@ namespace {
.limit(1u); .limit(1u);
} // namespace } // namespace
PgUserAuth::~PgUserAuth() {}
PgUserAuth::PgUserAuth(eedb::db::PgConnection & _db, const Wt::WEnvironment & env) : db(_db), _env(env) { PgUserAuth::PgUserAuth(eedb::db::PgConnection & _db, const Wt::WEnvironment & env) : db(_db), _env(env) {
this->setAuthService(eedb::auth::Services::authService()); this->setAuthService(eedb::auth::Services::authService());
} }
@ -106,7 +104,7 @@ User PgUserAuth::findWithId(const std::string & id) const {
User PgUserAuth::findWithIdentity(const std::string & provider, const Wt::WString & identity) const { User PgUserAuth::findWithIdentity(const std::string & provider, const Wt::WString & identity) const {
auto _identity = identity.toUTF8(); auto _identity = identity.toUTF8();
if(_authService && _authService->identityPolicy() == Wt::Auth::IdentityPolicy::EmailAddress ) { if(_authService && _authService->identityPolicy() == Wt::Auth::IdentityPolicy::EmailAddress) {
std::transform(_identity.begin(), _identity.end(), _identity.begin(), ::tolower); std::transform(_identity.begin(), _identity.end(), _identity.begin(), ::tolower);
} }

View File

@ -22,7 +22,6 @@ class PgUserAuth : public Wt::Auth::AbstractUserDatabase {
_authService = s; _authService = s;
} }
virtual ~PgUserAuth();
PgUserAuth(eedb::db::PgConnection & db, const Wt::WEnvironment & env); PgUserAuth(eedb::db::PgConnection & db, const Wt::WEnvironment & env);
Transaction * startTransaction() override; Transaction * startTransaction() override;

View File

@ -18,15 +18,16 @@ namespace {
class MyOAuth : public std::vector< const Wt::Auth::OAuthService * > { class MyOAuth : public std::vector< const Wt::Auth::OAuthService * > {
public: public:
~MyOAuth() { ~MyOAuth() {
for(unsigned i = 0; i < size(); ++i) for(unsigned i = 0; i < size(); ++i) {
delete(*this)[i]; delete(*this)[i];
}
} }
}; };
Wt::Auth::AuthService myAuthService; Wt::Auth::AuthService myAuthService;
Wt::Auth::PasswordService myPasswordService(myAuthService); Wt::Auth::PasswordService myPasswordService(myAuthService);
MyOAuth myOAuthServices; MyOAuth myOAuthServices;
} } // namespace
namespace eedb::auth { namespace eedb::auth {
Wt::Auth::AuthService * Services::authService() { Wt::Auth::AuthService * Services::authService() {
@ -46,7 +47,7 @@ void Services::configureAuth() {
myAuthService.setEmailVerificationEnabled(true); myAuthService.setEmailVerificationEnabled(true);
myAuthService.setEmailVerificationRequired(true); myAuthService.setEmailVerificationRequired(true);
{ {
auto verifier = std::unique_ptr<Wt::Auth::PasswordVerifier>(); auto verifier = std::unique_ptr< Wt::Auth::PasswordVerifier >();
verifier->addHashFunction(std::make_unique< Wt::Auth::BCryptHashFunction >(7)); verifier->addHashFunction(std::make_unique< Wt::Auth::BCryptHashFunction >(7));
myPasswordService.setVerifier(std::move(verifier)); myPasswordService.setVerifier(std::move(verifier));
} }
@ -54,13 +55,16 @@ void Services::configureAuth() {
myPasswordService.setAttemptThrottlingEnabled(true); myPasswordService.setAttemptThrottlingEnabled(true);
myPasswordService.setStrengthValidator(std::make_unique< Wt::Auth::PasswordStrengthValidator >()); myPasswordService.setStrengthValidator(std::make_unique< Wt::Auth::PasswordStrengthValidator >());
if(Wt::Auth::GoogleService::configured()) if(Wt::Auth::GoogleService::configured()) {
myOAuthServices.push_back(new Wt::Auth::GoogleService(myAuthService)); myOAuthServices.push_back(new Wt::Auth::GoogleService(myAuthService));
}
if(Wt::Auth::FacebookService::configured()) if(Wt::Auth::FacebookService::configured()) {
myOAuthServices.push_back(new Wt::Auth::FacebookService(myAuthService)); myOAuthServices.push_back(new Wt::Auth::FacebookService(myAuthService));
}
for(unsigned i = 0; i < myOAuthServices.size(); ++i) for(unsigned i = 0; i < myOAuthServices.size(); ++i) {
myOAuthServices[i]->generateRedirectEndpoint(); myOAuthServices[i]->generateRedirectEndpoint();
}
} }
}; } // namespace eedb::auth

View File

@ -19,4 +19,4 @@ class Services {
static std::vector< const Wt::Auth::OAuthService * > oAuthServices(); static std::vector< const Wt::Auth::OAuthService * > oAuthServices();
}; };
} } // namespace eedb::auth

View File

@ -4,4 +4,4 @@ namespace eedb {
class Category { class Category {
public: public:
}; };
} } // namespace eedb

View File

@ -27,4 +27,4 @@ class IUserRepository {
virtual void remove(User); virtual void remove(User);
}; };
} } // namespace eedb

View File

@ -28,14 +28,13 @@ auto auth = t_user.join(t_info).on(t_user.uid == t_info.user_uid).join(t_identit
auto auth_info_identity = t_info.join(t_identity).on(t_info.id == t_identity.auth_info_id); auto auth_info_identity = t_info.join(t_identity).on(t_info.id == t_identity.auth_info_id);
auto user_auth_info = t_user.join(t_info).on(t_info.user_uid == t_user.uid); auto user_auth_info = t_user.join(t_info).on(t_info.user_uid == t_user.uid);
auto auth_token_info = user_auth_info.join(authToken).on(authToken.auth_info_id == t_info.id); auto auth_token_info = user_auth_info.join(authToken).on(authToken.auth_info_id == t_info.id);
} } // namespace
namespace eedb { namespace eedb {
PgUserIdentity::PgUserIdentity(db::PgConnection & con, int uid, string provider) PgUserIdentity::PgUserIdentity(db::PgConnection & con, int uid, string provider) : _db(con), _provider(std::move(provider)), _email("") {
: _db(con), _provider(std::move(provider)), _email("") { select(all_of(t_identity)) //
select(all_of(t_identity)) // .from(auth_info_identity) //
.from(auth_info_identity) //
.where(t_info.user_uid == uid); .where(t_info.user_uid == uid);
} }
@ -44,18 +43,17 @@ AuthIdentity::string_view PgUserIdentity::identity() const {
const auto provider_eq = t_identity.provider == _provider; const auto provider_eq = t_identity.provider == _provider;
auto res = _db(select(t_identity.identity) // auto res = _db(select(t_identity.identity) //
.from(auth_info_identity) // .from(auth_info_identity) //
.where(id_eq and provider_eq)); .where(id_eq and provider_eq));
if(res.empty()) if(res.empty())
return {}; return {};
// _name = res.front().identity; // _name = res.front().identity;
return _name; return _name;
} }
AuthIdentity::string_view PgUserIdentity::provider() const {} AuthIdentity::string_view PgUserIdentity::provider() const {}
const AuthIdentity & PgUser::identity() const {} const AuthIdentity & PgUser::identity() const {}
@ -69,4 +67,4 @@ void PgUser::changePassword(UserPassword & password) {}
void PgUser::login(UserPassword & password) {} void PgUser::login(UserPassword & password) {}
void PgUser::logout() {} void PgUser::logout() {}
} } // namespace eedb

View File

@ -15,6 +15,7 @@ class PgUserIdentity : public AuthIdentity {
string_view identity() const override; string_view identity() const override;
string_view provider() const override; string_view provider() const override;
private: private:
eedb::db::PgConnection & _db; eedb::db::PgConnection & _db;
string _name; string _name;
@ -34,4 +35,4 @@ class PgUser : public User {
void login(UserPassword & password) override; void login(UserPassword & password) override;
void logout() override; void logout() override;
}; };
} } // namespace eedb

View File

@ -1,8 +1,8 @@
#include <eedb/data/PgUsers.hpp>
#include <eedb/data/PgUser.hpp> #include <eedb/data/PgUser.hpp>
#include <eedb/data/PgUsers.hpp>
#include <eedb/model/auth_info.h>
#include <eedb/model/auth_identity.h> #include <eedb/model/auth_identity.h>
#include <eedb/model/auth_info.h>
#include <eedb/model/auth_token.h> #include <eedb/model/auth_token.h>
namespace eedb { namespace eedb {
@ -10,24 +10,14 @@ namespace eedb {
template < typename T > template < typename T >
using shared_ptr = PgUsers::shared_ptr< T >; using shared_ptr = PgUsers::shared_ptr< T >;
shared_ptr< User > PgUsers::findWith(int) const { shared_ptr< User > PgUsers::findWith(int) const {}
}
shared_ptr< User > PgUsers::findWith(const AuthIdentity & identity) const { shared_ptr< User > PgUsers::findWith(const AuthIdentity & identity) const {}
}
shared_ptr< User > PgUsers::findWith(const Email & email) const { shared_ptr< User > PgUsers::findWith(const Email & email) const {}
}
shared_ptr< User > PgUsers::findWith(const Users::AuthToken & token) const { shared_ptr< User > PgUsers::findWith(const Users::AuthToken & token) const {}
}
shared_ptr< User > PgUsers::addUser(unique_ptr< AuthIdentity >) { shared_ptr< User > PgUsers::addUser(unique_ptr< AuthIdentity >) {}
}
} } // namespace eedb

View File

@ -13,4 +13,4 @@ class PgUsers : public Users {
shared_ptr< User > addUser(unique_ptr< AuthIdentity >) override; shared_ptr< User > addUser(unique_ptr< AuthIdentity >) override;
}; };
} } // namespace eedb

View File

@ -1,7 +1,3 @@
#include "User.hpp" #include "User.hpp"
namespace eedb { namespace eedb {}
}

View File

@ -139,4 +139,4 @@ class User {
virtual void login(UserPassword & password) = 0; virtual void login(UserPassword & password) = 0;
virtual void logout() = 0; virtual void logout() = 0;
}; };
} } // namespace eedb

View File

@ -27,4 +27,4 @@ class Users {
// adds new user into users // adds new user into users
virtual shared_ptr< User > addUser(unique_ptr< AuthIdentity >) = 0; virtual shared_ptr< User > addUser(unique_ptr< AuthIdentity >) = 0;
}; };
} } // namespace eedb

View File

@ -3,5 +3,6 @@
namespace eedb::db { namespace eedb::db {
PgConnection::PgConnection(std::shared_ptr<eedb::db::PgConfig> config) : _conn(std::make_unique< sqlpp::postgresql::connection >(config)) {} PgConnection::PgConnection(std::shared_ptr< eedb::db::PgConfig > config)
} : _conn(std::make_unique< sqlpp::postgresql::connection >(config)) {}
} // namespace eedb::db

View File

@ -15,7 +15,7 @@ class PgConnection {
return _conn.get(); return _conn.get();
} }
template < typename T > template < typename T >
auto operator()(T && t) { auto operator()(T && t) {
return _conn->operator()(std::forward< T >(t)); return _conn->operator()(std::forward< T >(t));
} }
@ -23,4 +23,4 @@ class PgConnection {
private: private:
std::unique_ptr< sqlpp::postgresql::connection > _conn; std::unique_ptr< sqlpp::postgresql::connection > _conn;
}; };
} } // namespace eedb::db

View File

@ -21,4 +21,4 @@ class AuthPage {
virtual void registerOnUserStrongLogin(std::function< void() > f) = 0; virtual void registerOnUserStrongLogin(std::function< void() > f) = 0;
virtual void registerOnUserLogout(std::function< void() > f) = 0; virtual void registerOnUserLogout(std::function< void() > f) = 0;
}; };
} } // namespace eedb

View File

@ -4,12 +4,12 @@
namespace eedb { namespace eedb {
std::shared_ptr<Wt::WTheme> BootstrapTheme::create() const { std::shared_ptr< Wt::WTheme > BootstrapTheme::create() const {
auto theme = std::shared_ptr<Wt::WBootstrapTheme>(); auto theme = std::shared_ptr< Wt::WBootstrapTheme >();
theme->setVersion(Wt::WBootstrapTheme::Version::v3); theme->setVersion(Wt::WBootstrapTheme::Version::v3);
// theme->setResponsive(true); // theme->setResponsive(true);
return theme; return theme;
} }
Theme::~Theme() = default; Theme::~Theme() = default;
} } // namespace eedb

View File

@ -11,4 +11,4 @@ class BootstrapTheme final : public Theme {
std::shared_ptr< Wt::WTheme > create() const override; std::shared_ptr< Wt::WTheme > create() const override;
}; };
} } // namespace eedb

View File

@ -18,4 +18,4 @@ class CategoriesTree {
virtual void registerOnCategoryChanged(std::function< void(const Category &) >) = 0; virtual void registerOnCategoryChanged(std::function< void(const Category &) >) = 0;
}; };
} } // namespace eedb

View File

@ -11,8 +11,9 @@ namespace std {
template <> template <>
struct default_delete< Wt::Auth::AuthWidget > { struct default_delete< Wt::Auth::AuthWidget > {
void operator()(Wt::Auth::AuthWidget * ptr) { void operator()(Wt::Auth::AuthWidget * ptr) {
if(ptr && !ptr->parent()) if(ptr && !ptr->parent()) {
delete ptr; delete ptr;
}
} }
}; };
} // namespace std } // namespace std
@ -23,7 +24,7 @@ struct DefaultAuthPage::DefaultAuthPagePriv {
DefaultAuthPagePriv(const auth::Services & baseAuth, DefaultAuthPagePriv(const auth::Services & baseAuth,
std::unique_ptr< Wt::Auth::AbstractUserDatabase > userDatabase, std::unique_ptr< Wt::Auth::AbstractUserDatabase > userDatabase,
Wt::Auth::Login & _login) Wt::Auth::Login & _login)
: _authWidget(std::make_unique< Wt::Auth::AuthWidget >(*baseAuth.authService(), *userDatabase.get(), _login)), : _authWidget(std::make_unique< Wt::Auth::AuthWidget >(*baseAuth.authService(), *userDatabase, _login)),
_userDatabase(std::move(userDatabase)) { _userDatabase(std::move(userDatabase)) {
_authWidget->model()->addPasswordAuth(eedb::auth::Services::passwordService()); _authWidget->model()->addPasswordAuth(eedb::auth::Services::passwordService());
_authWidget->model()->addOAuth(eedb::auth::Services::oAuthServices()); _authWidget->model()->addOAuth(eedb::auth::Services::oAuthServices());
@ -43,18 +44,18 @@ DefaultAuthPage::DefaultAuthPage(const auth::Services & baseAuth,
std::unique_ptr< Wt::Auth::AbstractUserDatabase > userDatabase, std::unique_ptr< Wt::Auth::AbstractUserDatabase > userDatabase,
Wt::Auth::Login & _login) Wt::Auth::Login & _login)
: _priv(std::make_unique< DefaultAuthPagePriv >(baseAuth, std::move(userDatabase), _login)) { : _priv(std::make_unique< DefaultAuthPagePriv >(baseAuth, std::move(userDatabase), _login)) {
///FIXME /// FIXME
// _priv->_authWidget->login().changed().connect([this](auto...) { // _priv->_authWidget->login().changed().connect([this](auto...) {
// if(_priv->_authWidget->login().state() == Wt::Auth::LoginState::Strong) { // if(_priv->_authWidget->login().state() == Wt::Auth::LoginState::Strong) {
// this->notifyUserStrongLogin(); // this->notifyUserStrongLogin();
// } else if(_priv->_authWidget->login().state() == Wt::Auth::LoginState::Weak) { // } else if(_priv->_authWidget->login().state() == Wt::Auth::LoginState::Weak) {
// this->notifyUserWeakLogin(); // this->notifyUserWeakLogin();
// } else if(_priv->_authWidget->login().state() == Wt::Auth::LoginState::Disabled) { // } else if(_priv->_authWidget->login().state() == Wt::Auth::LoginState::Disabled) {
// this->notifyNeedEmailVerification(); // this->notifyNeedEmailVerification();
// } else { // } else {
// this->notifyUserLogout(); // this->notifyUserLogout();
// } // }
// }); // });
} }
DefaultAuthPage::DefaultAuthPage(DefaultAuthPage && rhs) : _priv(std::move(rhs._priv)) {} DefaultAuthPage::DefaultAuthPage(DefaultAuthPage && rhs) : _priv(std::move(rhs._priv)) {}
@ -64,15 +65,15 @@ DefaultAuthPage & DefaultAuthPage::operator=(DefaultAuthPage && rhs) {
return *this; return *this;
} }
DefaultAuthPage::~DefaultAuthPage() = default;
void DefaultAuthPage::attachTo(Wt::WContainerWidget * parent) { void DefaultAuthPage::attachTo(Wt::WContainerWidget * parent) {
parent->addWidget(std::move(_priv->_authWidget)); parent->addWidget(std::move(_priv->_authWidget));
} }
void DefaultAuthPage::detach() { void DefaultAuthPage::detach() {
auto parent = dynamic_cast< Wt::WContainerWidget * >(_priv->_authWidget->parent()); auto parent = dynamic_cast< Wt::WContainerWidget * >(_priv->_authWidget->parent());
if(parent) if(parent) {
parent->removeWidget(_priv->_authWidget.get()); parent->removeWidget(_priv->_authWidget.get());
}
} }
void DefaultAuthPage::processEnvironment() { void DefaultAuthPage::processEnvironment() {

View File

@ -7,7 +7,7 @@
namespace Wt::Auth { namespace Wt::Auth {
class AbstractUserDatabase; class AbstractUserDatabase;
class Login; class Login;
} } // namespace Wt::Auth
namespace eedb::auth { namespace eedb::auth {
class Services; class Services;
@ -27,7 +27,6 @@ class DefaultAuthPage final : public AuthPage {
DefaultAuthPage & operator=(DefaultAuthPage &&); DefaultAuthPage & operator=(DefaultAuthPage &&);
// clang-format on // clang-format on
~DefaultAuthPage();
void attachTo(Wt::WContainerWidget * parent) override; void attachTo(Wt::WContainerWidget * parent) override;
void detach() override; void detach() override;
void processEnvironment() override; void processEnvironment() override;
@ -47,4 +46,4 @@ class DefaultAuthPage final : public AuthPage {
struct DefaultAuthPagePriv; struct DefaultAuthPagePriv;
std::unique_ptr< DefaultAuthPagePriv > _priv; std::unique_ptr< DefaultAuthPagePriv > _priv;
}; };
} } // namespace eedb

View File

@ -7,14 +7,16 @@
namespace std { namespace std {
/// TODO remove
template <> template <>
struct default_delete< Wt::WTreeView > { struct default_delete< Wt::WTreeView > {
void operator()(Wt::WTreeView * ptr) { void operator()(Wt::WTreeView * ptr) {
if(ptr && !ptr->parent()) if(ptr && !ptr->parent()) {
delete ptr; delete ptr;
}
} }
}; };
} } // namespace std
namespace eedb { namespace eedb {
@ -34,4 +36,4 @@ void DefaultCategoriesTree::attachTo(Wt::WContainerWidget * parent) {
} }
void DefaultCategoriesTree::registerOnCategoryChanged(std::function< void(const Category &) >) {} void DefaultCategoriesTree::registerOnCategoryChanged(std::function< void(const Category &) >) {}
} } // namespace eedb

View File

@ -10,7 +10,7 @@ class DefaultCategoriesTree final : public CategoriesTree {
// CategoriesTree interface // CategoriesTree interface
public: public:
DefaultCategoriesTree(); DefaultCategoriesTree();
~DefaultCategoriesTree(); ~DefaultCategoriesTree() override;
DefaultCategoriesTree(const DefaultCategoriesTree &) = delete; DefaultCategoriesTree(const DefaultCategoriesTree &) = delete;
DefaultCategoriesTree(DefaultCategoriesTree &&); DefaultCategoriesTree(DefaultCategoriesTree &&);
@ -28,4 +28,4 @@ class DefaultCategoriesTree final : public CategoriesTree {
struct DefaultCategoriesTreePriv; struct DefaultCategoriesTreePriv;
std::unique_ptr< DefaultCategoriesTreePriv > _priv; std::unique_ptr< DefaultCategoriesTreePriv > _priv;
}; };
} } // namespace eedb

View File

@ -8,7 +8,7 @@ namespace Wt {
class WContainerWidget; class WContainerWidget;
class WTreeView; class WTreeView;
class WNavigationBar; class WNavigationBar;
} } // namespace Wt
namespace eedb { namespace eedb {
class Session; class Session;
@ -17,7 +17,7 @@ class NavigationBar;
class DefaultHomePage final : public HomePage { class DefaultHomePage final : public HomePage {
public: public:
DefaultHomePage(Session & session, std::unique_ptr< NavigationBar > navigationBar); DefaultHomePage(Session & session, std::unique_ptr< NavigationBar > navigationBar);
~DefaultHomePage(); ~DefaultHomePage() override;
void attachTo(Wt::WContainerWidget * parent) override; void attachTo(Wt::WContainerWidget * parent) override;
@ -28,4 +28,4 @@ class DefaultHomePage final : public HomePage {
std::unique_ptr< NavigationBar > _navigationBar; std::unique_ptr< NavigationBar > _navigationBar;
Wt::WTreeView * _categoryTree; Wt::WTreeView * _categoryTree;
}; };
} } // namespace eedb

View File

@ -17,8 +17,8 @@ struct DefaultNavigationBar::DefaultNavigationBarPriv {
auto mainTabs = std::make_unique< Wt::WMenu >(); auto mainTabs = std::make_unique< Wt::WMenu >();
auto homeItem = mainTabs->addItem("Home"); auto homeItem = mainTabs->addItem("Home");
homeItem->setObjectName("navigation_bar.home_menu"); homeItem->setObjectName("navigation_bar.home_menu");
///FIXME /// FIXME
// homeItem->triggered().connect([=](auto...) {}); // homeItem->triggered().connect([=](auto...) {});
// Setup a Right-aligned menu. // Setup a Right-aligned menu.
// Create a popup submenu for the Help menu. // Create a popup submenu for the Help menu.

View File

@ -5,7 +5,7 @@
namespace Wt::Auth { namespace Wt::Auth {
class AbstractUserDatabase; class AbstractUserDatabase;
class Login; class Login;
} } // namespace Wt::Auth
namespace eedb { namespace eedb {
class DefaultNavigationBar final : public NavigationBar { class DefaultNavigationBar final : public NavigationBar {
@ -19,7 +19,7 @@ class DefaultNavigationBar final : public NavigationBar {
DefaultNavigationBar & operator=(const DefaultNavigationBar &) = delete; DefaultNavigationBar & operator=(const DefaultNavigationBar &) = delete;
DefaultNavigationBar & operator=(DefaultNavigationBar &&); DefaultNavigationBar & operator=(DefaultNavigationBar &&);
// clang-format on // clang-format on
~DefaultNavigationBar(); ~DefaultNavigationBar() override;
void attachTo(Wt::WContainerWidget * parent) override; void attachTo(Wt::WContainerWidget * parent) override;
void detach() override; void detach() override;
@ -30,4 +30,4 @@ class DefaultNavigationBar final : public NavigationBar {
struct DefaultNavigationBarPriv; struct DefaultNavigationBarPriv;
std::unique_ptr< DefaultNavigationBarPriv > _priv; std::unique_ptr< DefaultNavigationBarPriv > _priv;
}; };
} } // namespace eedb

View File

@ -4,7 +4,6 @@ namespace Wt {
class WContainerWidget; class WContainerWidget;
} }
namespace eedb { namespace eedb {
class HomePage { class HomePage {
@ -14,4 +13,4 @@ class HomePage {
virtual void attachTo(Wt::WContainerWidget * parent) = 0; virtual void attachTo(Wt::WContainerWidget * parent) = 0;
}; };
} } // namespace eedb

View File

@ -10,7 +10,7 @@
void eedb::MenuTree::createTree() { void eedb::MenuTree::createTree() {
using namespace eedb::db; using namespace eedb::db;
// using namespace sqlpp; // using namespace sqlpp;
Wt::WTree * tree = new Wt::WTree(); Wt::WTree * tree = new Wt::WTree();
@ -23,14 +23,14 @@ void eedb::MenuTree::createTree() {
tree->setTreeRoot(std::move(node)); tree->setTreeRoot(std::move(node));
node->label()->setTextFormat(Wt::TextFormat::Plain); node->label()->setTextFormat(Wt::TextFormat::Plain);
node->setLoadPolicy(Wt::ContentLoading::Lazy); node->setLoadPolicy(Wt::ContentLoading::Lazy);
///FIXME /// FIXME
// const eedb::category cat; // const eedb::category cat;
// auto r = _db(sqlpp::select(sqlpp::all_of(cat)).from(cat).where(cat.parent_path < 'root')); // auto r = _db(sqlpp::select(sqlpp::all_of(cat)).from(cat).where(cat.parent_path < 'root'));
// for(const auto & row : r) { // for(const auto & row : r) {
// node->addChildNode(new Wt::WTreeNode(row.Name)); // node->addChildNode(new Wt::WTreeNode(row.Name));
// } // }
// if (_db.is_open()){ // if (_db.is_open()){
// auto sql = "SELECT * FROM category WHERE parent_path <@ 'root'"; // auto sql = "SELECT * FROM category WHERE parent_path <@ 'root'";

View File

@ -9,16 +9,13 @@ namespace eedb::db {
class PgConnection; class PgConnection;
} }
namespace eedb { namespace eedb {
class MenuTree{ class MenuTree {
public: public:
MenuTree(db::PgConnection & con): MenuTree(db::PgConnection & con) : _db(con) {}
_db(con)
{}
private: private:
void createTree(); void createTree();
eedb::db::PgConnection & _db; eedb::db::PgConnection & _db;
}; };
} } // namespace eedb

View File

@ -12,9 +12,9 @@ class NavigationBar {
public: public:
virtual ~NavigationBar() = default; virtual ~NavigationBar() = default;
virtual void attachTo(Wt::WContainerWidget * parent) = 0; virtual void attachTo(Wt::WContainerWidget * parent) = 0;
virtual void detach() = 0; virtual void detach() = 0;
virtual void registerLogoutAction(std::function< void() > f) = 0; virtual void registerLogoutAction(std::function< void() > f) = 0;
}; };
} } // namespace eedb

View File

@ -14,8 +14,7 @@ class Theme {
virtual ~Theme(); virtual ~Theme();
virtual std::shared_ptr<Wt::WTheme> create() const = 0; virtual std::shared_ptr< Wt::WTheme > create() const = 0;
}; };
} // namespace eedb
}