Merge fix

This commit is contained in:
Sagi Dayan 2014-08-31 20:54:33 +03:00
commit 8172f695d1
36 changed files with 2455 additions and 1915 deletions

View file

@ -11,38 +11,6 @@ TARGET = jceGrade
TEMPLATE = app
RC_FILE = appConfigure.rc
CONFIG += c++11 static
SOURCES += main/coursestablemanager.cpp \
main/loginhandler.cpp \
main/main.cpp \
main/mainscreen.cpp \
src/connection/jcesslclient.cpp \
src/user.cpp \
src/grades/Course.cpp \
src/grades/GradePage.cpp \
src/grades/Page.cpp \
src/jce/jcedate.cpp \
src/jce/jcelogin.cpp \
src/data/savedata.cpp \
HEADERS += main/coursestablemanager.h \
main/loginhandler.h \
main/mainscreen.h \
src/connection/jcesslclient.h \
src/user.h \
src/grades/Course.h \
src/grades/GradePage.h \
src/grades/Page.h \
src/jce/jcedate.h \
src/jce/jcelogin.h \
src/jce/jceLoginHtmlScripts.h \
src/data/savedata.h \
TRANSLATIONS = jce_en.ts \
jce_he.ts
FORMS += \
main/mainscreen.ui
@ -51,3 +19,37 @@ OTHER_FILES +=
RESOURCES += \
resources/connectionstatus.qrc
HEADERS += \
main/CalendarTab/CalendarManager.h \
main/CourseTab/coursestablemanager.h \
main/LoginTab/loginhandler.h \
main/mainscreen.h \
src/appDatabase/savedata.h \
src/jceConnection/jcesslclient.h \
src/jceData/Calendar/calendarPage.h \
src/jceData/Grades/gradeCourse.h \
src/jceData/Grades/gradePage.h \
src/jceData/course.h \
src/jceData/page.h \
src/jceSettings/jcelogin.h \
src/jceSettings/jceLoginHtmlScripts.h \
src/jceSettings/user.h \
src/jceData/Calendar/calendarCourse.h
SOURCES += \
main/CalendarTab/CalendarManager.cpp \
main/CourseTab/coursestablemanager.cpp \
main/LoginTab/loginhandler.cpp \
main/main.cpp \
main/mainscreen.cpp \
src/appDatabase/savedata.cpp \
src/jceConnection/jcesslclient.cpp \
src/jceData/Calendar/calendarPage.cpp \
src/jceData/Grades/gradeCourse.cpp \
src/jceData/Grades/gradePage.cpp \
src/jceData/page.cpp \
src/jceSettings/jcelogin.cpp \
src/jceSettings/user.cpp \
src/jceData/Calendar/calendarCourse.cpp

251
jceGrade.pro.user Normal file
View file

@ -0,0 +1,251 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.1.1, 2014-08-31T12:32:46. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.3.0 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.3.0 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.53.win32_mingw482_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Dropbox/cpp/jceConQT/build-jceGrade-Desktop_Qt_5_3_0_MinGW_32bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Dropbox/cpp/jceConQT/build-jceGrade-Desktop_Qt_5_3_0_MinGW_32bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">jceGrade</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Dropbox/cpp/jceConQT/jceAverageCalculator/jceGrade.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">jceGrade.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
<value type="QByteArray">{f3f3b933-8225-47b3-aa78-fc5de0bd714b}</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">15</value>
</data>
</qtcreator>

View file

@ -0,0 +1,17 @@
#include "CalendarManager.h"
CalendarManager::CalendarManager(QPlainTextEdit *ptr)
{
this->ptr = ptr;
}
void CalendarManager::setCalendar(std::string html)
{
cali = new CalendarPage(html);
QString text;
for (calendarCourse *a: *cali->getCourses())
{
text += QString::fromStdString(a->courseToString());
}
ptr->setPlainText(text);
}

View file

@ -0,0 +1,24 @@
#ifndef CALENDARMANAGER_H
#define CALENDARMANAGER_H
#include "./src/jceData/Calendar/calendarPage.h"
#include <iostream>
#include <QPlainTextEdit>
class CalendarManager
{
public:
CalendarManager(QPlainTextEdit *ptr);
~CalendarManager()
{
delete cali;
}
void setCalendar(std::string html);
private:
QPlainTextEdit * ptr;
CalendarPage * cali;
};
#endif // CALENDARMANAGER_H

View file

