Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 114 → Rev 115

/trunk/DBViewer/mainwindow.h
80,7 → 80,11
QMap <QString, QString> getClassList(); // ïîëó÷àåì ñïèñîê êëàññîâ
void initComboBox();
QList<QTreeWidgetItem *> rootItems; // ñïèñîê óêàçàòåëåé êîðíåâûõ óçëîâ (ìîäåëåé)
QSqlTableModel * sql_mogel;
 
 
 
 
QMap <QString, QString> class_list_map;
void getDatabaseData();
void buildTree(QTreeWidgetItem * model_item);
90,10 → 94,14
void showObjects(QTreeWidgetItem * parent_object_item, QTreeWidgetItem * model_item, QString filtr);// // îòîáðàçèì îáúåêòû êëàññîâà
QString getPointerFieldName(QString parent_class_id, QString chield_class_id); // îïðåäåëÿåì èìÿ ïîëÿ, â êîòîðîì õðÿíÿòñÿ óêàçàòåëè íà îáúåêòû ðîäèòåëüñêîãî êëàññà
 
 
 
 
private slots:
void on_comboBox_currentIndexChanged( int index );
void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column );
void on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column );
void on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column );
};
 
 
/trunk/DBViewer/database.cpp
208,6 → 208,7
title_item->setText(0, className);
title_item->setText(1, tr("class"));
title_item->setText(2, classID);
title_item->setText(3, inctance);
title_item->setTextColor(0, Qt::darkBlue);
 
sql_str = tr("select * "
260,6 → 261,7
bool pointer_isEmpty;
model_item_tmp = model_item->child(i); // îòîáðàæàåì îáúåêòû äî÷åðíèõ êëàññîâ
pointer_name = getPointerFieldName(classID, model_item->child(i)->text(1));
itm->setText(4, pointer_name);
pointer_isEmpty = pointer_name.isEmpty();
filtr_tmp = tr("where ");
filtr_tmp.append(tr("`"));
288,6 → 290,7
 
}
 
 
QString MainWindow::getPointerFieldName(QString parent_class_id, QString chield_class_id){
 
QSqlQuery q;
324,3 → 327,59
return result;
}
 
 
 
void MainWindow::on_treeWidget_2_itemClicked ( QTreeWidgetItem * item, int column ){
QString item_type; // òèï óçëà (èìÿ êëàññà èäè îáúåêò)
QString parent_object_id;
int i;
QTreeWidgetItem * parent_item;
item_type = item->text(1);
parent_item = item->parent();
if (item_type == tr("object"))
{
QString class_id;
class_id = parent_item->text(2);
i++;
}
if (item_type == tr("class"))
{
QString parent_object_id; // èäåíòèôèêàòîð ðîäèòåëüñêîãî îáúåêòà
QString class_id; // èäåíòèôèêàòîð âûáðàííîãî êëàññà
QString inctance;
QString pointer_name;
QString filtr_tmp;
parent_object_id = parent_item->text(2);
class_id = item->text(2);
inctance = item->text(3);
pointer_name = parent_item->text(4);
 
filtr_tmp.append(tr("`"));
filtr_tmp.append(pointer_name);
filtr_tmp.append(tr("`"));
filtr_tmp.append(tr(" = '"));
filtr_tmp.append(parent_object_id);
filtr_tmp.append(tr("'"));
 
 
sql_mogel = new QSqlTableModel(this);
sql_mogel->setTable(inctance);
sql_mogel->setEditStrategy(QSqlTableModel::OnFieldChange);
sql_mogel->setFilter(filtr_tmp);
sql_mogel->select();
ui->tableView->setModel(sql_mogel);
 
i++;
}
 
//parent_object_id = parent_object_item->text(1);
 
 
 
 
 
i++;
 
}
 
 
/trunk/DBViewer/mainwindow.ui
35,7 → 35,7
<rect>
<x>10</x>
<y>10</y>
<width>701</width>
<width>491</width>
<height>451</height>
</rect>
</property>
54,6 → 54,16
<string>ID</string>
</property>
</column>
<column>
<property name="text">
<string>Хранилище</string>
</property>
</column>
<column>
<property name="text">
<string>Поле-указатель</string>
</property>
</column>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
137,6 → 147,42
<attribute name="title">
<string>Tab 1</string>
</attribute>
<widget class="QTableView" name="tableView">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>471</width>
<height>451</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>10</x>
<y>470</y>
<width>251</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>Добавить новый объект</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>269</x>
<y>470</y>
<width>211</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>Удалить объект</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">