Skip to content

Commit ee32753

Browse files
authored
Merge pull request #44 from mitchcamza/dev
Dev
2 parents 68a6f80 + 2805106 commit ee32753

13 files changed

+221
-59
lines changed

COS3711-03-01/COS3711-03-01.drawio

+7-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<mxfile host="Electron" modified="2024-08-03T22:19:03.055Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/24.6.4 Chrome/124.0.6367.207 Electron/30.0.6 Safari/537.36" etag="wzqjLYlRrMz9Hwo7XFZM" version="24.6.4" type="device">
1+
<mxfile host="Electron" modified="2024-08-06T13:08:42.070Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/24.6.4 Chrome/124.0.6367.207 Electron/30.0.6 Safari/537.36" etag="2MUYOWNRhgzR3xg8WMUV" version="24.6.4" type="device">
22
<diagram id="6iuWq0UelAJ61aAoiBDy" name="Book Shelf">
3-
<mxGraphModel dx="2265" dy="2298" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="0" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
3+
<mxGraphModel dx="1288" dy="1299" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="0" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
44
<root>
55
<mxCell id="0" />
66
<mxCell id="1" parent="0" />
@@ -97,42 +97,24 @@
9797
<mxCell id="gvHln3FCuM-_E14BoruI-77" value="+ BookProxyModel(parent: QObject)&lt;div&gt;+ setFilterText(filterText: QString)&lt;/div&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;labelBackgroundColor=none;" parent="gvHln3FCuM-_E14BoruI-74" vertex="1">
9898
<mxGeometry y="34" width="500" height="56" as="geometry" />
9999
</mxCell>
100-
<mxCell id="gvHln3FCuM-_E14BoruI-78" value="&lt;div&gt;BookView&lt;/div&gt;" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;labelBackgroundColor=none;" parent="1" vertex="1">
101-
<mxGeometry x="1050" y="-610" width="400" height="98" as="geometry" />
102-
</mxCell>
103-
<mxCell id="gvHln3FCuM-_E14BoruI-79" value="- tableView: QTableView&lt;div&gt;- model: BookTableModel&lt;/div&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;labelBackgroundColor=none;" parent="gvHln3FCuM-_E14BoruI-78" vertex="1">
104-
<mxGeometry y="26" width="400" height="34" as="geometry" />
105-
</mxCell>
106-
<mxCell id="gvHln3FCuM-_E14BoruI-80" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;labelBackgroundColor=none;" parent="gvHln3FCuM-_E14BoruI-78" vertex="1">
107-
<mxGeometry y="60" width="400" height="8" as="geometry" />
108-
</mxCell>
109-
<mxCell id="gvHln3FCuM-_E14BoruI-81" value="&lt;div&gt;+ addBook(title: QString, authors: QString, isbn: QString, date: QString)&lt;/div&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;labelBackgroundColor=none;" parent="gvHln3FCuM-_E14BoruI-78" vertex="1">
110-
<mxGeometry y="68" width="400" height="30" as="geometry" />
111-
</mxCell>
112100
<mxCell id="we9DT2KBn4o6eFFRd77e-5" value="&lt;div&gt;MainWindow&lt;/div&gt;" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;labelBackgroundColor=none;" vertex="1" parent="1">
113-
<mxGeometry x="1670" y="-375" width="500" height="360" as="geometry" />
101+
<mxGeometry x="1670" y="-410" width="500" height="310" as="geometry" />
114102
</mxCell>
115-
<mxCell id="we9DT2KBn4o6eFFRd77e-6" value="&lt;div&gt;- bookView: BookView&lt;/div&gt;&lt;div&gt;- bookModel: BookModel&lt;/div&gt;&lt;div&gt;- menuBar: QMenuBar&lt;/div&gt;&lt;div&gt;- statusBar: QStatusBar&lt;/div&gt;&lt;div&gt;- toolBar: QToolBar&lt;/div&gt;&lt;div&gt;- actionAddBook: QAction&lt;/div&gt;&lt;div&gt;- actionExportBooks: QAction&lt;/div&gt;&lt;div&gt;- actionSearchBook: QAction&lt;/div&gt;&lt;div&gt;- actionCloseApplicationWindow(): QAction&lt;/div&gt;&lt;div&gt;- lineEditSearch: QLineEdit&lt;/div&gt;&lt;div&gt;- pushButtonClear: QPushButton&lt;/div&gt;&lt;div&gt;- proxyModel: BookFilterProxyModel&lt;/div&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;labelBackgroundColor=none;" vertex="1" parent="we9DT2KBn4o6eFFRd77e-5">
116-
<mxGeometry y="26" width="500" height="184" as="geometry" />
103+
<mxCell id="we9DT2KBn4o6eFFRd77e-6" value="&lt;div&gt;&lt;span style=&quot;background-color: initial;&quot;&gt;- bookModel: BookModel&lt;/span&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- proxyModel: BookFilterProxyModel&lt;/div&gt;&lt;div&gt;- bookTableView: QTableView&lt;br&gt;&lt;/div&gt;&lt;div&gt;- actionAddBook: QAction&lt;/div&gt;&lt;div&gt;- actionExportBooks: QAction&lt;/div&gt;&lt;div&gt;- actionClose: QAction&lt;/div&gt;&lt;div&gt;- lineEditSearch: QLineEdit&lt;/div&gt;&lt;div&gt;- pushButtonClear: QPushButton&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;labelBackgroundColor=none;" vertex="1" parent="we9DT2KBn4o6eFFRd77e-5">
104+
<mxGeometry y="26" width="500" height="134" as="geometry" />
117105
</mxCell>
118106
<mxCell id="we9DT2KBn4o6eFFRd77e-7" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;labelBackgroundColor=none;" vertex="1" parent="we9DT2KBn4o6eFFRd77e-5">
119-
<mxGeometry y="210" width="500" height="8" as="geometry" />
107+
<mxGeometry y="160" width="500" height="8" as="geometry" />
120108
</mxCell>
121109
<mxCell id="we9DT2KBn4o6eFFRd77e-8" value="&lt;div&gt;&lt;div&gt;+ MainWindow(parent: QWidget)&lt;/div&gt;&lt;/div&gt;&lt;div&gt;+ ~MainWindow()&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;+ setupUI()&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;- addBook()&lt;/div&gt;&lt;div&gt;- exportBooks()&lt;/div&gt;&lt;div&gt;- clearFilter()&lt;/div&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;labelBackgroundColor=none;" vertex="1" parent="we9DT2KBn4o6eFFRd77e-5">
122-
<mxGeometry y="218" width="500" height="142" as="geometry" />
110+
<mxGeometry y="168" width="500" height="142" as="geometry" />
123111
</mxCell>
124112
<mxCell id="we9DT2KBn4o6eFFRd77e-9" value="" style="endArrow=diamondThin;endFill=1;endSize=24;html=1;rounded=0;" edge="1" parent="1" source="gvHln3FCuM-_E14BoruI-74" target="we9DT2KBn4o6eFFRd77e-5">
125113
<mxGeometry width="160" relative="1" as="geometry">
126114
<mxPoint x="660" y="-470" as="sourcePoint" />
127115
<mxPoint x="820" y="-470" as="targetPoint" />
128116
</mxGeometry>
129117
</mxCell>
130-
<mxCell id="we9DT2KBn4o6eFFRd77e-10" value="" style="endArrow=diamondThin;endFill=1;endSize=24;html=1;rounded=0;" edge="1" parent="1" source="gvHln3FCuM-_E14BoruI-78" target="we9DT2KBn4o6eFFRd77e-5">
131-
<mxGeometry width="160" relative="1" as="geometry">
132-
<mxPoint x="1340" y="-680" as="sourcePoint" />
133-
<mxPoint x="1500" y="-680" as="targetPoint" />
134-
</mxGeometry>
135-
</mxCell>
136118
<mxCell id="we9DT2KBn4o6eFFRd77e-11" value="" style="endArrow=diamondThin;endFill=0;endSize=24;html=1;rounded=0;" edge="1" parent="1" source="gvHln3FCuM-_E14BoruI-51" target="gvHln3FCuM-_E14BoruI-74">
137119
<mxGeometry width="160" relative="1" as="geometry">
138120
<mxPoint x="780" y="490" as="sourcePoint" />

