graph view, parent pointer to table
This commit is contained in:
parent
bec16503b7
commit
7980382db7
|
@ -22,7 +22,7 @@ coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
|
||||||
courseTBL->setShowGrid(true);
|
courseTBL->setShowGrid(true);
|
||||||
courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
|
courseTBL->setStyleSheet("QTableView {selection-background-color: red;}");
|
||||||
|
|
||||||
graph = new gradegraph(NULL);
|
graph = new gradegraph(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
coursesTableManager::~coursesTableManager()
|
coursesTableManager::~coursesTableManager()
|
||||||
|
@ -196,7 +196,8 @@ void coursesTableManager::addRow(const gradeCourse *courseToAdd)
|
||||||
hours->setFlags(hours->flags() & ~Qt::ItemIsEditable);
|
hours->setFlags(hours->flags() & ~Qt::ItemIsEditable);
|
||||||
|
|
||||||
grade = new QTableWidgetItem();
|
grade = new QTableWidgetItem();
|
||||||
grade->setData(Qt::EditRole,c->getGrade());
|
// grade->setData(Qt::EditRole,c->getGrade()); //BUG good for sorting, the problem is when you edit -> the cell indicator disappear
|
||||||
|
grade->setText(QString::number(c->getGrade()));
|
||||||
|
|
||||||
addition = new QTableWidgetItem();
|
addition = new QTableWidgetItem();
|
||||||
addition->setData(Qt::EditRole,c->getAddidtions());
|
addition->setData(Qt::EditRole,c->getAddidtions());
|
||||||
|
@ -210,6 +211,8 @@ void coursesTableManager::addRow(const gradeCourse *courseToAdd)
|
||||||
courseTBL->setItem(i,j++,points);
|
courseTBL->setItem(i,j++,points);
|
||||||
courseTBL->setItem(i,j++,hours);
|
courseTBL->setItem(i,j++,hours);
|
||||||
courseTBL->setItem(i,j,grade);
|
courseTBL->setItem(i,j,grade);
|
||||||
|
|
||||||
|
//FIXME : make it a function, add it when cell has changed
|
||||||
if(c->getGrade() < 55 && c->getGrade() != 0)
|
if(c->getGrade() < 55 && c->getGrade() != 0)
|
||||||
{
|
{
|
||||||
courseTBL->item(i, j)->setBackground(Qt::darkRed);
|
courseTBL->item(i, j)->setBackground(Qt::darkRed);
|
||||||
|
@ -249,11 +252,15 @@ double coursesTableManager::getAvg()
|
||||||
|
|
||||||
void coursesTableManager::showGraph()
|
void coursesTableManager::showGraph()
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
if (gp != NULL)
|
if (gp != NULL)
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << " Graph Dialog Opened. gp != NULL";
|
|
||||||
this->graph->showGraph(gp);
|
this->graph->showGraph(gp);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << Q_FUNC_INFO << "open with null grade page";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "mainscreen.h"
|
#include "mainscreen.h"
|
||||||
#include "ui_mainscreen.h"
|
#include "ui_mainscreen.h"
|
||||||
//TODO: busy flag to aboid overload request
|
//TODO: busy flag to avoid overload request
|
||||||
|
|
||||||
MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen)
|
MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen)
|
||||||
{
|
{
|
||||||
|
@ -136,6 +136,7 @@ void MainScreen::on_usrnmLineEdit_editingFinished()
|
||||||
//EVENTS ON GPA TAB
|
//EVENTS ON GPA TAB
|
||||||
void MainScreen::on_ratesButton_clicked()
|
void MainScreen::on_ratesButton_clicked()
|
||||||
{
|
{
|
||||||
|
|
||||||
ui->progressBar->setValue(0);
|
ui->progressBar->setValue(0);
|
||||||
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
|
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
|
||||||
if (!checkIfValidDates())
|
if (!checkIfValidDates())
|
||||||
|
@ -234,7 +235,7 @@ void MainScreen::on_clearTableButton_clicked()
|
||||||
|
|
||||||
void MainScreen::on_graphButton_clicked()
|
void MainScreen::on_graphButton_clicked()
|
||||||
{
|
{
|
||||||
qDebug() << "Show Graph button clicked";
|
qDebug() << Q_FUNC_INFO;
|
||||||
courseTableMgr->showGraph();
|
courseTableMgr->showGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -503,7 +503,7 @@ font-size: 15px;
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>-1</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="clearTableButton">
|
<widget class="QPushButton" name="clearTableButton">
|
||||||
|
@ -809,6 +809,9 @@ font-size: 15px;
|
||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -950,7 +953,7 @@ background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop:
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1133</width>
|
<width>1133</width>
|
||||||
<height>22</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuA_about">
|
<widget class="QMenu" name="menuA_about">
|
||||||
|
|
|
@ -4,23 +4,27 @@
|
||||||
* TODO: make graph understandable
|
* TODO: make graph understandable
|
||||||
* BUG: graph bug when theres small range of years
|
* BUG: graph bug when theres small range of years
|
||||||
*/
|
*/
|
||||||
gradegraph::gradegraph(QWidget *parent) :
|
gradegraph::gradegraph(QWidget *parent) : QDialog(parent), ui(new Ui::gradegraph)
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::gradegraph)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->setModal(true); //makes it on top of application
|
||||||
this->gp = NULL;
|
this->gp = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gradegraph::showGraph(GradePage *gpPTR)
|
void gradegraph::showGraph(GradePage *gpPTR)
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
this->gp = gpPTR;
|
this->gp = gpPTR;
|
||||||
|
|
||||||
|
clearGraph();
|
||||||
|
|
||||||
setVisualization();
|
setVisualization();
|
||||||
setGraphsData();
|
setGraphsData();
|
||||||
this->show();
|
|
||||||
this->setModal(true); //makes it on top of application
|
|
||||||
|
|
||||||
|
ui->graphwidget->replot();
|
||||||
|
|
||||||
|
this->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
gradegraph::~gradegraph()
|
gradegraph::~gradegraph()
|
||||||
|
@ -33,24 +37,37 @@ void gradegraph::setGraphsData()
|
||||||
int minYearInList = gp->getMinYearInList();
|
int minYearInList = gp->getMinYearInList();
|
||||||
int maxYearInList = gp->getMaxYearInList()+1;
|
int maxYearInList = gp->getMaxYearInList()+1;
|
||||||
int xRangeForYear = (maxYearInList - minYearInList+2)*3;
|
int xRangeForYear = (maxYearInList - minYearInList+2)*3;
|
||||||
QVector<double> SemesterialAvg(xRangeForYear),yearlyAvg(xRangeForYear),sem(xRangeForYear);
|
QVector<double> SemesterialAvg(xRangeForYear),yearlyAvg(xRangeForYear),indicatorX(xRangeForYear);
|
||||||
|
|
||||||
for (int yearCount=0,i=1; i<xRangeForYear; ++i) //filling data
|
for (int yearCount=0,i=1; i<xRangeForYear; ++i) //filling data
|
||||||
{
|
{
|
||||||
double lastAvg = 0;
|
|
||||||
sem[i] = i;
|
indicatorX[i] = i;
|
||||||
if (i%4==1) //years
|
if (i%4==1) //years
|
||||||
{
|
{
|
||||||
lastAvg = gp->getAvg(minYearInList+yearCount);
|
|
||||||
yearlyAvg[i] = lastAvg;
|
|
||||||
|
|
||||||
// add the text label at the top:
|
|
||||||
QCPItemText *textLabel = new QCPItemText(ui->graphwidget);
|
QCPItemText *textLabel = new QCPItemText(ui->graphwidget);
|
||||||
ui->graphwidget->addItem(textLabel);
|
ui->graphwidget->addItem(textLabel);
|
||||||
|
|
||||||
|
double lastAvg = gp->getAvg(minYearInList+yearCount);
|
||||||
|
|
||||||
|
if (lastAvg > 0)
|
||||||
|
{
|
||||||
|
// add the text label at the top:
|
||||||
|
if (lastAvg <= MIN_GRADE) //will be below the graph
|
||||||
|
{
|
||||||
|
textLabel->position->setCoords(i, MIN_GRADE+5); // place position at center/top of axis rect
|
||||||
|
textLabel->setText(QString::number(lastAvg,'g',4) + "<= Min Grade (" + QString::number(MIN_GRADE) + ")");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
textLabel->position->setCoords(i, lastAvg+1.5); // place position at center/top of axis rect
|
textLabel->position->setCoords(i, lastAvg+1.5); // place position at center/top of axis rect
|
||||||
textLabel->setText(QString::number(lastAvg,'g',4));
|
textLabel->setText(QString::number(lastAvg,'g',4));
|
||||||
|
}
|
||||||
|
}
|
||||||
textLabel->setFont(QFont(font().family(), 8)); // make font a bit larger
|
textLabel->setFont(QFont(font().family(), 8)); // make font a bit larger
|
||||||
textLabel->setPen(QPen(Qt::black)); // show black border around text
|
textLabel->setPen(QPen(Qt::black)); // show black border around text
|
||||||
|
|
||||||
|
yearlyAvg[i] = lastAvg;
|
||||||
yearCount++;
|
yearCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,17 +75,32 @@ void gradegraph::setGraphsData()
|
||||||
{
|
{
|
||||||
if (i+4 < xRangeForYear) //semesters
|
if (i+4 < xRangeForYear) //semesters
|
||||||
{
|
{
|
||||||
double avg = gp->getAvg(minYearInList+yearCount,(i-1)%4);
|
|
||||||
SemesterialAvg[i+4] = avg;
|
|
||||||
// add the text label at the top:
|
|
||||||
|
|
||||||
QCPItemText *textLabel = new QCPItemText(ui->graphwidget);
|
QCPItemText *textLabel = new QCPItemText(ui->graphwidget);
|
||||||
ui->graphwidget->addItem(textLabel);
|
ui->graphwidget->addItem(textLabel);
|
||||||
textLabel->position->setCoords(i+4, avg+0.5); // place position at center/top of axis rect
|
|
||||||
|
//qDebug() << "year: " << minYearInList+yearCount << "sem " << (i-1)%4;
|
||||||
|
double avg = gp->getAvg(minYearInList+yearCount,(i-1)%4);
|
||||||
|
//qDebug() << "avg: " << avg;
|
||||||
|
|
||||||
|
if (avg > 0)
|
||||||
|
{
|
||||||
|
// add the text label at the top:
|
||||||
|
if (avg <= MIN_GRADE) //will be below the graph
|
||||||
|
{
|
||||||
|
textLabel->position->setCoords(i+4, MIN_GRADE+1.5); // place position at center/top of axis rect
|
||||||
|
textLabel->setText(QString::number(avg,'g',4) + "<= Min Grade (" + QString::number(MIN_GRADE) + ")");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textLabel->position->setCoords(i+4, avg+1.5); // place position at center/top of axis rect
|
||||||
textLabel->setText(QString::number(avg,'g',4));
|
textLabel->setText(QString::number(avg,'g',4));
|
||||||
|
}
|
||||||
|
|
||||||
textLabel->setFont(QFont(font().family(), 8)); // make font a bit larger
|
textLabel->setFont(QFont(font().family(), 8)); // make font a bit larger
|
||||||
textLabel->setPen(QPen(Qt::black)); // show black border around text
|
textLabel->setPen(QPen(Qt::black)); // show black border around text
|
||||||
|
|
||||||
|
SemesterialAvg[i+4] = avg;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,9 +108,9 @@ void gradegraph::setGraphsData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//yearly
|
//yearly
|
||||||
ui->graphwidget->graph(0)->setData(sem,yearlyAvg);
|
ui->graphwidget->graph(0)->setData(indicatorX,yearlyAvg);
|
||||||
//yearly
|
//yearly
|
||||||
ui->graphwidget->graph(1)->setData(sem,SemesterialAvg);
|
ui->graphwidget->graph(1)->setData(indicatorX,SemesterialAvg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,18 +118,22 @@ void gradegraph::setGraphsData()
|
||||||
*/
|
*/
|
||||||
void gradegraph::setVisualization()
|
void gradegraph::setVisualization()
|
||||||
{
|
{
|
||||||
|
ui->graphwidget->setBackground(QBrush(Qt::white));
|
||||||
ui->graphwidget->axisRect()->setupFullAxesBox(true); //make the graph looks like a box
|
ui->graphwidget->axisRect()->setupFullAxesBox(true); //make the graph looks like a box
|
||||||
|
|
||||||
ui->graphwidget->addGraph(); //yearly and semesterial graphs
|
ui->graphwidget->addGraph(); //yearly and semesterial graphs
|
||||||
ui->graphwidget->addGraph();
|
ui->graphwidget->addGraph();
|
||||||
|
|
||||||
ui->graphwidget->graph(0)->setName(tr("Yearly Average"));
|
ui->graphwidget->graph(0)->setName(tr("Yearly Average"));
|
||||||
ui->graphwidget->graph(0)->setLineStyle(QCPGraph::lsLine);
|
|
||||||
ui->graphwidget->graph(0)->setPen(QPen(Qt::GlobalColor::blue));
|
ui->graphwidget->graph(0)->setPen(QPen(Qt::GlobalColor::blue));
|
||||||
|
ui->graphwidget->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::blue, Qt::blue, 7));
|
||||||
|
ui->graphwidget->graph(0)->setLineStyle(QCPGraph::lsImpulse );
|
||||||
|
|
||||||
ui->graphwidget->graph(1)->setName(tr("Semesterial Average"));
|
ui->graphwidget->graph(1)->setName(tr("Semesterial Average"));
|
||||||
ui->graphwidget->graph(1)->setLineStyle(QCPGraph::lsLine);
|
ui->graphwidget->graph(1)->setLineStyle(QCPGraph::lsStepLeft);
|
||||||
ui->graphwidget->graph(1)->setPen(QPen( QColor(Qt::GlobalColor::red)));
|
ui->graphwidget->graph(1)->setPen(QPen( QColor(Qt::GlobalColor::red)));
|
||||||
|
ui->graphwidget->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::red, Qt::red, 7));
|
||||||
|
|
||||||
|
|
||||||
int minYearInList = gp->getMinYearInList();
|
int minYearInList = gp->getMinYearInList();
|
||||||
int maxYearInList = gp->getMaxYearInList()+1;
|
int maxYearInList = gp->getMaxYearInList()+1;
|
||||||
|
@ -133,7 +169,7 @@ void gradegraph::setVisualization()
|
||||||
}
|
}
|
||||||
ui->graphwidget->yAxis->setLabel(tr("AVG Grade"));
|
ui->graphwidget->yAxis->setLabel(tr("AVG Grade"));
|
||||||
ui->graphwidget->yAxis->setTickLabelFont(QFont(QFont().family(), 8));
|
ui->graphwidget->yAxis->setTickLabelFont(QFont(QFont().family(), 8));
|
||||||
ui->graphwidget->yAxis->setRange(50,100);
|
ui->graphwidget->yAxis->setRange(MIN_GRADE,MAX_GRADE);
|
||||||
ui->graphwidget->yAxis->setTickStep(2);
|
ui->graphwidget->yAxis->setTickStep(2);
|
||||||
ui->graphwidget->yAxis->setAutoSubTicks(false);
|
ui->graphwidget->yAxis->setAutoSubTicks(false);
|
||||||
ui->graphwidget->yAxis->setAutoTickStep(false);
|
ui->graphwidget->yAxis->setAutoTickStep(false);
|
||||||
|
@ -146,13 +182,20 @@ void gradegraph::setVisualization()
|
||||||
ui->graphwidget->xAxis->setAutoTickStep(false);
|
ui->graphwidget->xAxis->setAutoTickStep(false);
|
||||||
ui->graphwidget->xAxis->setTickStep(1);
|
ui->graphwidget->xAxis->setTickStep(1);
|
||||||
ui->graphwidget->xAxis->setAutoSubTicks(false);
|
ui->graphwidget->xAxis->setAutoSubTicks(false);
|
||||||
ui->graphwidget->xAxis->setSubTickCount(1);
|
ui->graphwidget->xAxis->setSubTickCount(0);
|
||||||
ui->graphwidget->xAxis->setTickVectorLabels(xStrings);
|
ui->graphwidget->xAxis->setTickVectorLabels(xStrings);
|
||||||
ui->graphwidget->xAxis->setRange(1,xRangeForYear);
|
ui->graphwidget->xAxis->setRange(1,xRangeForYear);
|
||||||
|
|
||||||
ui->graphwidget->legend->setVisible(true); //show graph name on top right
|
ui->graphwidget->legend->setVisible(true); //show graph name on top right
|
||||||
}
|
}
|
||||||
|
void gradegraph::clearGraph()
|
||||||
|
{
|
||||||
|
int itemDeleted,graphs,plots;
|
||||||
|
itemDeleted = ui->graphwidget->clearItems();
|
||||||
|
graphs = ui->graphwidget->clearGraphs();
|
||||||
|
plots = ui->graphwidget->clearPlottables();
|
||||||
|
qDebug() << Q_FUNC_INFO << "items:" << itemDeleted << "graphs" << graphs << "plots:" << plots;
|
||||||
|
}
|
||||||
void gradegraph::on_pushButton_clicked()
|
void gradegraph::on_pushButton_clicked()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << " Closed Graph Dialog";
|
qDebug() << Q_FUNC_INFO << " Closed Graph Dialog";
|
||||||
|
|
|
@ -9,6 +9,9 @@ namespace Ui {
|
||||||
class gradegraph;
|
class gradegraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MIN_GRADE 50
|
||||||
|
#define MAX_GRADE 100
|
||||||
|
|
||||||
class gradegraph : public QDialog
|
class gradegraph : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -27,6 +30,8 @@ private:
|
||||||
|
|
||||||
void setVisualization();
|
void setVisualization();
|
||||||
void setGraphsData();
|
void setGraphsData();
|
||||||
|
void clearGraph();
|
||||||
|
|
||||||
Ui::gradegraph *ui;
|
Ui::gradegraph *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,11 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>GPA Graph View</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../../../resources/connectionstatus.qrc">
|
||||||
|
<normaloff>:/icons/icon.ico</normaloff>:/icons/icon.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
|
@ -29,7 +33,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p align="center"><span style=" font-size:18pt; font-weight:600;">Graph View</span></p></body></html></string>
|
<string><html><head/><body><p align="center"><span style=" font-size:18pt; font-weight:600;">GPA Graph View</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -82,6 +86,8 @@
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../../../resources/connectionstatus.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in a new issue