using refs, change exam qdate format

This commit is contained in:
liranbg 2014-10-10 20:36:00 +03:00
parent 65c23138e5
commit 054237a667
10 changed files with 58 additions and 19 deletions

View file

@ -21,9 +21,9 @@ void CalendarManager::setExamsSchedule(QString html)
examDialogPtr->initializingDataIntoTable();
examDialogPtr->show();
}
void CalendarManager::exportCalendarCSV() //need to add fix to the null pointer bug
void CalendarManager::exportCalendarCSV()
{
if (this->caliSchedPtr->getCourses() == NULL)
if (this->caliSchedPtr->getCourses().isEmpty())
return;
QMessageBox msgBox;
int buttonClicked = caliDialog->exec();

View file

@ -23,7 +23,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
if ((cal == NULL) || (calSched == NULL)) //pointers checking!
return false;
if (calSched->getCourses() == NULL)
if (calSched->getCourses().isEmpty())
return false;
qDebug() << Q_FUNC_INFO << "Getting path for csv file from user...";
@ -53,7 +53,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
out << CSV_CALENDAR_HEADER << "\n"; // macro in header file
for (calendarCourse *coursePtr: *(calSched->getCourses())) //main loop - running though all courses
for (calendarCourse *coursePtr: (calSched->getCourses())) //main loop - running though all courses
{
// Getting course info - store in vars for easy access
int day = coursePtr->getDay();

View file

@ -11,6 +11,8 @@ examDialog::examDialog(QWidget *parent, calendarExam *calSchedPtr) : QDialog(par
headLine << tr("Serial") << tr("Course") << tr("Lecturer") << tr("Field") << tr("Type") << tr("First") << tr("Begin") << tr("Second") << tr("Begin");
ui->tableWidget->verticalHeader()->setVisible(false);
ui->tableWidget->horizontalHeader()->setVisible(false);
ui->tableWidget->setColumnCount(EXAM_SCHEDULE_FIELDS);
ui->tableWidget->setHorizontalHeaderLabels(headLine);
ui->tableWidget->setLayoutDirection(Qt::LayoutDirection::RightToLeft);
@ -29,7 +31,6 @@ void examDialog::initializingDataIntoTable()
QTimeEdit *firstHourbegin;
QDateEdit *secondDate;
QTimeEdit *secondHourbegin;
for (calendarExamCourse * tempExam: *exams->getExams())
{
j=0;
@ -44,8 +45,10 @@ void examDialog::initializingDataIntoTable()
field = new QTableWidgetItem();
field->setData(Qt::EditRole, tempExam->getField());
firstDate = new QDateEdit();
firstDate->setDisplayFormat("d/M/yy");
firstDate->setDate(tempExam->getFirstDate());
secondDate = new QDateEdit();
secondDate->setDisplayFormat("d/M/yy");
secondDate->setDate(tempExam->getSecondDate());
firstHourbegin = new QTimeEdit();
firstHourbegin->setTime(tempExam->getFirstHourbegin());
@ -66,6 +69,8 @@ void examDialog::initializingDataIntoTable()
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
this->setMinimumHeight(ui->tableWidget->height());
this->setMinimumWidth(ui->tableWidget->width());
}
examDialog::~examDialog()

View file

@ -13,8 +13,8 @@
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@ -27,10 +27,10 @@
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">

View file

@ -18,6 +18,17 @@ namespace Ui {
class CalendarDialog;
}
/**
* @brief The CalendarDialog class
*
* This class preseting a Dialog with selection of dates
* The user has to choose between a starting point of semester to the end.
*
* This dialog main goal is to let the user an option to export his CSV
* containing data of his schedule.
*
* Made By Sagi Dayan, sagidayan@gmail.com On 22/09/2014
*/
class CalendarDialog : public QDialog
{
Q_OBJECT

View file

@ -6,11 +6,7 @@
*/
void CalendarPage::setPage(QString html)
{
if (courses == NULL)
courses = new QList<calendarCourse*>();
else
courses->clear();
courses.clear();
tempHtml = getString(html);
calendarListInit(tempHtml);
@ -33,7 +29,7 @@ void CalendarPage::calendarListInit(QString &linesTokinzedString)
{
calendarCourse *cTemp = lineToCourse(tempToken);
if (cTemp != NULL)
this->courses->push_back(cTemp);
this->courses.push_back(cTemp);
}
}
}

View file

@ -8,17 +8,25 @@
#define ROOM_DEFAULT_STRING "nullRoom"
#define LECTURER_DEFAULT_STRING "nullLecturer"
/**
* @brief The CalendarPage class
*
* This class generating html string to a list of calendarCourses
* Each item in a list is a course with its information (hour, day, name, serial and etc)
*
* Made By liran ben gida, LiranBG@gmail.com On 31/8/2014
*/
class CalendarPage : public Page
{
public:
QList<calendarCourse*> *getCourses() { return courses; }
QList<calendarCourse*> getCourses() { return courses; }
protected:
virtual void setPage(QString html);
CalendarPage() { courses = NULL; }
CalendarPage() { }
private:
@ -27,7 +35,7 @@ private:
calendarCourse * lineToCourse(QString line);
QString tempHtml;
QList<calendarCourse*> *courses;
QList<calendarCourse*> courses;
};

View file

@ -6,6 +6,17 @@
#define CALENDAR_COURSE_FIELDS 8
/**
* @brief The calendarCourse class
*
* This class holds each scheduled course
* the course scheme can be found below, inside the enum CourseScheme
*
* The class's constructor gets the data and manipulate it into an object
* with its relevant information.
*
* Made By liran ben gida, LiranBG@gmail.com On 31/8/2014
*/
class calendarCourse : public Course
{
public:

View file

@ -59,7 +59,7 @@ void calendarSchedule::insertCourseIntoTable()
QString courseString;
int currentHour,currentDay,blocksNumber;
int row,col;
for (calendarCourse *coursePtr: *getCourses())
for (calendarCourse *coursePtr: getCourses())
{
courseString = "";
currentHour = coursePtr->getHourBegin();

View file

@ -12,6 +12,14 @@
#define HOURS_END 20
#define ACADEMIN_HOUR 45
/**
* @brief The calendarSchedule class
*
* This class combining the courses schedule with each course into a table
* setpage -> insertingIntoTable -> showing data
*
* Made By liran ben gida, LiranBG@gmail.com On 31/8/2014
*/
class calendarSchedule : public QTableWidget, public CalendarPage
{
Q_OBJECT