COS3711-03-01/src/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ set(PROJECT_SOURCES
2323
)
2424

2525
# Create library
26-
add_library(MyProjectLib ${PROJECT_SOURCES})
26+
add_library(MyProjectLib ${PROJECT_SOURCES}
27+
bookfactory.h bookfactory.cpp)
2728

2829
# Include directories for the library
2930
target_include_directories(MyProjectLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

COS3711-03-01/src/bookfactory.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "bookfactory.h"
2+
#include "book.h"
3+
4+
5+
BookFactory::BookFactory() {}
6+
7+
BookFactory &BookFactory::getInstance()
8+
{
9+
static BookFactory bookFactoryInstance;
10+
return bookFactoryInstance;
11+
}
12+
13+
Book *BookFactory::createBook(const QString &title, const QStringList &authors, const QString &isbn, const QDate &publicationDate)
14+
{
15+
if (title.isEmpty() || authors.isEmpty() || isbn.isEmpty() || !publicationDate.isValid())
16+
{
17+
return nullptr;
18+
}
19+
return new Book(title, authors, isbn, publicationDate);
20+
}

COS3711-03-01/src/bookfactory.h

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef BOOKFACTORY_H
2+
#define BOOKFACTORY_H
3+
4+
class Book;
5+
class QDate;
6+
class QString;
7+
8+
#include <QStringList>
9+
10+
11+
class BookFactory
12+
{
13+
public:
14+
static BookFactory &getInstance();
15+
Book *createBook(const QString &title, const QStringList &authors, const QString &isbn, const QDate &publicationDate);
16+
17+
private:
18+
BookFactory();
19+
BookFactory(const BookFactory&) = delete;
20+
BookFactory &operator=(const BookFactory&) = delete;
21+
};
22+
23+
#endif // BOOKFACTORY_H

COS3711-03-01/src/bookinput.cpp

+43-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
#include "book.h"
12
#include "bookinput.h"
3+
#include "booktablemodel.h"
4+
#include "bookfactory.h"
25

36
#include <QDateEdit>
47
#include <QGridLayout>
@@ -12,8 +15,9 @@
1215
#include <QRegularExpressionMatch>
1316

1417

15-
BookInput::BookInput(QWidget *parent)
18+
BookInput::BookInput(BookTableModel *model, QWidget *parent)
1619
: QDialog{parent},
20+
bookTableModel(model),
1721
mainLayout(new QGridLayout(this)),
1822
gridLayoutBook(new QGridLayout()),
1923
gridLayoutAuthor(new QGridLayout()),
@@ -78,7 +82,30 @@ void BookInput::saveBook()
7882
return;
7983
}
8084

