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

  • Вид работы:
    Курсовая работа (т)
  • Предмет:
    Информационное обеспечение, программирование
  • Язык:
    Русский
    ,
    Формат файла:
    MS Word
    23,4 Кб
  • Опубликовано:
    2013-03-07
Вы можете узнать стоимость помощи в написании студенческой работы.
Помощь в написании работы, которую точно примут!

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

Реферат

Тема курсового проекта, представленная в пояснительной записке, звучит как "Информационная система жилищного агентства". Объём данной пояснительной записки к курсовому проекту по дисциплине "Математические и алгоритмические основы объектно-ориентированных систем и программирования" составляет 73 страницы, количество используемых источников 3.

Программа позволяет хранить и обрабатывать данные о съеме/сдаче жилья. Данная программа полезна риелторским фирмам, а так же индивидуальным риелторам. Так же осуществлён гостевой режим, позволяющий просматривать объявления без регистрации или авторизации.

Работа написана в среде Qt Creator. Частичная русификация. Объектно-ориентированный стиль.

Введение

Бывают ситуации, когда людям нужно купить или продать квартиру. Эта проблема была во все временна. Для этих целей обычно используют риэлторов, объявления, ищут сами или просят о помощи в поиске других людей.

Обрабатывать большие объемы информации без использования ЭВМ довольно не просто. Поэтому были созданы специальные программы, хранящие и обрабатывающие данные.

Информационная система (ИС) - взаимосвязанная совокупность средств, методов и персонала, используемых для хранения, обработки и выдачи информации[1].

Информационные системы - предназначены для сбора, хранения и обработки информации. Таким образом, в основе любой информационной системы лежат средства хранения и доступа к данным. Предназначены для конечного пользователя, не являющегося специалистом в области вычислительной техники. Из этого следует, что ИС должны включать в себя клиентские приложения, обеспечивающие интуитивно понятный интерфейс[1].

Информационные системы очень востребованы, т.к позволяют пользователям быстро использовать или дополнять имеющуюся информацию.

Основная часть

Рис1. - Эскизная схема алгоритма

В настоящее время есть большое количество программ, с частично схожим интерфейсом и функциями. А именно: регистрация, личный кабинет, вывод результата по запросу. Поэтому эти функции были взяты за основу.

Личный кабинет - индивидуальный раздел пользователя, доступ к которому защищен. Предназначен для управления личными данными.

В данной работе, личный кабинет пользователя представляет собой редактирование своих объявлений. Добавление, удаление, изменение, а так же удаление всех своих данных.

Список используемых идентификаторов

class PosterHiring

Класс, описывающий объявления о съеме жилья (поиск арендодателя).

Поля protected класса PosterHiring

QString login; логинcity; городarea; районnumberPhone; номер телефонаsumRoom; кол-во комнатtenant; квартиросъемщикprice; цена furtiture; наличие мебели

bool animal; возможность содержания животного

Методы public класса PosterHiring

конструкторы:

();

PosterHiring(const QString &_login, const QString &_city, const QString &_area,

const QString &_numberPhone, int _sumRoom, int _price, bool _furtiture,

bool _animal,int _tenant);

методы возвращающие значения полей:

getLogin();getCity();getArea;getNumberPhone;getSumRoom;getTenant();getPrice();getFurtiture();getAnimal();

методы задающие значения полей:

setLogin (const QString &_login);setCity (const QString &_city);setArea (const QString &_area);setNumberPhone(const QString &_numberPhone);setSumRoom(const QString &_sumRoom);setTenant(const QString &_tenant);setFurtiture(const bool &_furtiture);setAnimal(const bool &_animal);setPrice(int _price);

class PosterRent: public PosterHiring

Класс, описывающий объявления о сдачи жилья (поиск квартиросъемщика).

Поля protected класса PosterHiring

QString street; улицаnumberHome; номер домаnumberFloor; номер этажа

Методы public класса PosterHiring

конструкторы:

();(const QString &_login, const QString &_city, const QString &_area,

const QString &_street, const QString &_nHome, int _nFloor,QString &_numberPhone, int _sumRoom, int _price, bool _furtiture,

bool _animal,int _tenant);

методы возвращающие значения полей:

getStreet();getHome() ;getNumberFloor();

методы задающие значения полей:

setStreet (const QString &_street);setHome (const QString &_numberHome);setNumberFloor (int _floor);User

Класс, описывающий пользователя.

Поля protected класса User

login; логинpassword; парольaccess; доступ: true - admin, false - user<PosterHiring *> *postersHiring; указатели на объявления о съеме

QLinkedList<PosterRent *> *postersRent; указатели на объявления о сдаче

Методы public класса User

конструкторы:

();(const QString &_login, const QString &_password, bool _access = false );

методы возвращающие значения полей:

 getLogin;

String getPassword();getAccess();<PosterHiring *> *getPostersHiring();<PosterRent *> *getPostersRent();

методы задающие значения полей:

setLogin (const QString &_login);setPassword (const QString &_password) ;setPostersHiring (PosterHiring *poster);setPostersRent (PosterRent *poster);setAccess(const bool &_access);

bool check(const QString &_login, const QString &_password);  сравнение

class Login: public QDialog

Класс, описывающий вход пользователя в систему.

Поля protected класса Login

::login uiLogin;  форма *current;  ссылка на того пользователя который вошел

QLinkedList< User * > *users;  список указателей на пользователей

QFile *file;  указатель на файл

Методы protected класса Login

void consider();при наличии файла с пользователями вызывает функцию

считывающие данные, иначе функцию записывающие default данные

