Информационная система жилищного агентства

Тип работы:
Курсовая
Предмет:
Программирование


Узнать стоимость

Детальная информация о работе

Выдержка из работы

{

int i = 0;

city-> setText (poster->getCity ());

area-> setText (poster->getArea ());

nPhone-> setText (poster->getNumberPhone ());

for (i = 0; nRoom-> currentText () ≠ poster-> getSumRoom (); nRoom-> setCurrentIndex (++i));

furtiture-> setChecked (poster->getFurtiture ());

animal-> setChecked (poster->getAnimal ());

for (i = 0; tenant-> currentText () ≠ poster-> getTenant (); tenant-> setCurrentIndex (++i));

price-> setText (QString («%1»). arg (poster->getPrice ()));

}

void FunctionUser: :writePosterTiItemsRent (PosterRent *poster, QLineEdit *city, QLineEdit *area,

QLineEdit *street, QLineEdit *home, QSpinBox *floor, QLineEdit *nPhone,

QComboBox *nRoom, QCheckBox *furtiture, QCheckBox *animal,

QComboBox *tenant, QLineEdit *price)

{

writePosterTiItemsHiring (poster, city, area, nPhone, nRoom, furtiture, animal, tenant, price);

street-> setText (poster->getStreet ());

home-> setText (poster->getHome ());

floor-> setValue (poster->getNumberFloor ());

}

void FunctionUser: :slotEditPosterHiring ()

{

QLinkedList< PosterHiring *> :Iterator passage = current-> getPostersHiring ()->begin ();

int row;

for (row = 0; row < uiTabPostersHiring. tableWidget->currentRow (); ++row)

++passage;

QDialog *window = new QDialog (this);

Ui: :workWindowPoster uiWindow;

uiWindow. setupUi (window);

QObject: :connect (uiWindow. okButton, SIGNAL (clicked ()), window, SLOT (accept ()));

QObject: :connect (uiWindow. cancelButton, SIGNAL (clicked ()), window, SLOT (reject ()));

Ui: :posterHiring ui;

ui. setupUi (uiWindow. windowPoster);

writePosterTiItemsHiring (*passage, ui. cityLineEdit, ui. areaLineEdit, ui. nPhoneLineEdit,

ui. sRoomComboBox, ui. furtitureCheckBox, ui. animalCheckBox, ui. tenantComboBox,

ui. priceLineEdit);

if (window-> exec ())

{

readPosterHiring (*passage, current-> getLogin (), ui. cityLineEdit, ui. areaLineEdit,

ui. nPhoneLineEdit, ui. sRoomComboBox, ui. furtitureCheckBox, ui. animalCheckBox,

ui. tenantComboBox, ui. priceLineEdit);

uiTabPostersHiring. tableWidget->removeRow (row);

uiTabPostersHiring. tableWidget->insertRow (row);

addInTablePosterHiring (uiTabPostersHiring. tableWidget, *passage, row);

}

delete window;

viewButtonHiring (false);

uiTabPostersHiring. tableWidget->selectionModel ()->clearSelection ();

}

void FunctionUser: :slotEditPosterRent ()

{

QLinkedList< PosterRent *> :Iterator passage = current-> getPostersRent ()->begin ();

int row;

for (row = 0; row < uiTabPostersRent. tableWidget->currentRow (); ++row)

++passage;

QDialog *window = new QDialog (this);

Ui: :workWindowPoster uiWindow;

uiWindow. setupUi (window);

QObject: :connect (uiWindow. okButton, SIGNAL (clicked ()), window, SLOT (accept ()));

QObject: :connect (uiWindow. cancelButton, SIGNAL (clicked ()), window, SLOT (reject ()));

Ui: :posterRent ui;

ui. setupUi (uiWindow. windowPoster);

writePosterTiItemsRent (*passage, ui. cityLineEdit, ui. areaLineEdit, ui. streetLineEdit,

ui. nHomeLineEdit, ui. floorSpinBox, ui. nPhoneLineEdit, ui. sRoomComboBox,

ui. furtitureCheckBox, ui. animalCheckBox, ui. tenantComboBox, ui. priceLineEdit);

if (window-> exec ())

{

readPosterRent (*passage, current-> getLogin (), ui. cityLineEdit, ui. areaLineEdit,

ui. streetLineEdit, ui. nHomeLineEdit, ui. floorSpinBox, ui. nPhoneLineEdit,

ui. sRoomComboBox, ui. furtitureCheckBox, ui. animalCheckBox, ui. tenantComboBox,

ui. priceLineEdit);

uiTabPostersRent. tableWidget->removeRow (row);

uiTabPostersRent. tableWidget->insertRow (row);

addInTablePosterRent (uiTabPostersRent. tableWidget, *passage, row);

}

delete window;

viewButtonRent (false);

uiTabPostersRent. tableWidget->selectionModel ()->clearSelection ();

}

