WIP. Reorganizing things to get settings work. First attempt on Database settings

This commit is contained in:
emeric
2014-07-22 12:57:29 +02:00
parent f1cea2404e
commit 938e96cc40
32 changed files with 752 additions and 96 deletions
+29
View File
@@ -0,0 +1,29 @@
#include <boost/filesystem.hpp>
#include "DirectoryValidator.hpp"
namespace UserInterface {
DirectoryValidator::DirectoryValidator(bool mandatory, Wt::WObject *parent)
: Wt::WValidator(mandatory, parent)
{
}
Wt::WValidator::Result
DirectoryValidator::validate(const Wt::WString& input) const
{
boost::filesystem::path p(input.toUTF8());
boost::system::error_code ec;
bool res = boost::filesystem::is_directory(p, ec);
if (ec)
return Wt::WValidator::Result(Wt::WValidator::Invalid, ec.message());
else if (res)
return Wt::WValidator::Result(Wt::WValidator::Valid, "Valid");
else
return Wt::WValidator::Result(Wt::WValidator::Invalid, "Not a directory");
}
} // namespace UserInterface
+14
View File
@@ -0,0 +1,14 @@
#include <Wt/WValidator>
namespace UserInterface {
class DirectoryValidator : public Wt::WValidator
{
public:
DirectoryValidator(bool mandatory, Wt::WObject *parent = 0);
Wt::WValidator::Result validate(const Wt::WString& input) const;
};
} // namespace UserInterface
-7
View File
@@ -1,8 +1,6 @@
#ifndef UI_SESSION_DATA_HPP
#define UI_SESSION_DATA_HPP
#include <string>
#include <boost/filesystem.hpp>
#include "database/DatabaseHandler.hpp"
@@ -15,17 +13,12 @@ class SessionData
SessionData(boost::filesystem::path dbPath);
void setAuthenticatedUser(std::string user);
Database::Handler& getDatabaseHandler() { return _db;}
const Database::Handler& getDatabaseHandler() const { return _db;}
private:
Database::Handler _db;
std::string _authenticatedUser;
};