void readPostersHiring();считывает и распределяет между пользователями объявления о съеме

void readPostersRent();считывает и распределяет между пользователями объявления о сдаче

void fillPosterHiring(QDataStream &in, QString &tempQStr, int &tempInt,

void fillPosterRent(QDataStream &in, QString &tempQStr, int &tempInt,

bool &tempBool, PosterRent *poster); заполнения объявления о сдаче

void appointAdmin();проверяет наличие администратора, назначает права или записывает default данные

void readOutFile();считывает данные пользователей

Методы public класса Login

конструктор:

(QWidget *parent = 0);

деструктор:

~Login();saveInFile(const QString &login, const QString &password,

const bool &access); сохранение данных пользователя в файл

User *searchUser(const QString &login, const QString &password); поиск

пользователя по логину и паролю

reset(QLineEdit *login, QLineEdit *password); очистка на форме

User *getCurrentUser();вернуть ссылку на вошедшего пользователя

QLinkedList< User * > *getUsers();вернуть список пользователей

bool searchUserForLogin(const QString &login); поиск наличия пользователя с таким логином

Слоты protected класса Login

void slotCheck();нажата кнопка входа

void slotRegistration();нажата кнопка регистрации

void slotUserGuest();нажата кнопка гостевого входа

class MainWindow: public QMainWindow

Класс, описывающий главное окно программы.

Поля protected класса MainWindow

Ui::MainWindow uiMainWindow; форма главного окна

Методы public класса MainWindow

конструктор:

MainWindow(QWidget *parent = 0);FunctionGuest: public QWidget

Класс, описывающий функции гостя.

Поля protected класса FunctionGuest

QWidget *searchWindowPosterHiring; ссылка на виджет поиска объявления о съеме

QWidget *searchWindowPosterRent; ссылка на виджет поиска объявления о сдаче

QLinkedList<User *> *users; ссылка на список пользователей

Ui::searchPosterHiring uiSearchHiring; форма поиска объявления о съеме

Ui::searchPosterRent uiSearchRent; форма поиска объявления о сдаче

Ui::posterHiring uiHiring; форма объявления о съеме

Ui::posterRent uiRent; форма объявления о сдаче

Ui::tabFunction uiFunction; форма с главной таблицей с вкладками

Методы protected класса FunctionGuest

addQStringInTable(QTableWidget *table, QString text, const int row,

const int column); добавление записи

Методы public класса FunctionGuest

конструктор:

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

деструктор:

~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); отбор объявлений

о съеме

bool selectionPosterRent(PosterRent *poster, const QLineEdit *city,

const QLineEdit *area, const QLineEdit *street, const QLineEdit *home, QSpinBox *floor, const QComboBox *nRoom,QCheckBox *furtiture, const QCheckBox *animal,

const QComboBox *tenant, const QLineEdit *price); отбор объявлений

о сдаче

void addInTablePosterHiring(QTableWidget *table, PosterHiring *poster,

const int row); добавление объявления о съеме в таблицу

void addInTablePosterRent(QTableWidget *table, PosterRent *poster,

const int row); добавление объявления о сдаче в таблицу

void clearPosterHiring(QLineEdit *city, QLineEdit *area, QLineEdit *nPhone,

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

QComboBox *tenant, QLineEdit *price); очистка данных с формы

void clearPosterRent(QLineEdit *city, QLineEdit *area, QLineEdit *street,*home, QSpinBox *floor, QLineEdit *nPhone,*nRoom, QCheckBox *furtiture, QCheckBox *animal,

QComboBox *tenant, QLineEdit *price); очистка данных с формы

Слоты protected класса FunctionGuest

void searchPosterHiring();искать объявления о съеме searchPosterRent();искать объявления о сдаче

void clearPosterHiring();очистить форму объявления о съеме

void clearPosterRent();очистить форму объявления о сдаче

class FunctionUser: public FunctionGuest

Класс, описывающий функции пользователя.

Поля protected класса FunctionUser

QWidget *windowFunctionTabPostersHiring; окно объявлений пользователя о съеме

User *current; ссылка на вошедшего пользователя

Ui::functionTabPosterHiring uiMyTabPostersHiring; форма работы с объявлениями о съеме::functionTabPosterRent uiMyTabPostersRent; форма работы с объявлениями о сдаче::tabPostersHiring uiTabPostersHiring; форма с таблицей объявлений о съеме

Ui::tabPostersRent uiTabPostersRent; форма с таблицей объявлений о сдаче

Методы protected класса FunctionUser

void fillPosterTableHiring();заполение таблицы объявлениями пользователя

void fillPosterTableRent();заполение таблицы объявлениями пользователя

void setPosterHiringInFile(PosterHiring *poster, QDataStream &in); сохранение объявлений о съемеsetPosterRentInFile(PosterRent *poster, QDataStream &in); сохранение объявлений о сдаче

Методы public класса FunctionUser

конструктор:

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

~FunctionUser();деструктор

void viewButtonHiring(const bool &fl); активировать/деактивировать кнопкиviewButtonRent(const bool &fl); активировать/деактивировать кнопки

void readPosterHiring(PosterHiring *poster, const QString &login,

const QLineEdit *city, const QLineEdit *area, const QLineEdit *nPhone,QComboBox *nRoom, const QCheckBox *furtiture,QCheckBox *animal, const QComboBox *tenant,

const QLineEdit *price); считать с элементов данные в объявление

void readPosterRent(PosterRent *poster, const QString &login,

const QLineEdit *city, const QLineEdit *area, const QLineEdit *street,QLineEdit *home, const QSpinBox *floor, const QLineEdit *nPhone,QComboBox *nRoom, const QCheckBox *furtiture,

const QCheckBox *animal, const QComboBox *tenant,

const QLineEdit *price); считать с элементов данные в объявление

