gpa contains years and semester

This commit is contained in:
liranbg 2014-10-05 14:16:01 +03:00
parent fe6951dbf4
commit 026c6b937c
16 changed files with 25197 additions and 68 deletions

View file

@ -4,7 +4,7 @@
#
#-------------------------------------------------
QT += core gui network widgets
QT += core gui network widgets printsupport
CONFIG += qt c++11
@ -25,7 +25,8 @@ TRANSLATIONS = jce_en.ts \
FORMS += \
main/mainscreen.ui \
src/jceData/Calendar/calendarDialog.ui
src/jceData/Calendar/calendarDialog.ui \
src/jceData/Grades/graph/gradegraph.ui
RESOURCES += \
resources/connectionstatus.qrc
@ -50,7 +51,9 @@ HEADERS += \
src/jceData/CSV/csv_exporter.h \
src/appDatabase/simplecrypt.h \
src/jceData/Calendar/calendarDialog.h \
src/appDatabase/jce_logger.h
src/appDatabase/jce_logger.h \
src/jceData/Grades/graph/qcustomplot.h \
src/jceData/Grades/graph/gradegraph.h
SOURCES += \
main/CalendarTab/CalendarManager.cpp \
@ -71,4 +74,6 @@ SOURCES += \
src/jceData/CSV/csv_exporter.cpp \
src/appDatabase/simplecrypt.cpp \
src/jceData/Calendar/calendarDialog.cpp \
src/appDatabase/jce_logger.cpp
src/appDatabase/jce_logger.cpp \
src/jceData/Grades/graph/qcustomplot.cpp \
src/jceData/Grades/graph/gradegraph.cpp

View file

