Хранилища Subversion OpenInventory

Редакция

Редакция 113 | Редакция 116 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

Редакция 113 Редакция 114
1
1
#include "mainwindow.h"
2
2
#include "ui_mainwindow.h"
3
3
4
4
MainWindow::MainWindow(QWidget *parent) :
5
5
    QMainWindow(parent),
6
6
    ui(new Ui::MainWindow)
7
7
{
8
8
    ui->setupUi(this);
9
9
   // connect( ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_currentIndexChanged(int)));
10
10
11
11
   MainWindow::readModel();
12
12
13
13
   //QString model_str;
14
14
   MainWindow::creatModelString();
15
15
   int i;
16
16
   i++;
17
17
    QFile file_tmp("./temp.txt");
18
18
    bool ok;
19
19
    ok = file_tmp.open(QIODevice::ReadWrite | QIODevice::Text);
20
20
    QTextStream out(&file_tmp);
21
21
    out << MainWindow::modelString;
22
22
    file_tmp.close();
23
23
-
 
24
    ui->treeWidget->setAlternatingRowColors(true);
-
 
25
    ui->treeWidget_2->setAlternatingRowColors(true);
24
26
    MainWindow::openDataBase();
25
27
    MainWindow::buildPreviewModel(tr("Ìîÿ ìîäåëü"), tr("7"));
26
28
    MainWindow::initComboBox();
-
 
29
    getDatabaseData();
-
 
30
-
 
31
-
 
32
}
-
 
33
-
 
34
MainWindow::~MainWindow()
-
 
35
{
-
 
36
    delete ui;
-
 
37
}
-
 
38
-
 
39
void MainWindow::changeEvent(QEvent *e)
-
 
40
{
-
 
41
    QMainWindow::changeEvent(e);
-
 
42
    switch (e->type()) {
-
 
43
    case QEvent::LanguageChange:
-
 
44
        ui->retranslateUi(this);
-
 
45
        break;
-
 
46
    default:
-
 
47
        break;
-
 
48
    }
-
 
49
}
-
 
50
-
 
51
-
 
52
bool MainWindow::readModel(){
-
 
53
    bool result;
-
 
54
    QString model_str;
-
 
55
    QFile file(":/model.txt");
-
 
56
-
 
57
   rootItem1 = new  QTreeWidgetItem(ui->treeWidget);
-
 
58
    rootItem1->setText(0, tr("Óðîâåíü 1"));
-
 
59
   // rootItem2 = new  QTreeWidgetItem(rootItem1);
-
 
60
   // rootItem2->setText(0, tr("óðîâåíü 2"));
-
 
61
    rootItem1->setCheckState(0,Qt::Checked);
-
 
62
   // rootItem2->setCheckState(0,Qt::Checked);
-
 
63
-
 
64
-
 
65
-
 
66
    result = file.open(QIODevice::ReadOnly);
-
 
67
    if (result) {
-
 
68
                     model_str = QString(tr(file.readAll()));
-
 
69
                }
-
 
70
-
 
71
    setupModelData(model_str.split(QString("\n")), rootItem1);
-
 
72
-
 
73
-
 
74
    return result;
-
 
75
-
 
76
}
-
 
77
-
 
78
-
 
79
void MainWindow::setupModelData(const QStringList &lines, QTreeWidgetItem *parent)
-
 
80
{
-
 
81
    QList<QTreeWidgetItem*> parents;
-
 
82
    QList<int> indentations;
-
 
83
    parents << parent;
-
 
84
    indentations << 0;
-
 
85
-
 
86