void FunctionUser: :slotDelMyAccount ()

{

QLinkedList< User *> :Iterator passage = users-> begin ();

while ((*passage) ≠ current)

++passage;

users-> erase (passage);

slotSavePosterHiring ();

slotSavePosterRent ();

exit (1);

}

Листинг functionAdmin. h

functionAdmin

#ifndef FUNCTIONADMIN_H

#define FUNCTIONADMIN_H

#include «functionUser. h»

#include «ui_functionAdmin. h»

class FunctionAdmin: public FunctionUser

{

Q_OBJECT

protected:

QWidget *windowUsers;

Ui: :functionAdmin uiFunctionAdmin;

protected:

void fillUserInTable ();

public:

FunctionAdmin (QLinkedList< User *> *_users, User *_current, QWidget *parent = 0);

~FunctionAdmin ();

protected slots:

void newPassword ();

void editAccess ();

void saveUsers ();

void deleteUser ();

void editPostersUser ();

};

#endif // FUNCTIONADMIN_H

Листинг functionAdmin. cpp

functionAdmin. cpp

#include «functionAdmin. h»

#include «ui_editPassword. h»

#include «ui_editAccess. h»

FunctionAdmin: :FunctionAdmin (QLinkedList<User *> *_users, User *_current,

QWidget *parent):

FunctionUser (_users, _current, parent)

{

windowUsers = new QWidget (parent);

uiFunctionAdmin. setupUi (windowUsers);

uiFunction. tabWidget->addTab (windowUsers, windowUsers-> windowTitle ());

fillUserInTable ();

QObject: :connect (uiFunctionAdmin. newPasswordButton, SIGNAL (clicked ()),

SLOT (newPassword ()));

QObject: :connect (uiFunctionAdmin. editAccessButton, SIGNAL (clicked ()),

SLOT (editAccess ()));

QObject: :connect (uiFunctionAdmin. saveButton, SIGNAL (clicked ()), SLOT (saveUsers ()));

QObject: :connect (uiFunctionAdmin. delUserButton, SIGNAL (clicked ()), SLOT (deleteUser ()));

QObject: :connect (uiFunctionAdmin. editPostersButton, SIGNAL (clicked ()),

SLOT (editPostersUser ()));

}

FunctionAdmin: :~FunctionAdmin ()

{

delete windowUsers;

}

void FunctionAdmin: :fillUserInTable ()

{

QLinkedList< User *> :Iterator passage = users-> begin ();

int row = 0;

while (passage ≠ users-> end ())

{

if (row <= uiFunctionAdmin. usersTableWidget->rowCount ())

uiFunctionAdmin. usersTableWidget->insertRow (row);

addQStringInTable (uiFunctionAdmin. usersTableWidget, (*passage)-> getLogin (), row, 0);

if ((*passage)-> getAccess ())

addQStringInTable (uiFunctionAdmin. usersTableWidget, «ADMIN», row++, 1);

else addQStringInTable (uiFunctionAdmin. usersTableWidget, «USER», row++, 1);

++passage;

}

}

void FunctionAdmin: :newPassword ()

{

int row = uiFunctionAdmin. usersTableWidget->currentRow ();

QLinkedList< User *> :Iterator passage = users-> begin ();

for (row = 0; row < uiFunctionAdmin. usersTableWidget->currentRow (); row++)

++passage;

QDialog *window = new QDialog (this);

Ui: :editPassword ui;

ui. setupUi (window);

QObject: :connect (ui. okButton, SIGNAL (clicked ()), window, SLOT (accept ()));

QObject: :connect (ui. cancelButton, SIGNAL (clicked ()), window, SLOT (reject ()));

while (window-> exec ())

{

if (ui. passwordLineEdit->text (). isEmpty ())

QMessageBox: :information (this, tr («clear string»), tr («SORRY, clear string»),

QMessageBox: :Ok);

else

{

(*passage)-> setPassword (ui. passwordLineEdit->text ());

break;

}

}

delete window;

uiFunctionAdmin. usersTableWidget->selectionModel ()->clearSelection ();

}

void FunctionAdmin: :editAccess ()