@ -31,7 +31,7 @@ coursesTableManager::~coursesTableManager()
*/
void coursesTableManager::insertJceCoursesIntoTable()
{
for (Course *c: *gp->getCourses())
for (gradeCourse *c: *gp->getCourses())
{
if (us->getInfluenceCourseOnly())
{
@ -62,20 +62,20 @@ bool coursesTableManager::changes(QString change, int row, int col)
bool isNumFlag = true;
int serialCourse = courseTBL->item(row,Course::CourseScheme::SERIAL)->text().toInt();
for (Course *c: *gp->getCourses())
int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
for (gradeCourse *c: *gp->getCourses())
{
if (c->getSerialNum() == serialCourse)
{
switch (col)
{
case (Course::CourseScheme::NAME):
case (gradeCourse::CourseScheme::NAME):
c->setName(change.toStdString());
break;
case (Course::CourseScheme::TYPE):
case (gradeCourse::CourseScheme::TYPE):
c->setType(change.toStdString());
break;
case (Course::CourseScheme::POINTS):
case (gradeCourse::CourseScheme::POINTS):
{
change.toDouble(&isNumFlag);
@ -87,7 +87,7 @@ bool coursesTableManager::changes(QString change, int row, int col)
c->setPoints(change.toDouble());
break;
}
case (Course::CourseScheme::HOURS):
case (gradeCourse::CourseScheme::HOURS):
{
change.toDouble(&isNumFlag);
@ -99,7 +99,7 @@ bool coursesTableManager::changes(QString change, int row, int col)
c->setHours(change.toDouble());
break;
}
case (Course::CourseScheme::GRADE):
case (gradeCourse::CourseScheme::GRADE):
{
change.toDouble(&isNumFlag);
@ -116,7 +116,7 @@ bool coursesTableManager::changes(QString change, int row, int col)
}
break;
}
case (Course::CourseScheme::ADDITION):
case (gradeCourse::CourseScheme::ADDITION):
c->setAdditions(change.toStdString());
break;
}
@ -130,13 +130,13 @@ bool coursesTableManager::changes(QString change, int row, int col)
* @brief coursesTableManager::addRow adds row with given information
* @param courseToAdd if exists, add its information to table
*/
void coursesTableManager::addRow(const Course *courseToAdd)
void coursesTableManager::addRow(const gradeCourse *courseToAdd)
{
int i,j;
i = courseTBL->rowCount();
j = 0;
QTableWidgetItem *serial,*name,*type,*points,*hours,*grade,*addition;
const Course * c;
const gradeCourse * c;
if (courseToAdd != NULL)
{
c = courseToAdd;
@ -187,14 +187,14 @@ void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
int i = 0;
while (i < courseTBL->rowCount())
{
if (courseTBL->item(i,Course::CourseScheme::POINTS)->text().compare("0") == 0)
if (courseTBL->item(i,gradeCourse::CourseScheme::POINTS)->text().compare("0") == 0)
courseTBL->removeRow(i--);
i++;
}
}
else
{
for (Course *c: *gp->getCourses())
for (gradeCourse *c: *gp->getCourses())
{
if (!(isCourseAlreadyInserted(c->getSerialNum())))
if (c->getPoints() == 0)
@ -212,17 +212,17 @@ void coursesTableManager::clearTable()
int i = 0; //starting point
while (courseTBL->rowCount() > i)
{
gp->removeCourse(courseTBL->item(i,Course::CourseScheme::SERIAL)->text().toStdString());
gp->removeCourse(courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text().toStdString());
courseTBL->removeRow(i);
}
gp = NULL;
courseTBL->repaint();
}
Course *coursesTableManager::getCourseByRow(int row)
gradeCourse *coursesTableManager::getCourseByRow(int row)
{
QString courseSerial = courseTBL->item(row,Course::CourseScheme::SERIAL)->text();
for (Course *c: *gp->getCourses())
QString courseSerial = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text();
for (gradeCourse *c: *gp->getCourses())
{
if (c->getSerialNum() == courseSerial.toDouble())
return c;
@ -235,14 +235,14 @@ bool coursesTableManager::isCourseAlreadyInserted(double courseID)
int i=0;
for (i = 0; i < courseTBL->rowCount(); ++i)
{
QString courseSerial = courseTBL->item(i,Course::CourseScheme::SERIAL)->text();
QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
if (QString::number(courseID) == courseSerial)
return true;
}
return false;
}
bool coursesTableManager::isCourseInfluence(const Course *courseToCheck)
bool coursesTableManager::isCourseInfluence(const gradeCourse *courseToCheck)
{
if (courseToCheck->getPoints() > 0)
return true;

View file

@ -13,8 +13,8 @@
#include <list>
#include "src/grades/GradePage.h"
#include "src/user.h"
#include "./src/jceData/Grades/gradePage.h"
#include "./src/jceSettings/user.h"
class coursesTableManager
{
@ -24,7 +24,7 @@ public:
void insertJceCoursesIntoTable();
void setCoursesList(std::string &htmlPage);
bool changes(QString change, int row, int col);
void addRow(const Course * courseToAdd = 0);
void addRow(const gradeCourse * courseToAdd = 0);
double getAvg();
void influnceCourseChanged(bool status);
@ -35,9 +35,9 @@ private:
GradePage *gp;
user *us;
Course * getCourseByRow(int row);
gradeCourse * getCourseByRow(int row);
bool isCourseAlreadyInserted(double courseID);
bool isCourseInfluence(const Course *courseToCheck);
bool isCourseInfluence(const gradeCourse *courseToCheck);
};
#endif // COURSESTABLEMANAGER_H

View file

@ -59,7 +59,7 @@ bool loginHandler::makeConnection()
{
jceLog->reConnect();
/*
* Fix: need to add promte window to ask user whenever he wants to reconnect or not
* Fix: need to add a prompte window to ask user whether he wants to reconnect or not
*/
break;
}
@ -110,10 +110,18 @@ void loginHandler::makeDisconnectionRequest()
this->logggedInFlag = false;
}
int loginHandler::makeGradeRequest()
int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester)
{
if (isLoggedInFlag())
return jceLog->getGrades();
return jceLog->getGrades(fromYear, toYear, fromSemester, toSemester);
else
return jceLogin::JCE_NOT_CONNECTED;
}
int loginHandler::makeCalendarRequest(int year, int semester)
{
if (isLoggedInFlag())
return jceLog->getCalendar(year,semester);
else
return jceLogin::JCE_NOT_CONNECTED;
}

View file

@ -7,8 +7,8 @@
#include <QMessageBox>
#include <QPixmap>
#include "src/jce/jcelogin.h"
#include "./src/data/savedata.h"
#include "./src/jceSettings/jcelogin.h"
#include "./src/appDatabase/savedata.h"
class loginHandler
@ -21,7 +21,9 @@ public:
void setLoginFlag(bool flag);
QString getCurrentPageContect();
int makeGradeRequest();
int makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester);
int makeCalendarRequest(int year,int semester);
void makeDisconnectionRequest();

View file

@ -6,7 +6,7 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
{
ui->setupUi(this);
this->setFixedSize(this->size()); //main not resizeable
//this->setFixedSize(this->size()); //main not resizeable
//Login Tab
@ -21,9 +21,8 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
ui->statusBar->addPermanentWidget(statusLabel,1);
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
//Course and Setting Tab
//Course, Setting, Calendar Tab
ui->CoursesTab->setDisabled(true);
ui->SettingsTab->setDisabled(true);
ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue));
@ -32,8 +31,7 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
this->userLoginSetting = new user("","");
this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting);
this->loginHandel = new loginHandler(userLoginSetting);
updateDates();
this->calendar = new CalendarManager(ui->calendartext);
//check login File
SaveData::init();
@ -60,6 +58,24 @@ void MainScreen::on_loginButton_clicked()
uiSetConnectMode();
}
void MainScreen::on_pushButton_clicked()
{
int status = 0;
if (loginHandel->isLoggedInFlag())
{
if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_GRADE_PAGE_PASSED)
{
//Use it for debug. add plain text and change the object name to 'plainTextEdit' so you will get the html request
//ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect());
calendar->setCalendar(loginHandel->getCurrentPageContect().toStdString());
}
else if (status == jceLogin::JCE_NOT_CONNECTED)
{
QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
}
}
}
void MainScreen::on_ratesButton_clicked()
{
@ -67,7 +83,7 @@ void MainScreen::on_ratesButton_clicked()
int status = 0;
if (loginHandel->isLoggedInFlag())
{
if ((status = loginHandel->makeGradeRequest()) == jceLogin::JCE_GRADE_PAGE_PASSED)
if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(),ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_GRADE_PAGE_PASSED)
{
pageString = loginHandel->getCurrentPageContect().toStdString();
courseTableMgr->setCoursesList(pageString);
@ -82,51 +98,50 @@ void MainScreen::on_ratesButton_clicked()
}
void MainScreen::on_spinBoxFromYear_editingFinished()
void MainScreen::on_checkBoxCoursesInfluence_toggled(bool checked)
{
if (ui->spinBoxFromYear->value() > ui->spinBoxToYear->value())
{
ui->spinBoxFromYear->setValue(ui->spinBoxToYear->value());
ui->spinBoxFromYear->setFocus();
updateDates();
this->userLoginSetting->setInfluenceCourseOnly(checked);
this->courseTableMgr->influnceCourseChanged(checked);
}
else
updateDates();
void MainScreen::on_spinBoxCoursesFromYear_editingFinished()
{
if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value())
{
ui->spinBoxCoursesFromYear->setValue(ui->spinBoxCoursesToYear->value());
ui->spinBoxCoursesFromYear->setFocus();
}
void MainScreen::on_spinBoxToYear_editingFinished()
{
if (ui->spinBoxFromYear->value() > ui->spinBoxToYear->value())
{
ui->spinBoxToYear->setValue(ui->spinBoxFromYear->value());
ui->spinBoxToYear->setFocus();
updateDates();
}
else
updateDates();
}
void MainScreen::on_spinBoxFromSem_editingFinished()
void MainScreen::on_spinBoxCoursesToYear_editingFinished()
{
if (ui->spinBoxFromYear->value() == ui->spinBoxToYear->value())
if (ui->spinBoxCoursesFromYear->value() > ui->spinBoxCoursesToYear->value())
{
if (ui->spinBoxFromSem->value() > ui->spinBoxToSemester->value())
{
ui->spinBoxFromSem->setValue(ui->spinBoxToSemester->value());
ui->spinBoxFromSem->setFocus();
ui->spinBoxCoursesToYear->setValue(ui->spinBoxCoursesFromYear->value());
ui->spinBoxCoursesToYear->setFocus();
}
}
updateDates();
}
void MainScreen::on_spinBoxToSemester_editingFinished()
void MainScreen::on_spinBoxCoursesFromSemester_editingFinished()
{
if (ui->spinBoxFromYear->value() == ui->spinBoxToYear->value())
if (ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value())
{
if (ui->spinBoxFromSem->value() > ui->spinBoxToSemester->value())
if (ui->spinBoxCoursesFromSemester->value() > ui->spinBoxCoursesToSemester->value())
{
ui->spinBoxToSemester->setValue(ui->spinBoxFromSem->value());
ui->spinBoxToSemester->setFocus();
ui->spinBoxCoursesFromSemester->setValue(ui->spinBoxCoursesToSemester->value());
ui->spinBoxCoursesFromSemester->setFocus();
}
}
}
void MainScreen::on_spinBoxCoursesToSemester_editingFinished()
{
if (ui->spinBoxCoursesFromYear->value() == ui->spinBoxCoursesToYear->value())
{
if (ui->spinBoxCoursesFromSemester->value() > ui->spinBoxCoursesToSemester->value())
{
ui->spinBoxCoursesToSemester->setValue(ui->spinBoxCoursesFromSemester->value());
ui->spinBoxCoursesToSemester->setFocus();
}
}
updateDates();
}
void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
@ -137,27 +152,10 @@ void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
QMessageBox::critical(this,"Error","Missmatching data");
}
void MainScreen::on_checkBox_toggled(bool checked)
{
this->userLoginSetting->setInfluenceCourseOnly(checked);
this->courseTableMgr->influnceCourseChanged(checked);
}
void MainScreen::on_usrnmLineEdit_editingFinished()
{
ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower());
}
void MainScreen::updateDates()
{
std::string fy,ty,fs,ts;
fy = std::to_string(ui->spinBoxFromYear->value());
ty = std::to_string(ui->spinBoxToYear->value());
fs = std::to_string(ui->spinBoxFromSem->value());
ts = std::to_string(ui->spinBoxToSemester->value());
userLoginSetting->setDate(fy,fs,ty,ts);
}
void MainScreen::uiSetDisconnectMode()
{
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
@ -199,7 +197,6 @@ void MainScreen::uiSetConnectMode() //fix before distrbute
ui->loginButton->setText("&Logout");
this->ui->ratesButton->setEnabled(true);
ui->CoursesTab->setEnabled(true);
ui->SettingsTab->setEnabled(true);
}
else
@ -284,3 +281,5 @@ void MainScreen::on_actionHow_To_triggered()
"</ul>");
}

