NaklWindow::NaklWindow()
{
setupUi(this);
mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation,true);
db = QSqlDatabase::addDatabase("QIBASE");
db.setHostName("localhost");
db.setDatabaseName("D:\\Data\\data.fdb");
db.setUserName("sysdba");
db.setPassword("masterkey");
db.open();
model = new QSqlRelationalTableModel();
model->setTable("trustdoc");
model->setRelation(3,QSqlRelation("contragent","id","name"));
model->setRelation(4,QSqlRelation("datacompany", "id", "name"));
model->setRelation(5,QSqlRelation("sppeople", "id", "fio"));
model->setHeaderData(0, Qt::Horizontal, trUtf8("№"));
model->setHeaderData(1, Qt::Horizontal, trUtf8("Дата выдачи"));
model->setHeaderData(3, Qt::Horizontal, trUtf8("Поставщик"));
model->setHeaderData(5, Qt::Horizontal, trUtf8("Выдана"));
model->select();
tableView->setModel(model);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
tableView->setItemDelegate(new QSqlRelationalDelegate(tableView));
tableView->setColumnHidden(2,true);
tableView->setColumnHidden(4,true);
tableView->setColumnHidden(6,true);
tableView->setColumnHidden(7,true);
QMdiSubWindow *ssb= mdiArea->addSubWindow(tableView);
ssb->setWindowFlags(Qt::FramelessWindowHint);
ssb->showMaximized();
createAction();
createToolBar();
setCentralWidget(mdiArea);
}
void NaklWindow::createAction()
{
add = new QAction(QIcon(":/images/note_add.png"),trUtf8("Добавить"),this);
connect(add,SIGNAL(triggered()),SLOT(addShow()));
edit = new QAction(QIcon(":/images/note_edit.png"),trUtf8("Изменить"),this);
connect(edit,SIGNAL(triggered()),SLOT(editShow()));
del = new QAction(QIcon(":/images/note_del.png"),trUtf8("Удалить"),this);
connect(del,SIGNAL(triggered()),SLOT(delShow()));
find = new QAction(QIcon(":/images/note_find.png"),trUtf8("Поиск"),this);
}
void NaklWindow::createToolBar()
{
toolBar->addAction(add);
toolBar->addAction(edit);
toolBar->addAction(del);
toolBar->addAction(find);
}
void NaklWindow::addShow()
{
nkaddWindow = new NaklAddWindow;
QMdiSubWindow *ssb2 = mdiArea->addSubWindow(nkaddWindow);
connect(nkaddWindow->getButtonPol(),SIGNAL(clicked()),SLOT(addPolychatelShow()));
ssb2->show();
}
void NaklWindow::editShow()
{
}
void NaklWindow::delShow()
{
}
void NaklWindow::addPolychatelShow()
{
QTableView *table = new QTableView;
QMdiSubWindow *ssb3=mdiArea->addSubWindow(table);
ssb3->show();
}