Листинг functionGuest.cpp
functionGuest.cpp
| #include "functionGuest.h"
#include "ui_tabPostersHiring.h"
#include "ui_tabPostersRent.h"
FunctionGuest::FunctionGuest(QLinkedList<User *> *_users, QWidget *parent)
{
if(!parent)
parent = this;
users = _users;
searchWindowPosterHiring = new QWidget(parent);
searchWindowPosterRent = new QWidget(parent);
uiSearchHiring.setupUi(searchWindowPosterHiring);
uiSearchRent.setupUi(searchWindowPosterRent);
uiHiring.setupUi(uiSearchHiring.windowPosterHiring);
uiRent.setupUi(uiSearchRent.searchWindowPosterRent);
uiHiring.nPhoneLabel->hide();
uiHiring.nPhoneLineEdit->hide();
uiRent.nPhoneLabel->hide();
uiRent.nPhoneLineEdit->hide();
uiFunction.setupUi(parent);
uiFunction.delAccountButton->hide();
uiFunction.tabWidget->addTab(searchWindowPosterHiring, searchWindowPosterHiring
->windowTitle() );
uiFunction.tabWidget->addTab(searchWindowPosterRent, searchWindowPosterRent
->windowTitle());
QObject::connect(uiSearchHiring.okButton, SIGNAL(clicked()), SLOT(searchPosterHiring()));
QObject::connect(uiSearchRent.okButton, SIGNAL(clicked()), SLOT(searchPosterRent()));
QObject::connect(uiSearchHiring.clearButton, SIGNAL(clicked()), SLOT(clearPosterHiring()));
QObject::connect(uiSearchRent.clearButton, SIGNAL(clicked()), SLOT(clearPosterRent()));
}
FunctionGuest::~FunctionGuest()
{
delete searchWindowPosterHiring;
delete searchWindowPosterRent;
}
bool FunctionGuest::selectionPosterHiring(PosterHiring *poster, const QLineEdit *city,
const QLineEdit *area, const QComboBox *nRoom,
const QCheckBox *furtiture, const QCheckBox *animal,
const QComboBox *tenant, const QLineEdit *price)
{
if(!city->text().isEmpty())
if(poster->getCity() != city->text())
return false;
if(!area->text().isEmpty())
if(poster->getArea() != area->text())
return false;
if(!price->text().isEmpty())
if(poster->getPrice() > price->text().toInt())
return false;
if(nRoom->currentText() != poster->getSumRoom())
return false;
if(tenant->currentText() != poster->getTenant())
return false;
if(animal->isChecked() != poster->getAnimal())
return false;
if(furtiture->isChecked() != poster->getFurtiture())
return false;
return true;
}
bool FunctionGuest::selectionPosterRent(PosterRent *poster, const QLineEdit *city,
const QLineEdit *area,const QLineEdit *street,
const QLineEdit *home,const QSpinBox *floor,
const QComboBox *nRoom, const QCheckBox *furtiture,
const QCheckBox *animal, const QComboBox *tenant,
const QLineEdit *price)
{
if(!selectionPosterHiring(poster, city, area, nRoom, furtiture, animal, tenant, price))
return false;
if(!street->text().isEmpty())
if(poster->getStreet() != street->text())
return false;
if(!home->text().isEmpty())
if(poster->getHome() != home->text())
return false;
if(floor->value() != poster->getNumberFloor())
return false;
return true;
}
void FunctionGuest::addQStringInTable(QTableWidget *table, QString text, const int row, const int column)
{
QTableWidgetItem *item = new QTableWidgetItem(text);
table->setItem( row, column, item );
}
void FunctionGuest::addInTablePosterHiring(QTableWidget *table, PosterHiring *poster, const int row)
{
addQStringInTable(table, poster->getCity(), row, 0);
addQStringInTable(table, poster->getArea(), row, 1);
addQStringInTable(table, poster->getNumberPhone(), row, 2);
addQStringInTable(table, poster->getSumRoom(), row, 3);
if(poster->getFurtiture())
addQStringInTable(table, "true", row, 4);
else addQStringInTable(table, "false", row, 4);
if(poster->getAnimal())
addQStringInTable(table, "true", row, 5);
else addQStringInTable(table, "false", row, 5);
addQStringInTable(table, poster->getTenant(), row, 6);
addQStringInTable(table, QString("%1").arg(poster->getPrice()), row, 7);
}
void FunctionGuest::addInTablePosterRent(QTableWidget *table, PosterRent *poster,
const int row)
{
addQStringInTable(table, poster->getCity(), row, 0);
addQStringInTable(table, poster->getArea(), row, 1);
addQStringInTable(table, poster->getStreet(), row, 2);
addQStringInTable(table, poster->getHome(), row, 3);
addQStringInTable(table, QString("%1").arg(poster->getNumberFloor()), row, 4);
addQStringInTable(table, poster->getNumberPhone(), row, 5);
addQStringInTable(table, poster->getSumRoom(), row, 6);
if(poster->getFurtiture())
addQStringInTable(table, "true", row, 7);
else addQStringInTable(table, "false", row, 7);
if(poster->getAnimal())
addQStringInTable(table, "true", row, 8);
else addQStringInTable(table, "false", row, 8);
addQStringInTable(table, poster->getTenant(), row, 9);
addQStringInTable(table, QString("%1").arg(poster->getPrice()), row, 10);
}
void FunctionGuest::searchPosterHiring()
{
QDialog *windowSearchTable = new QDialog(this);
Ui::tabPostersHiring ui;
ui.setupUi(windowSearchTable);
QLinkedList<User *>::Iterator passageUser = users->begin();
while(passageUser != users->end())
{
QLinkedList<PosterHiring *>::Iterator passagePoster = (*passageUser)->getPostersHiring()
->begin();
while(passagePoster != (*passageUser)->getPostersHiring()->end())
{
if(selectionPosterHiring(*passagePoster, uiHiring.cityLineEdit,
uiHiring.areaLineEdit, uiHiring.sRoomComboBox,
uiHiring.furtitureCheckBox, uiHiring.animalCheckBox,
uiHiring.tenantComboBox, uiHiring.priceLineEdit))
{
ui.tableWidget->insertRow(ui.tableWidget->rowCount());
addInTablePosterHiring(ui.tableWidget, *passagePoster, ui.tableWidget->rowCount()
- 1);
}
passagePoster++;
}
++passageUser;
}
windowSearchTable->exec();
delete windowSearchTable;
}
void FunctionGuest::searchPosterRent()
{
QDialog *windowSearchTable = new QDialog(this);
Ui::tabPostersRent ui;
ui.setupUi(windowSearchTable);
QLinkedList<User *>::Iterator passageUser = users->begin();
while(passageUser != users->end())
{
QLinkedList<PosterRent *>::Iterator passagePoster = (*passageUser)->getPostersRent()
->begin();
while(passagePoster != (*passageUser)->getPostersRent()->end())
{
if(selectionPosterRent(*passagePoster, uiRent.cityLineEdit,
uiRent.areaLineEdit, uiRent.streetLineEdit,
uiRent.nHomeLineEdit, uiRent.floorSpinBox,
uiRent.sRoomComboBox, uiRent.furtitureCheckBox,
uiRent.animalCheckBox, uiRent.tenantComboBox,
uiRent.priceLineEdit ))
{
ui.tableWidget->insertRow(ui.tableWidget->rowCount());
addInTablePosterRent(ui.tableWidget, *passagePoster, ui.tableWidget->rowCount() - 1);
}
passagePoster++;
}
++passageUser;
}
windowSearchTable->exec();
delete windowSearchTable;
}
void FunctionGuest::clearPosterHiring(QLineEdit *city, QLineEdit *area,
QLineEdit *nPhone, QComboBox *nRoom,
QCheckBox *furtiture, QCheckBox *animal,
QComboBox *tenant, QLineEdit *price)
{
city->clear();
area->clear();
nPhone->clear();
nRoom->setCurrentIndex(0);
furtiture->setChecked(true);
animal->setChecked(false);
tenant->setCurrentIndex(0);
price->clear();
}
void FunctionGuest::clearPosterRent(QLineEdit *city, QLineEdit *area,
QLineEdit *street, QLineEdit *home,
QSpinBox *floor, QLineEdit *nPhone,
QComboBox *nRoom, QCheckBox *furtiture,
QCheckBox *animal, QComboBox *tenant,
QLineEdit *price)
{
clearPosterHiring(city, area, nPhone, nRoom, furtiture, animal, tenant, price);
street->clear();
home->clear();
floor->setValue(0);
}
void FunctionGuest::clearPosterHiring()
{
clearPosterHiring(uiHiring.cityLineEdit, uiHiring.areaLineEdit,
uiHiring.nPhoneLineEdit, uiHiring.sRoomComboBox,
uiHiring.furtitureCheckBox, uiHiring.animalCheckBox,
uiHiring.tenantComboBox, uiHiring.priceLineEdit);
}
void FunctionGuest::clearPosterRent()
{
clearPosterRent(uiRent.cityLineEdit, uiRent.areaLineEdit,
uiRent.streetLineEdit, uiRent.nHomeLineEdit,
uiRent.floorSpinBox,
uiRent.nPhoneLineEdit, uiRent.sRoomComboBox,
uiRent.furtitureCheckBox, uiRent.animalCheckBox,
uiRent.tenantComboBox, uiRent.priceLineEdit);
}
|
|
Обсуждений еще не было, будьте первым... ↓↓↓
|
|
Популярное:
©2015-2024 megaobuchalka.ru Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. (360)
|
Почему 1285321 студент выбрали МегаОбучалку...
Система поиска информации
Мобильная версия сайта
Удобная навигация
Нет шокирующей рекламы
|