Subversion Repositories OpenInventory

Rev

Rev 131 | Rev 136 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 131 Rev 132
Line 21... Line 21...
21
    out << MainWindow::modelString;
21
    out << MainWindow::modelString;
22
    file_tmp.close();
22
    file_tmp.close();
23
23
24
    ui->treeWidget->setAlternatingRowColors(true);
24
    ui->treeWidget->setAlternatingRowColors(true);
25
    ui->treeWidget_2->setAlternatingRowColors(true);
25
    ui->treeWidget_2->setAlternatingRowColors(true);
-
 
26
-
 
27
-
 
28
    MainWindow::readSettings();
-
 
29
26
    MainWindow::openDataBase();
30
    MainWindow::openDataBase();
27
    MainWindow::buildPreviewModel(tr("Ìîÿ ìîäåëü"), tr("1"));
31
    MainWindow::buildPreviewModel(tr("Ìîÿ ìîäåëü"), tr("1"));
28
    MainWindow::initComboBox();
32
    MainWindow::initComboBox();
29
    getDatabaseData();
33
    getDatabaseData();
30
    //// sql_mogel = new QSqlTableModel();
34
    //// sql_mogel = new QSqlTableModel();
Line 34... Line 38...
34
    model_is_build = true;
38
    model_is_build = true;
35
    connect(sql_mogel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_sql_mogel_dataChanged(QModelIndex,QModelIndex)));
39
    connect(sql_mogel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_sql_mogel_dataChanged(QModelIndex,QModelIndex)));
36
    ui->pushButton_3->setEnabled(false);
40
    ui->pushButton_3->setEnabled(false);
37
    ui->pushButton_4->setEnabled(false);
41
    ui->pushButton_4->setEnabled(false);
38
42
-
 
43
   // setFrm.show();
-
 
44
-
 
45
    connect(ui->getsettingAct, SIGNAL(triggered()), this, SLOT(getSetting())); // âûáîð â ãëàâíîé ôîðìå â ìåíþ "Áàçà äàííûõ" ïóíêòà "Ïàðàìåòðû ñîåäèíåíèÿ"
-
 
46
    connect(setFrm.pushButton, SIGNAL(clicked()), this, SLOT(applySetting()));
-
 
47
-
 
48
39
49
40
}
50
}
41
51
42
MainWindow::~MainWindow()
52
MainWindow::~MainWindow()
43
{
53
{
Line 252... Line 262...
252
bool MainWindow::openDataBase(){
262
bool MainWindow::openDataBase(){
253
    QString errorString;
263
    QString errorString;
254
    sql = QSqlDatabase::addDatabase("QMYSQL");
264
    sql = QSqlDatabase::addDatabase("QMYSQL");
255
//    sql.setDatabaseName(tr("an_db"));
265
//    sql.setDatabaseName(tr("an_db"));
256
266
257
    sql.setDatabaseName(tr("inventory"));
267
    // // // sql.setDatabaseName(tr("inventory"));
-
 
268
-
 
269
    sql.setDatabaseName(baseName);
-
 
270
-
 
271
-
 
272
258
    sql.setHostName(tr("localhost"));
273
    // // // sql.setHostName(tr("localhost"));
259
274
-
 
275
    sql.setHostName(hostName);
260
276
261
277
-
 
278
    // // // sql.setUserName(tr("an"));
-
 
279
-
 
280
    sql.setUserName(userName);
-
 
281
-
 
282
-
 
283
-
 
284
   // // //  sql.setPassword(tr("393939"));
-
 
285
-
 
286
-
 
287
    sql.setPassword(password);
-
 
288
262
289
263
    sql.setUserName(tr("an"));
-
 
264
    sql.setPassword(tr("393939"));
-
 
265
290
266
    bool ok;
291
    bool ok;
267
    ok = sql.open();
292
    ok = sql.open();
268
293
269
    /*
294
    /*
Line 605... Line 630...
605
         tmp_str.append(interator.key());
630
         tmp_str.append(interator.key());
606
         tmp_str.append(tr(")"));
631
         tmp_str.append(tr(")"));
607
         tmp_stringList << tmp_str;
632
         tmp_stringList << tmp_str;
608
633
609
     }
634
     }
-
 
635
//    int count = ui->comboBox->count();
-
 
636
-
 
637
    ui->comboBox->clear();
610
    ui->comboBox->addItems(tmp_stringList);
638
    ui->comboBox->addItems(tmp_stringList);
611
639
612
640
613
}
641
}
614
642
615
643
616
void MainWindow::on_comboBox_currentIndexChanged( int index ){
644
void MainWindow::on_comboBox_currentIndexChanged( int index ){
617
QStringList classesNameList;
645
QStringList classesNameList;
618
QStringList classesID_list;
646
QStringList classesID_list;
619
QString ID_str;
647
QString ID_str;
-
 
648
if (index == -1) return;
-
 
649
620
classesID_list = class_list_map.keys();
650
classesID_list = class_list_map.keys();
621
classesNameList = class_list_map.values();
651
classesNameList = class_list_map.values();
622
ID_str =  classesID_list[index];
652
ID_str =  classesID_list[index];
623
ui->label->setText(ID_str);
653
ui->label->setText(ID_str);
624
if (root_items_list.indexOf(ui->treeWidget->currentItem()) != -1) rebuildPreviewModel(ui->treeWidget->currentItem(), ID_str);
654
if (root_items_list.indexOf(ui->treeWidget->currentItem()) != -1) rebuildPreviewModel(ui->treeWidget->currentItem(), ID_str);
Line 645... Line 675...
645
675
646
        int index;
676
        int index;
647
        classesID_list = class_list_map.keys();
677
        classesID_list = class_list_map.keys();
648
        classesNameList = class_list_map.values();
678
        classesNameList = class_list_map.values();
649
        index = classesID_list.indexOf(item->child(0)->text(1));
679
        index = classesID_list.indexOf(item->child(0)->text(1));
650
        ui->comboBox->setCurrentIndex(index);
680
        if (index != -1) ui->comboBox->setCurrentIndex(index);
651
681
652
        ui->comboBox->setEnabled(true);
682
        ui->comboBox->setEnabled(true);
653
683
654
684
655
    }
685
    }