Skip to content

Commit

Permalink
Merge pull request #90 from mitchcamza/wip3
Browse files Browse the repository at this point in the history
Tidy up documentation for COS3711-02-03
  • Loading branch information
mitchcamza authored Jul 18, 2024
2 parents 80bc003 + c7d1023 commit a6b3345
Show file tree
Hide file tree
Showing 24 changed files with 235 additions and 457 deletions.
8 changes: 0 additions & 8 deletions COS3711-02-03/filereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,13 @@
#include <QTextStream>


/**
* @brief Constructs a FileReader object with the specified file name.
* @param fileName The name of the file to read.
*/
FileReader::FileReader(const QString &fileName)
: m_FileName(fileName)
{

}


/**
* @brief Reads the contents of the file.
* @return The contents of the file as a QString.
*/
QString FileReader::read() const
{
QFile file(m_FileName);
Expand Down
10 changes: 1 addition & 9 deletions COS3711-02-03/filewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,13 @@
#include <QTextStream>


/**
* @brief Constructs a FileWriter object with the specified file name.
* @param fileName The name of the file to write to.
*/
FileWriter::FileWriter(const QString &fileName)
: m_FileName(fileName)
{

}

/**
* @brief Writes the specified contents to the file.
* @param contents The contents to write to the file.
* @return True if the write operation was successful, false otherwise.
*/

bool FileWriter::write(const QString &contents) const
{
QFile file(m_FileName);
Expand Down
21 changes: 3 additions & 18 deletions COS3711-02-03/guestregistration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,28 @@
#include "guestregistration.h"


/**
* @brief Constructs a GuestRegistration object with the given attendee, booking date, and category.
* @param attendee The person attending the event.
* @param bookingDate The date of the booking.
* @param category The category of the guest registration.
*/
GuestRegistration::GuestRegistration(const Person &attendee, const QDate &bookingDate, const QString &category)
: Registration(attendee, bookingDate),
m_Category(category)
{

}

/**
* @brief Calculates the registration fee for the guest registration.
* @return The calculated registration fee.
*/

double GuestRegistration::calculateFee() const
{
return STANDARD_FEE * 0.1;
}

/**
* @brief Returns a string representation of the guest registration.
* @return The string representation of the guest registration.
*/

QString GuestRegistration::toString() const
{
return Registration::toString() + QString("Category: %1\nRegistration Fee: %2\n")
.arg(m_Category)
.arg(calculateFee());
}

/**
* @brief Returns the category of the guest registration.
* @return The category of the guest registration.
*/

QString GuestRegistration::getCategory() const
{
return m_Category;
Expand Down
76 changes: 22 additions & 54 deletions COS3711-02-03/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,34 @@
* @author Mitch Campbell
* @date 2024-07-11
* @copyright Copyright (c) Mitch Campbell 2024
* @brief Implementation file for the MainWindow class.
* @details This file contains the implementation of the MainWindow class, which represents the main application window for a conference registration system. It includes the setup of the user interface, menu actions, toolbar, and signal-slot connections for various actions.
*/


#include "mainwindow.h"
#include "newregistrationdialog.h"
#include "totalfeesdialog.h"
#include "totalregistereddialog.h"
#include "registrationmodel.h"
#include "registrationlist.h"
#include "registration.h"
#include "registrationfilterproxymodel.h"
#include "registrationlistwriter.h"
#include "registrationlist.h"
#include "registrationlistreader.h"
#include "registration.h"
#include "registrationlistwriter.h"
#include "registrationmodel.h"
#include "totalfeesdialog.h"
#include "totalregistereddialog.h"

#include <QTableView>
#include <QStandardItem>
#include <QFileDialog>
#include <QGridLayout>
#include <QHeaderView>
#include <QMenuBar>
#include <QStatusBar>
#include <QToolBar>
#include <QIcon>
#include <QGridLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QFileDialog>
#include <QMenuBar>
#include <QMessageBox>
#include <QPushButton>
#include <QStandardItem>
#include <QStatusBar>
#include <QTableView>
#include <QToolBar>


/**
* @brief Constructs a MainWindow object.
* @param parent The parent widget.
*/
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
registrationModel(new RegistrationModel(this)),
Expand Down Expand Up @@ -67,18 +61,13 @@ MainWindow::MainWindow(QWidget *parent)
setupUI(this);
}

/**
* @brief Destroys the MainWindow object.
*/

MainWindow::~MainWindow()
{

}

/**
* @brief Sets up the user interface for the main application window.
* @param mainApplicationWindow The main application window.
*/

void MainWindow::setupUI(QMainWindow *mainApplicationWindow)
{
// Main Application window
Expand Down Expand Up @@ -149,51 +138,36 @@ void MainWindow::setupUI(QMainWindow *mainApplicationWindow)
gridLayout->addWidget(tableViewRegistrations, 1, 0, 1, 4);
}

/**
* @brief Slot for the "New Registration" action.
* Opens the dialog for adding a new registration.
*/

void MainWindow::on_actionAddAttendee_triggered()
{
NewRegistrationDialog *newRegistrationDialog = new NewRegistrationDialog(registrationList);
newRegistrationDialog->show();
}

/**
* @brief Slot for the "Total Fees" action.
* Opens the dialog for displaying the total fees.
*/

void MainWindow::on_actionGetTotalFees_triggered()
{
TotalFeesDialog *totalFeesDialog = new TotalFeesDialog(registrationList);
totalFeesDialog->show();
}

/**
* @brief Slot for the "Registration per Affiliation" action.
* Opens the dialog for displaying the total number of attendees per affiliation.
*/

void MainWindow::on_actionGetNumberOfAttendeesFromAffiliation_triggered()
{
TotalRegisteredDialog *totalRegisteredDialog = new TotalRegisteredDialog(registrationList);
totalRegisteredDialog->show();
}

/**
* @brief Slot for the "Clear Filter" action.
* Clears the search filter and sets focus to the search bar.
*/

void MainWindow::on_actionClearFilter_triggered()
{
lineEditSearch->clear();
lineEditSearch->setFocus();
proxyModel->setFilterText(lineEditSearch->text());
}

/**
* @brief Slot for the "Export Registration List" action.
* Opens a file dialog to export the registration list to an XML file.
*/

void MainWindow::on_actionExportRegistrationList_triggered()
{
// Open a file dialog to save the XML file
Expand All @@ -212,21 +186,15 @@ void MainWindow::on_actionExportRegistrationList_triggered()
}
}

/**
* @brief Slot for the "Import Registration List" action.
* Opens a file dialog to import an existing registration list from an XML file and appends it to the current registration list.
*/

void MainWindow::on_actionImportRegistrationList_triggered()
{
// Open a file dialog to select the XML file
QString fileName = QFileDialog::getOpenFileName(this, tr("Import Registration List"), "", tr("XML Files (*.xml);;All Files (*)"));
if (fileName.isEmpty()) { return; }

// Read the file, deserialize XML, and store registrations in a new QList
RegistrationListReader reader(fileName);
QList<Registration*> importedRegistrations = reader.read();

// If there is nothing to import, return
if (importedRegistrations.isEmpty())
{
QMessageBox::warning(this, tr("Import Failed"), tr("Failed to import the registration list. Check that the file exists, and that the XML structure is well-formed."));
Expand Down
6 changes: 3 additions & 3 deletions COS3711-02-03/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

#include <QMainWindow>

class QTableView;
class RegistrationModel;
class RegistrationList;
class QGridLayout;
class QLineEdit;
class QPushButton;
class QTableView;
class RegistrationFilterProxyModel;
class RegistrationList;
class RegistrationModel;


/**
Expand Down
Loading

0 comments on commit a6b3345

Please sign in to comment.