Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 220 → Rev 221

/trunk/DBViewer/mainwindow.cpp
77,13 → 77,15
getDatabaseData();
//// sql_mogel = new QSqlTableModel();
sql_mogel = new MyModel();
filtr_model = new MyModel();
filter_model = new MyModel();
 
 
model_is_build = true;
connect(sql_mogel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_sql_mogel_dataChanged(QModelIndex,QModelIndex)));
connect(model_for_ListModelsTable, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_model_for_ListModelsTable_dataChanged(QModelIndex,QModelIndex)));
connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
 
 
ui->pushButton_3->setEnabled(false);
ui->pushButton_4->setEnabled(false);
 
113,7 → 115,7
MainWindow::~MainWindow()
{
delete sql_mogel;
delete filtr_model;
delete filter_model;
delete ui;
delete model_for_ListModelsTable;
}
851,9 → 853,10
ui->pushButton_12->setEnabled(false);
// ui->tableView->reset();
// MainWindow::filtr_model->clear();
delete filtr_model;
filtr_model = new MyModel();
 
disconnect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
delete filter_model;
filter_model = new QSqlTableModel();
connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
int index;
classesID_list = class_list_map.keys();
classesNameList = class_list_map.values();
877,9 → 880,12
QString class_id;
QString model_id;
QString filtr_str;
QString inctance;
QStringList conditionList;
class_id = item->text(1);
model_id = item->text(6);
inctance = MainWindow::getClassInctance(class_id);
 
filtr_str = tr("`Model_ID` = ");
filtr_str.append(model_id);
filtr_str.append(tr(" AND `Class_ID` = "));
886,14 → 892,16
filtr_str.append(class_id);
// filtr_str.append(tr("`"));
 
delete filtr_model;
disconnect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
delete filter_model;
// filtr_model = new MyModel();
 
filtr_model = new QSqlTableModel();
filtr_model->setTable(tr("Filters"));
filtr_model->setFilter(filtr_str);
filtr_model->select();
ui->tableView_3->setModel(filtr_model);
filter_model = new QSqlTableModel();
connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
filter_model->setTable(tr("Filters"));
filter_model->setFilter(filtr_str);
filter_model->select();
ui->tableView_3->setModel(filter_model);
 
 
ui->tableView_3->hideColumn(0);
946,7 → 954,7
ui->treeWidget->hideColumn(2);
ui->treeWidget->hideColumn(3);
ui->treeWidget->hideColumn(4);
ui->treeWidget->hideColumn(5);
// ui->treeWidget->hideColumn(5);
ui->treeWidget->hideColumn(6);
 
ui->tableView_2->hideColumn(0);
/trunk/DBViewer/mainwindow.h
111,7 → 111,7
MyModel * sql_mogel;
// MyModel * filtr_model;
 
QSqlTableModel * filtr_model;
QSqlTableModel * filter_model;
 
QSqlTableModel * model_for_ListModelsTable;
 
193,6 → 193,7
 
void on_sql_mogel_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò
void on_model_for_ListModelsTable_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà îáúåêòà èëè äîáàâèëè íîâûé îáúåêò
void on_filter_model_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); // èçìåíèëè ñâîéñòâà ôèëüòðà èëè äîáàâèëè íîâûé ôèëüòð
void applySetting();
void getSetting(); // îòêðîåì îêíî íàñòðîåê
};
/trunk/DBViewer/database.cpp
816,10 → 816,10
QString model_id;
class_id = ui->treeWidget->currentItem()->text(1);
model_id = ui->treeWidget->currentItem()->text(6);
int row = filtr_model->rowCount();
filtr_model->insertRows(row, 1);
filtr_model->setData(filtr_model->index(row, 1), QVariant(model_id), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "Model ID"
filtr_model->setData(filtr_model->index(row, 2), QVariant(class_id), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "Class ID"
int row = filter_model->rowCount();
filter_model->insertRows(row, 1);
filter_model->setData(filter_model->index(row, 1), QVariant(model_id), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "Model ID"
filter_model->setData(filter_model->index(row, 2), QVariant(class_id), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "Class ID"
ui->pushButton_11->setEnabled(true);
ui->pushButton_12->setEnabled(true);
 
827,17 → 827,42
 
void MainWindow::on_pushButton_10_clicked()// íàæàòèå êíîïêè "Óäàëèòü ôèëüòð" (íà âêëàäêå ôèëüòðîâ)
{
QModelIndex model_index;
QItemSelectionModel *selectionModel = ui->tableView_3->selectionModel();
QModelIndexList indexes = selectionModel->selectedIndexes();
QList<int> selectedRows;
selectedRows.clear();
foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê
if (!selectedRows.contains(model_index.row()) /*&& (model_index.column()==1)*/) selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå
 
}
qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // ñîðòèðóåì â îáðàòíîì ïîðÿäêå
 
 
for (int m =0; m < selectedRows.size(); ++m){
 
// ClassEditor::removeClass(selectedRows.at(m));
 
filter_model->removeRow(selectedRows.at(m));
 
}
filter_model->submitAll();
// getDatabaseData();
 
}
 
void MainWindow::on_pushButton_11_clicked()// íàæàòèå êíîïêè "Ïðèìåíèòü" (íà âêëàäêå ôèëüòðîâ)
{
filtr_model->submitAll();
filter_model->submitAll();
ui->pushButton_11->setEnabled(false);
ui->pushButton_12->setEnabled(false);
}
 
void MainWindow::on_pushButton_12_clicked()// íàæàòèå êíîïêè "Ñáðîñèòü èçìåíåíèÿ" (íà âêëàäêå ôèëüòðîâ)
{
 
filter_model->select();
ui->pushButton_11->setEnabled(false);
ui->pushButton_12->setEnabled(false);
}
 
 
870,6 → 895,19
}
 
 
 
 
void MainWindow::on_filter_model_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ) // èçìåíèëè ñâîéñòâà ôèëüòðà èëè äîáàâèëè íîâûé ôèëüòð
 
{
ui->pushButton_11->setEnabled(true);
ui->pushButton_12->setEnabled(true);
}
 
 
 
 
 
// ïîëó÷àåì ñïèñîê âñåõ ïîëåé-óêàçàòåëåé, â êà÷åñòâå êëþ÷åé ïîëó÷èì èìåíà ïîëåé-óêàçàòåëåé
// â êà÷åñòâå çíà÷åíèé ïîëó÷èì ñïèñîê òàáëèö-õðàíèëèù îáúåêòîâ ðîäèòåëüñêèõ êëàññîâ