DisplayComputersWindow::DisplayComputersWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DisplayComputersWindow)
{
    ui->setupUi(this);
    displayAllComputers();
    connect(ui->display_pushButton,SIGNAL(clicked()), this, SLOT(displayAllComputers()));
}
Пример #2
0
void MainWindow::on_button_add_computer_clicked() {
    AddComputerDialog addCompDialog;
    int addCompReturnValue = addCompDialog.exec();
    if (addCompReturnValue == 1) {
        ui->input_filter_computers->setText("");
        displayAllComputers();
        ui->statusBar->showMessage("Successfully added computer", 2500);
    } else if (addCompReturnValue == -1) {
        int answer = QMessageBox::warning(this, "FAIL", "Failed to add computer");
    }
}
void MainWindow::on_showComps_clicked()
{
    whatList = false;
    ui->moreUI->setHidden(1);
    Controller cont;
    QVector<Computers> list;
    list = cont.getComputers("");
    displayAllComputers(list);

    return;
}
void MainWindow::on_addCompDone_clicked()
{
    Controller cont;
    bool check = true;
    QMessageBox warning;
    QVector<Computers> list;
    QString name;
    QString created = "No";
    QString creationYear = "Never";
    QString type;
    QString description;


    if(ui->inCompName->text() == ""){
        check = false;
        errorHandle(0);
    }
    else if(ui->inCompYear->text() == ""){
        check = false;
        errorHandle(4);
    }
    else if(ui->inCompType->text() == ""){
        check = false;
        errorHandle(3);
    }
    else if(ui->inCompDesc->toPlainText() == ""){
        check = false;
        errorHandle(1);
    }
    if(check){
        name = ui->inCompName->text();
        if(ui->inCompCreated->isChecked()){
            created = "Yes";
            creationYear = ui->inCompYear->text();
        }
        type = ui->inCompType->text();
        description = ui->inCompDesc->toPlainText();
        cont.add(name, created, creationYear, type, description, false);
        list = cont.getComputers("");
        displayAllComputers(list);
        ui->inCompDesc->clear();
        ui->inCompName->clear();
        ui->inCompType->clear();
        ui->inCompYear->setValue(0);
        ui->inCompCreated->setChecked(false);
    }

    return;
}
void MainWindow::on_searchButton_clicked()
{
    currSelectedID = -1;
    Controller cont;
    QString name = ui->searchText->text();
    if(whatList){
        QVector<Scientist> list;
        list = cont.getScientists(name);
        displayAllScientists(list);
    }
    else{
        QVector<Computers> list;
        list = cont.getComputers(name);
        displayAllComputers(list);
    }

    return;
}
Пример #6
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);
    ui->dropdown_order_by->addItem("Name");
    ui->dropdown_order_by->addItem("Type");
    ui->dropdown_order_by->addItem("Was Built");
    ui->dropdown_order_by->addItem("Year Built");
    ui->dropdown_scientist_order_by->addItem("First Name");
    ui->dropdown_scientist_order_by->addItem("Last Name");
    ui->dropdown_scientist_order_by->addItem("Gender");
    ui->dropdown_scientist_order_by->addItem("Year of Birth");
    ui->dropdown_scientist_order_by->addItem("Year of Death");
    ui->dropdown_order_by_ascending->addItem("Ascending");
    ui->dropdown_order_by_ascending->addItem("Descending");
    ui->dropdown_scientist_order_by_ascending->addItem("Ascending");
    ui->dropdown_scientist_order_by_ascending->addItem("Descending");
    ui->table_computers->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    ui->table_scientists->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    displayAllComputers();
    displayAllScientists();
    displayAllComputersForComputerConnections();
    displayAllScientistsForScientistConnections();
}
Пример #7
0
void MainWindow::on_button_remove_computer_clicked() {
    int currentlySelectedComputerIndex = ui->table_computers->currentIndex().row();

    Computer currentlySelectedComputer = currentlyDisplayedComputers.at(currentlySelectedComputerIndex);

    int idToRemove = currentlySelectedComputer.getId();
    string stringIdToRemove = static_cast<ostringstream*>( &(ostringstream() << idToRemove) )->str();

    int answer = QMessageBox::question(this, "Confirm", "Are you sure?");
    if (answer == QMessageBox::No) {
        return;
    }

    bool success = compService.remove(stringIdToRemove);

    if (success) {
        ui->input_filter_computers->setText("");
        displayAllComputers();
        ui->statusBar->showMessage("Successfully removed computer", 2500);
        ui->button_remove_computer->setEnabled(false);
    } else {
        int answer = QMessageBox::warning(this, "FAIL", "Failed to remove computer");
    }
}