Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 106 → Rev 107

/trunk/DBViewer/mainwindow.h
68,6 → 68,9
 
bool openDataBase();
bool buildPreviewModel(QString modelName, QString rootClassID);
 
bool rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID);
 
QString ClassName(QString class_id); //âîçâðàùàåò èìÿ êëàññà ïî åãî ID
void addChildsItems(QTreeWidgetItem *perent_class_item); // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì
QStringList classChields(QString class_id);
/trunk/DBViewer/mainwindow.cpp
339,7 → 339,85
}
 
 
bool MainWindow::rebuildPreviewModel(QTreeWidgetItem* root_item, 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);
// root_items_list << rootItem1;
// rootItem1->setText(0, modelName);
 
// rootItem1->setCheckState(0,Qt::Checked);
// rootItems.append(rootItem1);
 
// root_item->removeChild(root_item->child(0)); // î÷èùàåì ñïèñîê äî÷åðíèõ êëàññîâ
if (root_item->childCount()==1){
root_item->child(0)->setText(0, root_class_name);
root_item->child(0)->setText(1, rootClassID);
root_item->child(0)->setCheckState(0,Qt::Checked);}
 
//delete rootItem2;
 
 
// rootItem2 = new QTreeWidgetItem(rootItem1);
 
 
 
// rootItem2->setText(0, root_class_name);
// rootItem2->setText(1, rootClassID);
// rootItem2->setCheckState(0,Qt::Checked);
 
int child_count = root_item->child(0)->childCount();
 
 
 
for (int i=0; i < child_count; i++){
root_item->child(0)->removeChild(root_item->child(0)->child(0));
}
 
child_count = root_item->child(0)->childCount();
addChildsItems(root_item->child(0));
/*
sql_str = tr("select * "
" 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;
525,6 → 603,9
classesNameList = class_list_map.values();
ID_str = classesID_list[index];
ui->label->setText(ID_str);
if (root_items_list.indexOf(ui->treeWidget->currentItem()) != -1) rebuildPreviewModel(ui->treeWidget->currentItem(), ID_str);
 
 
}
 
void MainWindow::on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column ){