void writePosterTiItemsHiring(PosterHiring *poster, QLineEdit *city,

QLineEdit *area, QLineEdit *nPhone, QComboBox *nRoom,*furtiture, QCheckBox *animal, QComboBox *tenant,

QLineEdit *price); записать с объявления данные в элементы

void writePosterTiItemsRent(PosterRent *poster, QLineEdit *city, QLineEdit *area, QLineEdit *street, QLineEdit *home, QSpinBox *floor, QLineEdit *nPhone,*nRoom, QCheckBox *furtiture, QCheckBox *animal,

QComboBox *tenant, QLineEdit *price); записать данные в элементы

bool isEmptyPosterHiring(const QLineEdit *city, const QLineEdit *area,

const QLineEdit *price); проверка на заполненность всех строк

bool isEmptyPosterRent(const QLineEdit *city, const QLineEdit *area,

const QLineEdit *street, const QLineEdit *home, QLineEdit *price); проверка на заполненность всех строк

Слоты protected класса FunctionUser

void slotAddPosterHiring();добавить объявление

void slotAddPosterRent();добавить объявление

void slotSavePosterHiring();сохранить объявления

void slotSavePosterRent();сохранить объявления

void slotDeleteMyPosterHiring();удалить объявление

void slotDeleteMyPosterRent();удалить объявление

void slotEditPosterHiring();изменить объявление

void slotEditPosterRent();изменить объявление

void slotDelMyAccount();удалить свой аккаунт

void slotViewButtonHiring();деактивировать кнопки

void slotViewButtonRent();деактивировать кнопки

class FunctionAdmin: public FunctionUser

Класс, описывающий функции администратора.

Поля protected класса FunctionAdmin

QWidget *windowUsers; окно для изменения и просмотра пользователей

Ui::functionAdmin uiFunctionAdmin; форма

Методы protected класса FunctionAdmin

void fillUserInTable();заполение таблицы пользователями

Методы public класса FunctionAdmin, конструктор:

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

QWidget *parent = 0);

деструктор: ~FunctionAdmin();

Слоты protected класса FunctionUser

void newPassword();задать новый пароль пользователю

void editAccess();изменить права пользователя

void saveUsers();сохранить изменение

void deleteUser();удалить пользователя

void editPostersUser();изменить объявления пользователя

Инструкция к программе

Работа в программе поддерживает 3 режима. Гость, пользователь, администратор. Так же присутствует процесс регистрации новых пользователей.

Для входа гостя, не требуется ввод логина и пароля. Доступны функции: просмотр объявлений о сдаче и о съеме жилья.

Для входа пользователя требуется ввод логина и пароля. Реестр учитывается. Доступны функции: просмотр объявлений о сдаче и о съеме жилья, редактирование своих объявлений, удаление своего аккаунта (включая всю информацию, хранимую от данного пользователя).

Для входа администратора требуется ввод логина и пароля. Реестр учитывается. Доступны функции: просмотр объявлений о сдаче и о съеме жилья, редактирование своих объявлений, удаление своего аккаунта (включая всю информацию, хранимую от данного пользователя), редактирование чужих объявлений, удаление пользователей, изменение прав пользователей, назначение нового пароля пользователям.

Логин администратора по умолчанию: ADMIN

Пароль администратора по умолчанию: KI11-08

Всегда требуется наличие администратора, поэтому предусмотрена система сохранения режима администратора, а именно: при отсутствии пользователей с режимом администратора, проверяется наличие пользователя с логином ADMIN. При наличии такого пользователя, ему назначаются права администратора. При отсутствии пользователя с таким логином, создается встроенная учетная запись, с логином и паролем, описанная выше.

Заключение

программа приложение windows linux

Достоинства программы:

1.      Программа написана на языке C++ с использованием библиотеки Qt, является кроссплатформенной, что делает возможным использовать исходный код для создания приложения под Windows, Linux или Mac OS X без дополнительных изменений исходного кода.

.        Данные сохраняются в двоичные файлы, что позволяет переносить из одной системы в другую без дополнительных преобразований.

.        Практически полностью русифицирована.

Недостатки программы:

1.      Программа может корректно работать только с одним пользователем в данный момент времени.

.        Использование Qt Designed увеличивает объем памяти занимаемый программой.

.        Не полная русификация.

.        Русификация проводилась только через Qt Designed, из-за чего есть повторяющиеся по содержанию формы.

Список используемых источников

1.      Информационные системы: http://www.itcompanies.ru/04info.html

.        Шлее М. Qt 4.8. Профессиональное программирование на C++. - СПБ.: БХВ-Петербугр, 2012. - 912 с.: ил. - (В подлиннике)

Приложения

Листинг posterHiring.h

posterHiring.h

