Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 127 → Rev 128

/trunk/DBViewer/database.cpp
394,6 → 394,8
filtr_tmp.append(tr("'"));
sql_mogel->setFilter(filtr_tmp);
sql_mogel->select();
 
 
ui->tableView->setModel(sql_mogel);
ui->tableView->resizeColumnsToContents();
 
463,8 → 465,23
 
sql_mogel->select();
 
QMap <QString, QString> pointersList = getPointersList(class_id);
QMap <int, QString> pointersToModel;
 
QStringList pointersNames = pointersList.keys(); //
QStringList parentInctancesList = pointersList.values();
 
for (i=0; i < pointersNames.size(); i++){
QString pointerName;
 
int pointerIndex;
pointerName = pointersNames.at(i);
pointerIndex = sql_mogel->record().indexOf(pointerName);
pointersToModel.insert(pointerIndex, parentInctancesList.at(i));
}
 
sql_mogel->setPointers(pointersToModel);
 
pointer_index = sql_mogel->record().indexOf(pointer_name);
 
ui->tableView->setModel(sql_mogel);
555,3 → 572,55
 
 
}
 
 
// ïîëó÷àåì ñïèñîê âñåõ ïîëåé-óêàçàòåëåé, â êà÷åñòâå êëþ÷åé ïîëó÷èì èìåíà ïîëåé-óêàçàòåëåé
// â êà÷åñòâå çíà÷åíèé ïîëó÷èì ñïèñîê òàáëèö-õðàíèëèù îáúåêòîâ ðîäèòåëüñêèõ êëàññîâ
 
QMap <QString, QString> MainWindow::getPointersList(QString class_id){
QMap <QString, QString> result_map;
QSqlQuery q;
QString sql_str;
QString str_tmp;
QString field;
QString result;
int field_name, field_default_value;
bool ok;
sql_str = tr("select * "
" from `DescriptionOfClasses` where `DescriptionOfClasses`.`FieldType` = 'pointer' and `DescriptionOfClasses`.`ClassIdentifer` = " //íàõîäèì âñå îáúåêòû êëàññà â òàáëèöå - õðàíèëèùå îáúåêòîâ êëàññà
);
 
sql_str.append(tr("'"));
sql_str.append(class_id);
sql_str.append(tr("' "));
// sql_str.append(tr(" and `DescriptionOfClasses`.`ClassIdentifer` = '"));
// sql_str.append(chield_class_id);
// sql_str.append(tr("'"));
q.prepare(sql_str);
 
ok = q.exec();
if (!ok) {
QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
this, // Ðîäèòåëüñêèé âèäæåò.
QObject::tr("Database Error"), // Çàãîëîâîê.
q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
return result_map;
}
field_name = q.record().indexOf(tr("FieldName"));
field_default_value = q.record().indexOf(tr("DefaultValue"));
while(q.next()){
QString pointerFieldName;
QString parentClassID;
QString parentClassInctance;
 
pointerFieldName = q.value(field_name).toString();
parentClassID = q.value(field_default_value).toString();
parentClassInctance = getClassInctance(parentClassID);
result_map.insert(pointerFieldName, parentClassInctance);
 
 
}
 
return result_map;
}