View file

@ -10,8 +10,9 @@
#include <string>
#include <iostream>
#include "coursestablemanager.h"
#include "loginhandler.h"
#include "./CourseTab/coursestablemanager.h"
#include "./LoginTab/loginhandler.h"
#include "./CalendarTab/CalendarManager.h"
#define StatusIconHeight 35
namespace Ui {
@ -30,18 +31,16 @@ private slots:
void on_ratesButton_clicked();
void on_spinBoxFromYear_editingFinished();
void on_spinBoxCoursesFromYear_editingFinished();
void on_spinBoxFromSem_editingFinished();
void on_spinBoxCoursesFromSemester_editingFinished();
void on_spinBoxToYear_editingFinished();
void on_spinBoxCoursesToYear_editingFinished();
void on_spinBoxToSemester_editingFinished();
void on_spinBoxCoursesToSemester_editingFinished();
void on_loginButton_clicked();
void on_checkBox_toggled(bool checked);
void on_usrnmLineEdit_editingFinished();
void on_actionCredits_triggered();
@ -56,9 +55,12 @@ private slots:
void on_actionHow_To_triggered();
void on_pushButton_clicked();
void on_checkBoxCoursesInfluence_toggled(bool checked);
private:
void updateDates();
void uiSetDisconnectMode();
void uiSetConnectMode();
void setLabelConnectionStatus(jceLogin::jceStatus statusDescription);
@ -67,6 +69,7 @@ private:
user *userLoginSetting;
CalendarManager * calendar;
coursesTableManager *courseTableMgr;
loginHandler *loginHandel;

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>855</width>
<height>649</height>
<height>517</height>
</rect>
</property>
<property name="sizePolicy">
@ -21,7 +21,7 @@
</property>
<property name="windowIcon">
<iconset resource="../resources/connectionstatus.qrc">
<normaloff>:/icons/icon.png</normaloff>:/icons/icon.png</iconset>
<normaloff>:/icons/icon.ico</normaloff>:/icons/icon.ico</iconset>
</property>
<property name="styleSheet">
<string notr="true">#centralWidget
@ -61,7 +61,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<property name="documentMode">
<bool>false</bool>
@ -303,7 +303,7 @@ font-size: 15px;
<string notr="true"/>
</property>
<attribute name="title">
<string>Courses</string>
<string>GPA</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
@ -311,7 +311,7 @@ font-size: 15px;
<property name="leftMargin">
<number>0</number>
</property>
<item row="0" column="0">
<item row="3" column="0">
<widget class="QTableWidget" name="coursesTable">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@ -330,7 +330,7 @@ font-size: 15px;
</property>
</widget>
</item>
<item row="1" column="0">
<item row="4" column="0">
<layout class="QHBoxLayout" name="coursesTableControlHorizontalLayout">
<item>
<layout class="QHBoxLayout" name="coursesButtonLayout">
@ -375,7 +375,7 @@ font-size: 15px;
<item>
<layout class="QHBoxLayout" name="AvghorizontalLayout">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="labelAverage">
<property name="text">
<string>Average:</string>
</property>
@ -410,48 +410,67 @@ font-size: 15px;
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="SettingsTab">
<property name="enabled">
<bool>false</bool>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="checkBoxCoursesInfluence">
<property name="text">
<string>Only Main Courses</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelFrom">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string>Settings</string>
</attribute>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>251</width>
<height>159</height>
</rect>
<property name="text">
<string>From</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<widget class="QLabel" name="labelFromYear">
<property name="text">
<string>Year:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<widget class="QSpinBox" name="spinBoxCoursesFromYear">
<property name="minimum">
<number>2008</number>
</property>
<property name="maximum">
<number>2015</number>
</property>
<property name="value">
<number>2011</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelFromSemester">
<property name="text">
<string>Semester:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxCoursesFromSemester">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>3</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -460,210 +479,142 @@ font-size: 15px;
</property>
<property name="sizeHint" stdset="0">
<size>
<width>48</width>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="semNyearHorizontalLayout">
<item>
<widget class="QLabel" name="SemLabel">
<property name="text">
<string>Semester</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="YearLabel">
<property name="text">
<string>Year</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="fromNtoLabel">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="FromLabel">
<widget class="QLabel" name="labelTo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ToLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>To</string>
</property>
</widget>
</item>
</layout>
<item>
<widget class="QLabel" name="labelToYear">
<property name="text">
<string>Year:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxCoursesToYear">
<property name="minimum">
<number>2008</number>
</property>
<property name="maximum">
<number>2015</number>
</property>
<property name="value">
<number>2014</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelToSemester">
<property name="text">
<string>Semester</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxCoursesToSemester">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>3</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="CalendarTab">
<attribute name="title">
<string>Calendar</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="SpinBoxeshorizontalLayout1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSpinBox" name="spinBoxFromSem">
<property name="maximum">
<number>3</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBoxFromYear">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="showGroupSeparator" stdset="0">
<bool>false</bool>
</property>
<widget class="QSpinBox" name="spinBoxYear">
<property name="minimum">
<number>2009</number>
<number>2012</number>
</property>
<property name="maximum">
<number>2015</number>
<number>2020</number>
</property>
<property name="value">
<number>2009</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="SpinBoxeshorizontalLayout2">
<item>
<widget class="QSpinBox" name="spinBoxToSemester">
<property name="maximum">
<number>3</number>
</property>
<property name="value">
<number>3</number>
<number>2014</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBoxToYear">
<widget class="QSpinBox" name="spinBoxSemester">
<property name="minimum">
<number>2010</number>
<number>1</number>
</property>
<property name="maximum">
<number>2026</number>
<number>3</number>
</property>
<property name="value">
<number>2015</number>
<number>2</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Only influence Courses</string>
<string>Get Calendar</string>
</property>
<property name="checked">
<bool>false</bool>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="calendartext">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
@ -675,7 +626,7 @@ font-size: 15px;
<x>0</x>
<y>0</y>
<width>855</width>
<height>29</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuA_about">
@ -723,15 +674,9 @@ font-size: 15px;
<tabstop>usrnmLineEdit</tabstop>
<tabstop>pswdLineEdit</tabstop>
<tabstop>loginButton</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>ratesButton</tabstop>
<tabstop>clearTableButton</tabstop>
<tabstop>checkBox</tabstop>
<tabstop>spinBoxFromSem</tabstop>
<tabstop>coursesTable</tabstop>
<tabstop>spinBoxFromYear</tabstop>
<tabstop>spinBoxToSemester</tabstop>
<tabstop>spinBoxToYear</tabstop>
</tabstops>
<resources>
<include location="../resources/connectionstatus.qrc"/>

View file

@ -3,6 +3,6 @@
<file>blueStatusIcon.png</file>
<file>greenStatusIcon.png</file>
<file>redStatusIcon.png</file>
<file>icon.png</file>
<file>icon.ico</file>
</qresource>
</RCC>

View file

@ -57,3 +57,4 @@ private:
};
#endif // SAVEDATA_H

