Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 144 → Rev 145

/trunk/DBViewer/mainwindow.cpp
8,7 → 8,7
ui->setupUi(this);
// connect( ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_currentIndexChanged(int)));
model_is_build = false;
MainWindow::readModel();
// MainWindow::readModel();
 
//QString model_str;
 
34,16 → 34,18
 
MainWindow::initComboBox();
 
MainWindow::buildPreviewModel(tr("Ìîÿ ìîäåëü"), tr("7"));
// MainWindow::buildPreviewModel(tr("Ìîÿ ìîäåëü"), tr("11"));
 
MainWindow::initListModelsTablle();
 
MainWindow::readModels();
 
MainWindow::creatModelString();
// MainWindow::creatModelString();
//int i;
//i++;
QFile file_tmp("./modelstring.txt");
 
/*
QFile file_tmp("./modelstring.txt");
bool ok;
file_tmp.remove();
ok = file_tmp.open(QIODevice::ReadWrite | QIODevice::Text);
51,10 → 53,10
out.setCodec("cp1251");
out << MainWindow::modelString;
file_tmp.close();
*/
 
 
 
 
getDatabaseData();
//// sql_mogel = new QSqlTableModel();
sql_mogel = new MyModel();
256,12 → 258,13
// for (int i =0; i < rootItem1->childCount(); ++i )
 
{MainWindow::addChildsString(rootItem1, 0);}
 
// {MainWindow::addChildsString(ui->treeWidget, 0);}
/*
int root_item_child_count;
int i;
root_item_child_count = rootItem1->childCount();
i++;
 
*/
}
 
 
365,8 → 368,9
 
root_class_name = MainWindow::ClassName(rootClassID); // îïðåäåëÿåì èìÿ êëàññà
 
 
rootItem1 = new QTreeWidgetItem(ui->treeWidget);
root_items_list << rootItem1;
root_items_list << rootItem1;
rootItem1->setText(0, modelName);
 
rootItem1->setCheckState(0,Qt::Checked);
374,13 → 378,16
 
 
 
rootItem2 = new QTreeWidgetItem(rootItem1);
rootItem2->setText(0, root_class_name);
rootItem2->setText(1, rootClassID);
rootItem2->setCheckState(0,Qt::Checked);
rootItem2 = new QTreeWidgetItem(rootItem1);
rootItem2->setText(0, root_class_name);
rootItem2->setText(1, rootClassID);
rootItem2->setCheckState(0,Qt::Checked);
 
addChildsItems(rootItem2);
addChildsItems(rootItem2);
 
 
/*
 
sql_str = tr("select * "
" from DescriptionOfClasses where DescriptionOfClasses.DefaultValue = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì
);
407,6 → 414,9
 
 
 
*/
 
 
}
 
 
431,11 → 441,19
// rootItems.append(rootItem1);
 
// root_item->removeChild(root_item->child(0)); // î÷èùàåì ñïèñîê äî÷åðíèõ êëàññîâ
if (root_item->childCount()==1){
if (root_item->childCount()==0){ // íåò êîðíåâîãî êëàññà, ñîçäàäèì åãî
QTreeWidgetItem* item_tmp;
item_tmp = new QTreeWidgetItem (root_item);
 
}
 
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;
 
 
450,8 → 468,7
int child_count = root_item->child(0)->childCount();
 
 
 
for (int i=0; i < child_count; i++){
for (int i=0; i < child_count; i++){ // åñëè êîðíåâîé êëàññ åñòü è íå ïóñòîé, î÷èùàåì åãî
root_item->child(0)->removeChild(root_item->child(0)->child(0));
}
 
679,8 → 696,13
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);
getDatabaseData();
if (root_items_list.indexOf(ui->treeWidget->currentItem()) != -1)
{
model_is_build = false; // ÷òîáû íå âûçûâàëîñü ñîáûòèå on_treeWidget_itemChanged
rebuildPreviewModel(ui->treeWidget->currentItem(), ID_str);
model_is_build = true; // òåïåðü ïóñòü âûçûâàåòñÿ
}
getDatabaseData();
 
 
}
704,7 → 726,12
int index;
classesID_list = class_list_map.keys();
classesNameList = class_list_map.values();
index = classesID_list.indexOf(item->child(0)->text(1));
if (item->childCount()>0) index = classesID_list.indexOf(item->child(0)->text(1)); // åñëè ìîäåëü íå ïóñòàÿ, óçíàåì êîðíåâîé êëàññ
else { // åñëè ïóñòàÿ
ui->comboBox->setEnabled(true);
return;
 
}
if (index != -1) ui->comboBox->setCurrentIndex(index);
 
ui->comboBox->setEnabled(true);