MainForm::MainForm()
{
    createDepartmentPanel();
    createEmployeePanel();

    addButton = new QPushButton(tr("Add Dept."));
    deleteButton = new QPushButton(tr("Delete Dept."));
    editButton = new QPushButton(tr("Edit Employees..."));
    quitButton = new QPushButton(tr("Quit"));
    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(addButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(deleteButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(editButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::ActionRole);

    connect(addButton, SIGNAL(clicked()),this,SLOT(addDepartment()));
    connect(deleteButton,SIGNAL(clicked()), this, SLOT(deleteDepartment()));
    connect(editButton, SIGNAL(clicked()), this, SLOT(editEmployees()));
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));

    departmentView->setCurrentIndex(departmentModel->index(0,0));

    QVBoxLayout *departmentLayout = new QVBoxLayout;
    departmentLayout->addWidget(departmentLabel);
    departmentLayout->addWidget(departmentView);
    QVBoxLayout *employeeLayout = new QVBoxLayout;
    employeeLayout->addWidget(employeeLabel);
    employeeLayout->addWidget(employeeView);
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(departmentLayout);
    mainLayout->addLayout(employeeLayout);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

}
Esempio n. 2
0
MainForm::MainForm()
{
    createDepartmentPanel();
    createEmployeePanel();

    splitter = new QSplitter(Qt::Vertical);
    splitter->setFrameStyle(QFrame::StyledPanel);
    splitter->addWidget(departmentPanel);
    splitter->addWidget(employeePanel);

    addButton = new QPushButton(tr("&Add Dept."));
    deleteButton = new QPushButton(tr("&Delete Dept."));
    editButton = new QPushButton(tr("&Edit Employees..."));
    quitButton = new QPushButton(tr("&Quit"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(addButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(deleteButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(editButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::AcceptRole);

    connect(addButton, SIGNAL(clicked()), this, SLOT(addDepartment()));
    connect(deleteButton, SIGNAL(clicked()),
            this, SLOT(deleteDepartment()));
    connect(editButton, SIGNAL(clicked()), this, SLOT(editEmployees()));
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(splitter);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("Staff Manager"));
    departmentView->setCurrentIndex(departmentModel->index(0, 0));
}