#ifndef POSTERHIRING_H #define POSTERHIRING_H #include <QtGui> class PosterHiring { protected: QString login; QString city; QString area; QString numberPhone; QString sumRoom; QString tenant; int price; bool furtiture; bool animal; public: PosterHiring() { price = 0; furtiture = false; animal = false; } PosterHiring(const QString &_login, const QString &_city, const QString &_area, const QString &_numberPhone, int _sumRoom, int _price, bool _furtiture, bool _animal,int _tenant) { login = _login; city = _city; area = _area; numberPhone = _numberPhone; sumRoom = _sumRoom; tenant = _tenant; furtiture = _furtiture; animal = _animal; setPrice(_price); } QString getLogin() { return login; } QString getCity() { return city; } QString getArea() { return area; } QString getNumberPhone() { return numberPhone; } QString getSumRoom() { return sumRoom; } QString getTenant() { return tenant; } int getPrice() { return price; } bool getFurtiture() { return furtiture; } bool getAnimal() { return animal; } void setLogin (const QString &_login ) { login = _login; } void setCity (const QString &_city ) { city = _city; } void setArea (const QString &_area ) { area = _area; } void setNumberPhone(const QString &_numberPhone) { numberPhone = _numberPhone; } void setSumRoom (const QString &_sumRoom) { sumRoom = _sumRoom; } void setTenant (const QString &_tenant) { tenant = _tenant; } void setFurtiture (const bool &_furtiture ) { furtiture = _furtiture; } void setAnimal (const bool &_animal ) { animal = _animal; } void setPrice(int _price) { if(_price < 0) price = 0; else price = _price; }


Листинг posterRent.h

posterRent.h

#ifndef POSTERRENT_H #define POSTERRENT_H #include "posterHiring.h" class PosterRent: public PosterHiring { protected: QString street; QString numberHome; int numberFloor; public: PosterRent(): PosterHiring() { numberFloor = 1; } PosterRent(const QString &_login, const QString &_city, const QString &_area, const QString &_street, const QString &_nHome, int _nFloor, const QString &_numberPhone, int _sumRoom, int _price, bool _furtiture, bool _animal,int _tenant): PosterHiring(_login, _city, _area, _numberPhone, _sumRoom, _price, _furtiture, _animal, _tenant) { street = _street; numberHome = _nHome; numberFloor = _nFloor; } QString getStreet() { return street; } QString getHome() { return numberHome; } int getNumberFloor() { return numberFloor; } void setStreet (const QString &_street ) { street = _street; } void setHome (const QString &_numberHome) { numberHome = _numberHome; } void setNumberFloor (int _floor) { if(_floor < 0) numberFloor = 0; else if(_floor > 101) numberFloor = 101; else numberFloor = _floor; }}; #endif // POSTERRENT_H


Листинг user.h

user.h

#ifndef USER_H #define USER_H #define USER false #define ADMIN true #include <QtGui> #include "posterHiring.h" #include "posterRent.h" class User { protected: QString login; QString password; bool access; QLinkedList<PosterHiring *> *postersHiring; QLinkedList<PosterRent *> *postersRent; public: User() { access = USER; } User(const QString &_login, const QString &_password, bool _access = false ) { login = _login; password = _password; setAccess(_access); postersHiring = new QLinkedList<PosterHiring *>; postersRent = new QLinkedList<PosterRent *>; } bool check(const QString &_login, const QString &_password) { if( login == _login && password == _password) return true; return false; } QString getLogin() { return login; } QString getPassword() { return password; } bool getAccess() { return access; } QLinkedList<PosterHiring *> *getPostersHiring() { return postersHiring; } QLinkedList<PosterRent *> *getPostersRent() { return postersRent; } void setLogin (const QString &_login) { login = _login; } void setPassword (const QString &_password) { password = _password; } void setPostersHiring (PosterHiring *poster) { postersHiring->push_back(poster); } void setPostersRent (PosterRent *poster) { postersRent->push_back(poster); } void setAccess(const bool &_access) { if(_access == false) access = USER; else access = ADMIN; }}; #endif // USER_H

Листинг login.h

login.h

#ifndef LOGIN_H #define LOGIN_H #include <QtGui> #include "user.h" #include "ui_login.h" class Login: public QDialog { Q_OBJECT protected: Ui::login uiLogin; User *current; QLinkedList<User *> *users; QFile *file; protected: void consider(); void readPostersHiring(); void readPostersRent(); void fillPosterHiring(QDataStream &in, QString &tempQStr, int &tempInt, bool &tempBool, PosterHiring *poster); void fillPosterRent(QDataStream &in, QString &tempQStr, int &tempInt, bool &tempBool, posterRent *poster); void appointAdmin(); void readOutFile(); public: Login(QWidget *parent = 0); ~Login(); void saveInFile(const QString &login, const QString &password, const bool &access); void reset(QLineEdit *login, QLineEdit *password); User *searchUser(const QString &login, const QString &password); User *getCurrentUser(); QLinkedList< User * > *getUsers(); bool searchUserForLogin(const QString &login); protected slots: void slotCheck(); void slotRegistration(); void slotUserGuest(); }; #endif // LOGIN_H

Листинг login.cpp

login.cpp

