修bug。
This commit is contained in:
@@ -21,7 +21,7 @@ int main() {
|
||||
cout << "test" << f << endl;
|
||||
const std::function<const int(const int)> &func([](const int a) { return a + 1;});
|
||||
const std::function<const int(const int)> &func2 = func;
|
||||
|
||||
cout << -20 / 20 << endl;
|
||||
std::string aString;
|
||||
cin >> aString;
|
||||
cout << aString << endl;
|
||||
|
||||
@@ -26,11 +26,12 @@ ListDisplay::ListDisplay(const List<BaseRecord *> &_allRecordsPtrList)
|
||||
searchForStu(), searchForCourseName(""),
|
||||
searchForRecordType(StuRecord::Any), recordNumPerPage(20),
|
||||
currentPageIndex(0),
|
||||
maxPageIndex(allRecordsPtrList.length() / recordNumPerPage),
|
||||
maxPageIndex((allRecordsPtrList.length() - 1) / recordNumPerPage),
|
||||
sortOrder(ASCENT), sortByProp(RecordID) {
|
||||
this->filteredRecordsPtrList =
|
||||
allRecordsPtrList.filtered([](BaseRecord *const &) { return true; });
|
||||
};
|
||||
// -1 / 20 = 0, so don't worry about the maxPageIndex being -1.
|
||||
|
||||
bool ListDisplay::hasNext() {
|
||||
return currentPageIndex < maxPageIndex;
|
||||
@@ -45,7 +46,6 @@ void ListDisplay::next() {
|
||||
throw(PageIndexError("No next page!"));
|
||||
}
|
||||
this->currentPageIndex++;
|
||||
this->reapplyFilter();
|
||||
}
|
||||
|
||||
void ListDisplay::prev() {
|
||||
@@ -53,7 +53,6 @@ void ListDisplay::prev() {
|
||||
throw(PageIndexError("No prev page!"));
|
||||
}
|
||||
this->currentPageIndex--;
|
||||
this->reapplyFilter();
|
||||
}
|
||||
|
||||
void ListDisplay::display() {
|
||||
@@ -158,8 +157,8 @@ void ListDisplay::flipSortOrder() {
|
||||
void ListDisplay::reapplyFilter() {
|
||||
this->filteredRecordsPtrList = this->allRecordsPtrList.filtered(
|
||||
[&](BaseRecord *const &recordPtr) -> bool {
|
||||
return (recordPtr->getDate() > this->fromDate &&
|
||||
recordPtr->getDate() < this->toDate &&
|
||||
return (recordPtr->getDate() >= this->fromDate &&
|
||||
recordPtr->getDate() <= this->toDate &&
|
||||
recordPtr->getStudent() == this->searchForStu &&
|
||||
(this->searchForCourseName.empty() ||
|
||||
recordPtr->getCourseName() == this->searchForCourseName) &&
|
||||
@@ -226,7 +225,7 @@ void ListDisplay::reapplyFilter() {
|
||||
}
|
||||
this->currentPageIndex = 0;
|
||||
this->maxPageIndex =
|
||||
this->filteredRecordsPtrList.length() / this->recordNumPerPage;
|
||||
(this->filteredRecordsPtrList.length() - 1) / this->recordNumPerPage;
|
||||
}
|
||||
|
||||
void ListDisplay::promptForRecordID() {
|
||||
@@ -263,35 +262,35 @@ void ListDisplay::promptForFromDate() {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Year: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_year =
|
||||
(tempInput == 0 ? curDate->tm_year : tempInput - 1900);
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Month: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_mon = (tempInput == 0 ? curDate->tm_mon : tempInput - 1);
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Day: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_mday = (tempInput == 0 ? curDate->tm_mday : tempInput);
|
||||
}
|
||||
else {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Year: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_year = tempInput - 1900;
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Month: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_mon = tempInput - 1;
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Day: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_mday = tempInput;
|
||||
}
|
||||
this->fromDate = mktime(curDate);
|
||||
@@ -312,37 +311,41 @@ void ListDisplay::promptForToDate() {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Year: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_year =
|
||||
(tempInput == 0 ? curDate->tm_year : tempInput - 1900);
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Month: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_mon = (tempInput == 0 ? curDate->tm_mon : tempInput - 1);
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Day: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_mday = (tempInput == 0 ? curDate->tm_mday : tempInput);
|
||||
}
|
||||
else {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Year: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_year = tempInput - 1900;
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Month: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_mon = tempInput - 1;
|
||||
std::cout << setoutputcolor(ConsoleColorTool::blue)
|
||||
<< "Day: " << resetOutputColor << std::flush;
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
std::cin.ignore();
|
||||
curDate->tm_mday = tempInput;
|
||||
}
|
||||
curDate->tm_hour = 0;
|
||||
curDate->tm_min = 0;
|
||||
curDate->tm_sec = 0;
|
||||
curDate->tm_isdst = 0;
|
||||
this->toDate = mktime(curDate);
|
||||
this->reapplyFilter();
|
||||
}
|
||||
@@ -424,15 +427,15 @@ void ListDisplay::promptForRecordType() {
|
||||
}
|
||||
else if (tempIn == "1" || tempIn == "l" || tempIn == "late" ||
|
||||
tempIn == "L" || tempIn == "Late") {
|
||||
tempIn = StuRecord::Late;
|
||||
this->searchForRecordType = StuRecord::Late;
|
||||
}
|
||||
else if (tempIn == "2" || tempIn == "a" || tempIn == "absent" ||
|
||||
tempIn == "A" || tempIn == "Absent") {
|
||||
tempIn = StuRecord::Absent;
|
||||
this->searchForRecordType = StuRecord::Absent;
|
||||
}
|
||||
else if (tempIn == "3" || tempIn == "p" || tempIn == "personal" ||
|
||||
tempIn == "P" || tempIn == "Personal") {
|
||||
tempIn = StuRecord::PersonalLeave;
|
||||
this->searchForRecordType = StuRecord::PersonalLeave;
|
||||
}
|
||||
else {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::red)
|
||||
|
||||
20
大作业/Makefile
20
大作业/Makefile
@@ -1,28 +1,28 @@
|
||||
generalArguments = -std=c++17
|
||||
generalArguments = -std=c++17 -g
|
||||
|
||||
main.out: main.o Tools.o Exceptions.o Record.o Date.o Student.o StudentInfoManager.o ListDisplay.o
|
||||
clang++ $(generalArguments) -g $^ -o main.out
|
||||
clang++ $(generalArguments) $^ -o main.out
|
||||
|
||||
main.o: main.cpp ListE.hpp Node.hpp
|
||||
clang++ $(generalArguments) -g -c main.cpp -o main.o
|
||||
clang++ $(generalArguments) -c main.cpp -o main.o
|
||||
|
||||
Exceptions.o: Exceptions.cpp Exceptions.hpp
|
||||
clang++ $(generalArguments) -g -c Exceptions.cpp -o Exceptions.o
|
||||
clang++ $(generalArguments) -c Exceptions.cpp -o Exceptions.o
|
||||
|
||||
Record.o: Record.cpp Record.hpp Date.hpp Student.hpp Tools.hpp
|
||||
clang++ $(generalArguments) -g -c Record.cpp -o Record.o
|
||||
clang++ $(generalArguments) -c Record.cpp -o Record.o
|
||||
|
||||
Date.o: Date.cpp Date.hpp Exceptions.hpp
|
||||
clang++ $(generalArguments) -g -c Date.cpp -o Date.o
|
||||
clang++ $(generalArguments) -c Date.cpp -o Date.o
|
||||
|
||||
Tools.o: Tools.cpp Tools.hpp
|
||||
clang++ $(generalArguments) -g -c Tools.cpp -o Tools.o
|
||||
clang++ $(generalArguments) -c Tools.cpp -o Tools.o
|
||||
|
||||
ListDisplay.o: ListDisplay.cpp ListDisplay.hpp Date.hpp Student.hpp
|
||||
clang++ $(generalArguments) -g -c ListDisplay.cpp -o ListDisplay.o
|
||||
clang++ $(generalArguments) -c ListDisplay.cpp -o ListDisplay.o
|
||||
|
||||
Student.o: Student.cpp Student.hpp
|
||||
clang++ $(generalArguments) -g -c Student.cpp -o Student.o
|
||||
clang++ $(generalArguments) -c Student.cpp -o Student.o
|
||||
|
||||
StudentInfoManager.o: StudentInfoManager.cpp StudentInfoManager.hpp ListDisplay.o
|
||||
clang++ $(generalArguments) -g -c StudentInfoManager.cpp -o StudentInfoManager.o
|
||||
clang++ $(generalArguments) -c StudentInfoManager.cpp -o StudentInfoManager.o
|
||||
@@ -9,8 +9,7 @@
|
||||
bool StudentInfoManager::promptForFileName() {
|
||||
bool selectedCommand = false;
|
||||
bool isNewFile = false;
|
||||
infoManagerCommand::promptFileName::cmd cmd =
|
||||
infoManagerCommand::promptFileName::unknown;
|
||||
infoManagerCommand::promptFileName::cmd cmd;
|
||||
while (true) {
|
||||
// Display title.
|
||||
clearScreen();
|
||||
@@ -29,6 +28,7 @@ bool StudentInfoManager::promptForFileName() {
|
||||
|
||||
std::cout << "(Command)" << std::flush;
|
||||
backSpaceCount = 9;
|
||||
cmd = (infoManagerCommand::promptFileName::cmd)0;
|
||||
disableEchoBack();
|
||||
while (true) {
|
||||
commandLetter = std::cin.get();
|
||||
@@ -44,15 +44,16 @@ bool StudentInfoManager::promptForFileName() {
|
||||
cmd = infoManagerCommand::promptFileName::newFile;
|
||||
}
|
||||
else if (commandLetter == 13) {
|
||||
if (cmd != infoManagerCommand::promptFileName::unknown) {
|
||||
if (cmd != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::red) << "Unknown"
|
||||
<< resetOutputColor << std::flush;
|
||||
backSpaceCount = 7;
|
||||
cmd = infoManagerCommand::promptFileName::unknown;
|
||||
std::cout << setoutputcolor(ConsoleColorTool::red)
|
||||
<< "Unknown file operation" << resetOutputColor
|
||||
<< std::flush;
|
||||
backSpaceCount = 22;
|
||||
cmd = (infoManagerCommand::promptFileName::cmd)0;
|
||||
}
|
||||
}
|
||||
enableEchoBack();
|
||||
@@ -89,14 +90,35 @@ bool StudentInfoManager::promptForFileName() {
|
||||
}
|
||||
else if (cmd == infoManagerCommand::promptFileName::newFile) {
|
||||
if (tempFile.exists() && tempFile.is_regular_file()) {
|
||||
std::cout << "The file already exists. Replace? Type y for "
|
||||
"\"yes\" and anything else for no. "
|
||||
int backSpaceCount = 0;
|
||||
bool overWrite = false;
|
||||
std::cout << "The file already exists. Replace? (y / n): "
|
||||
<< std::flush;
|
||||
|
||||
std::cout << "no" << std::flush;
|
||||
backSpaceCount = 2;
|
||||
disableEchoBack();
|
||||
// commandLetter reused here.
|
||||
commandLetter = std::cin.get();
|
||||
while (true) {
|
||||
commandLetter = std::cin.get();
|
||||
if (commandLetter == 'y') {
|
||||
backSpace(backSpaceCount);
|
||||
std::cout << "yes" << std::flush;
|
||||
backSpaceCount = 3;
|
||||
overWrite = true;
|
||||
}
|
||||
else if (commandLetter == 'n') {
|
||||
backSpace(backSpaceCount);
|
||||
std::cout << "no" << std::flush;
|
||||
backSpaceCount = 2;
|
||||
overWrite = false;
|
||||
}
|
||||
else if (commandLetter == 13) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
enableEchoBack();
|
||||
if (commandLetter != 'y') {
|
||||
if (!overWrite) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -255,7 +277,7 @@ bool StudentInfoManager::cmdNew() {
|
||||
|
||||
std::cout << "(Record Type)" << std::flush;
|
||||
backSpaceCount = 13;
|
||||
cmd = infoManagerCommand::promptNewRecord::unknown;
|
||||
cmd = (infoManagerCommand::promptNewRecord::cmd)0;
|
||||
disableEchoBack();
|
||||
while (true) {
|
||||
commandLetter = std::cin.get();
|
||||
@@ -276,7 +298,7 @@ bool StudentInfoManager::cmdNew() {
|
||||
cmd = infoManagerCommand::promptNewRecord::PersonalLeaveRecord;
|
||||
}
|
||||
else if (commandLetter == 13) {
|
||||
if (cmd != infoManagerCommand::promptNewRecord::unknown) {
|
||||
if (cmd != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -289,7 +311,7 @@ bool StudentInfoManager::cmdNew() {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::red) << "Unknown"
|
||||
<< resetOutputColor << std::flush;
|
||||
backSpaceCount = 7;
|
||||
cmd = infoManagerCommand::promptNewRecord::unknown;
|
||||
cmd = (infoManagerCommand::promptNewRecord::cmd)0;
|
||||
}
|
||||
}
|
||||
enableEchoBack();
|
||||
@@ -333,6 +355,10 @@ bool StudentInfoManager::cmdNew() {
|
||||
newDate.tm_year = curDate->tm_year;
|
||||
newDate.tm_mon = curDate->tm_mon;
|
||||
newDate.tm_mday = curDate->tm_mday;
|
||||
newDate.tm_hour = 0;
|
||||
newDate.tm_min = 0;
|
||||
newDate.tm_sec = 0;
|
||||
newDate.tm_isdst = 0;
|
||||
newDateTime = mktime(&newDate);
|
||||
}
|
||||
else {
|
||||
@@ -353,6 +379,10 @@ bool StudentInfoManager::cmdNew() {
|
||||
std::cin >> tempInput;
|
||||
std::cin.ignore();
|
||||
newDate.tm_mday = tempInput;
|
||||
newDate.tm_hour = 0;
|
||||
newDate.tm_min = 0;
|
||||
newDate.tm_sec = 0;
|
||||
newDate.tm_isdst = 0;
|
||||
newDateTime = mktime(&newDate);
|
||||
}
|
||||
|
||||
@@ -439,7 +469,7 @@ bool StudentInfoManager::cmdModify() {
|
||||
|
||||
std::cout << "(Property to be changed)" << std::flush;
|
||||
backSpaceCount = 24;
|
||||
cmd = infoManagerCommand::promptNewInfo::unknown;
|
||||
cmd = (infoManagerCommand::promptNewInfo::cmd)0;
|
||||
disableEchoBack();
|
||||
while (true) {
|
||||
commandLetter = std::cin.get();
|
||||
@@ -460,7 +490,7 @@ bool StudentInfoManager::cmdModify() {
|
||||
cmd = infoManagerCommand::promptNewInfo::studentInfo;
|
||||
}
|
||||
else if (commandLetter == 13) {
|
||||
if (cmd != infoManagerCommand::promptNewInfo::unknown) {
|
||||
if (cmd != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -468,7 +498,7 @@ bool StudentInfoManager::cmdModify() {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::red) << "Unknown"
|
||||
<< resetOutputColor << std::flush;
|
||||
backSpaceCount = 7;
|
||||
cmd = infoManagerCommand::promptNewInfo::unknown;
|
||||
cmd = (infoManagerCommand::promptNewInfo::cmd)0;
|
||||
}
|
||||
}
|
||||
enableEchoBack();
|
||||
@@ -498,7 +528,12 @@ bool StudentInfoManager::cmdSetFilter() {
|
||||
while (true) {
|
||||
commandLetter = std::cin.get();
|
||||
backSpace(backSpaceCount);
|
||||
if (commandLetter == 'f') {
|
||||
if (commandLetter == 'i') {
|
||||
std::cout << "Record ID" << std::flush;
|
||||
backSpaceCount = 9;
|
||||
cmd = infoManagerCommand::filterSettings::recordID;
|
||||
}
|
||||
else if (commandLetter == 'f') {
|
||||
std::cout << "From date" << std::flush;
|
||||
backSpaceCount = 9;
|
||||
cmd = infoManagerCommand::filterSettings::fromDate;
|
||||
@@ -513,7 +548,7 @@ bool StudentInfoManager::cmdSetFilter() {
|
||||
backSpaceCount = 11;
|
||||
cmd = infoManagerCommand::filterSettings::courseName;
|
||||
}
|
||||
else if (commandLetter == 'i') {
|
||||
else if (commandLetter == 't') {
|
||||
std::cout << "Student ID" << std::flush;
|
||||
backSpaceCount = 10;
|
||||
cmd = infoManagerCommand::filterSettings::studentID;
|
||||
@@ -547,6 +582,12 @@ bool StudentInfoManager::cmdSetFilter() {
|
||||
enableEchoBack();
|
||||
|
||||
switch (cmd) {
|
||||
case infoManagerCommand::filterSettings::recordID:
|
||||
clearScreen();
|
||||
this->displayer.promptForRecordID();
|
||||
waitForAnyInput();
|
||||
break;
|
||||
|
||||
case infoManagerCommand::filterSettings::fromDate:
|
||||
this->displayer.promptForFromDate();
|
||||
break;
|
||||
@@ -679,10 +720,11 @@ void StudentInfoManager::displayHelp() {
|
||||
std::cout << "(M)odify record\n";
|
||||
std::cout << "(S)et filter\n";
|
||||
std::cout << resetOutputColor;
|
||||
std::cout << "├─ Record (I)D\n";
|
||||
std::cout << "├─ (F)rom date\n";
|
||||
std::cout << "├─ (T)o date\n";
|
||||
std::cout << "├─ (C)ourse name\n";
|
||||
std::cout << "├─ Student (I)D\n";
|
||||
std::cout << "├─ Studen(t) ID\n";
|
||||
std::cout << "├─ Student (N)ame\n";
|
||||
std::cout << "└─ (R)ecord type\n";
|
||||
std::cout << setoutputcolor(ConsoleColorTool::green);
|
||||
@@ -701,6 +743,7 @@ void StudentInfoManager::displayHelp() {
|
||||
std::cout << "Previous Page (k)\n";
|
||||
std::cout << "Show (h)elp\n";
|
||||
std::cout << "(Q)uit" << resetOutputColor << std::endl;
|
||||
waitForAnyInput();
|
||||
}
|
||||
|
||||
void StudentInfoManager::mainloop() {
|
||||
@@ -708,7 +751,7 @@ void StudentInfoManager::mainloop() {
|
||||
|
||||
char commandLetter;
|
||||
int backSpaceCount = 0;
|
||||
infoManagerCommand::home::cmd cmd = infoManagerCommand::home::unknown;
|
||||
infoManagerCommand::home::cmd cmd;
|
||||
|
||||
while (run) {
|
||||
// Display the info
|
||||
@@ -717,7 +760,7 @@ void StudentInfoManager::mainloop() {
|
||||
|
||||
std::cout << "(Command)" << std::flush;
|
||||
backSpaceCount = 9;
|
||||
cmd = infoManagerCommand::home::unknown;
|
||||
cmd = (infoManagerCommand::home::cmd)0;
|
||||
disableEchoBack();
|
||||
while (true) {
|
||||
commandLetter = std::cin.get();
|
||||
@@ -758,27 +801,50 @@ void StudentInfoManager::mainloop() {
|
||||
cmd = infoManagerCommand::home::flipSortOrder;
|
||||
}
|
||||
else if (commandLetter == 'j') {
|
||||
std::cout << "Next Page" << std::flush;
|
||||
backSpaceCount = 9;
|
||||
cmd = infoManagerCommand::home::nextPage;
|
||||
// std::cout << "Next Page" << std::flush;
|
||||
// backSpaceCount = 9;
|
||||
// cmd = infoManagerCommand::home::nextPage;
|
||||
if (this->displayer.hasNext()) {
|
||||
this->displayer.next();
|
||||
break;
|
||||
}
|
||||
else {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::red)
|
||||
<< "No next page" << resetOutputColor;
|
||||
backSpaceCount = 12;
|
||||
}
|
||||
}
|
||||
else if (commandLetter == 'k') {
|
||||
std::cout << "Previous Page" << std::flush;
|
||||
backSpaceCount = 13;
|
||||
cmd = infoManagerCommand::home::prevPage;
|
||||
// std::cout << "Previous Page" << std::flush;
|
||||
// backSpaceCount = 13;
|
||||
// cmd = infoManagerCommand::home::prevPage;
|
||||
if (this->displayer.hasPrev()) {
|
||||
this->displayer.prev();
|
||||
break;
|
||||
}
|
||||
else {
|
||||
std::cout << setoutputcolor(ConsoleColorTool::red)
|
||||
<< "No previous page" << resetOutputColor;
|
||||
backSpaceCount = 16;
|
||||
}
|
||||
}
|
||||
else if (commandLetter == 'h') {
|
||||
std::cout << "Show help" << std::flush;
|
||||
backSpaceCount = 9;
|
||||
cmd = infoManagerCommand::home::help;
|
||||
}
|
||||
else if (commandLetter == 'w') {
|
||||
std::cout << "Write to disk" << std::flush;
|
||||
backSpaceCount = 13;
|
||||
cmd = infoManagerCommand::home::saveFile;
|
||||
}
|
||||
else if (commandLetter == 'q') {
|
||||
std::cout << "Quit" << std::flush;
|
||||
backSpaceCount = 4;
|
||||
cmd = infoManagerCommand::home::quit;
|
||||
}
|
||||
else if (commandLetter == 13) {
|
||||
if (cmd != infoManagerCommand::home::unknown) {
|
||||
if (cmd != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -787,7 +853,7 @@ void StudentInfoManager::mainloop() {
|
||||
<< "Unknown (type h + <Enter> for help)"
|
||||
<< resetOutputColor << std::flush;
|
||||
backSpaceCount = 35;
|
||||
cmd = infoManagerCommand::home::unknown;
|
||||
cmd = (infoManagerCommand::home::cmd)0;
|
||||
}
|
||||
}
|
||||
enableEchoBack();
|
||||
@@ -822,16 +888,6 @@ void StudentInfoManager::mainloop() {
|
||||
else if (cmd == infoManagerCommand::home::flipSortOrder) {
|
||||
this->displayer.flipSortOrder();
|
||||
}
|
||||
else if (cmd == infoManagerCommand::home::nextPage) {
|
||||
if (this->displayer.hasNext()) {
|
||||
this->displayer.next();
|
||||
}
|
||||
}
|
||||
else if (cmd == infoManagerCommand::home::prevPage) {
|
||||
if (this->displayer.hasPrev()) {
|
||||
this->displayer.prev();
|
||||
}
|
||||
}
|
||||
else if (cmd == infoManagerCommand::home::help) {
|
||||
this->displayHelp();
|
||||
}
|
||||
@@ -848,7 +904,6 @@ void StudentInfoManager::mainloop() {
|
||||
this->closeFile();
|
||||
this->hasChangePendingSave = false;
|
||||
run = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,42 +9,40 @@
|
||||
namespace infoManagerCommand {
|
||||
namespace home {
|
||||
enum cmd {
|
||||
newRecord,
|
||||
newRecord = 1,
|
||||
removeRecord,
|
||||
modifyRecord,
|
||||
setFilter,
|
||||
unsetFilter,
|
||||
setSortBy,
|
||||
flipSortOrder,
|
||||
nextPage,
|
||||
prevPage,
|
||||
help,
|
||||
saveFile,
|
||||
closeFile,
|
||||
quit,
|
||||
unknown
|
||||
quit
|
||||
};
|
||||
}
|
||||
|
||||
namespace promptFileName {
|
||||
enum cmd { openFile, newFile, unknown };
|
||||
enum cmd { openFile = 1, newFile };
|
||||
}
|
||||
|
||||
namespace promptSaveBeforeClose {
|
||||
enum cmd { save, noSave };
|
||||
enum cmd { save = 1, noSave };
|
||||
}
|
||||
|
||||
namespace promptNewRecord {
|
||||
enum cmd { lateRecord, absentRecord, PersonalLeaveRecord, unknown };
|
||||
enum cmd { lateRecord = 1, absentRecord, PersonalLeaveRecord };
|
||||
}
|
||||
|
||||
namespace promptNewInfo {
|
||||
enum cmd { date, courseName, studentInfo, unknown };
|
||||
enum cmd { date = 1, courseName, studentInfo };
|
||||
}
|
||||
|
||||
namespace filterSettings {
|
||||
enum cmd {
|
||||
fromDate = 1,
|
||||
recordID = 1,
|
||||
fromDate,
|
||||
toDate,
|
||||
courseName,
|
||||
studentID,
|
||||
|
||||
Reference in New Issue
Block a user