{

int row = uiFunctionAdmin. usersTableWidget->currentRow ();

QLinkedList< User *> :Iterator passage = users-> begin ();

for (row = 0; row < uiFunctionAdmin. usersTableWidget->currentRow (); row++)

++passage;

QDialog *window = new QDialog (this);

Ui: :editAccess ui;

ui. setupUi (window);

QObject: :connect (ui. okButton, SIGNAL (clicked ()), window, SLOT (accept ()));

QObject: :connect (ui. cancelButton, SIGNAL (clicked ()), window, SLOT (reject ()));

if (window-> exec ())

if (ui. AccessComboBox->currentIndex ())

{

(*passage)-> setAccess (ADMIN);

uiFunctionAdmin. usersTableWidget->item (row, 1)-> setText («ADMIN»);

}

else

{

(*passage)-> setAccess (USER);

uiFunctionAdmin. usersTableWidget->item (row, 1)-> setText («USER»);

}

delete window;

uiFunctionAdmin. usersTableWidget->selectionModel ()->clearSelection ();

}

void FunctionAdmin: :saveUsers ()

{

QFile *file = new QFile («login. bin»);

file-> open (QIODevice:WriteOnly);

QDataStream in (file);

QLinkedList< User *> :Iterator passage = users-> begin ();

while (passage ≠ users-> end ())

{

in < < (*passage)-> getLogin ();

in < < (*passage)-> getPassword ();

in < < (*passage)-> getAccess ();

++passage;

}

file-> close ();

delete file;

uiFunctionAdmin. usersTableWidget->selectionModel ()->clearSelection ();

}

void FunctionAdmin: :deleteUser ()

{

int row = uiFunctionAdmin. usersTableWidget->currentRow ();

QLinkedList< User *> :Iterator passage = users-> begin ();

for (row = 0; row < uiFunctionAdmin. usersTableWidget->currentRow (); row++)

++passage;

if ((*passage) == current)

{

users-> erase (passage);

slotSavePosterHiring ();

slotSavePosterRent ();

saveUsers ();

exit (1);

}

users-> erase (passage);

uiFunctionAdmin. usersTableWidget->removeRow (row);

uiFunctionAdmin. usersTableWidget->selectionModel ()->clearSelection ();

}

void FunctionAdmin: :editPostersUser ()

{

int row = uiFunctionAdmin. usersTableWidget->currentRow ();

QLinkedList< User *> :Iterator passage = users-> begin ();

for (row = 0; row < uiFunctionAdmin. usersTableWidget->currentRow (); row++)

++passage;

QDialog *window = new QDialog (this);

FunctionAdmin *user = new FunctionAdmin (users, *passage, window);

user-> uiFunction. tabWidget->removeTab (0);

user-> uiFunction. tabWidget->removeTab (0);

user-> uiFunction. tabWidget->removeTab (2);

user-> uiFunction. delAccountButton->hide ();

window-> exec ();

if (*passage == current)

{

row = uiTabPostersHiring. tableWidget->rowCount ();

while (row > 0)

uiTabPostersHiring. tableWidget->removeRow (--row);

row = uiTabPostersRent. tableWidget->rowCount ();

while (row > 0)

uiTabPostersRent. tableWidget->removeRow (--row);

fillPosterTableHiring ();

fillPosterTableRent ();

}

delete user;

delete window;

uiFunctionAdmin. usersTableWidget->selectionModel ()->clearSelection ();

}

Листинг main. cpp

main. cpp

#include < QtGui>

#include «mainWindow. h»

#include «functionAdmin. h»

#include «login. h»

int main (int argc, char **argv)

{

QApplication app (argc, argv);

MainWindow mainWindow;

FunctionGuest *guestWindow;

FunctionUser *userWindow;

FunctionAdmin *adminWindow;

Login loginWindow;

if (!loginWindow. exec ())

return 0;

if (!loginWindow. getCurrentUser ())

guestWindow = new FunctionGuest (loginWindow. getUsers (), mainWindow. centralWidget ());

else

if (loginWindow. getCurrentUser ()->getAccess () == USER)

userWindow = new FunctionUser (loginWindow. getUsers (), loginWindow. getCurrentUser (),

mainWindow. centralWidget ());

else

adminWindow = new FunctionAdmin (loginWindow. getUsers (),

loginWindow. getCurrentUser (), mainWindow. centralWidget ());

mainWindow. show ();

return app. exec ();

}

ПоказатьСвернуть
Заполнить форму текущей работой