本文整理汇总了C++中Controller::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Controller::add方法的具体用法?C++ Controller::add怎么用?C++ Controller::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_addCompDone_clicked
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;
}
示例2: on_addSciDone_clicked
void MainWindow::on_addSciDone_clicked()
{
Controller cont;
bool check = true;
QMessageBox box;
QVector<Scientist> list;
QString name;
QString gender = "Male";
QString birth;
QString death = "Alive";
QString desc;
if(ui->inSciName->text() == ""){
errorHandle(0);
check = false;
}
else if(ui->inSciBirth->date() > ui->inSciDeath->date() && !ui->inSciAlive->isChecked()){
errorHandle(2);
check = false;
}
else if(ui->inSciDesc->toPlainText() == ""){
errorHandle(1);
check = false;
}
if(check){
name = ui->inSciName->text();
if(ui->inSciFemale->isChecked()){
gender = "Female";
}
birth = ui->inSciBirth->date().toString("yyyy-MM-dd");
if(!ui->inSciAlive->isChecked()){
death = ui->inSciDeath->date().toString("yyyy-MM-dd");
}
desc = ui->inSciDesc->toPlainText();
cont.add(name, gender, birth, death, desc, true);
list = cont.getScientists("");
displayAllScientists(list);
ui->inSciName->clear();
ui->inSciAlive->setChecked(true);
ui->inSciDesc->clear();
}
return;
}