DBTable TableSetting::getTable()//доделать атрибуты { QModelIndex myInName,myInType,myInPK,myInNN,myInU; QVariant myDatName,myDatType,myDatPK,myDatNN,myDatU; DBTable table; table.setIdTable(idTable); for(int i = 0;i< model->rowCount();i++) { myInName=model->index(i,0,QModelIndex()); myInType=model->index(i,1,QModelIndex()); myInPK=model->index(i,2,QModelIndex()); myInNN=model->index(i,3,QModelIndex()); myInU=model->index(i,4,QModelIndex()); myDatName=model->data(myInName,Qt::DisplayRole); myDatType=model->data(myInType,Qt::DisplayRole); myDatPK=model->data(myInPK,Qt::CheckStateRole); myDatNN=model->data(myInNN,Qt::CheckStateRole); myDatU=model->data(myInU,Qt::CheckStateRole); DBAttribute attribute; attribute.name = myDatName.toString(); attribute.type = myDatType.toString(); if(myDatNN.toInt()==2) attribute.NN = "1"; else attribute.NN = "0"; if(myDatU.toInt()==2) attribute.UNIQ = "1"; else attribute.UNIQ = "0"; if(myDatPK.toInt()==2) { attribute.PK = "1"; attribute.NN = "1"; attribute.UNIQ = "1"; } else attribute.PK = "0"; table.addAttribute(attribute); } QString tabname = ui->lineEdit->text(); table.addName(tabname); for(int i = 0; i < modelConection->rowCount();i++) { auto indexTable=modelConection->index(i,0,QModelIndex()); auto dataTable=modelConection->data(indexTable,Qt::DisplayRole); DBTable *ptable = MainData::getTableByName(dataTable.toString()); indexTable=modelConection->index(i,1,QModelIndex()); dataTable=modelConection->data(indexTable,Qt::DisplayRole); DBForeign::TypeForeign typeForeign = dataTable.toString() == "1:1" ? DBForeign::ONE_TO_ONE : DBForeign::ONE_TO_MANY; table.addConnection(DBForeign(ptable->getIdTable(), typeForeign)); } return table; }