-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_window.h
executable file
·247 lines (170 loc) · 4.94 KB
/
main_window.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
//QT libraries
#include <QApplication>
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QRadioButton>
#include <QTextEdit>
#include <QListWidget>
#include <QDesktopWidget>
#include <QDate>
//C++ libraries
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include "taobao.h" //For instantianting data store and accessing data member functions
#include "product.h" //For accessing product member functions
#include "review.h" //For instantiating review objects
#include "mergesort.h" //To mergesort product and review matches
#include "user.h" //For accessing user member functions
#include <wctype.h>
class MainWindow : public QWidget {
Q_OBJECT
public:
MainWindow();
MainWindow(TaoBao& datastore);
MainWindow(TaoBao& passed_datastore, std::string user);
MainWindow(TaoBao& datastore, bool* not_hacker);
~MainWindow();
private:
//Datastore pointer
TaoBao* ds;
//Overall layout of GUI
QVBoxLayout* overall_layout;
//Greeting layout
QHBoxLayout* greeting_layout;
QLabel* greeting;
//Main layout for products and search
QHBoxLayout* search_interface;
//Product recommendation layout
QVBoxLayout* product_rec_layout;
QLabel* product_rec_label;
QListWidget* product_rec_list;
QPushButton* product_rec_button;
//Product information layout
QVBoxLayout* product_layout;
QLabel* display_product_info;
//List of product matches layout
QVBoxLayout* product_matches_layout;
QLabel* product_matches_label;
QListWidget* product_matches_list;
//Main layout for search
QVBoxLayout* search_layout;
//Search input layout
QLineEdit* search_entries;
QPushButton* search_button;
//And/Or button layout
QHBoxLayout* and_or_layout;
QRadioButton* and_button;
QRadioButton* or_button;
bool and_;
bool or_;
//Sort search layout
QHBoxLayout* sort_search_layout;
QLabel* sort_label;
QPushButton* alphabet;
QPushButton* rating;
//Cart layout
QHBoxLayout* cart_options_layout;
QPushButton* add_cart_button;
QPushButton* view_cart_button;
//Output to file
QPushButton* save_database;
QLineEdit* output_file;
//Close QT window
QHBoxLayout* exit_store_layout;
QPushButton* exit_store_button;
//Main layout for reviews
QHBoxLayout* review_interface;
//Selected review layout
QVBoxLayout* selected_review_layout;
QLabel* selected_review_label;
QLabel* selected_review_info;
//List of reviews found
QListWidget* list_of_reviews;
//Overall form layout
QVBoxLayout* overall_add_review_layout;
//Form date layout
QHBoxLayout* date_layout;
QLabel* date_format;
QLineEdit* date_input;
//Form rating layout
QHBoxLayout* rating_layout;
QLabel* rating_format;
QLineEdit* rating_input;
//Form add review layout
QHBoxLayout* review_text_layout;
QLabel* review_text_label;
QTextEdit* review_text_input;
//Add new review
QPushButton* add_review_button;
//Stores search matches
std::vector<Product*> product_matches;
//Stores review matches
std::vector<Review*> reviews_for_current_product;
//User_Cart
std::string customer_name;
QLabel* customer_cart;
QListWidget* list_of_cart_products;
QPushButton* buy_cart_button;
QPushButton* close_cart_window_button;
QPushButton* remove_product_button;
vector<Product*> cart_products;
/*
For login window
*/
QVBoxLayout* login_layout;
QHBoxLayout* login_greeting_layout;
QHBoxLayout* request_layout;
QLabel* login_greeting;
QLabel* request;
QHBoxLayout* user_input_layout;
QVBoxLayout* user_layout;
QLabel* user_label;
QLineEdit* username;
QVBoxLayout* password_layout;
QLabel* password_label;
QLineEdit* password;
QHBoxLayout* buttons_layout;
QPushButton* login_button;
QPushButton* quit_button;
//QPushButton* new_user_button;
QLabel* incorrect;
QHBoxLayout* incorrect_layout;
//Determines whether or not to instantiate main window
bool* not_hack;
//Account holder
User* user;
//Product to be recommended to the account holder
Product* top_product;
public slots:
void and_search();
void or_search();
void search_taobao();
void display_product_information(int productIndex);
void add_product_rec_to_cart();
void add_user_cart();
void view_user_cart();
void buy_user_cart();
void remove_from_user_cart();
void sort_by_average_rating();
void sort_alphabetically();
void get_reviews_for_product();
void display_selected_review(int reviewIndex);
void add_new_review();
void save_to_file();
/*
Additions
*/
void verify_user();
};
#endif