Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 117 → Rev 118

/trunk/DBViewer/mainwindow.h
68,6 → 68,7
void addChildsString(QTreeWidgetItem *parentItem, int level);
 
QSqlDatabase sql;
bool model_is_build; // ôëàã ãîâîðèò, ïîñòðîåíà ëè ìîäêëü (true) èëè íåò (false)
 
bool openDataBase();
bool buildPreviewModel(QString modelName, QString rootClassID);
81,10 → 82,10
void initComboBox();
QList<QTreeWidgetItem *> rootItems; // ñïèñîê óêàçàòåëåé êîðíåâûõ óçëîâ (ìîäåëåé)
QSqlTableModel * sql_mogel;
int pointer_index; //èíäåêñ ïîëÿ-óêàçàòåëÿ íà ðîäèòåëüñêèé êëàññ
QString parentObject_id;
 
 
 
 
QMap <QString, QString> class_list_map;
void getDatabaseData();
void buildTree(QTreeWidgetItem * model_item);
102,6 → 103,8
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 );
void on_pushButton_clicked();
 
};
 
 
/trunk/DBViewer/database.cpp
32,6 → 32,7
model_name = model_item->text(0);
if (model_item->checkState(0) == false) return;
 
ui->treeWidget_2->clear();
//font.setWeight(20);
font.setItalic(true);
item = new QTreeWidgetItem (ui->treeWidget_2);
203,6 → 204,8
className = model_item->text(0);
inctance = getClassInctance(classID);
 
if (!model_item->checkState(0)) return;
 
title_item = new QTreeWidgetItem(parent_object_item);
title_item->setFont(0, font);
title_item->setText(0, className);
224,10 → 227,19
 
ok = q.exec();
if (!ok) {
QString debug_str;
debug_str.append(tr("ôóí showObjects(): Database Error "));
debug_str.append(tr(" õð: "));
debug_str.append(inctance);
debug_str.append(tr(" ô: "));
debug_str.append(filtr);
debug_str.append(q.lastError().text());
QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
this, // Ðîäèòåëüñêèé âèäæåò.
QObject::tr("Database Error"), // Çàãîëîâîê.
q.lastError().text()); // Òåêñò ñîîáùåíèÿ.
QObject::tr("ôóíêöèÿ showObjects(): Database Error"), // Çàãîëîâîê.
debug_str
// q.lastError().text()
); // Òåêñò ñîîáùåíèÿ.
return;
}
 
360,6 → 372,7
sql_mogel->setFilter(filtr_tmp);
sql_mogel->select();
ui->tableView->setModel(sql_mogel);
ui->tableView->resizeColumnsToContents();
 
//sql_mogel->clear();
//sql_mogel->select();
376,6 → 389,9
// sql_mogel->clear();
 
parent_object_id = parent_item->text(2);
 
parentObject_id = parent_item->text(2);
 
class_id = item->text(2);
inctance = item->text(3);
pointer_name = parent_item->text(4);
398,6 → 414,8
}
sql_mogel->select();
 
pointer_index = sql_mogel->record().indexOf(pointer_name);
 
ui->tableView->setModel(sql_mogel);
 
// ui->tableView->setVisible(true);;
415,3 → 433,13
}
 
 
void MainWindow::on_pushButton_clicked(){ // íàæàòèå êíîïêè "äîáàâèòü ñòðîêó"
int row = sql_mogel->rowCount();
sql_mogel->insertRows(row, 1);
sql_mogel->setData(sql_mogel->index(row, 1), QVariant(tr("íå îïðåäåëåíî")), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà"
if (pointer_index > 0) {
sql_mogel->setData(sql_mogel->index(row, pointer_index), QVariant(parentObject_id), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà"
}
sql_mogel->submitAll();
 
}
/trunk/DBViewer/mainwindow.cpp
7,7 → 7,7
{
ui->setupUi(this);
// connect( ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_currentIndexChanged(int)));
 
model_is_build = false;
MainWindow::readModel();
 
//QString model_str;
24,11 → 24,11
ui->treeWidget->setAlternatingRowColors(true);
ui->treeWidget_2->setAlternatingRowColors(true);
MainWindow::openDataBase();
MainWindow::buildPreviewModel(tr("Ìîÿ ìîäåëü"), tr("46"));
MainWindow::buildPreviewModel(tr("Ìîÿ ìîäåëü"), tr("7"));
MainWindow::initComboBox();
getDatabaseData();
sql_mogel = new QSqlTableModel();
 
model_is_build = true;
}
 
MainWindow::~MainWindow()
608,6 → 608,7
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();
 
 
}
616,6 → 617,8
int i;
i++;
 
if ((column) == 0 && (model_is_build)) getDatabaseData();
 
}