#include "login.h" #include "ui_registration.h" Login::Login(QWidget *parent): QDialog(parent) { if(!parent) parent = this; uiLogin.setupUi(parent); current = 0; file = new QFile("login.bin"); users = new QLinkedList<User *>; consider(); } Login::~Login() { delete file; delete users; } void Login::appointAdmin() { QLinkedList<User *>::Iterator passage = users->begin(); while(passage != users->end()) { if((*passage)->getLogin() == "ADMIN") { (*passage)->setAccess(ADMIN); return; } ++passage; } saveInFile("ADMIN", "KI11-08", ADMIN); } void Login::consider() { if(!file) return; if( file->exists()) readOutFile(); else saveInFile("ADMIN", "KI11-08", ADMIN); } void Login::readOutFile() { file->open(QIODevice::ReadOnly); QDataStream in(file); QString login; QString password; bool access; bool flAdmin = false; while(! in.atEnd() ) { in >> login; in >> password; in >> access; if(access) flAdmin = true; users->push_back(new User(login, password, access)); } if(!flAdmin) appointAdmin(); file->close(); } void Login::saveInFile(const QString &login, const QString &password, const bool &access) { file->open(QIODevice::Append); QDataStream out(file); out << login; out << password; out << access; users->push_back(new User(login, password, access)); file->close(); } User * Login::searchUser(const QString &login, const QString &password) { QLinkedList< User * >::iterator passage = users->begin(); while( passage != users->end() ) { if( (*passage)->check(login, password) ) return *passage; passage++; } return 0; } bool Login::searchUserForLogin(const QString &login) { QLinkedList< User * >::iterator passage = users->begin(); while( passage != users->end() ) { if( (*passage)->getLogin() == login ) return true; passage++; } return false; } void Login::slotCheck() { current = searchUser(uiLogin.loginLineEdit->text(), uiLogin.passwordLineEdit->text()); if(current == 0) { QMessageBox::information(this, tr("Error"), tr("Error write login or password!"), QMessageBox::Ok); uiLogin.passwordLineEdit->clear(); } else { emit accept(); readPostersHiring(); readPostersRent(); } } void Login::reset(QLineEdit *login, QLineEdit *password) { login->clear(); password->clear(); } void Login::slotRegistration() { QDialog *windowRegistration = new QDialog(this); Ui::registration uiReg; uiReg.setupUi(windowRegistration); while( windowRegistration->exec() ) { if (! searchUserForLogin(uiReg.loginLineEdit->text())) { saveInFile(uiReg.loginLineEdit->text(), uiReg.passwordLineEdit->text(), USER); break; } else { QMessageBox::information(this, tr("Error"), tr("Error, user is have this login"), QMessageBox::Ok); reset(uiReg.loginLineEdit, uiReg.passwordLineEdit); } } delete windowRegistration; } void Login::slotUserGuest() { emit accept(); readPostersHiring(); readPostersRent(); } User *Login::getCurrentUser() { return current; } QLinkedList< User * > *Login::getUsers() { return users; } void Login::fillPosterHiring (QDataStream &in, QString &tempQStr, int &tempInt, bool &tempBool, PosterHiring *poster) { in >> tempQStr; poster->setLogin( tempQStr ); in >> tempQStr; poster->setCity(tempQStr); in >> tempQStr; poster->setArea(tempQStr); in >> tempQStr; poster->setNumberPhone(tempQStr); in >> tempInt; poster->setPrice(tempInt); in >> tempBool; poster->setFurtiture(tempBool); in >> tempBool; poster->setAnimal(tempBool); in >> tempQStr; poster->setSumRoom(tempQStr); in >> tempQStr; poster->setTenant(tempQStr); } void Login::fillPosterRent (QDataStream &in, QString &tempQStr, int &tempInt, bool &tempBool, PosterRent *poster) { fillPosterHiring (in, tempQStr, tempInt, tempBool, poster); in >> tempQStr; poster->setStreet(tempQStr); in >> tempQStr; poster->setHome(tempQStr); in >> tempInt; poster->setNumberFloor(tempInt); } void Login::readPostersHiring() { file->setFileName("posterHiring.bin"); if(!file->open(QIODevice::ReadOnly)) return; QDataStream in(file); QString tempQStr; int tempInt; bool tempBool; PosterHiring *poster = 0; QLinkedList<User *>::Iterator passage = users->begin(); while( passage != users->end() ) { if(!poster) { poster = new PosterHiring; fillPosterHiring(in, tempQStr, tempInt, tempBool, poster); } if ( (*passage)->getLogin() == poster->getLogin() ) { (*passage)->setPostersHiring(poster); if(!in.atEnd()) poster = 0; else break; } else ++passage; } file->close(); } void Login::readPostersRent() { file->setFileName("posterRent.bin"); if(!file->open(QIODevice::ReadOnly)) return; QDataStream in(file); QString tempQStr; int tempInt; bool tempBool; PosterRent *poster = 0; QLinkedList<User *>::Iterator passage = users->begin(); while( passage != users->end()) { if(!poster) { poster = new PosterRent; fillPosterRent(in, tempQStr, tempInt, tempBool, poster); } if ( (*passage)->getLogin() == poster->getLogin() ) { (*passage)->setPostersRent(poster); if(!in.atEnd()) poster = 0; else break; } else ++passage; } if(!poster) delete poster; file->close(); }


Листинг mainWindow.h

mainWindow.h

#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include "ui_mainWindow.h" class MainWindow : public QMainWindow { Q_OBJECT protected: Ui::MainWindow uiMainWindow; public: MainWindow(QWidget *parent = 0): QMainWindow(parent) { uiMainWindow.setupUi(this); } }; #endif // MAINWINDOW_H


Листинг functionGuest.h

functionGuest.h

