added exam revert

This commit is contained in:
liranbg 2014-10-13 06:17:57 +03:00
parent ae7d20beda
commit 6cafe6dc70
9 changed files with 210 additions and 83 deletions

View file

@ -1,8 +1,4 @@
#include "coursestablemanager.h" #include "coursestablemanager.h"
/*
* TODO: revert gpa to origin
*
*/
coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr) coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
{ {
this->gp = NULL; this->gp = NULL;
@ -322,7 +318,7 @@ void coursesTableManager::revertChanges()
(temp->getSerialNum() == notChangedCourse->getSerialNum())) (temp->getSerialNum() == notChangedCourse->getSerialNum()))
{ {
courseTBL->item(i,gradeCourse::CourseScheme::GRADE)->setText(QString::number(notChangedCourse->getGrade())); courseTBL->item(i,gradeCourse::CourseScheme::GRADE)->setText(QString::number(notChangedCourse->getGrade()));
break;
} }
} }
} }

View file

@ -2,8 +2,8 @@
/* /*
* *
* Class doc can be bound in csv_exporter.h * Class doc can be found in csv_exporter.h
* * TODO: add exam exportation
*/ */
CSV_Exporter::CSV_Exporter() CSV_Exporter::CSV_Exporter()
{ {

View file

@ -4,6 +4,21 @@ calendarExam::calendarExam()
{ {
htmlDataHolderParsed = ""; htmlDataHolderParsed = "";
} }
/**
* @brief calendarExam::calendarExam
* copy constructor
* @param other
*/
calendarExam::calendarExam(calendarExam &other)
{
examsCounter = 0;
exams.clear();
for (calendarExamCourse * tempExam: other.getExams())
{
this->exams.push_back(new calendarExamCourse(*tempExam));
examsCounter++;
}
}
/** /**
* @brief calendarExam::setPage - getting a html page and stripping it into a exams schedule in a list * @brief calendarExam::setPage - getting a html page and stripping it into a exams schedule in a list

View file

@ -20,6 +20,7 @@ class calendarExam : public Page
{ {
public: public:
calendarExam(); calendarExam();
calendarExam(calendarExam &other);
void setPage(QString html); void setPage(QString html);
QList<calendarExamCourse*> getExams() { return exams; } QList<calendarExamCourse*> getExams() { return exams; }

View file

@ -12,6 +12,19 @@ calendarExamCourse::calendarExamCourse(int serial, QString name, QString lecture
setTime(firstHourbegin,true); setTime(firstHourbegin,true);
setTime(secondHourbegin,false); setTime(secondHourbegin,false);
}
calendarExamCourse::calendarExamCourse(calendarExamCourse &other)
:Course (other.getSerialNum(),other.getName(),other.getType())
{
this->lecturer = other.lecturer;
this->field = other.field;
this->firstDate = other.getFirstDate();
this->firstHourbegin = other.firstHourbegin;
this->secondDate = other.secondDate;
this->secondHourbegin = other.secondHourbegin;
} }
/** /**
* @brief calendarExamCourse::setDate * @brief calendarExamCourse::setDate

View file

@ -45,6 +45,7 @@ public:
calendarExamCourse(int serial, QString name, QString lecturer, QString field, calendarExamCourse(int serial, QString name, QString lecturer, QString field,
QString type, QString firstDate, QString firstHourbegin, QString type, QString firstDate, QString firstHourbegin,
QString secondDate, QString secondHourbegin); QString secondDate, QString secondHourbegin);
calendarExamCourse(calendarExamCourse &other);
QString getLecturer() const; QString getLecturer() const;

View file

@ -1,18 +1,17 @@
#include "examDialog.h" #include "examDialog.h"
#include "ui_examDialog.h" #include "ui_examDialog.h"
/*
*TODO: exam revert, add to csv exportation, dialog size
*/
/** /**
* @brief examDialog::examDialog * @brief examDialog::examDialog
* @param parent * @param parent
* @param calSchedPtr - list of courses with information about each exam * @param calSchedPtr - list of courses with information about each exam
*/ */
examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(parent), examDialog::examDialog(QWidget *parent, calendarExam *calExamPtr) : QDialog(parent),
ui(new Ui::examDialog) ui(new Ui::examDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
exams = calSchedPtr; exams = calExamPtr;
this->examsCpy = NULL;
QStringList headLine; QStringList headLine;
//SERIAL, NAME, LECTURER, FIELD, TYPE, FIRST_DATE, FIRST_HOUR_BEGIN, SECOND_DATE, SECOND_HOUR_BEGIN //SERIAL, NAME, LECTURER, FIELD, TYPE, FIRST_DATE, FIRST_HOUR_BEGIN, SECOND_DATE, SECOND_HOUR_BEGIN
@ -42,6 +41,8 @@ void examDialog::initializingDataIntoTable()
{ {
disconnect(ui->tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(upgradeExamsTime(QTableWidgetItem*))); disconnect(ui->tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(upgradeExamsTime(QTableWidgetItem*)));
ui->tableWidget->setRowCount(exams->getExamsCounter()); ui->tableWidget->setRowCount(exams->getExamsCounter());
this->examsCpy = new calendarExam(*exams);
int i=0,j=0; int i=0,j=0;
int year,month,day; //for constructin qdate by setdate int year,month,day; //for constructin qdate by setdate
QTableWidgetItem *lecturer,*name,*type; QTableWidgetItem *lecturer,*name,*type;
@ -180,11 +181,65 @@ void examDialog::resetGeo()
mHeight += ui->tableWidget->rowHeight(i) + 4; mHeight += ui->tableWidget->rowHeight(i) + 4;
} }
mHeight += ui->buttonBox->height() + 4; mHeight += ui->frameBtns->height() + 30;
mHeight += ui->labelHeader->height() + 4; mHeight += ui->labelHeader->height() + 4;
this->setMinimumHeight(mHeight); this->setMinimumHeight(mHeight);
// this->setMaximumHeight(mHeight);
} }
void examDialog::on_pushButtonOk_clicked()
{
qDebug() << Q_FUNC_INFO;
this->hide();
}
void examDialog::on_pushButtonRevert_clicked()
{
qDebug() << Q_FUNC_INFO;
if (ui->tableWidget->rowCount() <= 0)
return;
if (this->exams == NULL)
return;
if (this->examsCpy == NULL)
return;
for (int i = 0; i < ui->tableWidget->rowCount(); ++i)
{
calendarExamCourse * temp = getExamByRow(i);
for (calendarExamCourse * notChangedCourse: examsCpy->getExams())
{
if (temp->getSerialNum() == notChangedCourse->getSerialNum())
{
if (temp->getFirstHourbegin() != notChangedCourse->getFirstHourbegin())
{
ui->tableWidget->item(i,calendarExamCourse::CourseScheme::FIRST_HOUR_BEGIN)->setData(Qt::EditRole, QTime(notChangedCourse->getFirstHourbegin().hour(),notChangedCourse->getFirstHourbegin().minute()).toString("hh:mm"));
}
if (temp->getSecondHourbegin() != notChangedCourse->getSecondHourbegin())
{
ui->tableWidget->item(i,calendarExamCourse::CourseScheme::SECOND_HOUR_BEGIN)->setData(Qt::EditRole, QTime(notChangedCourse->getSecondHourbegin().hour(),notChangedCourse->getSecondHourbegin().minute()).toString("hh:mm"));
}
break; //done with course. go to next row
}
}
}
}
calendarExamCourse *examDialog::getExamByRow(int row)
{
int serialNum = ui->tableWidget->item(row,calendarExamCourse::CourseScheme::SERIAL)->text().toInt();
for (calendarExamCourse * temp : exams->getExams())
{
if (serialNum == temp->getSerialNum())
return temp;
}
return NULL;
}
void examDialog::on_pushButtonCancel_clicked()
{
on_pushButtonRevert_clicked(); //make revert to discard all changes
this->hide();
}

View file

@ -27,7 +27,7 @@ class examDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit examDialog(QWidget *parent,calendarExam * calSchedPtr); explicit examDialog(QWidget *parent, calendarExam * calExamPtr);
void initializingDataIntoTable(); void initializingDataIntoTable();
~examDialog(); ~examDialog();
@ -35,12 +35,20 @@ private slots:
bool upgradeExamsTime(QTableWidgetItem* item); bool upgradeExamsTime(QTableWidgetItem* item);
void on_pushButtonOk_clicked();
void on_pushButtonRevert_clicked();
void on_pushButtonCancel_clicked();
private: private:
calendarExamCourse *getExamByRow(int row);
void resetGeo(); void resetGeo();
Ui::examDialog *ui; Ui::examDialog *ui;
calendarExam * exams; calendarExam * exams;
calendarExam * examsCpy;
}; };
#endif // EXAMDIALOG_H #endif // EXAMDIALOG_H

View file

@ -19,7 +19,101 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QFrame" name="frameAll">
<property name="styleSheet">
<string notr="true">#frameAll {
border: 0px solids;
}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QFrame" name="frameBtns">
<property name="styleSheet">
<string notr="true">#frameBtns {
border: 0px solids;
}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="rightMargin">
<number>0</number>
</property>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pushButtonRevert">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Revert changes&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Revert</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonCancel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Discard and hide&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonOk">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Save and hide&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer">
<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>
<zorder>pushButtonRevert</zorder>
<zorder></zorder>
<zorder>horizontalSpacer</zorder>
</widget>
</item>
<item row="1" column="0">
<widget class="QTableWidget" name="tableWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelHeader"> <widget class="QLabel" name="labelHeader">
<property name="sizePolicy"> <property name="sizePolicy">
@ -33,67 +127,11 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> </layout>
<widget class="QTableWidget" name="tableWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
<connections> <connections/>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>examDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>examDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>