81-
// TODO: add book and author to model
85+
// Add book and author to model
86+
QString title = lineEditTitle->text();
87+
QStringList authors;
88+
for (int i = 0; i < listWidgetAuthors->count(); i++)
89+
{
90+
QListWidgetItem *item = listWidgetAuthors->item(i);
91+
if (item)
92+
{
93+
authors.append(item->text());
94+
}
95+
}
96+
QString isbn = lineEditIsbn->text();
97+
QDate publicationDate = dateEditPublicationDate->date();
98+
99+
// Create the new book using the book factory
100+
BookFactory &bookFactory = BookFactory::getInstance();
101+
Book *newBook = bookFactory.createBook(title, authors, isbn, publicationDate);
102+
103+
// Add the new book to the model
104+
bookTableModel->addBook(newBook);
105+
106+
// Close the dialog
107+
accept();
108+
82109
}
83110

84111
void BookInput::cancel()
@@ -108,6 +135,8 @@ void BookInput::setupBookGroup()
108135

109136
// ISBN
110137
QLabel *labelIsbn = new QLabel("ISBN", this);
138+
lineEditIsbn->setInputMask("999-9-99-999999-9;_");
139+
lineEditIsbn->setPlaceholderText("978-3-16-148410-0");
111140
gridLayoutBook->addWidget(labelIsbn, 1, 0);
112141
gridLayoutBook->addWidget(lineEditIsbn, 1, 1, 1, 3);
113142

@@ -174,12 +203,19 @@ bool BookInput::isValidInput()
174203
return false;
175204
}
176205

