Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 94 → Rev 95

/trunk/DBViewer/mainwindow.h
63,8 → 63,10
 
bool openDataBase();
bool buildPreviewModel(QString rootClassID);
QString ClassName(QString class_id); //âîçâðàùàåò èìÿ êëàññà ïî åãî ID
 
 
 
};
 
#endif // MAINWINDOW_H
/trunk/DBViewer/mainwindow.cpp
21,6 → 21,7
file_tmp.close();
 
MainWindow::openDataBase();
MainWindow::buildPreviewModel(tr("3"));
 
}
 
281,11 → 282,84
bool MainWindow::buildPreviewModel(QString rootClassID){
QSqlQuery q;
QString sql_str;
QString field_name_str;
QString root_class_name;
bool ok;
int field_name;
 
//ui->treeWidget->clear();
 
root_class_name = MainWindow::ClassName(rootClassID); // îïðåäåëÿåì èìÿ êëàññà
 
rootItem1 = new QTreeWidgetItem(ui->treeWidget);
rootItem1->setText(0, root_class_name);
// rootItem2 = new QTreeWidgetItem(rootItem1);
// rootItem2->setText(0, tr("óðîâåíü 2"));
rootItem1->setCheckState(0,Qt::Checked);
 
 
 
 
sql_str = tr("select * "
" from DescriptionOfClasses where DescriptionOfClasses.ID = "
" from DescriptionOfClasses where DescriptionOfClasses.DefaultValue = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì
);
sql_str.append(rootClassID);
 
sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' "));
 
q.prepare(sql_str);
 
ok = q.exec();
if (!ok) {
QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
this, // Ðîäèòåëüñêèé âèäæåò.
QObject::tr("Database Error"), // Çàãîëîâîê.
q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
}
field_name = q.record().indexOf(tr("FieldName"));
while(q.next()){
 
field_name_str = q.value(field_name).toString();
 
}
 
}
 
 
 
QString MainWindow::ClassName(QString class_id){ //âîçâðàùàåò èìÿ êëàññà ïî åãî ID
QSqlQuery q;
QString sql_str;
QString class_name_str;
bool ok;
int field_class_name;
 
sql_str = tr("select * "
" from ListOfClasses where ListOfClasses.ID = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì
);
 
sql_str.append(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()); // Òåêñò ñîîáùåíèÿ.
}
 
field_class_name = q.record().indexOf(tr("ClassName"));
while(q.next()){
 
class_name_str = q.value(field_class_name).toString();
 
}
 
return class_name_str;
 
}
/trunk/DBViewer/model.txt
3,4 → 3,4
Ñîòðóäíèê false 3
SubSubstring2 true 4
SubSubstring3 false 5
Bay true 6
Bay true 688