View file

@ -1,55 +0,0 @@
#include "Course.h"
Course::Course(int serial, std::string name, std::string type, double points, double hours, double grade, std::string additions)
{
this->serialNum = serial;
this->name = name;
this->type = type;
this->points = points;
this->hours = hours;
this->grade = grade;
this->additions = additions;
}
Course::~Course()
{
}
double Course::getGrade() const
{
double noGrade = NO_GRADE_YET;
if (grade == noGrade)
return 0;
else
return this->grade;
}
void Course::setName(std::string name)
{
this->name = name;
}
void Course::setType(std::string type)
{
this->type = type;
}
void Course::setPoints(double points)
{
this->points=points;
}
void Course::setHours(double hours)
{
this->hours = hours;
}
void Course::setGrade(double grade)
{
this->grade = grade;
}
void Course::setAdditions(std::string additions)
{
this->additions = additions;
}

View file

@ -1,164 +0,0 @@
#include "Page.h"
Page::Page(std::string& html)
{
makeText(html);
}
void Page::makeText(std::string& html)
{
int index = 0;
index = findTitle(html, index);
index = runToActualText(html, index); //set index into the actual place where the data is
manageTableContent(html, index);
}
int Page::findTitle(std::string& from, int index)
{
std::string temp;
while(index < (int)from.length())
{
if(from[index] == '<')
{
//title>
index++;
std::string titleTag = from.substr(index, 5); //legth of title
if(titleTag == "title") //check if the tag is title
{
while(from[index] != '>')
index++;
index++;
while(from[index] != '<')
{
temp += from[index];
index++;
}
this->title = temp; //sets the title
return index;
}
}
index++;
}
return -1;
}
int Page::runToActualText(std::string& from, int index)
{
while(index < (int)from.length())
{
if(from[index] == '<')
{
index++;
if(from[index] == '!')
{
//!--FileName
std::string bodyTag = from.substr(index, 11); //!--FileName
if(bodyTag == "!--FileName") //check if the tag is body tag
{
while(from[index] != '>')
index++;
return index;
}
}
}
index++;
}
return -1;
}
void Page::manageTableContent(std::string& html, int index)
{
std::string temp;
for (int i = index; i < (int)html.length(); i++)
{
if(html[i] == '<')
{
//<tr> / <td> / <th>
std::string endofTable = "</tbody>";
std::string tableTag = html.substr(i, 4); //legth of "tr/td"
if(tableTag == "<tr>")
{
temp += "\n"; //new row -> new line
i = stitchText(html, temp, i+4);
if(i == -1) //EOF
break;
}
else if(tableTag == "<td>" || tableTag == "<th>")
{
temp += "\t"; // new cell -> tab between data
i = stitchText(html, temp, i+4);
if (i == -1) //EOF
break;
}
else if(tableTag == "<td ") // a Year title (in grades table)
{
temp += "\t";
while(html[i] != '>')
i++;
i = stitchText(html, temp, i+1);
}
else if (html.substr(i,(endofTable).length()) == endofTable) //is end of table
{
break;
}
}
}
this->text = temp;
}
int Page::stitchText(std::string& from, std::string& to, int index)
{
if (from[index] == '<')
{
std::string bTag = from.substr(index, 3);
if (bTag != "<b>")
return index-1; //go back one step - for the main function to inc i
index += 3;
}
while (from[index] != '<' && index < (int)from.length())
{
if (from[index] == '&')
{
//&nbsp;
std::string nbspChr = from.substr(index, 6);
if (nbspChr == "&nbsp;")
{
index += 5;
from.at(index) = ' ';
}
}
if (endOfString(index,(int) from.length()))
return -1; //EOF
else if (from[index] == '<')
return index - 1; //go back one step - for the main function to inc i
if (from[index] != '\n') //check the actuall data before continue
to += from[index];
index++;
}
return index-1;
}
bool Page::endOfString(int index, int length)
{
if(index < length)
return false;
return true;
}
std::string Page::getString()
{
return this->text;
}
std::string Page::getTitle()
{
return this->title;
}

