added exam revert
This commit is contained in:
parent
ae7d20beda
commit
6cafe6dc70
9 changed files with 210 additions and 83 deletions
|
@ -1,8 +1,4 @@
|
|||
#include "coursestablemanager.h"
|
||||
/*
|
||||
* TODO: revert gpa to origin
|
||||
*
|
||||
*/
|
||||
coursesTableManager::coursesTableManager(QTableWidget *ptr, user *usrPtr)
|
||||
{
|
||||
this->gp = NULL;
|
||||
|
@ -322,7 +318,7 @@ void coursesTableManager::revertChanges()
|
|||
(temp->getSerialNum() == notChangedCourse->getSerialNum()))
|
||||
{
|
||||
courseTBL->item(i,gradeCourse::CourseScheme::GRADE)->setText(QString::number(notChangedCourse->getGrade()));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -4,6 +4,21 @@ calendarExam::calendarExam()
|
|||
{
|
||||
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
|
||||
|
|
|
@ -20,6 +20,7 @@ class calendarExam : public Page
|
|||
{
|
||||
public:
|
||||
calendarExam();
|
||||
calendarExam(calendarExam &other);
|
||||
void setPage(QString html);
|
||||
|
||||
QList<calendarExamCourse*> getExams() { return exams; }
|
||||
|
|
|
@ -12,6 +12,19 @@ calendarExamCourse::calendarExamCourse(int serial, QString name, QString lecture
|
|||
setTime(firstHourbegin,true);
|
||||
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
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
calendarExamCourse(int serial, QString name, QString lecturer, QString field,
|
||||
QString type, QString firstDate, QString firstHourbegin,
|
||||
QString secondDate, QString secondHourbegin);
|
||||
calendarExamCourse(calendarExamCourse &other);
|
||||
|
||||
|
||||
QString getLecturer() const;
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
#include "examDialog.h"
|
||||
#include "ui_examDialog.h"
|
||||
/*
|
||||
*TODO: exam revert, add to csv exportation, dialog size
|
||||
*/
|
||||
/**
|
||||
* @brief examDialog::examDialog
|
||||
* @param parent
|
||||
* @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->setupUi(this);
|
||||
exams = calSchedPtr;
|
||||
exams = calExamPtr;
|
||||
this->examsCpy = NULL;
|
||||
|
||||
QStringList headLine;
|
||||
//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*)));
|
||||
ui->tableWidget->setRowCount(exams->getExamsCounter());
|
||||
this->examsCpy = new calendarExam(*exams);
|
||||
|
||||
int i=0,j=0;
|
||||
int year,month,day; //for constructin qdate by setdate
|
||||
QTableWidgetItem *lecturer,*name,*type;
|
||||
|
@ -180,11 +181,65 @@ void examDialog::resetGeo()
|
|||
mHeight += ui->tableWidget->rowHeight(i) + 4;
|
||||
|
||||
}
|
||||
mHeight += ui->buttonBox->height() + 4;
|
||||
mHeight += ui->frameBtns->height() + 30;
|
||||
mHeight += ui->labelHeader->height() + 4;
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class examDialog : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit examDialog(QWidget *parent,calendarExam * calSchedPtr);
|
||||
explicit examDialog(QWidget *parent, calendarExam * calExamPtr);
|
||||
void initializingDataIntoTable();
|
||||
~examDialog();
|
||||
|
||||
|
@ -35,12 +35,20 @@ private slots:
|
|||
|
||||
bool upgradeExamsTime(QTableWidgetItem* item);
|
||||
|
||||
void on_pushButtonOk_clicked();
|
||||
|
||||
void on_pushButtonRevert_clicked();
|
||||
|
||||
void on_pushButtonCancel_clicked();
|
||||
|
||||
private:
|
||||
|
||||
calendarExamCourse *getExamByRow(int row);
|
||||
void resetGeo();
|
||||
|
||||
Ui::examDialog *ui;
|
||||
calendarExam * exams;
|
||||
calendarExam * examsCpy;
|
||||
};
|
||||
|
||||
#endif // EXAMDIALOG_H
|
||||
|
|
|
@ -19,81 +19,119 @@
|
|||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelHeader">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QFrame" name="frameAll">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#frameAll {
|
||||
border: 0px solids;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-size:14pt;">Exams Schedule</span></p></body></html></string>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
</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="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 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">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButtonRevert">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Revert changes</p></body></html></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><html><head/><body><p>Discard and hide</p></body></html></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><html><head/><body><p>Save and hide</p></body></html></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">
|
||||
<widget class="QLabel" name="labelHeader">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-size:14pt;">Exams Schedule</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<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>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in a new issue