This repository was archived by the owner on Aug 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
156 lines (151 loc) · 3.36 KB
/
main.cpp
File metadata and controls
156 lines (151 loc) · 3.36 KB
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
#undef UNICODE // Avoid VS compilation error
#include <iostream>
#include "Query.h"
#include "Base.h"
#include "Files.h"
#include "Operations.h"
void option(int posX, int posY);
bool search(baseData* data);
int main()
{
resizeConsole(1200, 700);
fixConsoleWindow();
HidePointer();
option(OPTION_POSX, OPTION_POSY);
return 0;
}
bool search(baseData* data)
{
drawBoard(38, 23, 3, 95, 13);
goToXY(40, 24); cout << "ENTER YOUR SEARCH: ";
ShowPointer();
string str;
if (!getQuery(str, 12))
{
HidePointer();
return false;
}
HidePointer();
system("cls");
printNote(NOTE_POSX, NOTE_POSY);
goToXY(14, 3);
textColor(0, 13); cout << "YOUR QUERY: ";
textColor(0, 13); cout<< shortenName(str, 110) << endl;
drawBoard(10, 2, 2, 130, 13);
queryData q1 = queryData(str, true);
double processingTime = Operations::opWrapper(&q1, data, false);
vector<pair<int, double> > scores = q1.getScores();
vector<pair<int, double>> listFile;
listFile = q1.getScores();
drawBoard(FILES_POSX - 5, FILES_POSY - 2, FILES_CNT * 2 + 6, FILES_LEN + 10, 12);
if (listFile.size() == 0)
{
textColor(0, 4);
int x = FILES_POSX, y = FILES_POSY + 2;
goToXY(x, y++); cout << "[INFO] No file matches your query!";
goToXY(x, y++); cout << "[INFO] Please try again!";
goToXY(x, y); system("pause");
return true;
}
else
{
FilesList filesList(listFile, data, &q1, processingTime);
filesList.printList(0);
while (true)
{
if (!filesList.moveFiles())
return true;
}
}
}
void option(int posX, int posY)
{
baseData data;
int cur = 0;
bool isArrow = false;
int keyValue;
system("cls");
printNote(NOTE_POSX, NOTE_POSY);
printHCMUS(40, 8);
data.theLoadFromCSV();
printOptionList(cur, posX, posY);
drawBoard(OPTION_POSX - 5, OPTION_POSY - 2, 12, 20, 13);
while (true)
{
while (true)
{
if (_kbhit())
{
keyValue = toupper(_getch());
if (keyValue == 224)
{
isArrow = true;
continue;
}
if (isArrow)
{
isArrow = false;
if (keyValue == 72 && cur > 0)
printOptionList(--cur, posX, posY);
if (keyValue == 80 && cur < 3)
printOptionList(++cur, posX, posY);
break;
}
if (keyValue == 13)
{
if (cur == 0)
{
textColor(0, 4);
int x = 45, y = 22;
data.clear();
data.loadFromFiles("newData", x, y);
data.saveToFile(x, y);
goToXY(x, y); system("pause");
}
if (cur == 1)
{
textColor(0, 4);
int x = 45, y = 22;
data.clear();
data.readFromFile(x, y);
goToXY(x, y); system("pause");
}
if (cur == 2)
{
bool ok = true;
if (data.isEmpty)
{
ok = false;
textColor(0, 4);
int x = 45, y = 22;
goToXY(x, y++); cout << "[ERROR] The data is empty, please try loading data!";
goToXY(x, y); system("pause");
}
while (ok)
{
if (!search(&data))
break;
system("cls");
printNote(NOTE_POSX, NOTE_POSY);
printHCMUS(40, 8);
printOptionList(cur, posX, posY);
drawBoard(OPTION_POSX - 5, OPTION_POSY - 2, 12, 20, 13);
}
}
if (cur == 3)
{
system("cls");
data.clear();
return;
}
system("cls");
printNote(NOTE_POSX, NOTE_POSY);
printHCMUS(40, 8);
printOptionList(cur, posX, posY);
drawBoard(OPTION_POSX - 5, OPTION_POSY - 2, 12, 20, 13);
break;
}
}
}
}
}