View file

@ -1,34 +0,0 @@
#include "jcedate.h"
jceDate::jceDate(std::string fromYear,std::string fromSemester,std::string toYear,std::string toSemester)
{
this->fSemester = fromSemester;
this->fYear = fromYear;
this->tSemester = toSemester;
this->tYear = toYear;
}
void jceDate::setFYear(std::string fromYear)
{
this->fYear = fromYear;
}
void jceDate::setTYear(std::string toYear)
{
this->tYear = toYear;
}
void jceDate::setFSemester(std::string fromSemester)
{
this->fSemester = fromSemester;
}
void jceDate::setTSemester(std::string toSemester)
{
this->tSemester = toSemester;
}
jceDate::~jceDate()
{
}

View file

@ -1,33 +0,0 @@
#ifndef JCEDATE_H
#define JCEDATE_H
#include <iostream>
class jceDate
{
public:
jceDate(std::string fromYear, std::string fromSemester, std::string toYear, std::string toSemester);
~jceDate();
void setFYear(std::string fromYear);
void setTYear(std::string toYear);
void setFSemester(std::string fromSemester);
void setTSemester(std::string toSemester);
std::string getFYear() { return this->fYear;}
std::string getTYear() { return this->tYear;}
std::string getFSemester() { return this->fSemester;}
std::string getTSemester() { return this->tSemester;}
private:
std::string fYear; //from
std::string fSemester;
std::string tYear; //to
std::string tSemester;
};
#endif // JCEDATE_H

View file

@ -0,0 +1,142 @@
#include "calendarCourse.h"
calendarCourse::calendarCourse(int serial, std::string name, std::string type, std::string lecturer, double points,
double semesterHours, std::string dayAndHour,
std::string room) : Course(serial,name, type,points)
{
this->lecturer = lecturer;
this->semesterHours = semesterHours;
this->room = room;
setDayAndHour(dayAndHour);
}
void calendarCourse::setDayAndHour(std::string phrase)
{
int ctr = 0;
std::string temp = "";
QTime timetemp;
char *tok;
char* textToTok = strdup(phrase.c_str());
tok = strtok(textToTok, " -");
while(tok != NULL)
{
temp = tok;
switch (ctr)
{
case 0:
setDay(temp);
break;
case 1:
timetemp = QTime::fromString(QString::fromStdString(temp),"hh:mm");
setHourBegin(timetemp.hour());
setMinutesBegin(timetemp.minute());
break;
case 2:
timetemp = QTime::fromString(QString::fromStdString(temp),"hh:mm");
setHourEnd(timetemp.hour());
setMinutesEnd(timetemp.minute());
break;
}
ctr++;
tok = strtok(NULL, " -");
}
}
std::string calendarCourse::getLecturer() const
{
return lecturer;
}
void calendarCourse::setLecturer(const std::string &value)
{
lecturer = value;
}
double calendarCourse::getSemesterHours() const
{
return semesterHours;
}
void calendarCourse::setSemesterHours(double value)
{
semesterHours = value;
}
int calendarCourse::getHourBegin() const
{
return hourBegin;
}
void calendarCourse::setHourBegin(int value)
{
hourBegin = value;
}
int calendarCourse::getMinutesBegin() const
{
return minutesBegin;
}
void calendarCourse::setMinutesBegin(int value)
{
minutesBegin = value;
}
int calendarCourse::getHourEnd() const
{
return hourEnd;
}
void calendarCourse::setHourEnd(int value)
{
hourEnd = value;
}
int calendarCourse::getMinutesEnd() const
{
return minutesEnd;
}
void calendarCourse::setMinutesEnd(int value)
{
minutesEnd = value;
}
std::string calendarCourse::courseToString()
{
std::string courseText = "";
courseText += " " + std::to_string(this->getSerialNum());
courseText += " " + this->getName();
courseText += " " + this->getType();
courseText += " " + this->lecturer;
courseText += " " + std::to_string(this->getPoints());
courseText += " " + std::to_string(this->semesterHours);
courseText += " " + this->day;
courseText += " " + std::to_string(this->hourBegin) + ":" + std::to_string(this->minutesBegin) + "-" + std::to_string(this->hourEnd) + ":" + std::to_string(this->minutesEnd);
courseText += " " + this->room;
courseText += "\n";
return courseText;
}
std::string calendarCourse::getDay() const
{
return day;
}
void calendarCourse::setDay(const std::string &value)
{
day = value;
}
std::string calendarCourse::getRoom() const
{
return room;
}
void calendarCourse::setRoom(const std::string &value)
{
room = value;
}

View file

@ -0,0 +1,69 @@
#ifndef CALENDARCOURSE_H
#define CALENDARCOURSE_H
#include "../course.h"
#include <string>
#include <iostream>
#include <list>
#include <QTime>
#define CALENDAR_COURSE_FIELDS 8
class calendarCourse : public Course
{
public:
enum CourseScheme
{
SERIAL,
NAME,
TYPE,
LECTURER,
POINTS,
SEM_HOURS,
DAY_AND_HOURS,
ROOM
};
calendarCourse(int serial, std::string name, std::string type, std::string lecturer,
double points, double semesterHours, std::string dayAndHour, std::string room);
~calendarCourse(){}
std::string getDay() const;
std::string getLecturer() const;
std::string getRoom() const;
double getSemesterHours() const;
int getHourBegin() const;
int getMinutesBegin() const;
int getHourEnd() const;
int getMinutesEnd() const;
void setDay(const std::string &value);
void setLecturer(const std::string &value);
void setRoom(const std::string &value);
void setSemesterHours(double value);
void setHourBegin(int value);
void setMinutesBegin(int value);
void setHourEnd(int value);
void setMinutesEnd(int value);
std::string courseToString();
private:
void setDayAndHour(std::string phrase);
std::string lecturer;
double semesterHours;
std::string day;
int hourBegin;
int minutesBegin;
int hourEnd;
int minutesEnd;
std::string room;
};
#endif // CALENDARCOURSE_H

View file

