Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 146 → Rev 147

/trunk/DBViewer/mainwindow.cpp
116,7 → 116,7
model_str = QString(tr(file.readAll()));
}
 
setupModelData(model_str.split(QString("\n")), rootItem1);
setupModelData(model_str.split(QString("\n")), rootItem1, -1);
 
 
return result;
124,7 → 124,7
}
 
 
void MainWindow::setupModelData(const QStringList &lines, QTreeWidgetItem *parent)
void MainWindow::setupModelData(const QStringList &lines, QTreeWidgetItem *parent, int row)
{
QList<QTreeWidgetItem*> parents;
QList<int> indentations;
180,6 → 180,7
itm_tmp->setText(1, QString(columnData.at(2).toString()));
itm_tmp->setText(2, QVariant(number).toString()); // íîìåð ñòðîêè â ôàéëå-ìîäåëè îòîáðàæåíèÿ
itm_tmp->setText(3, QVariant(indentations.size()).toString());
itm_tmp->setText(4, QVariant(row).toString());
}
}
 
387,7 → 388,7
rootItem2->setText(1, rootClassID);
rootItem2->setCheckState(0,Qt::Checked);
 
addChildsItems(rootItem2);
addChildsItems(rootItem2, -1);
 
 
/*
424,7 → 425,7
}
 
 
bool MainWindow::rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID){
bool MainWindow::rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID, int row){
QSqlQuery q;
QString sql_str;
QString field_name_str;
448,6 → 449,7
if (root_item->childCount()==0){ // íåò êîðíåâîãî êëàññà, ñîçäàäèì åãî
QTreeWidgetItem* item_tmp;
item_tmp = new QTreeWidgetItem (root_item);
item_tmp->setText(4, QVariant(row).toString());
 
}
 
454,10 → 456,13
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);}
root_item->child(0)->setCheckState(0,Qt::Checked);
root_item->setText(4, QVariant(row).toString());
 
}
 
 
 
//delete rootItem2;
 
 
477,7 → 482,7
}
 
child_count = root_item->child(0)->childCount();
addChildsItems(root_item->child(0));
addChildsItems(root_item->child(0), row);
/*
sql_str = tr("select * "
" from DescriptionOfClasses where DescriptionOfClasses.DefaultValue = '" //îïðåäåëèì êëàññû, äëÿ êîòîðûõ êîðíåâîé ÿâëÿåòñÿ êîíòåéíåðîì
547,7 → 552,7
 
}
 
void MainWindow::addChildsItems(QTreeWidgetItem *perent_class_item){ // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì
void MainWindow::addChildsItems(QTreeWidgetItem *perent_class_item, int row){ // äîáîâëÿåì ê ýëåìåíòó äåðåâà â êà÷åñòâå äî÷åðíèõ ýëåìåíòîâ âñå êëàññû, äëÿ êîòîðûõ êëàññ ýëåìåíòà ÿâëÿåòñÿ êîíòåéíåðîì
QStringList chields_list;
QString parent_ID;
QTreeWidgetItem *Item_tmp;
565,7 → 570,8
Item_tmp->setText(0, chield_class_name);
Item_tmp->setText(1, chield_id);
Item_tmp->setCheckState(0, Qt::Checked);
MainWindow::addChildsItems(Item_tmp);
Item_tmp->setText(4, QVariant(row).toString());
MainWindow::addChildsItems(Item_tmp, row);
}
 
i++;
695,6 → 701,7
QStringList classesID_list;
QString ID_str;
if (index == -1) return;
int row;
 
classesID_list = class_list_map.keys();
classesNameList = class_list_map.values();
702,9 → 709,12
ui->label->setText(ID_str);
if (root_items_list.indexOf(ui->treeWidget->currentItem()) != -1)
{
row = QVariant(ui->treeWidget->currentItem()->text(4)).toInt();
model_is_build = false; // ÷òîáû íå âûçûâàëîñü ñîáûòèå on_treeWidget_itemChanged
rebuildPreviewModel(ui->treeWidget->currentItem(), ID_str);
rebuildPreviewModel(ui->treeWidget->currentItem(), ID_str, row);
model_is_build = true; // òåïåðü ïóñòü âûçûâàåòñÿ
QString mdl_str = MainWindow::creatModelString(ui->treeWidget->currentItem()); //
model_for_ListModelsTable->setData(model_for_ListModelsTable->index(row, 2), QVariant(mdl_str));
}
getDatabaseData();
 
714,9 → 724,45
void MainWindow::on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column ){
int i;
i++;
QTreeWidgetItem * item_tmp;
QString mdl_str;
QString row; // íîìåð ñòðîêè â òàáëèöå ìîäåëåé, ñîîòâåòñòâóþùèé èçìåíåííîé ìîäåëå
QList <int> rows_list;
 
 
if ((column) == 0 && (model_is_build)) {
// if (!model_is_build) return; // ìîäåëü åù¸ íå ïîñòðîåíà
rows_list = models_items.keys();
 
row= item->text(4);
if (!row.isEmpty()){
 
 
int row_int;
row_int = QVariant(row).toInt();
if (rows_list.indexOf(row_int) != -1)
{
item_tmp = models_items[row_int];
mdl_str = MainWindow::creatModelString(item_tmp);
model_for_ListModelsTable->setData(model_for_ListModelsTable->index(row_int, 2), QVariant(mdl_str));
}
 
 
}
 
 
}
 
/*
QTreeWidgetItem * item_tmp;
item_tmp = item;
while (item_tmp ){
item_tmp = item_tmp->parent();
}
*/
if ((column) == 0 && (model_is_build)) getDatabaseData();
 
 
}