From 2a4b2452345b2904356a693eac3945a3d2c6dbe2 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Fri, 26 Sep 2014 23:00:40 +0300 Subject: [PATCH] Added some more documentation DocBlocks to all major functions. hope it helps... --- src/appDatabase/savedata.cpp | 73 ++++++++++++++++++++++++- src/jceData/CSV/csv_exporter.cpp | 9 ++- src/jceData/CSV/csv_exporter.h | 8 +++ src/jceData/Calendar/calendarDialog.cpp | 26 +++++++-- src/jceData/Calendar/calendarDialog.h | 9 +++ src/jceData/course.h | 3 +- src/jceData/page.h | 2 +- 7 files changed, 119 insertions(+), 11 deletions(-) diff --git a/src/appDatabase/savedata.cpp b/src/appDatabase/savedata.cpp index 107f7fa..bb0e439 100644 --- a/src/appDatabase/savedata.cpp +++ b/src/appDatabase/savedata.cpp @@ -20,6 +20,12 @@ SaveData::SaveData() load(); } +/** + * @brief This will check if the is data saved ie. username and password. + * the only way in JCE manager is to store a username and password together. therefore if there is + * a user name in the file, so there is a password ass well. + * @return true if the is a username in the file. (if not the username will be "") + */ bool SaveData::isSaved() { if(DB.value("username") == "") @@ -27,6 +33,14 @@ bool SaveData::isSaved() return true; } +/** + * @brief This void function will erase all data. QMap will be cleard and saved to the file. + * data thet will be deleted: + * # username + * # password + * # calendar + * # local + */ void SaveData::reset() { DB.clear(); @@ -34,52 +48,89 @@ void SaveData::reset() save(); } +/** + * @brief gest a username and saves it into the QMap. + * QMap then is saved to the file. + * @param username - users username from the mainwindow ui pointer. + */ void SaveData::setUsername(QString username) { DB.insert("username", username); save(); } +/** + * @brief gets a password, sends it to encyption, and saves the encrypter password to QMap. + * saves the QMap into the file. + * @param password - raw password (not encrypted) + */ void SaveData::setPassword(QString password) { DB.insert("password", encrypt(password)); save(); } +/** + * @brief gest a calendar and saves it into the QMap. + * QMap then is saved to the file. + * @param cal - last calendar that user seen + */ void SaveData::setCal(QString cal) { DB.insert("calendar", cal); save(); } +/** + * @brief gest a local and saves it into the QMap. + * QMap then is saved to the file. + * @param local - QString (he, en, default) + */ void SaveData::setLocal(QString local) { DB.insert("local", local); save(); } +/** + * @brief read from file + * @return - username + */ QString SaveData::getUsername() { return DB.value("username"); } +/** + * @brief read from file + * @return - unencrypted password + */ QString SaveData::getPassword() { return decrypte(DB.value("password")); } +/** + * @brief read from file + * @return local + */ QString SaveData::getLocal() { return DB.value("local"); } +/** + * @brief read from file + * @return calendar + */ QString SaveData::getCal() { return DB.value("calendar"); } - - +/** + * @brief read from file the QMap object into the DB inside "this" object. + */ void SaveData::load() { QFile file(FILE_NAME); @@ -89,6 +140,9 @@ void SaveData::load() file.close(); } +/** + * @brief Saves the QMap to the file. overriding the content of the file. + */ void SaveData::save() { QFile file(FILE_NAME); @@ -99,6 +153,9 @@ void SaveData::save() file.close(); } +/** + * @brief Creates en empty tamplate for QMap (use only on init! if there is no file.) + */ void SaveData::createDB() { DB.insert("username", ""); @@ -107,12 +164,24 @@ void SaveData::createDB() DB.insert("calendar", ""); } +/** + * @brief this function will connect this class to the simplecrypt class. + * sends the raw password to encryption and returns the encrypted one. + * @param pass - raw password. + * @return encrypted password. + */ QString SaveData::encrypt(QString pass) { SimpleCrypt crypto(Q_UINT64_C(0x0c2ad4a4acb9f027)); return crypto.encryptToString(pass); } +/** + * @brief this function will connect this class to the simplecrypt class. + * sends the encrypted password to decryption and returns the raw one. + * @param pass - encrypted password. + * @return raw password. + */ QString SaveData::decrypte(QString pass) { SimpleCrypt crypto(Q_UINT64_C(0x0c2ad4a4acb9f027)); diff --git a/src/jceData/CSV/csv_exporter.cpp b/src/jceData/CSV/csv_exporter.cpp index a5fb2ef..a79385c 100644 --- a/src/jceData/CSV/csv_exporter.cpp +++ b/src/jceData/CSV/csv_exporter.cpp @@ -124,7 +124,7 @@ QString CSV_Exporter::getFileFath() * @param name * @param date * @param startH - * @param startM + * @param startM - Not used at the moment. * @param endH * @param endM * @param lecturer @@ -203,6 +203,13 @@ QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM return CSV_line; } +/** + * @brief The QDate.dayOfWeek() returns an integer as follows (Sunday = 7, monday = 1... Friday = 5) + * This method will make that return integer more uderstandble and easy to use with the Calander classes of + * JCE Manager. so Sunday = 1, Monday = 2 and so on... + * + * @param QtDay - A Qt dayOfWeek integer pointer. it will cange his value. + */ void CSV_Exporter::changeDayNumberFromQtToNormal(int *QtDay) { switch(*QtDay){ diff --git a/src/jceData/CSV/csv_exporter.h b/src/jceData/CSV/csv_exporter.h index 99218b7..52d8dc8 100644 --- a/src/jceData/CSV/csv_exporter.h +++ b/src/jceData/CSV/csv_exporter.h @@ -1,3 +1,11 @@ +/** + * This simple static class will generate a csv file of a given semester. + * + * the class wat written for the JCE Manager and exporting a calendar to Goolgle Calendar. + * + * this CSV file should also work for iCal and Outlook. but have not been tested. + * + */ #ifndef CSV_EXPORTER_H #define CSV_EXPORTER_H diff --git a/src/jceData/Calendar/calendarDialog.cpp b/src/jceData/Calendar/calendarDialog.cpp index 7bbeaf7..cf6be72 100644 --- a/src/jceData/Calendar/calendarDialog.cpp +++ b/src/jceData/Calendar/calendarDialog.cpp @@ -26,30 +26,42 @@ QDate CalendarDialog::getEndDate() return ui->calEnd->selectedDate(); } +/** + * @breif This method will return the state of the dates aka User input. + * @return true - if dates are valid, invalid false. + */ bool CalendarDialog::ok() { return this->isOK; } + +/** + * @breif A Slot - triggers when the start calendar widget is selected (Date changed by user) + * it will change the status label (ui->lbl_status) according to the users input. + */ void CalendarDialog::on_calStart_selectionChanged() { - if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate()) + if(ui->calStart->selectedDate() >= ui->calEnd->selectedDate()) //User input is invalid { changeLabeStatusIcon(false); ui->lbl_status->setText(tr("The end of the semester can NOT be equal or before the semester begin.")); this->isOK = false; } - else + else // input is valid { changeLabeStatusIcon(true); - ui->lbl_status->setText(tr("Looks ok, Press OK")); + ui->lbl_status->setText(tr("Looks fine, Click \"OK\"")); this->isOK = true; } } +/** + * @breif A Slot triggerd when OK clicked + */ void CalendarDialog::on_buttonBox_accepted() { - if(ui->calStart->selectedDate() > ui->calEnd->selectedDate()) - qDebug() << "start is bigger than end!"; + if(this->isOK) + qDebug() << "CalendarDialog: Valid input"; } void CalendarDialog::on_calEnd_selectionChanged() @@ -69,6 +81,10 @@ void CalendarDialog::on_calEnd_selectionChanged() } +/** + * @breif changes the status icon according to the... status... smart huh? + * @param goodOrBad - self explained + */ void CalendarDialog::changeLabeStatusIcon(bool goodOrBad) { if (goodOrBad == true) //good date! diff --git a/src/jceData/Calendar/calendarDialog.h b/src/jceData/Calendar/calendarDialog.h index 1c7ee38..8d26ba0 100644 --- a/src/jceData/Calendar/calendarDialog.h +++ b/src/jceData/Calendar/calendarDialog.h @@ -1,3 +1,12 @@ +/** + * JCE Manager (C) + * + * This QDialog widget will hold the dates of a Semester, Start and End. + * + * this dialog will help the csv_exporter class to export a CSV file that will contain + * all the courses within that period of time. + */ + #ifndef CALENDARDIALOG_H #define CALENDARDIALOG_H diff --git a/src/jceData/course.h b/src/jceData/course.h index 22921bb..3c90351 100644 --- a/src/jceData/course.h +++ b/src/jceData/course.h @@ -3,8 +3,7 @@ /* This Code Made By Sagi Dayan * SagiDayan@gmail.com - * - * minor changes by Liran Ben Gida + * & Liran Ben Gida * LiranBG@gmail.com */ diff --git a/src/jceData/page.h b/src/jceData/page.h index 1facc9f..2651366 100644 --- a/src/jceData/page.h +++ b/src/jceData/page.h @@ -4,7 +4,7 @@ /* This Code Made By Sagi Dayan * SagiDayan@gmail.com * - * Changes has been made by Liran Ben Gida + * Changes have been made by Liran Ben Gida * LiranBG@gmail.com */ #include