177-
// Check if ISBN is empty or invalid
178-
static QRegularExpression isbnRegex("\\d{3}-\\d{1,5}-\\d{1,7}-\\d{1,7}-\\d{1}");
179-
QRegularExpressionMatch isbnMatch = isbnRegex.match(lineEditIsbn->text());
180-
if (lineEditIsbn->text().isEmpty() || !isbnMatch.hasMatch())
206+
// // Check if ISBN is empty or invalid
207+
// static QRegularExpression isbnRegex("\\d{3}-\\d{1,5}-\\d{1,7}-\\d{1,7}-\\d{1}");
208+
// QRegularExpressionMatch isbnMatch = isbnRegex.match(lineEditIsbn->text());
209+
// if (lineEditIsbn->text().isEmpty() || !isbnMatch.hasMatch())
210+
// {
211+
// QMessageBox::warning(this, "Input Error", "Please enter a valid ISBN (format: 978-3-16-148410-0).");
212+
// lineEditIsbn->setFocus();
213+
// return false;
214+
// }
215+
// Check if ISBN is empty
216+
if (lineEditIsbn->text().isEmpty())
181217
{
182-
QMessageBox::warning(this, "Input Error", "Please enter a valid ISBN (format: 978-3-16-148410-0).");
218+
QMessageBox::warning(this, "Input Error", "Please enter an ISBN.");
183219
lineEditIsbn->setFocus();
184220
return false;
185221
}

COS3711-03-01/src/bookinput.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ class QGroupBox;
99
class QLineEdit;
1010
class QListWidget;
1111
class QPushButton;
12+
class BookTableModel;
1213

1314

1415
class BookInput : public QDialog
1516
{
1617
Q_OBJECT
1718
public:
18-
explicit BookInput(QWidget *parent = nullptr);
19-
// TODO: inject model into constructor
20-
19+
explicit BookInput(BookTableModel *model, QWidget *parent = nullptr);
2120
~BookInput();
2221

2322
private slots:
@@ -33,6 +32,7 @@ private slots:
3332
void setupButtons();
3433
bool isValidInput();
3534

35+
BookTableModel *bookTableModel;
3636
QLineEdit *lineEditTitle;
3737
QLineEdit *lineEditIsbn;
3838
QDateEdit *dateEditPublicationDate;

COS3711-03-01/src/booktablemodel.cpp

+25-19
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ BookTableModel::BookTableModel(QObject *parent)
88

99
BookTableModel::~BookTableModel()
1010
{
11-
qDeleteAll(books);
11+
qDeleteAll(bookList);
1212
}
1313

1414
int BookTableModel::rowCount(const QModelIndex &parent) const
@@ -17,7 +17,7 @@ int BookTableModel::rowCount(const QModelIndex &parent) const
1717
{
1818
return 0;
1919
}
20-
return books.size();
20+
return bookList.size();
2121
}
2222

2323
int BookTableModel::columnCount(const QModelIndex &parent) const
@@ -27,7 +27,7 @@ int BookTableModel::columnCount(const QModelIndex &parent) const
2727
{
2828
return 0;
2929
}
30-
return 4; // title, author, publication date, isbn
30+
return 4; // title, authors, publication date, isbn
3131
}
3232

3333
QVariant BookTableModel::data(const QModelIndex &index, int role) const
@@ -42,10 +42,20 @@ QVariant BookTableModel::data(const QModelIndex &index, int role) const
4242
int col = index.column();
4343
int row = index.row();
4444

45-
if (col == 0) { return books.at(row)->getTitle(); }
46-
if (col == 1) { return books.at(row)->getAuthors(); }
47-
if (col == 2) { return books.at(row)->getPublicationDate(); }
48-
if (col == 3) { return books.at(row)->getIsbn(); }
45+
if (col == 0) { return bookList.at(row)->getTitle(); }
46+
if (col == 1)
47+
{
48+
if (bookList.at(row)->getAuthors().count() == 1)
49+
{
50+
return bookList.at(row)->getAuthors();
51+
}
52+
else if (bookList.at(row)->getAuthors().count() > 1)
53+
{
54+
return bookList.at(row)->getAuthors().join("; ");
55+
}
56+
}
57+
if (col == 2) { return bookList.at(row)->getPublicationDate(); }
58+
if (col == 3) { return bookList.at(row)->getIsbn(); }
4959
}
5060
return QVariant();
5161
}
@@ -75,10 +85,6 @@ QVariant BookTableModel::headerData(int section, Qt::Orientation orientation, in
7585
break;
7686
}
7787
}
78-
else if (orientation == Qt::Vertical)
79-
{
80-
return section + 1; // row numbers
81-
}
8288
return QVariant();
8389
}
8490