@ -0,0 +1,111 @@
#include "calendarPage.h"
CalendarPage::CalendarPage(std::string html)
{
courses = new std::list<calendarCourse*>();
tempHtml = getString(html);
tempHtml = tokenToLines(tempHtml);
std::cout << "last one..." << std::endl;
calendarListInit(tempHtml);
}
std::string CalendarPage::htmlToString()
{
return tempHtml;
}
std::string CalendarPage::tokenToLines(std::string &textToPhrase)
{
int ctr = 0;
std::string temp = "";
char *tok;
char* textToTok = strdup(textToPhrase.c_str());
tok = strtok(textToTok, "\n");
while(tok != NULL)
{
//amount of data before the actual needed data and no empty lines
if (strcmp(tok," \t ") != 0)
{
temp += tok;
temp += "\n";
}
ctr++;
tok = strtok(NULL, "\n");
}
return temp;
}
void CalendarPage::calendarListInit(std::string &linesTokinzedString)
{
std::list<std::string> stringHolder;
std::string temp;
calendarCourse * cTemp = NULL;
char* tok;
char* textToTok = strdup(linesTokinzedString.c_str());
tok = strtok(textToTok,"\n");
while (tok != NULL)
{
temp = tok;
stringHolder.push_back(temp);
tok = strtok(NULL, "\n");
}
for(std::string temp: stringHolder)
{
cTemp = lineToCourse(temp);
if (cTemp != NULL)
courses->push_back(cTemp);
}
}
calendarCourse *CalendarPage::lineToCourse(std::string line)
{
calendarCourse *tempC = NULL;
std::string templinearray[CALENDAR_COURSE_FIELDS];//[serial,name,type,lecturer,points,semesterhours,dayandhours,room]
int serial;
double points,semesterHours;
std::string name,type, lecturer,dayAndHour,room;
std::string tempS = "";
std::string emptyTab = " ";
int i = 0;
char* tok;
char* cLine = strdup(line.c_str());
tok = strtok(cLine, "\t");
while(tok != NULL)
{
tempS = tok;
if (i>=1)
templinearray[i-1] = tempS;
i++;
if (i > 8)
break;
tok=strtok(NULL, "\t");
}
if (templinearray[0] == "") //empty phrasing
return NULL;
for (int p = 0; p < 8; ++p)
{
std::cout << "index : " << p << " is: " << templinearray[p] << std::endl;
}
serial = stoi(templinearray[calendarCourse::CourseScheme::SERIAL]);
name = templinearray[calendarCourse::CourseScheme::NAME];
type = templinearray[calendarCourse::CourseScheme::TYPE];
lecturer = templinearray[calendarCourse::CourseScheme::LECTURER];
if (templinearray[calendarCourse::CourseScheme::POINTS].compare(" ") == 0)
points = stod(templinearray[calendarCourse::CourseScheme::POINTS]);
else
points = 0;
if (templinearray[calendarCourse::CourseScheme::SEM_HOURS].compare(" ") == 0)
semesterHours = stod(templinearray[calendarCourse::CourseScheme::SEM_HOURS]);
else
semesterHours = 0;
dayAndHour = templinearray[calendarCourse::CourseScheme::DAY_AND_HOURS];
room = templinearray[calendarCourse::CourseScheme::ROOM];
tempC = new calendarCourse(serial,name,type,lecturer,points,semesterHours,dayAndHour,room);
return tempC;
}

View file

@ -0,0 +1,26 @@
#ifndef CALENDARPAGE_H
#define CALENDARPAGE_H
#include "../page.h"
#include "calendarCourse.h"
#include <list>
#include <string.h> //strlen and strtok to phrase the html file
#include <ctype.h> //checks if character is numeric
class CalendarPage : public Page
{
public:
CalendarPage(std::string html);
std::string htmlToString();
std::list<calendarCourse*>* getCourses() { return courses; }
private:
std::string tokenToLines(std::string& textToPhrase);
void calendarListInit(std::string& linesTokinzedString);
calendarCourse* lineToCourse(std::string line);
std::string tempHtml;
std::list<calendarCourse*>* courses;
};
#endif // CALENDARPAGE_H

View file

@ -0,0 +1,36 @@
#include "gradeCourse.h"
gradeCourse::gradeCourse(int serial,std::string name, std::string type, double points, double hours, double grade, std::string additions) : Course(serial,name,type,points)
{
this->hours = hours;
this->grade = grade;
this->additions = additions;
}
gradeCourse::~gradeCourse()
{
}
double gradeCourse::getGrade() const
{
double noGrade = NO_GRADE_YET;
if (grade == noGrade)
return 0;
else
return this->grade;
}
void gradeCourse::setHours(double hours)
{
this->hours = hours;
}
void gradeCourse::setGrade(double grade)
{
this->grade = grade;
}
void gradeCourse::setAdditions(std::string additions)
{
this->additions = additions;
}

View file

