QList <Setup> SetupDAO::getSetups() { QList <Setup> retorno; if(db.open()) { query = QSqlQuery(db); query.prepare("SELECT CodigoMaquina, OP, CodigoUsuario, DataInicio, HoraInicio, DataFim, HoraFim FROM Setup"); if(!query.exec()){ std::cout << query.lastError().text().toStdString() << std::endl; db.close(); return retorno; } else { int i = 0; while (query.next()) { MaquinaDAO maqDAO(db); Maquina * maq = maqDAO.getMaquina(query.value(0).toInt()); OrdemDeProducaoDAO opDAO(db); OrdemDeProducao * op = opDAO.getOP(query.value(1).toString()); UsuarioDAO usuDAO(db); Usuario * usu = usuDAO.getUsuario(query.value(2).toInt()); Setup dialogSetup(maq,op,usu,query.value(3).toDate(),query.value(4).toInt(),query.value(5).toDate(),query.value(6).toInt()); retorno.insert(i,dialogSetup); i++; } } db.close(); } else { std::cout << db.lastError().text().toStdString() << std::endl; } return retorno; }
DialogActiveRunways::DialogActiveRunways(ATCAirspace *airspace, ATCActiveRunways *activeRunways, QWidget *parent) : ATCDialog(parent, "Active Runways", 600, 650), airspace(airspace), activeRunways(activeRunways), uiInner(new Ui::DialogActiveRunways) { uiInner->setupUi(this); windowSetup(); dialogSetup(); fillModel(); }