#ifndef FUNCTIONGUEST_H #define FUNCTIONGUEST_H #include <QtGui> #include "user.h" #include "ui_posterHiring.h" #include "ui_posterRent.h" #include "ui_tabFunction.h" #include "ui_searchPosterHiring.h" #include "ui_searchPosterRent.h" class FunctionGuest: public QWidget { Q_OBJECT protected: QWidget *searchWindowPosterHiring; QWidget *searchWindowPosterRent; QLinkedList<User *> *users; Ui::searchPosterHiring uiSearchHiring; Ui::searchPosterRent uiSearchRent; Ui::posterHiring uiHiring; Ui::posterRent uiRent; Ui::tabFunction uiFunction; protected: void addQStringInTable(QTableWidget *table, QString text, const int row, const int column); public: FunctionGuest(QLinkedList<User *> *_users, QWidget *parent = 0); ~FunctionGuest(); bool selectionPosterHiring(PosterHiring *poster, const QLineEdit *city, const QLineEdit *area, const QComboBox *nRoom, const QCheckBox *furtiture, const QCheckBox *animal, const QComboBox *tenant, const QLineEdit *price); bool 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); void addInTablePosterHiring(QTableWidget *table, PosterHiring *poster, const int row); void addInTablePosterRent(QTableWidget *table, PosterRent *poster, const int row); void clearPosterHiring(QLineEdit *city, QLineEdit *area, QLineEdit *nPhone, QComboBox *nRoom, QCheckBox *furtiture, QCheckBox *animal, QComboBox *tenant, QLineEdit *price); void clearPosterRent(QLineEdit *city, QLineEdit *area, QLineEdit *street, QLineEdit *home, QSpinBox *floor, QLineEdit *nPhone, QComboBox *nRoom, QCheckBox *furtiture, QCheckBox *animal, QComboBox *tenant, QLineEdit *price); protected slots: void searchPosterHiring(); void searchPosterRent(); void clearPosterHiring(); void clearPosterRent(); }; #endif // FUNCTIONGUEST_H


Листинг 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); }


Листинг functionUser.h

functionUser.h

#ifndef FUNCTIONUSER_H #define FUNCTIONUSER_H #include "functionGuest.h" #include "ui_tabPostersHiring.h" #include "ui_tabPostersRent.h" #include "ui_functionTabPosterHiring.h" #include "ui_functionTabPosterRent.h" class FunctionUser:public FunctionGuest { Q_OBJECT protected: QWidget *windowFunctionTabPostersHiring; QWidget *windowFunctionTabPostersRent; User *current; Ui::functionTabPosterHiring uiMyTabPostersHiring; Ui::functionTabPosterRent uiMyTabPostersRent; Ui::tabPostersHiring uiTabPostersHiring; Ui::tabPostersRent uiTabPostersRent; protected: void fillPosterTableHiring(); void fillPosterTableRent(); void setPosterHiringInFile(PosterHiring *poster, QDataStream &in); void setPosterRentInFile(PosterRent *poster, QDataStream &in); public: FunctionUser(QLinkedList<User *> *_users, User *_current, QWidget *parent = 0); ~FunctionUser(); void viewButtonHiring(const bool &fl); void viewButtonRent(const bool &fl); void readPosterHiring(PosterHiring *poster, const QString &login, const QLineEdit *city, const QLineEdit *area, const QLineEdit *nPhone, const QComboBox *nRoom, const QCheckBox *furtiture, const QCheckBox *animal, const QComboBox *tenant, const QLineEdit *price); void readPosterRent(PosterRent *poster, const QString &login, const QLineEdit *city, const QLineEdit *area, const QLineEdit *street, const QLineEdit *home, const QSpinBox *floor, const QLineEdit *nPhone, const QComboBox *nRoom, const QCheckBox *furtiture, const QCheckBox *animal, const QComboBox *tenant, const QLineEdit *price); void writePosterTiItemsHiring(PosterHiring *poster, QLineEdit *city, QLineEdit *area, QLineEdit *nPhone, QComboBox *nRoom, QCheckBox *furtiture, QCheckBox *animal, QComboBox *tenant, QLineEdit *price); void 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); bool isEmptyPosterHiring(const QLineEdit *city, const QLineEdit *area, const QLineEdit *price); bool isEmptyPosterRent(const QLineEdit *city, const QLineEdit *area, const QLineEdit *street, const QLineEdit *home, const QLineEdit *price); protected slots: void slotAddPosterHiring(); void slotAddPosterRent(); void slotSavePosterHiring(); void slotSavePosterRent(); void slotDeleteMyPosterHiring(); void slotDeleteMyPosterRent(); void slotEditPosterHiring(); void slotEditPosterRent(); void slotDelMyAccount(); void slotViewButtonHiring(); void slotViewButtonRent(); }; #endif // FUNCTIONUSER_H


Листинг functionUser.cpp

functionUser.cpp