@ -12,12 +12,17 @@ coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
courseTBL->setRowCount(0);
courseTBL->setColumnCount(COURSE_FIELDS);
QStringList mz;
mz << QObject::tr("Code") << QObject::tr("Name") << QObject::tr("Type") << QObject::tr("Points") << QObject::tr("Hours") << QObject::tr("Grade") << QObject::tr("Additions");
mz << QObject::tr("Number") << QObject::tr("Year") << QObject::tr("Semester") << QObject::tr("Serial") << QObject::tr("Name") << QObject::tr("Type") << QObject::tr("Points") << QObject::tr("Hours") << QObject::tr("Grade") << QObject::tr("Additions");
courseTBL->setHorizontalHeaderLabels(mz);
courseTBL->verticalHeader()->setVisible(true);
courseTBL->verticalHeader()->setVisible(false);
courseTBL->setSelectionMode(QAbstractItemView::SingleSelection);
courseTBL->setShowGrid(true);
courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
/*
*
*/
graph = new gradegraph(NULL,gp);
}
coursesTableManager::~coursesTableManager()
@ -61,6 +66,8 @@ bool coursesTableManager::changes(QString change, int row, int col)
{
bool isNumFlag = true;
if (courseTBL->item(row,gradeCourse::CourseScheme::SERIAL) == NULL)
return true;
int serialCourse = courseTBL->item(row,gradeCourse::CourseScheme::SERIAL)->text().toInt();
for (gradeCourse *c: *gp->getCourses())
@ -69,6 +76,15 @@ bool coursesTableManager::changes(QString change, int row, int col)
{
switch (col)
{
case (gradeCourse::CourseScheme::COURSE_NUMBER_IN_LIST):
c->setCourseNumInList(change.toInt());
break;
case (gradeCourse::CourseScheme::YEAR):
c->setYear(change.toInt());
break;
case (gradeCourse::CourseScheme::SEMESTER):
c->setSemester(change.toInt());
break;
case (gradeCourse::CourseScheme::NAME):
c->setName(change);
break;
@ -132,30 +148,40 @@ bool coursesTableManager::changes(QString change, int row, int col)
*/
void coursesTableManager::addRow(const gradeCourse *courseToAdd)
{
int i,j;
i = courseTBL->rowCount();
int i=1,j=1;
j = 0;
QTableWidgetItem *serial,*name,*type,*points,*hours,*grade,*addition;
QTableWidgetItem *number,*year,*semester,*serial,*name,*type,*points,*hours,*grade,*addition;
const gradeCourse * c;
if (courseToAdd != NULL)
{
c = courseToAdd;
if (!isCourseAlreadyInserted(c->getSerialNum()))
{
courseTBL->setRowCount(courseTBL->rowCount()+1);
courseTBL->setRowCount(courseTBL->rowCount() + 1);
i = courseTBL->rowCount()-1;
number = new QTableWidgetItem(QString::number(c->getCourseNumInList()));
number->setFlags(number->flags() & ~Qt::ItemIsEditable);
year = new QTableWidgetItem(QString::number(c->getYear()));
year->setFlags(year->flags() & ~Qt::ItemIsEditable);
semester = new QTableWidgetItem(QString::number(c->getSemester()));
semester->setFlags(semester->flags() & ~Qt::ItemIsEditable);
serial = new QTableWidgetItem(QString::number(c->getSerialNum()));
serial->setFlags(serial->flags() & ~Qt::ItemIsEditable);
points = new QTableWidgetItem(QString::number(c->getPoints()));
points->setFlags(serial->flags() & ~Qt::ItemIsEditable);
points->setFlags(points->flags() & ~Qt::ItemIsEditable);
hours = new QTableWidgetItem(QString::number(c->getHours()));
hours->setFlags(serial->flags() & ~Qt::ItemIsEditable);
hours->setFlags(hours->flags() & ~Qt::ItemIsEditable);
grade = new QTableWidgetItem(QString::number(c->getGrade()));
name = new QTableWidgetItem(c->getName());
name->setFlags(serial->flags() & ~Qt::ItemIsEditable);
name->setFlags(name->flags() & ~Qt::ItemIsEditable);
type = new QTableWidgetItem(c->getType());
type->setFlags(serial->flags() & ~Qt::ItemIsEditable);
type->setFlags(type->flags() & ~Qt::ItemIsEditable);
addition = new QTableWidgetItem(c->getAddidtions());
courseTBL->setItem(i,j++,number);
courseTBL->setItem(i,j++,year);
courseTBL->setItem(i,j++,semester);
courseTBL->setItem(i,j++,serial);
courseTBL->setItem(i,j++,name);
courseTBL->setItem(i,j++,type);
@ -164,10 +190,12 @@ void coursesTableManager::addRow(const gradeCourse *courseToAdd)
courseTBL->setItem(i,j++,grade);
courseTBL->setItem(i,j,addition);
}
}
else
{
qCritical() << Q_FUNC_INFO << "no course to load!";
}
courseTBL->resizeColumnsToContents();
@ -179,6 +207,12 @@ double coursesTableManager::getAvg()
return 0;
}
void coursesTableManager::showGraph()
{
if (gp != NULL)
this->graph->show();
}
void coursesTableManager::influnceCourseChanged(bool ignoreCourseStatus)
{
@ -232,12 +266,15 @@ gradeCourse *coursesTableManager::getCourseByRow(int row)
bool coursesTableManager::isCourseAlreadyInserted(double courseID)
{
int i=0;
for (i = 0; i < courseTBL->rowCount(); ++i)
int i;
for (i = courseTBL->rowCount(); i >= 0; --i)
{
QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
if (QString::number(courseID) == courseSerial)
return true;
if (courseTBL->item(i,gradeCourse::CourseScheme::SERIAL) != NULL)
{
QString courseSerial = courseTBL->item(i,gradeCourse::CourseScheme::SERIAL)->text();
if (QString::number(courseID) == courseSerial)
return true;
}
}
return false;
}

View file

@ -13,6 +13,7 @@
#include <list>
#include "./src/jceData/Grades/graph/gradegraph.h"
#include "./src/jceData/Grades/gradePage.h"
#include "./src/jceSettings/user.h"
@ -27,10 +28,13 @@ public:
void addRow(const gradeCourse * courseToAdd = 0);
double getAvg();
void showGraph();
void influnceCourseChanged(bool status);
void clearTable();
private:
gradegraph *graph;
QTableWidget *courseTBL;
GradePage *gp;
user *us;

View file

@ -229,6 +229,10 @@ void MainScreen::on_clearTableButton_clicked()
courseTableMgr->clearTable();
ui->avgLCD->display(courseTableMgr->getAvg());
}
void MainScreen::on_graphButton_clicked()
{
courseTableMgr->showGraph();
}
//EVENTS ON CALENDAR TAB
void MainScreen::on_getCalendarBtn_clicked()
{

View file

@ -67,6 +67,8 @@ private slots:
void on_labelMadeBy_linkActivated(const QString &link);
void on_graphButton_clicked();
private:
void checkLocale();

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>855</width>
<height>517</height>
<width>1133</width>
<height>623</height>
</rect>
</property>
<property name="sizePolicy">
@ -64,7 +64,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>0</number>
<number>1</number>
</property>
<property name="documentMode">
<bool>false</bool>
@ -385,6 +385,13 @@ font-size: 15px;
</item>
<item>
<layout class="QHBoxLayout" name="AvghorizontalLayout">
<item>
<widget class="QPushButton" name="graphButton">
<property name="text">
<string>Graph View</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelAverage">
<property name="text">
@ -629,6 +636,13 @@ font-size: 15px;
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="labelMadeBy">
<property name="text">
<string>&lt;p align=&quot;center&quot;&gt;Made By &lt;a href=&quot;http://liranbg.github.io/JceManager/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;JceManager&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="sizePolicy">
@ -641,7 +655,7 @@ font-size: 15px;
<string notr="true">#progressBar::horizontal {
border: 1px solid gray;
border-radius: 3px;
background: white;
background: transparent;
padding: 1px;
}
#progressBar::chunk:horizontal {
@ -652,7 +666,7 @@ background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop:
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignCenter</set>
</property>
<property name="textVisible">
<bool>true</bool>
@ -668,13 +682,6 @@ background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop:
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelMadeBy">
<property name="text">
<string>&lt;p align=&quot;center&quot;&gt;Made By &lt;a href=&quot;http://liranbg.github.io/JceManager/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;JceManager&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
@ -682,8 +689,8 @@ background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop:
<rect>
<x>0</x>
<y>0</y>
<width>855</width>
<height>21</height>
<width>1133</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuA_about">

View file

@ -1,10 +1,13 @@
#include "gradeCourse.h"
gradeCourse::gradeCourse(int serial, QString name, QString type, double points, double hours, double grade, QString additions) : Course(serial,name,type,points)
gradeCourse::gradeCourse(int year, int semester, int courseNumInList, int serial, QString name, QString type, double points,double hours, double grade, QString additions) : Course(serial,name,type,points)
{
this->hours = hours;
this->grade = grade;
this->additions = additions;
this->year = year;
this->semester = semester;
this->courseNumInList = courseNumInList;
}
gradeCourse::~gradeCourse()
@ -34,3 +37,23 @@ void gradeCourse::setAdditions(QString additions)
{
this->additions = additions;
}
void gradeCourse::setYear(int year)
{
this->year = year;
}
void gradeCourse::setSemester(int semester)
{
this->semester = semester;
}
int gradeCourse::getCourseNumInList() const
{
return courseNumInList;
}
void gradeCourse::setCourseNumInList(int value)
{
courseNumInList = value;
}

View file

@ -12,7 +12,7 @@
#include <iostream>
#include <list>
#define COURSE_FIELDS 7
#define COURSE_FIELDS 10
#define NO_GRADE_YET 101;
@ -21,6 +21,9 @@ class gradeCourse : public Course {
public:
enum CourseScheme
{
YEAR,
SEMESTER,
COURSE_NUMBER_IN_LIST,
SERIAL,
NAME,
TYPE,
@ -30,22 +33,32 @@ public:
ADDITION
};
gradeCourse(int serial, QString name, QString type, double points,double hours, double grade, QString additions);
gradeCourse(int year, int semester, int courseNumInList, int serial, QString name, QString type, double points,double hours, double grade, QString additions);
~gradeCourse();
int getYear() const { return this->year; }
int getSemester() const { return this->semester; }
double getHours() const {return this->hours;}
double getGrade() const ;
double getGrade() const;
QString getAddidtions() const {return this->additions;}
void setHours(double hours);
void setGrade(double grade);
void setAdditions(QString additions);
void setYear(int year);
void setSemester(int semester);
int getCourseNumInList() const;
void setCourseNumInList(int value);
private:
double hours;
double grade;
double hours;
double grade;
QString additions;
int year;
int semester;
int courseNumInList;
};

View file

@ -36,13 +36,13 @@ void GradePage::coursesListInit(QString &linesTokinzedString)
char* tok;
char* textToTok = strdup(linesTokinzedString.toStdString().c_str());
tok = strtok(textToTok,"\n");
while (tok != NULL)
while (tok != NULL) //putting every line in a string holder before parsing it
{
temp = tok;
stringHolder.push_back(temp);
tok = strtok(NULL, "\n");
}
for(QString temp: stringHolder)
for (QString temp: stringHolder)
{
cTemp = lineToCourse(temp);
if (cTemp != NULL)
@ -52,7 +52,6 @@ void GradePage::coursesListInit(QString &linesTokinzedString)
QString GradePage::tokenToLines(QString &textToPhrase)
{
int ctr = 0;
QString temp = "";
char *tok;
char* textToTok = strdup(textToPhrase.toStdString().c_str());
@ -65,7 +64,6 @@ QString GradePage::tokenToLines(QString &textToPhrase)
temp += tok;
temp += "\n";
}
ctr++;
tok = strtok(NULL, "\n");
}
return temp;
@ -75,7 +73,7 @@ gradeCourse* GradePage::lineToCourse(QString line)
{
gradeCourse *tempC = NULL;
QString templinearray[COURSE_FIELDS];//[serial,name,type,points,hours,grade,additions]
int serial;
int serial,year,semester,courseNumInList;
double points,hours,grade;
QString name,type, additions;
QString tempS = "";
@ -85,35 +83,44 @@ gradeCourse* GradePage::lineToCourse(QString line)
tok = strtok(cLine, "\t");
while(tok != NULL)
{
tempS = tok;
if (i == 1) //skip the tokenizing loop just once
if (i == gradeCourse::CourseScheme::SERIAL) //we need to extract the serial manually
{
tempS = "";
char *tokTemp;
tokTemp = tok;
while (!(isdigit((int)*tokTemp)))
while (!(isdigit((int)*tokTemp))) //getting to serial number starting pointer
tokTemp++;
while (isdigit((int)*tokTemp))
while (isdigit((int)*tokTemp)) //serial number
{
tempS += QString(*tokTemp);
tokTemp++;
}
templinearray[i-1] = tempS.trimmed();
templinearray[i] = QString(tokTemp).trimmed();
templinearray[i] = tempS.trimmed();
templinearray[i+1] = QString(tokTemp).trimmed();
i +=2; //skipping on serial and course name
}
else if (i > 1)
else
{
templinearray[i] = tempS;
templinearray[i] = tempS.trimmed();
i++;
}
i++;
if (i == COURSE_FIELDS)
break;
tok=strtok(NULL, "\t");
}
if (templinearray[0] == "") //empty phrasing
if (templinearray[0] == "") //empty parsing
{
qCritical() << Q_FUNC_INFO << "empty parsing";
return NULL;
}
year = templinearray[gradeCourse::CourseScheme::YEAR].toInt();
semester = templinearray[gradeCourse::CourseScheme::SEMESTER].toInt();
courseNumInList = templinearray[gradeCourse::CourseScheme::COURSE_NUMBER_IN_LIST].toInt();
serial = templinearray[gradeCourse::CourseScheme::SERIAL].toInt();
name = templinearray[gradeCourse::CourseScheme::NAME];
@ -129,7 +136,7 @@ gradeCourse* GradePage::lineToCourse(QString line)
additions = templinearray[gradeCourse::CourseScheme::ADDITION];
tempC = new gradeCourse(serial,name,type,points,hours,grade,additions);
tempC = new gradeCourse(year,semester,courseNumInList,serial,name,type,points,hours,grade,additions);
return tempC;
}

View file

@ -0,0 +1,15 @@
#include "gradegraph.h"
#include "ui_gradegraph.h"
gradegraph::gradegraph(QWidget *parent, GradePage *gpPTR) :
QDialog(parent),
ui(new Ui::gradegraph)
{
ui->setupUi(this);
this->gp = gpPTR;
}
gradegraph::~gradegraph()
{
delete ui;
}

View file

@ -0,0 +1,26 @@
#ifndef GRADEGRAPH_H
#define GRADEGRAPH_H
#include "./src/jceData/Grades/gradePage.h"
#include "qcustomplot.h"
#include <QDialog>
namespace Ui {
class gradegraph;
}
class gradegraph : public QDialog
{
Q_OBJECT
public:
gradegraph(QWidget *parent = 0, GradePage *gpPTR = 0);
~gradegraph();
private:
GradePage *gp;
Ui::gradegraph *ui;
};
#endif // GRADEGRAPH_H

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>gradegraph</class>
<widget class="QDialog" name="gradegraph">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>597</width>
<height>461</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:18pt; font-weight:600;&quot;&gt;Graph View&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QCustomPlot" name="graphwidget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QCustomPlot</class>
<extends>QWidget</extends>
<header>src/jceData/Grades/graph/qcustomplot.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
#include "page.h"
Page::Page() {}
Page::Page() { dateHeader = "";}
/**
* @brief Page::getString
* @param htmlToPhrased
@ -29,17 +29,23 @@ void Page::manageTableContent(QString &html, int index)
QString temp;
for (int i = index; i < html.length(); i++)
{
if(html.at(i) == '<')
if (html.at(i) == '<')
{
//<tr> / <td> / <th>
QString endofTable = "</tbody>";
QString tableTag = html.mid(i, 4); //legth of "tr/td"
if (tableTag == "<tr>")
{
temp += "\n"; //new row -> new line
temp += dateHeader;
i = stitchText(html, temp, i+4);
if(i == -1) //EOF
if (i == -1) //EOF
break;
}
else if (tableTag == "</tr")
{
temp += "\n"; //end row -> new line
i+=5;
}
else if (tableTag == "<td>" || tableTag == "<th>")
{
@ -55,14 +61,20 @@ void Page::manageTableContent(QString &html, int index)
if (i == -1) //EOF
break;
}
else if(tableTag == "<td ") // a Year title (in grades table)
else if (tableTag == "<td ") // a Year title (in grades table)
{
temp += "\t";
while(html.at(i) != '>')
if (!temp.isEmpty())
if (temp.lastIndexOf(dateHeader) == temp.length()-dateHeader.length())
{
temp.chop(dateHeader.length()+1);
temp += "\t";
}
while (html.mid(i,3) != "<b>")
i++;
i = stitchText(html, temp, i+1);
i = stitchText(html, temp, i);
}
else if (html.mid(i,(endofTable).length()) == endofTable) //is end of table
if (html.mid(i,(endofTable).length()) == endofTable) //is end of table
{
break;
}
@ -78,9 +90,32 @@ int Page::stitchText(QString &from, QString &to, int index)
if (from.at(index) == '<')
{
QString bTag = from.mid(index, 3);
QString dateline = from.mid(index,from.indexOf("</b>",index+4)-index);
QString temp;
QString date;
char* tok;
int i = 0;
char* textToTok = strdup(dateline.toStdString().c_str());
tok = strtok(textToTok,"<>&nbsp;:");
while (tok != NULL)
{
if (i == 1)
{
temp = tok;
date += temp + "\t";
}
else if (i == 3)
{
temp = tok;
date += temp;
}
i++;
tok = strtok(NULL, "<>&nbsp;:");
}
dateHeader = date;
if (bTag != "<b>")
return index-1; //go back one step - for the main function to inc i
index += 3;
index += dateline.length();
}
while (from.at(index) != '<' && index < (int)from.length())
@ -103,7 +138,7 @@ int Page::stitchText(QString &from, QString &to, int index)
else if (from.at(index) == '<')
return index - 1; //go back one step - for the main function to inc i
if (from.at(index) != '\n') //check the actuall data before continue
if ((from.at(index) != '\n') && (from.at(index) != '\t')) //check the actuall data before continue
to += from.at(index);
index++;
}

View file

@ -33,6 +33,7 @@ private:
bool endOfString(int index, int length);
QString text;
QString dateHeader;
QString title;
};