@ -1,5 +1,5 @@
#ifndef COURSE_H
#define COURSE_H
#ifndef GRADE_COURSE_H
#define GRADE_COURSE_H
/* This Code Made By Sagi Dayan
* SagiDayan@gmail.com
@ -7,7 +7,7 @@
* Minor changes has been made by Liran Ben Gida
* LiranBG@gmail.com
*/
#include "../course.h"
#include <string>
#include <iostream>
#include <list>
@ -16,7 +16,7 @@
#define NO_GRADE_YET 101;
class Course{
class gradeCourse : public Course {
public:
enum CourseScheme
@ -30,30 +30,19 @@ public:
ADDITION
};
Course(int serial,std::string name, std::string type, double points, double hours, double grade, std::string additions);
~Course();
gradeCourse(int serial, std::string name, std::string type, double points,double hours, double grade, std::string additions);
~gradeCourse();
int getSerialNum() const {return this->serialNum;}
std::string getName() const {return this->name;}
std::string getType() const {return this->type;}
double getPoints() const {return this->points;}
double getHours() const {return this->hours;}
double getGrade() const ;
std::string getAddidtions() const {return this->additions;}
void setName(std::string name);
void setType(std::string type);
void setPoints(double points);
void setHours(double hours);
void setGrade(double grade);
void setAdditions(std::string additions);
private:
int serialNum;
std::string name;
std::string type;
double points;
double hours;
double grade;
std::string additions;

View file

@ -1,10 +1,11 @@
#include "GradePage.h"
#include "gradePage.h"
GradePage::GradePage(std::string html) : Page(html)
GradePage::GradePage(std::string html) : Page()
{
courses = new std::list<Course*>();
tempHtml = getString();
genList();
this->courses = new std::list<gradeCourse*>();
this->tempHtml = getString(html);
this->tempHtml = tokenToLines(this->tempHtml);
coursesListInit(this->tempHtml);
}
GradePage::~GradePage()
@ -13,15 +14,8 @@ GradePage::~GradePage()
delete c;
delete courses;
}
void GradePage::genList()
{
this->tempHtml = tokenToLines( this->tempHtml , INFO_DATA_LINES_BEFORE_GRADES_DATA );
coursesListInit(this->tempHtml);
}
void GradePage::addCourse(Course *a)
void GradePage::addCourse(gradeCourse *a)
{
GradePage::courses->push_back(a);
return;
@ -29,7 +23,7 @@ void GradePage::addCourse(Course *a)
void GradePage::removeCourse(std::string courseSerialID)
{
for(Course* c : *courses)
for(gradeCourse* c : *courses)
{
if (c->getSerialNum() == stoi(courseSerialID))
{
@ -44,7 +38,7 @@ void GradePage::coursesListInit(std::string& linesTokinzedString)
{
std::list<std::string> stringHolder;
std::string temp;
Course* cTemp = NULL;
gradeCourse* cTemp = NULL;
char* tok;
char* textToTok = strdup(linesTokinzedString.c_str());
tok = strtok(textToTok,"\n");
@ -62,7 +56,7 @@ void GradePage::coursesListInit(std::string& linesTokinzedString)
}
}
std::string GradePage::tokenToLines(std::string& textToPhrase,int fromLine)
std::string GradePage::tokenToLines(std::string& textToPhrase)
{
int ctr = 0;
std::string temp = "";
@ -72,7 +66,7 @@ std::string GradePage::tokenToLines(std::string& textToPhrase,int fromLine)
while(tok != NULL)
{
//amount of data before the actual needed data and no empty lines
if ((ctr >= fromLine) && (strcmp(tok," \t ") != 0))
if (strcmp(tok," \t ") != 0)
{
temp += tok;
temp += "\n";
@ -83,9 +77,9 @@ std::string GradePage::tokenToLines(std::string& textToPhrase,int fromLine)
return temp;
}
Course* GradePage::lineToCourse(std::string line)
gradeCourse* GradePage::lineToCourse(std::string line)
{
Course *tempC = NULL;
gradeCourse *tempC = NULL;
std::string templinearray[COURSE_FIELDS];//[serial,name,type,points,hours,grade,additions]
int serial;
double points,hours,grade;
@ -125,22 +119,22 @@ Course* GradePage::lineToCourse(std::string line)
if (templinearray[0] == "") //empty phrasing
return NULL;
serial = stoi(templinearray[Course::CourseScheme::SERIAL]);
serial = stoi(templinearray[gradeCourse::CourseScheme::SERIAL]);
name = templinearray[Course::CourseScheme::NAME];
type = templinearray[Course::CourseScheme::TYPE];
name = templinearray[gradeCourse::CourseScheme::NAME];
type = templinearray[gradeCourse::CourseScheme::TYPE];
points = stod(templinearray[Course::CourseScheme::POINTS]);
hours = stod(templinearray[Course::CourseScheme::HOURS]);
points = stod(templinearray[gradeCourse::CourseScheme::POINTS]);
hours = stod(templinearray[gradeCourse::CourseScheme::HOURS]);
if (isGradedYet(templinearray[Course::CourseScheme::GRADE]))
grade = stod(templinearray[Course::CourseScheme::GRADE]);
if (isGradedYet(templinearray[gradeCourse::CourseScheme::GRADE]))
grade = stod(templinearray[gradeCourse::CourseScheme::GRADE]);
else
grade = NO_GRADE_YET;
additions = templinearray[Course::CourseScheme::ADDITION];
additions = templinearray[gradeCourse::CourseScheme::ADDITION];
tempC = new Course(serial,name,type,points,hours,grade,additions);
tempC = new gradeCourse(serial,name,type,points,hours,grade,additions);
return tempC;
}
@ -164,7 +158,7 @@ double GradePage::getAvg()
{
double avg = 0;
double points = 0;
for(Course* c : *courses)
for(gradeCourse* c : *courses)
{
if ((c->getGrade() != 0))
{

View file

@ -8,15 +8,13 @@
* LiranBG@gmail.com
*/
#include "Page.h"
#include "Course.h"
#include "../page.h"
#include "../Grades/gradeCourse.h"
#include <list>
#include <string.h> //strlen and strtok to phrase the html file
#include <ctype.h> //checks if character is numeric
#define INFO_DATA_LINES_BEFORE_GRADES_DATA 5
class GradePage : public Page
{
@ -24,22 +22,21 @@ public:
GradePage(std::string html);
~GradePage();
void addCourse(Course *);
void addCourse(gradeCourse *);
void removeCourse(std::string courseSerialID);
double getAvg();
std::list<Course*>* getCourses() { return courses; }
std::list<gradeCourse*>* getCourses() { return courses; }
private:
void genList();
std::string tokenToLines(std::string& textToPhrase,int fromLine = 0);
std::string tokenToLines(std::string& textToPhrase);
void coursesListInit(std::string& linesTokinzedString);
Course* lineToCourse(std::string line);
gradeCourse* lineToCourse(std::string line);
bool isGradedYet(std::string grade);
std::list<Course*>* courses;
std::list<gradeCourse*>* courses;
std::string tempHtml;
};

View file

@ -19,16 +19,13 @@ public:
~Page() {}
protected:
Page(std::string& html);
std::string getString();
std::string getTitle();
Page();
std::string getString(std::string& htmlToPhrased);
void makeText(std::string& html);
private:
int findTitle(std::string& from, int index);
int runToActualText(std::string& from, int index);
void manageTableContent(std::string& html, int index);
int stitchText(std::string& from, std::string& to, int index);

49
src/jceData/course.h Normal file
View file

@ -0,0 +1,49 @@
#ifndef COURSE_H
#define COURSE_H
/* This Code Made By Sagi Dayan
* SagiDayan@gmail.com
*
* minor changes by Liran Ben Gida
* LiranBG@gmail.com
*/
#include <string>
#include <iostream>
#include <list>
class Course {
public:
Course(int serial,std::string name, std::string type, double points) {
this->serialNum = serial;
this->name = name;
this->type = type;
this->points = points;
}
virtual ~Course() { }
int getSerialNum() const {return this->serialNum;}
virtual std::string getName() const {return this->name;}
virtual std::string getType() const {return this->type;}
virtual double getPoints() const {return this->points;}
virtual void setName(std::string name) { this->name = name;}
virtual void setType(std::string type){ this->type = type;}
virtual void setPoints(double points){ this->points = points;}
private:
int serialNum;
std::string name;
std::string type;
double points;
};
#endif

144
src/jceData/page.cpp Normal file
View file

@ -0,0 +1,144 @@
#include "page.h"
Page::Page()
{
}
std::string Page::getString(std::string& htmlToPhrased)
{
makeText(htmlToPhrased);
return this->text;
}
void Page::makeText(std::string& html)
{
int index = 0;
index = runToActualText(html, index); //set index into the actual place where the data is
manageTableContent(html, index);
}
int Page::runToActualText(std::string& from, int index)
{
while (index < (int)from.length())
{
if (from[index] == '<')
{
if (from.substr(index,7) == "<tbody>")
return index+7;
}
index++;
}
// while(index < (int)from.length())
// {
// if(from[index] == '<')
// {
// index++;
// if(from[index] == '!')
// {
// //!--FileName
// std::string bodyTag = from.substr(index, 11); //!--FileName
// if(bodyTag == "!--FileName") //check if the tag is body tag
// {
// while(from[index] != '>')
// index++;
// return index;
// }
// }
// }
// index++;
//}
return -1;
}
void Page::manageTableContent(std::string& html, int index)
{
std::string temp;
for (int i = index; i < (int)html.length(); i++)
{
if(html[i] == '<')
{
//<tr> / <td> / <th>
std::string endofTable = "</tbody>";
std::string tableTag = html.substr(i, 4); //legth of "tr/td"
if(tableTag == "<tr>")
{
temp += "\n"; //new row -> new line
i = stitchText(html, temp, i+4);
if(i == -1) //EOF
break;
}
else if(tableTag == "<td>" || tableTag == "<th>")
{
temp += "\t"; // new cell -> tab between data
if (html.substr(i, 6) == "<td><a") //link to lecturer portal, need to be deleted
{
i += 6;
while (html.at(++i) != '>');
i = stitchText(html, temp, i+1);
}
else
i = stitchText(html, temp, i+4);
if (i == -1) //EOF
break;
}
else if(tableTag == "<td ") // a Year title (in grades table)
{
temp += "\t";
while(html[i] != '>')
i++;
i = stitchText(html, temp, i+1);
}
else if (html.substr(i,(endofTable).length()) == endofTable) //is end of table
{
break;
}
}
}
this->text = temp;
}
int Page::stitchText(std::string& from, std::string& to, int index)
{
if (from[index] == '<')
{
std::string bTag = from.substr(index, 3);
if (bTag != "<b>")
return index-1; //go back one step - for the main function to inc i
index += 3;
}
while (from[index] != '<' && index < (int)from.length())
{
if (from[index] == '&')
{
//&nbsp;
std::string nbspChr = from.substr(index, 6);
if (nbspChr == "&nbsp;")
{
index += 5;
from.at(index) = ' ';
}
}
if (endOfString(index,(int) from.length()))
return -1; //EOF
else if (from[index] == '<')
return index - 1; //go back one step - for the main function to inc i
if (from[index] != '\n') //check the actuall data before continue
to += from[index];
index++;
}
return index-1;
}
bool Page::endOfString(int index, int length)
{
if(index < length)
return false;
return true;
}

View file

@ -6,7 +6,7 @@
#define dst_host "yedion.jce.ac.il"
#define dst_port 443
#include "../user.h"
#include "./src/jceSettings/user.h"
class jceLoginHtmlScripts
{
@ -52,19 +52,34 @@ public:
parameters += ",-A,-A";
return parameters;
}
const static std::string getGradesPath(const user &usr)
const static std::string getGradesPath(const user &usr,
int fromYear,
int toYear,
int fromSemester,
int toSemester)
{
std::string parameters;
parameters = "PRGNAME=HADPASAT_MISMAHIM_LETALMID&ARGUMENTS=TZ,-N4,R1C2,R1C4,R1C1,R1C3,-A,-A,R1C5,-A,UNIQ&";
parameters += "TZ=" + usr.getUserID() + "&";
parameters += "UNIQ=" + usr.getHashedPassword() + "&";
parameters += "R1C2=" + usr.date->getFYear() + "&";
parameters += "R1C1=" + usr.date->getTYear() + "&";
parameters += "R1C3=" + usr.date->getTSemester() + "&";
parameters += "R1C4=" + usr.date->getFSemester() + "&";
parameters += "R1C2=" + std::to_string(fromYear) + "&";
parameters += "R1C1=" + std::to_string(toYear) + "&";
parameters += "R1C3=" + std::to_string(toSemester) + "&";
parameters += "R1C4=" + std::to_string(fromSemester) + "&";
parameters += "R1C5=0";
return parameters;
}
const static std::string getCalendar(const user &usr,int year, int semester)
{
std::string parameters;
parameters = "PRGNAME=Bitsua_maarechet_shaot&ARGUMENTS=TZ,UNIQ,MisparSheilta,R1C1,R1C2&";
parameters += "TZ=" + usr.getUserID() + "&";
parameters += "UNIQ=" + usr.getHashedPassword() + "&";
parameters += "MisparSheilta=3&";
parameters += "R1C1=" + std::to_string(year) + "&";
parameters += "R1C2=" + std::to_string(semester) + "&";
return parameters;
}
};

View file

@ -149,9 +149,25 @@ int jceLogin::makeSecondVisit()
return true;
}
int jceLogin::getGrades()
int jceLogin::getCalendar(int year, int semester)
{
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA)))))
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getCalendar(*jceA,year,semester)))))
{
if (!(JceConnector->recieveData(*recieverPage,false)))
return jceLogin::ERROR_ON_GETTING_GRADES;
else
return jceLogin::JCE_GRADE_PAGE_PASSED;
}
else
return jceLogin::ERROR_ON_SEND_REQUEST;
return true;
}
int jceLogin::getGrades(int fromYear, int toYear, int fromSemester, int toSemester)
{
std::cout << fromYear << " " << toYear << " " << fromSemester << " " << toSemester << std::endl;
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA,fromYear, toYear, fromSemester, toSemester)))))
{
if (!(JceConnector->recieveData(*recieverPage,false)))
return jceLogin::ERROR_ON_GETTING_GRADES;

View file

@ -4,8 +4,8 @@
#include <string>
#include <fstream>
#include "../connection/jcesslclient.h"
#include "../user.h"
#include "./src/jceConnection/jcesslclient.h"
#include "./src/jceSettings/user.h"
#include "jceLoginHtmlScripts.h"
class jceLogin
@ -33,7 +33,8 @@ public:
bool checkConnection();
void reConnect() throw (jceStatus);
void closeAll();
int getGrades();
int getCalendar(int year, int semester);
int getGrades(int fromYear, int toYear, int fromSemester, int toSemester);
bool isLoginFlag() const;
std::string getPage();

View file

@ -9,16 +9,9 @@ user::user(string username,string password) : hashedPassword(""),userID(""), inf
}
user::~user()
{
delete date;
}
void user::setDate(std::string fromYear, std::string fromSemester, std::string toYear, std::string toSemester)
{
date->setFYear(fromYear);
date->setFSemester(fromSemester);
date->setTYear(toYear);
date->setTSemester(toSemester);
}
void user::setInfluenceCourseOnly(bool status)
{
this->influenceCourseOnly = status;

View file

@ -3,7 +3,6 @@
#include <string>
#include <iostream>
#include "jce/jcedate.h"
using namespace std;
class user
@ -23,13 +22,9 @@ public:
string getUserID() const;
string getHashedPassword() const;
void setDate(std::string fromYear, std::string fromSemester, std::string toYear, std::string toSemester);
void setInfluenceCourseOnly(bool status);
bool getInfluenceCourseOnly() const;
jceDate * const date = new jceDate("","","",""); //we do not change the pointer
private:
string username;