#include "functionUser.h" #include "ui_workWindowPoster.h" #include <stdlib.h> FunctionUser::FunctionUser(QLinkedList<User *> *_users, User *_current, QWidget *parent): FunctionGuest(_users, parent) { windowFunctionTabPostersHiring = new QWidget(parent); windowFunctionTabPostersRent = new QWidget(parent); uiMyTabPostersHiring.setupUi(windowFunctionTabPostersHiring); uiMyTabPostersRent.setupUi(windowFunctionTabPostersRent); uiTabPostersHiring.setupUi(uiMyTabPostersHiring.windowTabPosterHiring); uiTabPostersRent.setupUi(uiMyTabPostersRent.windowTabPosterRent); uiFunction.tabWidget->addTab(windowFunctionTabPostersHiring, windowFunctionTabPostersHiring->windowTitle()); uiFunction.tabWidget->addTab(windowFunctionTabPostersRent, windowFunctionTabPostersRent->windowTitle()); uiFunction.delAccountButton->show(); current = _current; fillPosterTableHiring(); fillPosterTableRent(); viewButtonHiring(false); viewButtonRent(false); QObject::connect(uiMyTabPostersHiring.addPosterButton, SIGNAL(clicked()), SLOT(slotAddPosterHiring())); QObject::connect(uiMyTabPostersRent.addPosterButton, SIGNAL(clicked()),  SLOT(slotAddPosterRent())); QObject::connect(uiMyTabPostersHiring.savePostersButton, SIGNAL(clicked()),  SLOT(slotSavePosterHiring())); QObject::connect(uiMyTabPostersRent.savePostersButton, SIGNAL(clicked()), SLOT(slotSavePosterRent())); QObject::connect(uiMyTabPostersHiring.delPosterButton, SIGNAL(clicked()), SLOT(slotDeleteMyPosterHiring())); QObject::connect(uiMyTabPostersRent.delPosterButton, SIGNAL(clicked()), SLOT(slotDeleteMyPosterRent())); QObject::connect(uiMyTabPostersHiring.editPosterButton, SIGNAL(clicked()), SLOT(slotEditPosterHiring())); QObject::connect(uiMyTabPostersRent.editPosterButton, SIGNAL(clicked()), SLOT(slotEditPosterRent())); QObject::connect(uiFunction.delAccountButton, SIGNAL(clicked()), SLOT(slotDelMyAccount())); QObject::connect(uiTabPostersHiring.tableWidget, SIGNAL(cellClicked(int,int)), SLOT(slotViewButtonHiring())); QObject::connect(uiTabPostersRent.tableWidget, SIGNAL(cellClicked(int,int)), SLOT(slotViewButtonRent())); } void FunctionUser::viewButtonHiring(const bool &fl) { if(fl) { uiMyTabPostersHiring.editPosterButton->setEnabled(true); uiMyTabPostersHiring.delPosterButton->setEnabled(true); } else { uiMyTabPostersHiring.editPosterButton->setEnabled(false); uiMyTabPostersHiring.delPosterButton->setEnabled(false); } } void FunctionUser::viewButtonRent(const bool &fl) { if(fl) { uiMyTabPostersRent.editPosterButton->setEnabled(true); uiMyTabPostersRent.delPosterButton->setEnabled(true); } else { uiMyTabPostersRent.editPosterButton->setEnabled(false); uiMyTabPostersRent.delPosterButton->setEnabled(false); } } void FunctionUser::slotViewButtonHiring() { viewButtonHiring(true); } void FunctionUser::slotViewButtonRent() { viewButtonRent(false); } void FunctionUser::fillPosterTableHiring() { QLinkedList<PosterHiring *>::Iterator passage; passage = current->getPostersHiring()->begin(); while(passage != current->getPostersHiring()->end()) { uiTabPostersHiring.tableWidget->insertRow(uiTabPostersHiring.tableWidget->rowCount()); addInTablePosterHiring(uiTabPostersHiring.tableWidget, *passage, uiTabPostersHiring.tableWidget->rowCount() - 1); ++passage; } } void FunctionUser::fillPosterTableRent() { QLinkedList<PosterRent *>::Iterator passage; passage = current->getPostersRent()->begin(); while(passage != current->getPostersRent()->end()) { uiTabPostersRent.tableWidget->insertRow(uiTabPostersRent.tableWidget->rowCount()); addInTablePosterRent(uiTabPostersRent.tableWidget, *passage, uiTabPostersRent.tableWidget->rowCount() - 1); ++passage; } } FunctionUser::~FunctionUser() { delete windowFunctionTabPostersHiring; delete windowFunctionTabPostersRent; } void FunctionUser::readPosterHiring(PosterHiring *poster, const QString &login, const QLineEdit *city, const QLineEdit *area, const QLineEdit *nPhone, const QComboBox *nRoom, const QCheckBox *furtiture, const QCheckBox *animal, const QComboBox *tenant, const QLineEdit *price) { poster->setLogin(login); poster->setCity(city->text()); poster->setArea(area->text()); poster->setNumberPhone(nPhone->text()); poster->setSumRoom(nRoom->currentText()); poster->setFurtiture(furtiture->isChecked()); poster->setAnimal(animal->isChecked()); poster->setTenant(tenant->currentText()); poster->setPrice(price->text().toInt()); } void FunctionUser::readPosterRent(PosterRent *poster, const QString &login, const QLineEdit *city, const QLineEdit *area, const QLineEdit *street, const QLineEdit *home, const QSpinBox *floor, const QLineEdit *nPhone, const QComboBox *nRoom, const QCheckBox *furtiture, const QCheckBox *animal, const QComboBox *tenant, const QLineEdit *price) { readPosterHiring(poster, login, city, area, nPhone, nRoom, furtiture, animal, tenant, price); poster->setStreet(street->text()); poster->setHome(home->text()); poster->setNumberFloor(floor->value()); } bool FunctionUser::isEmptyPosterHiring(const QLineEdit *city, const QLineEdit *area, const QLineEdit *price) { if(city->text().isEmpty()) return false; if(area->text().isEmpty()) return false; if(price->text().isEmpty()) return false; return true; } bool FunctionUser::isEmptyPosterRent(const QLineEdit *city, const QLineEdit *area, const QLineEdit *street, const QLineEdit *home, const QLineEdit *price) { if(!isEmptyPosterHiring(city, area, price)) return false; if(street->text().isEmpty()) return false; if(home->text().isEmpty()) return false; return true; } void FunctionUser::slotAddPosterHiring() { QDialog *window = new QDialog(this); PosterHiring *poster; Ui::workWindowPoster uiWindow; Ui::posterHiring ui; uiWindow.setupUi(window); ui.setupUi(uiWindow.windowPoster); QObject::connect(uiWindow.okButton, SIGNAL(clicked()), window, SLOT(accept())); QObject::connect(uiWindow.cancelButton, SIGNAL(clicked()), window, SLOT(reject())); while(window->exec()) { if(isEmptyPosterHiring(ui.cityLineEdit, ui.areaLineEdit, ui.priceLineEdit)) { poster = new PosterHiring; readPosterHiring(poster, current->getLogin(), ui.cityLineEdit, ui.areaLineEdit, ui.nPhoneLineEdit, ui.sRoomComboBox, ui.furtitureCheckBox, ui.animalCheckBox, ui.tenantComboBox, ui.priceLineEdit); uiTabPostersHiring.tableWidget->insertRow(uiTabPostersHiring.tableWidget ->rowCount()); addInTablePosterHiring(uiTabPostersHiring.tableWidget, poster, uiTabPostersHiring.tableWidget->rowCount() - 1); current->getPostersHiring()->push_back(poster); break; } else QMessageBox::information(this, tr("clear string"), tr("SORRY, clear string"), QMessageBox::Ok); } delete window; viewButtonHiring(false); uiTabPostersHiring.tableWidget->selectionModel()->clearSelection(); } void FunctionUser::slotAddPosterRent() { QDialog *window = new QDialog(this); PosterRent *poster; Ui::workWindowPoster uiWindow; Ui::posterRent ui; uiWindow.setupUi(window); ui.setupUi(uiWindow.windowPoster); QObject::connect(uiWindow.okButton, SIGNAL(clicked()), window, SLOT(accept())); QObject::connect(uiWindow.cancelButton, SIGNAL(clicked()), window, SLOT(reject())); while(window->exec()) { if(isEmptyPosterRent(ui.cityLineEdit, ui.areaLineEdit, ui.streetLineEdit, ui.nHomeLineEdit, ui.priceLineEdit)) { poster = new PosterRent; readPosterRent(poster, current->getLogin(), ui.cityLineEdit, ui.areaLineEdit, streetLineEdit, ui.nHomeLineEdit, ui.floorSpinBox, ui.nPhoneLineEdit, ui.sRoomComboBox, ui.furtitureCheckBox, ui.animalCheckBox, ui.tenantComboBox, ui.priceLineEdit); uiTabPostersRent.tableWidget->insertRow(uiTabPostersRent.tableWidget->rowCount()); addInTablePosterRent(uiTabPostersRent.tableWidget, poster, uiTabPostersRent.tableWidget->rowCount() - 1); current->getPostersRent()->push_back(poster); break; } else QMessageBox::information(this, tr("clear string"), tr("SORRY, clear string"), QMessageBox::Ok); } delete window; viewButtonRent(false); uiTabPostersRent.tableWidget->selectionModel()->clearSelection(); } void FunctionUser::setPosterHiringInFile(PosterHiring *poster, QDataStream &in) { in << poster->getLogin(); in << poster->getCity(); in << poster->getArea(); in << poster->getNumberPhone(); in << poster->getPrice(); in << poster->getFurtiture(); in << poster->getAnimal(); in << poster->getSumRoom(); in << poster->getTenant(); } void FunctionUser::setPosterRentInFile(PosterRent *poster, QDataStream &in) { setPosterHiringInFile(poster, in); in << poster->getStreet(); in << poster->getHome(); in << poster->getNumberFloor(); } void FunctionUser::slotSavePosterHiring() { QFile *file = new QFile("posterHiring.bin"); file->open(QIODevice::WriteOnly); QDataStream in(file); QLinkedList<User *>::Iterator passageUser = users->begin(); QLinkedList<PosterHiring *>::Iterator passagePoster; while(passageUser != users->end()) { passagePoster = (*passageUser)->getPostersHiring()->begin(); while(passagePoster != (*passageUser)->getPostersHiring()->end()) { setPosterHiringInFile((*passagePoster), in); ++passagePoster; } ++passageUser; } file->close(); delete file; uiTabPostersHiring.tableWidget->selectionModel()->clearSelection(); } void FunctionUser::slotSavePosterRent() { QFile *file = new QFile("posterRent.bin"); file->open(QIODevice::WriteOnly); QDataStream in(file); QLinkedList<User *>::Iterator passageUser = users->begin(); QLinkedList<PosterRent *>::Iterator passagePoster; while(passageUser != users->end()) { passagePoster = (*passageUser)->getPostersRent()->begin(); while(passagePoster != (*passageUser)->getPostersRent()->end()) { setPosterRentInFile((*passagePoster), in); ++passagePoster; } ++passageUser; } file->close(); delete file; uiTabPostersRent.tableWidget->selectionModel()->clearSelection(); } void FunctionUser::slotDeleteMyPosterHiring() { QLinkedList<PosterHiring *>::Iterator passage = current->getPostersHiring()->begin(); int row; for(row = 0; row < uiTabPostersHiring.tableWidget->currentRow(); ++row) ++passage; current->getPostersHiring()->erase(passage); uiTabPostersHiring.tableWidget->removeRow(row); viewButtonHiring(false); uiTabPostersHiring.tableWidget->selectionModel()->clearSelection(); } void FunctionUser::slotDeleteMyPosterRent() { QLinkedList<PosterRent *>::Iterator passage = current->getPostersRent()->begin(); int row; for(row = 0; row < uiTabPostersRent.tableWidget->currentRow(); ++row) ++passage; current->getPostersRent()->erase(passage); uiTabPostersRent.tableWidget->removeRow(row); viewButtonRent(false); uiTabPostersRent.tableWidget->selectionModel()->clearSelection(); } void FunctionUser::writePosterTiItemsHiring(PosterHiring *poster, QLineEdit *city, QLineEdit *area, QLineEdit *nPhone, QComboBox *nRoom, QCheckBox *furtiture, QCheckBox *animal, QComboBox *tenant, QLineEdit *price) { 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(); }


Похожие работы на - Информационная система жилищного агентства

 

Не нашли материал для своей работы?
Поможем написать уникальную работу
Без плагиата!