Search added, but change window and back lets app crash
This commit is contained in:
38
src/app.h
38
src/app.h
@@ -7,6 +7,7 @@
|
||||
#include "curl/curl.h"
|
||||
#include <libxml2/libxml/tree.h>
|
||||
#include <libxml2/libxml/xpath.h>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Magick {
|
||||
class Image;
|
||||
@@ -18,7 +19,7 @@ public:
|
||||
~App();
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> genders_ {
|
||||
std::map<Wt::WString, Wt::WString> genders_ {
|
||||
{"F", "Female"},
|
||||
{"M", "Male"},
|
||||
{"P", "Pair"},
|
||||
@@ -46,6 +47,22 @@ private:
|
||||
{";p", Smiley("1F61C", "Twinkle tongue")},
|
||||
{":'(", Smiley("1F622", "Cry")}
|
||||
};
|
||||
struct Search {
|
||||
Wt::WContainerWidget *outputContainer;
|
||||
Wt::WString userName{""};
|
||||
int minAge{18};
|
||||
int maxAge{150};
|
||||
std::unordered_set<std::string> gender;
|
||||
std::unordered_set<std::string> countries;
|
||||
Search()=default;
|
||||
Search(Wt::WContainerWidget *outputContainer_):
|
||||
outputContainer(outputContainer_) {
|
||||
set = true;
|
||||
gender.insert("All");
|
||||
countries.insert("All");
|
||||
}
|
||||
bool set = false;
|
||||
};
|
||||
Wt::WString smileyPlaceholder_ = "&#x{1};";
|
||||
const Wt::WEnvironment &env_;
|
||||
Broadcast &server_;
|
||||
@@ -60,7 +77,9 @@ private:
|
||||
bool inboxOpen_{false};
|
||||
int messageCursorPosition_{-1};
|
||||
std::unique_ptr<Wt::WSound> messageReceived_;
|
||||
Search searchFields;
|
||||
void initApp();
|
||||
void reSetUser();
|
||||
Wt::WVBoxLayout *createVerticalLayout();
|
||||
Wt::WHBoxLayout *createActionLayout(Wt::WVBoxLayout *verticalContainer);
|
||||
void createUserListContainer(Wt::WHBoxLayout *layout);
|
||||
@@ -88,7 +107,10 @@ private:
|
||||
void addIdentifier();
|
||||
void addSearchButton();
|
||||
void addInboxButton();
|
||||
void executeSearch();
|
||||
void showSearchWindow();
|
||||
void startSearch();
|
||||
void showSearch(Wt::Json::Object broadcast);
|
||||
template<class Class> Class *addSearchItemLine(Wt::WVBoxLayout *layout, std::string label, std::unique_ptr<Wt::WContainerWidget> additionalItem = nullptr);
|
||||
void openInbox();
|
||||
bool isNickAllowed(const std::string &nick);
|
||||
bool compareJsonObjects(const Wt::Json::Object &obj1, const Wt::Json::Object &obj2);
|
||||
@@ -146,6 +168,18 @@ private:
|
||||
Wt::WWebWidget *createImageElement(Wt::Json::Object &line, const std::string &writer, Wt::WContainerWidget *outputContainer);
|
||||
Wt::WWebWidget *createTextElement(const std::string &writer, const std::string &text, Wt::WContainerWidget *outputContainer);
|
||||
void createImprintContainer(Wt::WVBoxLayout *containerLayout);
|
||||
Wt::WContainerWidget *setupSearchButton(Wt::WVBoxLayout *contentLayout);
|
||||
void restoreSearchFields(Wt::WContainerWidget *searchResultContainer, Wt::WLineEdit *userNameEdit, Wt::WSpinBox *minAgeEdit, Wt::WSpinBox *maxAgeEdit, Wt::WContainerWidget *countryDropDownContainer, Wt::WContainerWidget *gendersDropDownContainer, Wt::WPushButton *countryOpenList, Wt::WPushButton *gendersOpenList);
|
||||
Wt::WLineEdit *setupNameSearchField(Wt::WVBoxLayout *contentLayout);
|
||||
std::pair<Wt::WPushButton *, Wt::WContainerWidget *> setupGendersDropDown(Wt::WVBoxLayout *contentLayout);
|
||||
std::pair<Wt::WPushButton *, Wt::WContainerWidget *> setupCountryDropDown(Wt::WVBoxLayout *contentLayout);
|
||||
std::pair<Wt::WSpinBox*, Wt::WSpinBox*> setupSearchFields(Wt::WVBoxLayout *contentLayout);
|
||||
Wt::WVBoxLayout *resetSearchFields();
|
||||
void itemChanged(Wt::WCheckBox *item, Wt::WContainerWidget *dropDownContainer, Wt::WPushButton *openButton, std::unordered_set<std::string> *saveItems);
|
||||
void addItem(const std::string &country, Wt::WContainerWidget *dropDownContainer, Wt::WPushButton *openListButton, std::unordered_set<std::string> *saveItems, bool isSelected = false);
|
||||
void addUserItemToLayout(Wt::WVBoxLayout *layout, Wt::Json::Object userObject);
|
||||
std::unordered_set<std::string> gendersListToShortGendersList(std::unordered_set<std::string> gendersList);
|
||||
std::string genderShortOfGender(const std::string incomingGender);
|
||||
};
|
||||
|
||||
#endif // APP_H
|
||||
|
||||
Reference in New Issue
Block a user