@@ -92,16 +98,16 @@ bool BookTableModel::setData(const QModelIndex &index, const QVariant &value, in
9298
switch (col)
9399
{
94100
case 0:
95-
books.at(row)->setTitle(value.toString());
101+
bookList.at(row)->setTitle(value.toString());
96102
break;
97103
case 1:
98-
books.at(row)->setAuthors(value.toStringList());
104+
bookList.at(row)->setAuthors(value.toStringList());
99105
break;
100106
case 2:
101-
books.at(row)->setPublicationDate(value.toDate());
107+
bookList.at(row)->setPublicationDate(value.toDate());
102108
break;
103109
case 3:
104-
books.at(row)->setIsbn(value.toString());
110+
bookList.at(row)->setIsbn(value.toString());
105111
break;
106112
}
107113
emit dataChanged(index, index, { role });
@@ -114,7 +120,7 @@ Qt::ItemFlags BookTableModel::flags(const QModelIndex &index) const
114120
{
115121
if (index.isValid())
116122
{
117-
return (Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
123+
return (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
118124
}
119125
else
120126
{
@@ -124,8 +130,8 @@ Qt::ItemFlags BookTableModel::flags(const QModelIndex &index) const
124130

125131
void BookTableModel::addBook(Book *book)
126132
{
127-
int row = books.size();
128-
beginInsertRows(QModelIndex(), row + 1, row + 1);
129-
books.append(book);
133+
int row = bookList.size();
134+
beginInsertRows(QModelIndex(), row, row);
135+
bookList.append(book);
130136
endInsertRows();
131137
}

COS3711-03-01/src/booktablemodel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class BookTableModel : public QAbstractTableModel
2121
void addBook(Book *book);
2222

2323
private:
24-
QList<Book*> books;
24+
QList<Book*> bookList;
2525

2626
};
2727

COS3711-03-01/src/mainwindow.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ MainWindow::MainWindow(QWidget *parent)
3333
actionExportBooks(new QAction(QIcon(":/icons/export"), tr("Export Books"), this)),
3434
actionClose(new QAction(QIcon(":/icons/exit"), tr("Exit Application"), this)),
3535
lineEditSearch(new QLineEdit(this)),
36-
pushButtonClear(new QPushButton("Clear", this))
36+
pushButtonClear(new QPushButton("Clear Filter", this))
3737
{
3838
// Proxy Model
3939
bookProxyModel->setSourceModel(bookTableModel);
@@ -43,7 +43,7 @@ MainWindow::MainWindow(QWidget *parent)
4343
// Signals and Slots connections
4444
connect(actionAddBook, &QAction::triggered, this, &MainWindow::addBook);
4545
connect(actionExportBooks, &QAction::triggered, this, &MainWindow::exportBooks);
46-
// connect(lineEditSearch, &QLineEdit::textEdited, bookProxyModel, &BookProxyModel::setFilterText);
46+
connect(lineEditSearch, &QLineEdit::textEdited, bookProxyModel, &BookProxyModel::setFilter);
4747
connect(pushButtonClear, &QPushButton::clicked, this, &MainWindow::clearFilter);
4848
connect(actionClose, &QAction::triggered, this, &MainWindow::close);
4949

@@ -106,7 +106,7 @@ void MainWindow::setupUI()
106106

107107
void MainWindow::addBook()
108108
{
109-
BookInput *bookInputDialog = new BookInput(this);
109+
BookInput *bookInputDialog = new BookInput(bookTableModel, this);
110110
bookInputDialog->show();
111111
}
112112

COS3711-03-01/tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ set(UNIT_TEST_SOURCES
1919
testbook.h testbook.cpp
2020
testbooktablemodel.h testbooktablemodel.cpp
2121
testbookproxymodel.h testbookproxymodel.cpp
22+
testbookfactory.h testbookfactory.cpp
2223
)
2324

2425
add_executable(UnitTests ${UNIT_TEST_SOURCES}

COS3711-03-01/tests/main.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "testbook.h"
33
#include "testbooktablemodel.h"
44
#include "testbookproxymodel.h"
5+
#include "testbookfactory.h"
56

67

78
int main(int argc, char *argv[])
@@ -23,6 +24,10 @@ int main(int argc, char *argv[])
2324
TestBookProxyModel tc;
2425
status |= QTest::qExec(&tc, argc, argv);
2526
}
27+
{
28+
TestBookFactory tc;
29+
status |= QTest::qExec(&tc, argc, argv);
30+
}
2631

2732
return status;
2833
}

0 commit comments

Comments
 (0)