Edit Lesson 5 Task 2
This commit is contained in:
parent
4c94b72e20
commit
571578b022
1 changed files with 6 additions and 4 deletions
|
@ -1,6 +1,5 @@
|
||||||
#include "autoservice.h"
|
#include "autoservice.h"
|
||||||
#include "ui_autoservice.h"
|
#include "ui_autoservice.h"
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
AutoService::AutoService(QWidget *parent)
|
AutoService::AutoService(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
|
@ -26,10 +25,13 @@ void AutoService::filter()
|
||||||
bool typeEmpty = ui->e_type->text().isEmpty();
|
bool typeEmpty = ui->e_type->text().isEmpty();
|
||||||
bool priceEmpty = ui->e_price->text().isEmpty();
|
bool priceEmpty = ui->e_price->text().isEmpty();
|
||||||
for (int automobile = 0; automobile < m_automobiles.size(); ++automobile) {
|
for (int automobile = 0; automobile < m_automobiles.size(); ++automobile) {
|
||||||
|
bool manufacturerMatch = m_automobiles[automobile]->getManufacturer() == ui->e_manufacturer->text();
|
||||||
|
bool typeMatch = m_automobiles[automobile]->getType().contains(ui->e_type->text());
|
||||||
|
bool priceMatch = m_automobiles[automobile]->getPrice() <= ui->e_price->text().toInt();
|
||||||
if (
|
if (
|
||||||
(manufacturerEmpty || m_automobiles[automobile]->getManufacturer() == ui->e_manufacturer->text())
|
(manufacturerEmpty || manufacturerMatch)
|
||||||
&& (typeEmpty || (m_automobiles[automobile]->getType().contains(ui->e_type->text())))
|
&& (typeEmpty || typeMatch)
|
||||||
&& (priceEmpty || (m_automobiles[automobile]->getPrice() <= ui->e_price->text().toInt()))
|
&& (priceEmpty || priceMatch)
|
||||||
)
|
)
|
||||||
addAutomobile(m_automobiles[automobile]);
|
addAutomobile(m_automobiles[automobile]);
|
||||||
|
|
||||||
|
|
Reference in a new issue