Хранилища Subversion OpenInventory

Редакция

Редакция 228 | Редакция 230 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
88 pingvin 1
#include "mainwindow.h"
2
#include "ui_mainwindow.h"
3
 
4
MainWindow::MainWindow(QWidget *parent) :
5
    QMainWindow(parent),
6
    ui(new Ui::MainWindow)
7
{
8
    ui->setupUi(this);
222 pingvin 9
/*
10
    QPalette p = this->palette();
11
    p.setBrush(this->backgroundRole(), QBrush(QColor(255,255,255,128)));
12
    this->setAutoFillBackground(true);
13
    this->setPalette(p);
14
*/
15
 
205 pingvin 16
    ui->centralWidget->setLayout(ui->verticalLayout);
17
    ui->tab->setLayout(ui->horizontalLayout);
18
    ui->tab_2->setLayout(ui->horizontalLayout_3);
106 pingvin 19
   // connect( ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_currentIndexChanged(int)));
118 pingvin 20
    model_is_build = false;
145 pingvin 21
   // MainWindow::readModel();
89 pingvin 22
 
91 pingvin 23
   //QString model_str;
140 pingvin 24
 
25
 
26
   /*
91 pingvin 27
   MainWindow::creatModelString();
28
   int i;
29
   i++;
93 pingvin 30
    QFile file_tmp("./temp.txt");
92 pingvin 31
    bool ok;
32
    ok = file_tmp.open(QIODevice::ReadWrite | QIODevice::Text);
33
    QTextStream out(&file_tmp);
34
    out << MainWindow::modelString;
35
    file_tmp.close();
140 pingvin 36
*/
174 pingvin 37
 
38
 
39
 
40
 
114 pingvin 41
    ui->treeWidget->setAlternatingRowColors(true);
42
    ui->treeWidget_2->setAlternatingRowColors(true);
132 pingvin 43
 
177 pingvin 44
    ui->treeWidget->setIconSize(QSize(30,30));
209 pingvin 45
    ui->treeWidget->setColumnWidth(0, 400);
193 pingvin 46
    ui->treeWidget_2->setIconSize(QSize(128,128));
132 pingvin 47
 
48
    MainWindow::readSettings();
49
 
93 pingvin 50
    MainWindow::openDataBase();
136 pingvin 51
 
174 pingvin 52
    classesIcons = MainWindow::getClassesIcons(); //    
53
 
104 pingvin 54
    MainWindow::initComboBox();
136 pingvin 55
 
145 pingvin 56
//    MainWindow::buildPreviewModel(tr(" "), tr("11"));
136 pingvin 57
 
142 pingvin 58
    MainWindow::initListModelsTablle();
140 pingvin 59
 
144 pingvin 60
    MainWindow::readModels();
61
 
145 pingvin 62
 //   MainWindow::creatModelString();
140 pingvin 63
    //int i;
64
    //i++;
145 pingvin 65
 
66
    /*
67
    QFile file_tmp("./modelstring.txt");
140 pingvin 68
     bool ok;
69
     file_tmp.remove();
70
     ok = file_tmp.open(QIODevice::ReadWrite | QIODevice::Text);
71
     QTextStream out(&file_tmp);
72
     out.setCodec("cp1251");
73
     out << MainWindow::modelString;
74
     file_tmp.close();
145 pingvin 75
    */
140 pingvin 76
 
77
 
151 pingvin 78
    ui->treeWidget_2->hideColumn(1);
79
    ui->treeWidget_2->hideColumn(2);
80
    ui->treeWidget_2->hideColumn(3);
81
    ui->treeWidget_2->hideColumn(4);
140 pingvin 82
 
151 pingvin 83
 
109 pingvin 84
    getDatabaseData();
127 pingvin 85
    //// sql_mogel = new QSqlTableModel();
86
    sql_mogel = new MyModel();
87
 
223 pingvin 88
    /// filter_model = new MyModel();
89
    filter_model = new QSqlTableModel();
227 pingvin 90
    filter_model->setEditStrategy(QSqlTableModel::OnManualSubmit);
127 pingvin 91
 
118 pingvin 92
    model_is_build = true;
119 pingvin 93
    connect(sql_mogel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_sql_mogel_dataChanged(QModelIndex,QModelIndex)));
146 pingvin 94
    connect(model_for_ListModelsTable, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_model_for_ListModelsTable_dataChanged(QModelIndex,QModelIndex)));
221 pingvin 95
    connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
146 pingvin 96
 
221 pingvin 97
 
119 pingvin 98
    ui->pushButton_3->setEnabled(false);
99
    ui->pushButton_4->setEnabled(false);
100
 
217 pingvin 101
 
102
    ui->pushButton_9->setEnabled(false);
103
    ui->pushButton_10->setEnabled(false);
104
    ui->pushButton_11->setEnabled(false);
105
    ui->pushButton_12->setEnabled(false);
106
 
132 pingvin 107
   // setFrm.show();
119 pingvin 108
 
212 pingvin 109
    // treeForm.show();
110
 
132 pingvin 111
    connect(ui->getsettingAct, SIGNAL(triggered()), this, SLOT(getSetting())); //       " "  " "
112
    connect(setFrm.pushButton, SIGNAL(clicked()), this, SLOT(applySetting()));
113
 
158 pingvin 114
 //   connect(ui->tableView_2,SIGNAL(activated(QModelIndex)),ui->tableView_2,SLOT(edit(QModelIndex)));
132 pingvin 115
 
158 pingvin 116
    picture_delegate = new CPictureDelegate(this);
189 pingvin 117
    iconDelegate = new IconDelegate(this);
201 pingvin 118
    fileDelegate = new FileDelegate(this);
158 pingvin 119
 
200 pingvin 120
 //   fileForm.show();
196 pingvin 121
 
228 pingvin 122
 
123
    cursor = new QTextCursor(&doc);
124
    buildReport(true);
125
 
126
 
88 pingvin 127
}
128
 
129
MainWindow::~MainWindow()
130
{
117 pingvin 131
    delete sql_mogel;
221 pingvin 132
    delete filter_model;
88 pingvin 133
    delete ui;
149 pingvin 134
    delete model_for_ListModelsTable;
88 pingvin 135
}
136
 
137
void MainWindow::changeEvent(QEvent *e)
138
{
139
    QMainWindow::changeEvent(e);
140
    switch (e->type()) {
141
    case QEvent::LanguageChange:
142
        ui->retranslateUi(this);
143
        break;
144
    default:
145
        break;
146
    }
147
}
89 pingvin 148
 
149
 
150
bool MainWindow::readModel(){
151
    bool result;
152
    QString model_str;
140 pingvin 153
    QFile file("modelstring.txt");
141 pingvin 154
  //  QFile file("model.txt");
91 pingvin 155
   rootItem1 = new  QTreeWidgetItem(ui->treeWidget);
89 pingvin 156
    rootItem1->setText(0, tr(" 1"));
157
   // rootItem2 = new  QTreeWidgetItem(rootItem1);
158
   // rootItem2->setText(0, tr(" 2"));
159
    rootItem1->setCheckState(0,Qt::Checked);
160
   // rootItem2->setCheckState(0,Qt::Checked);
161
 
162
 
163
 
164
    result = file.open(QIODevice::ReadOnly);
165
    if (result) {
90 pingvin 166
                     model_str = QString(tr(file.readAll()));
89 pingvin 167
                }
168
 
215 pingvin 169
    setupModelData(model_str.split(QString("\n")), rootItem1, -1, tr("1"));
89 pingvin 170
 
171
 
172
    return result;
173
 
174
}
175
 
176
 
215 pingvin 177
void MainWindow::setupModelData(const QStringList &lines, QTreeWidgetItem *parent, int row, QString model_id)
89 pingvin 178
{
179
    QList<QTreeWidgetItem*> parents;
180
    QList<int> indentations;
181
    parents << parent;
182
    indentations << 0;
183
 
184
    int number = 0;
185
 
186
    while (number < lines.count()) {
187
        int position = 0;
188
        while (position < lines[number].length()) {
189
            if (lines[number].mid(position, 1) != " ")
190
                break;
191
            position++;
192
        }
193
 
194
        QString lineData = lines[number].mid(position).trimmed();
195
 
196
        if (!lineData.isEmpty()) {
197
            // Read the column data from the rest of the line.
198
            QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
199
            QList<QVariant> columnData;
200
            for (int column = 0; column < columnStrings.count(); ++column)
201
                columnData << columnStrings[column];
202
 
203
            if (position > indentations.last()) {
204
                // The last child of the current parent is now the new parent
205
                // unless the current parent has no children.
206
 
207
                if (parents.last()->childCount() > 0) {
208
                    parents << parents.last()->child(parents.last()->childCount()-1);
209
                    indentations << position;
210
                }
211
            } else {
212
                while (position < indentations.last() && parents.count() > 0) {
213
                    parents.pop_back();
214
                    indentations.pop_back();
215
                }
216
            }
217
 
218
            // Append a new item to the current parent's list of children.
219
          // // //  parents.last()->appendChild(new QTreeWidgetItem(columnData, parents.last()));
220
            QTreeWidgetItem* itm_tmp;
221
            itm_tmp = new QTreeWidgetItem( parents.last());
215 pingvin 222
        //    itm_tmp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
89 pingvin 223
 
209 pingvin 224
/*
225
            QLineEdit * edit_line;
226
            edit_line = new QLineEdit(this);
227
            ui->treeWidget->setItemWidget(itm_tmp, 5, edit_line);
228
*/
229
//static QStandartDelegate delegate;
230
            ui->treeWidget->setItemDelegateForColumn(5, &standart_delegate);
231
 
232
 
89 pingvin 233
            itm_tmp->setText(0, QString(columnData.at(0).toString()));
234
            if (columnData.at(1).toString() == "true") {
235
                                                            itm_tmp->setCheckState(0,Qt::Checked);
236
                                                        }
237
            else itm_tmp->setCheckState(0,Qt::Unchecked);
141 pingvin 238
            if (columnData.count()>2)
239
            {
173 pingvin 240
            QString class_id;
222 pingvin 241
            QString filtr_str;
174 pingvin 242
            QPixmap pxmp;
243
            QIcon icon;
173 pingvin 244
            class_id = QString(columnData.at(2).toString());
174 pingvin 245
            pxmp = MainWindow::classesIcons.value(class_id);
246
 
173 pingvin 247
           // itm_tmp->setText(1, QString(columnData.at(2).toString())); // id 
248
            itm_tmp->setText(1, class_id); // id 
215 pingvin 249
            itm_tmp->setText(6, model_id); // id 
90 pingvin 250
            itm_tmp->setText(2, QVariant(number).toString()); //    - 
173 pingvin 251
            itm_tmp->setText(3, QVariant(indentations.size()).toString()); //  
252
            itm_tmp->setText(4, QVariant(row).toString()); //    
222 pingvin 253
            filtr_str = getFiltrString(model_id,class_id);
254
            itm_tmp->setText(5,filtr_str);
174 pingvin 255
 
256
            if (!pxmp.isNull())
257
                {
258
                    icon.addPixmap(pxmp);
175 pingvin 259
                    itm_tmp->setIcon(0, icon);                  
174 pingvin 260
                }
141 pingvin 261
            }
89 pingvin 262
        }
263
 
264
        number++;
265
    }
266
}
267
 
268
 
269
/*
270
void MainWindow::openBase()
271
{
272
 
273
        db = QSqlDatabase::addDatabase("QMYSQL");
274
        pdb = &db;
275
        raportFrm.pdb = &db;
276
 
277
        pdb->setHostName(hostName);
278
        pdb->setDatabaseName(baseName);
279
        pdb->setUserName(userName);
280
        pdb->setPassword(password);
281
        bool ok = pdb->open();
282
        if (!ok) {
283
                                QMessageBox::critical( //     .
284
                                                                                this,                      //  .
285
                                                                                QObject::tr("Database Error"),   // .
286
                                                                                pdb->lastError().text());          //  .
287
                         }
288
        if (ok)
289
        {lineEdit-> insert(tr("  "));
290
        }
291
        else {lineEdit-> insert(tr(" .  : "));
292
                  lineEdit-> insert(pdb->lastError().text());
293
                 }
294
 
295
 
296
 
297
        model = new QSqlTableModel(this);
298
        model->setTable(tableName);
299
 
300
        model->setEditStrategy(QSqlTableModel::OnManualSubmit);
301
        model->setSort(0, Qt::AscendingOrder);
302
 
303
        model->select();
304
 
305
 
306
        QSqlField field(tr("age"), QVariant::Int);
307
        field.setValue(QString(tr("123")));
308
 
309
        bool okey;
310
        int index;
311
        QSqlRecord record;
312
 
313
 
314
        tableView->setModel(model);
315
        view.setModel(model);
316
 
317
 
318
        tableView->setAlternatingRowColors(true);
319
        view.setAlternatingRowColors(true);
320
 
321
        tableView->resizeColumnsToContents();
322
 
323
 
324
        view.resizeColumnsToContents();
325
 
326
        tableView->show();
327
 
328
 
329
 
330
        initTreeWidget();
331
}
332
*/
91 pingvin 333
 
334
 
146 pingvin 335
QString MainWindow::creatModelString(QTreeWidgetItem* model){
91 pingvin 336
 
337
    MainWindow::modelString.clear(); //   
338
 //   for (int i =0; i < rootItem1->childCount(); ++i )
339
 
146 pingvin 340
    {MainWindow::addChildsString(model, 0);}
341
 
342
    return MainWindow::modelString;
145 pingvin 343
// {MainWindow::addChildsString(ui->treeWidget, 0);}
344
 /*
91 pingvin 345
    int root_item_child_count;
346
    int i;
347
    root_item_child_count = rootItem1->childCount();
348
    i++;
145 pingvin 349
*/
91 pingvin 350
}
351
 
352
 
353
void MainWindow::addChildsString(QTreeWidgetItem *parentItem, int level){
354
    int child_count;
355
    child_count = parentItem->childCount();
356
    for (int i=0; i < child_count; ++i){
357
        for (int m=0; m < level; ++m){
358
        modelString.append(tr("    ")); //   -  ,     
359
    }
360
        modelString.append(parentItem->child(i)->text(0)); //    -  
361
        modelString.append(tr("\t\t\t\t")); //   -   
362
        if (parentItem->child(i)->checkState(0) ==  Qt::Checked) {modelString.append(tr("true"));} //   ,  "true",      
363
            else {modelString.append(tr("false"));} //     -  "false",       
364
        modelString.append(tr("\t\t\t\t")); //   -   
365
        modelString.append(parentItem->child(i)->text(1)); //    - ID 
366
         modelString.append(tr("\n")); //  
367
        if (parentItem->child(i)->childCount() > 0) { MainWindow::addChildsString(parentItem->child(i), level+1);}
368
 
369
    }
370
int i;
371
i++;
372
}
93 pingvin 373
 
374
 
375
bool MainWindow::openDataBase(){
376
    QString errorString;
377
    sql = QSqlDatabase::addDatabase("QMYSQL");
131 pingvin 378
//    sql.setDatabaseName(tr("an_db"));
379
 
132 pingvin 380
    // // // sql.setDatabaseName(tr("inventory"));
131 pingvin 381
 
132 pingvin 382
    sql.setDatabaseName(baseName);
131 pingvin 383
 
384
 
385
 
132 pingvin 386
    // // // sql.setHostName(tr("localhost"));
93 pingvin 387
 
132 pingvin 388
    sql.setHostName(hostName);
389
 
390
 
391
    // // // sql.setUserName(tr("an"));
392
 
393
    sql.setUserName(userName);
394
 
395
 
396
 
397
   // // //  sql.setPassword(tr("393939"));
398
 
399
 
400
    sql.setPassword(password);
401
 
402
 
403
 
93 pingvin 404
    bool ok;
405
    ok = sql.open();
406
 
407
    /*
408
    if (!ok) {
409
                                QMessageBox::critical( //     .
410
                                                                                this,                      //  .
411
                                                                                QObject::tr("Database Error"),   // .
412
                                                                                sql.lastError().text() );         //  .
413
 
414
 
415
                            }
416
 
417
*/
418
    if (!ok) {
419
                            QMessageBox::critical( //     .
420
                                                                            this,                      //  .
421
                                                                            QObject::tr("Database Error"),   // .
422
                                                                            sql.lastError().text());          //  .
423
                     }
424
else {
425
 
426
        QMessageBox::information( //     .
427
                                                        this,                      //  .
428
                                                        QObject::tr("Database Connect"),   // .
429
                                                        QObject::tr("     ."));         //  .
430
 
431
 
432
 
433
 
434
 
435
    }
436
 
437
     return ok;
438
}
94 pingvin 439
 
440
 
97 pingvin 441
bool MainWindow::buildPreviewModel(QString modelName, QString rootClassID){
94 pingvin 442
QSqlQuery q;
443
QString sql_str;
95 pingvin 444
QString field_name_str;
445
QString root_class_name;
192 pingvin 446
//bool ok;
447
//int field_name;
95 pingvin 448
 
449
//ui->treeWidget->clear();
450
 
451
root_class_name = MainWindow::ClassName(rootClassID); //   
452
 
145 pingvin 453
 
95 pingvin 454
rootItem1 = new  QTreeWidgetItem(ui->treeWidget);
145 pingvin 455
 root_items_list << rootItem1;
97 pingvin 456
 rootItem1->setText(0, modelName);
457
 
95 pingvin 458
 rootItem1->setCheckState(0,Qt::Checked);
104 pingvin 459
 rootItems.append(rootItem1);
95 pingvin 460
 
461
 
104 pingvin 462
 
145 pingvin 463
 rootItem2 = new  QTreeWidgetItem(rootItem1);
464
 rootItem2->setText(0, root_class_name);
465
 rootItem2->setText(1, rootClassID);
466
 rootItem2->setCheckState(0,Qt::Checked);
95 pingvin 467
 
147 pingvin 468
 addChildsItems(rootItem2, -1);
95 pingvin 469
 
145 pingvin 470
 
471
/*
472
 
94 pingvin 473
sql_str = tr("select * "
95 pingvin 474
             " from DescriptionOfClasses where  DescriptionOfClasses.DefaultValue = '"       // ,     
94 pingvin 475
             );
476
sql_str.append(rootClassID);
477
 
95 pingvin 478
sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' "));
94 pingvin 479
 
95 pingvin 480
q.prepare(sql_str);
481
 
482
ok = q.exec();
483
if (!ok) {
484
                        QMessageBox::critical( //     .
485
                                                                        this,                      //  .
486
                                                                        QObject::tr("Database Error"),   // .
487
                                                                        q.lastError().text());          //  .
488
                 }
489
field_name = q.record().indexOf(tr("FieldName"));
490
while(q.next()){
491
 
492
                field_name_str = q.value(field_name).toString();
493
 
494
                }
495
 
100 pingvin 496
 
497
 
498
 
145 pingvin 499
*/
500
 
501
 
94 pingvin 502
}
95 pingvin 503
 
504
 
147 pingvin 505
bool MainWindow::rebuildPreviewModel(QTreeWidgetItem* root_item, QString rootClassID, int row){
107 pingvin 506
QSqlQuery q;
507
QString sql_str;
508
QString field_name_str;
509
QString root_class_name;
192 pingvin 510
//bool ok;
511
//int field_name;
95 pingvin 512
 
107 pingvin 513
//ui->treeWidget->clear();
514
 
515
root_class_name = MainWindow::ClassName(rootClassID); //   
516
 
517
 
518
// rootItem1 = new  QTreeWidgetItem(ui->treeWidget);
519
// root_items_list << rootItem1;
520
// rootItem1->setText(0, modelName);
521
 
522
// rootItem1->setCheckState(0,Qt::Checked);
523
// rootItems.append(rootItem1);
524
 
525
// root_item->removeChild(root_item->child(0)); //    
145 pingvin 526
if (root_item->childCount()==0){ //   ,  
527
    QTreeWidgetItem* item_tmp;
528
    item_tmp = new QTreeWidgetItem (root_item);
147 pingvin 529
    item_tmp->setText(4, QVariant(row).toString());
145 pingvin 530
 
531
}
532
 
533
if (root_item->childCount()==1){ //      ,    
107 pingvin 534
root_item->child(0)->setText(0, root_class_name);
535
root_item->child(0)->setText(1, rootClassID);
147 pingvin 536
root_item->child(0)->setCheckState(0,Qt::Checked);
537
root_item->setText(4, QVariant(row).toString());
107 pingvin 538
 
147 pingvin 539
}
145 pingvin 540
 
541
 
147 pingvin 542
 
107 pingvin 543
//delete rootItem2;
544
 
545
 
546
// rootItem2 = new  QTreeWidgetItem(rootItem1);
547
 
548
 
549
 
550
// rootItem2->setText(0, root_class_name);
551
// rootItem2->setText(1, rootClassID);
552
// rootItem2->setCheckState(0,Qt::Checked);
553
 
554
int child_count = root_item->child(0)->childCount();
555
 
556
 
145 pingvin 557
for (int i=0; i < child_count; i++){ //       ,  
107 pingvin 558
    root_item->child(0)->removeChild(root_item->child(0)->child(0));
559
}
560
 
561
child_count = root_item->child(0)->childCount();
147 pingvin 562
addChildsItems(root_item->child(0), row);
107 pingvin 563
/*
564
sql_str = tr("select * "
565
             " from DescriptionOfClasses where  DescriptionOfClasses.DefaultValue = '"       // ,     
566
             );
567
sql_str.append(rootClassID);
568
 
569
sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' "));
570
 
571
q.prepare(sql_str);
572
 
573
ok = q.exec();
574
if (!ok) {
575
                        QMessageBox::critical( //     .
576
                                                                        this,                      //  .
577
                                                                        QObject::tr("Database Error"),   // .
578
                                                                        q.lastError().text());          //  .
579
                 }
580
field_name = q.record().indexOf(tr("FieldName"));
581
while(q.next()){
582
 
583
                field_name_str = q.value(field_name).toString();
584
 
585
                }
586
 
587
*/
588
 
589
 
590
}
591
 
592
 
593
 
594
 
95 pingvin 595
QString MainWindow::ClassName(QString class_id){ //     ID
596
    QSqlQuery q;
597
    QString sql_str;
598
    QString class_name_str;
599
    bool ok;
600
    int field_class_name;
601
 
602
    sql_str = tr("select * "
603
                 " from ListOfClasses where ListOfClasses.ID = '"       // ,     
604
                 );
605
 
606
    sql_str.append(class_id);
607
    sql_str.append(tr("' "));
608
 
609
    q.prepare(sql_str);
610
 
611
    ok = q.exec();
612
 
613
 
614
    if (!ok) {
615
                            QMessageBox::critical( //     .
616
                                                                            this,                      //  .
617
                                                                            QObject::tr("Database Error"),   // .
618
                                                                            q.lastError().text());          //  .
619
                     }
620
 
621
    field_class_name = q.record().indexOf(tr("ClassName"));
622
    while(q.next()){
623
 
624
                    class_name_str = q.value(field_class_name).toString();
625
 
626
                    }
627
 
628
    return class_name_str;
629
 
630
}
98 pingvin 631
 
147 pingvin 632
void MainWindow::addChildsItems(QTreeWidgetItem *perent_class_item, int row){ //          ,      
100 pingvin 633
QStringList chields_list;
634
QString parent_ID;
635
QTreeWidgetItem *Item_tmp;
636
parent_ID = perent_class_item->text(1);
637
int chields_count, i;
98 pingvin 638
 
100 pingvin 639
chields_list = MainWindow::classChields(parent_ID);
640
if(chields_list.isEmpty()) return;
641
chields_count = chields_list.size();
642
for (int l = 0; l < chields_count; ++l){
643
    QString chield_class_name, chield_id;
644
    chield_id = chields_list.at(l);
645
    chield_class_name = MainWindow::ClassName(chield_id);
646
    Item_tmp = new QTreeWidgetItem(perent_class_item);
647
    Item_tmp->setText(0, chield_class_name);
648
    Item_tmp->setText(1, chield_id);
649
    Item_tmp->setCheckState(0, Qt::Checked);
147 pingvin 650
    Item_tmp->setText(4, QVariant(row).toString());
651
    MainWindow::addChildsItems(Item_tmp, row);
98 pingvin 652
}
653
 
100 pingvin 654
i++;
99 pingvin 655
 
100 pingvin 656
}
657
 
658
 
99 pingvin 659
/********************************************************
660
*    "" 
661
*
662
*
663
*
664
********************************************************/
665
 
666
QStringList MainWindow::classChields(QString class_id){
667
   // QMap<QString, QString> map;
668
   // TClass class_tmp;
669
   // QList <TClass> chields_class_list; //   
670
    QStringList result;
671
    QSqlQuery q;
672
    QString sql_str;
673
    QString classIdentifer_str; //      -
674
    QString field_id_str;
675
    bool ok;
676
    int field_classIdentifer;
677
    sql_str = tr("select * "
678
                 " from DescriptionOfClasses where  DescriptionOfClasses.DefaultValue = '"       // ,     
679
                 );
680
    sql_str.append(class_id);
681
 
682
    sql_str.append(tr("' and DescriptionOfClasses.FieldType = 'pointer' "));
683
 
684
    q.prepare(sql_str);
685
 
686
    ok = q.exec();
687
    if (!ok) {
688
                            QMessageBox::critical( //     .
689
                                                                            this,                      //  .
690
                                                                            QObject::tr("Database Error"),   // .
691
                                                                            q.lastError().text());          //  .
692
                     }
693
    field_classIdentifer = q.record().indexOf(tr("ClassIdentifer"));
694
      while(q.next()){
695
 
696
                    classIdentifer_str = q.value(field_classIdentifer).toString();
697
                    result.append(classIdentifer_str);
698
                    }
699
 
700
    return result;
701
 
702
  }
102 pingvin 703
 
704
 
705
QMap <QString, QString> MainWindow::getClassList(){ //   
706
QMap <QString, QString> result_map;
707
QSqlQuery q;
708
QString sql_str;
103 pingvin 709
QString class_name_str, class_id_str;
710
 
102 pingvin 711
int field_class_id, field_class_name;
712
bool ok;
713
sql_str = tr("select * "
714
             " from ListOfClasses "       // ,     
715
             );
716
 q.prepare(sql_str);
717
 ok = q.exec();
718
 if (!ok) {
719
                         QMessageBox::critical( //     .
720
                                                                         this,                      //  .
721
                                                                         QObject::tr("Database Error"),   // .
722
                                                                         q.lastError().text());          //  .
723
                         return result_map; //   -   
724
                  }
725
field_class_id = q.record().indexOf(tr("ID"));
726
field_class_name = q.record().indexOf(tr("ClassName"));
727
 
103 pingvin 728
while(q.next()){
102 pingvin 729
 
103 pingvin 730
                class_name_str = q.value(field_class_name).toString();
731
                class_id_str = q.value(field_class_id).toString();
732
                result_map[class_id_str] = class_name_str;
733
                }
102 pingvin 734
 return result_map;
735
}
104 pingvin 736
 
737
 
738
 
739
 
740
 
741
void MainWindow::initComboBox(){
742
 
106 pingvin 743
 
104 pingvin 744
    QStringList classesNameList;
745
    QStringList classesID_list;
746
    QStringList tmp_stringList;
747
 
748
 
749
 
750
    QString tmp_str;
751
 
752
    class_list_map = MainWindow::getClassList();
753
    classesID_list = class_list_map.keys();
754
    classesNameList = class_list_map.values();
755
    QMapIterator<QString, QString> interator(class_list_map);
756
//    ui->comboBox->addItems(classesID_list);
757
  //  ui->comboBox->addItems(classesNameList);
758
    while (interator.hasNext()) {
759
         interator.next();
760
         tmp_str =  interator.value();
761
         tmp_str.append(tr(" \t(ID="));
762
         tmp_str.append(interator.key());
763
         tmp_str.append(tr(")"));
764
         tmp_stringList << tmp_str;
765
 
766
     }
132 pingvin 767
//    int count = ui->comboBox->count();
768
 
769
    ui->comboBox->clear();
104 pingvin 770
    ui->comboBox->addItems(tmp_stringList);
771
 
772
 
773
}
105 pingvin 774
 
775
 
106 pingvin 776
void MainWindow::on_comboBox_currentIndexChanged( int index ){
777
QStringList classesNameList;
778
QStringList classesID_list;
779
QString ID_str;
132 pingvin 780
if (index == -1) return;
152 pingvin 781
if (!comboBox_slot_enable) return; //   ,     , 
147 pingvin 782
int row;
132 pingvin 783
 
106 pingvin 784
classesID_list = class_list_map.keys();
785
classesNameList = class_list_map.values();
786
ID_str =  classesID_list[index];
787
ui->label->setText(ID_str);
145 pingvin 788
if (root_items_list.indexOf(ui->treeWidget->currentItem()) != -1)
789
{
147 pingvin 790
    row = QVariant(ui->treeWidget->currentItem()->text(4)).toInt();
145 pingvin 791
    model_is_build = false; //     on_treeWidget_itemChanged
147 pingvin 792
    rebuildPreviewModel(ui->treeWidget->currentItem(), ID_str, row);
145 pingvin 793
    model_is_build = true; //   
147 pingvin 794
    QString mdl_str = MainWindow::creatModelString(ui->treeWidget->currentItem()); //
795
    model_for_ListModelsTable->setData(model_for_ListModelsTable->index(row, 2), QVariant(mdl_str));
145 pingvin 796
}
797
    getDatabaseData();
107 pingvin 798
 
799
 
105 pingvin 800
}
801
 
106 pingvin 802
void MainWindow::on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column ){
803
    int i;
804
    i++;
147 pingvin 805
    QTreeWidgetItem * item_tmp;
806
    QString mdl_str;
807
    QString row; //     ,   
148 pingvin 808
    QList <QTreeWidgetItem *> mdl_itm_list;
147 pingvin 809
    QList <int> rows_list;
106 pingvin 810
 
147 pingvin 811
 
812
    if ((column) == 0 && (model_is_build)) {
813
    // if (!model_is_build) return; //    
148 pingvin 814
 
815
    mdl_itm_list = models_items.values();
147 pingvin 816
    rows_list =  models_items.keys();
148 pingvin 817
    row= item->text(4);
147 pingvin 818
 
148 pingvin 819
 
820
    if ( mdl_itm_list.indexOf(item) != -1){ //    ( )
821
        if (item->checkState(0)) model_for_ListModelsTable->setData(model_for_ListModelsTable->index(QVariant(row).toInt(), 3), QVariant(1));
822
        else model_for_ListModelsTable->setData(model_for_ListModelsTable->index(QVariant(row).toInt(), 3), QVariant(0));
823
        }
824
 
825
 
826
 
827
 
147 pingvin 828
    if (!row.isEmpty()){
829
 
830
 
831
        int row_int;
832
    row_int = QVariant(row).toInt();
833
     if (rows_list.indexOf(row_int) != -1)
834
        {
835
            item_tmp = models_items[row_int];
836
            mdl_str = MainWindow::creatModelString(item_tmp);
837
            model_for_ListModelsTable->setData(model_for_ListModelsTable->index(row_int, 2), QVariant(mdl_str));
838
        }
839
 
840
 
841
    }
842
 
843
 
844
}
845
 
846
/*
847
    QTreeWidgetItem * item_tmp;
848
    item_tmp = item;
849
    while (item_tmp ){
850
        item_tmp = item_tmp->parent();
851
    }
852
  */
118 pingvin 853
    if ((column) == 0 && (model_is_build)) getDatabaseData();
854
 
147 pingvin 855
 
106 pingvin 856
}
857
 
858
 
859
void MainWindow::on_treeWidget_itemClicked ( QTreeWidgetItem * item, int column ){
860
    int i;
861
    i++;
214 pingvin 862
    if (root_items_list.indexOf(item) != -1) { //      
108 pingvin 863
        QStringList classesNameList;
864
        QStringList classesID_list;
106 pingvin 865
 
217 pingvin 866
        ui->pushButton_9->setEnabled(false);
867
        ui->pushButton_10->setEnabled(false);
868
        ui->pushButton_11->setEnabled(false);
869
        ui->pushButton_12->setEnabled(false);
870
     //   ui->tableView->reset();
871
     //   MainWindow::filtr_model->clear();
221 pingvin 872
          disconnect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
873
        delete filter_model;
223 pingvin 874
 
875
        filter_model = new QSqlTableModel();
876
       /// filter_model = new MyModel();
227 pingvin 877
    filter_model->setEditStrategy(QSqlTableModel::OnManualSubmit);
223 pingvin 878
 
879
        connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
108 pingvin 880
        int index;
881
        classesID_list = class_list_map.keys();
882
        classesNameList = class_list_map.values();
145 pingvin 883
        if (item->childCount()>0) index = classesID_list.indexOf(item->child(0)->text(1)); //    ,   
884
        else { //  
885
        ui->comboBox->setEnabled(true);
206 pingvin 886
        comboBox_slot_enable = true;
145 pingvin 887
        return;
888
 
889
        }
152 pingvin 890
        comboBox_slot_enable = false; //   comboBox    
132 pingvin 891
        if (index != -1) ui->comboBox->setCurrentIndex(index);
152 pingvin 892
        comboBox_slot_enable = true;
108 pingvin 893
        ui->comboBox->setEnabled(true);
894
 
895
 
896
    }
106 pingvin 897
  //  if ((rootItem1) == (item) ) ui->comboBox->setEnabled(true);
214 pingvin 898
else //     
899
    {
215 pingvin 900
        QString class_id;
901
        QString model_id;
902
        QString filtr_str;
221 pingvin 903
        QString inctance;
219 pingvin 904
        QStringList conditionList;
215 pingvin 905
        class_id = item->text(1);
906
        model_id = item->text(6);
221 pingvin 907
        inctance = MainWindow::getClassInctance(class_id);
908
 
217 pingvin 909
        filtr_str = tr("`Model_ID` = ");
215 pingvin 910
        filtr_str.append(model_id);
217 pingvin 911
        filtr_str.append(tr(" AND `Class_ID` = "));
215 pingvin 912
        filtr_str.append(class_id);
217 pingvin 913
       // filtr_str.append(tr("`"));
215 pingvin 914
 
221 pingvin 915
        disconnect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
916
        delete filter_model;
223 pingvin 917
  ///      filter_model = new MyModel();
215 pingvin 918
 
221 pingvin 919
        filter_model = new QSqlTableModel();
227 pingvin 920
       filter_model->setEditStrategy(QSqlTableModel::OnManualSubmit);
921
 
221 pingvin 922
        connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
923
        filter_model->setTable(tr("Filters"));
924
        filter_model->setFilter(filtr_str);
226 pingvin 925
 
926
 
927
 
221 pingvin 928
        filter_model->select();
226 pingvin 929
 
930
        filter_model->sort(0,Qt::AscendingOrder);
931
 
221 pingvin 932
        ui->tableView_3->setModel(filter_model);
215 pingvin 933
 
219 pingvin 934
 
935
        ui->tableView_3->hideColumn(0);
936
        ui->tableView_3->hideColumn(1);
937
        ui->tableView_3->hideColumn(2);
938
 
939
 
940
        filterSpinDelegate.setClassID(class_id);
941
        filterSpinDelegate.getItems();
942
        ui->tableView_3->setItemDelegateForColumn(4, &filterSpinDelegate);
943
 
224 pingvin 944
       // ui->tableView_3->setItemDelegate();
219 pingvin 945
        conditionList <<"" << "and" << "or" << "(" << "and (" << "or (";
946
        filterConditionDelegate.setItems(conditionList);
947
        ui->tableView_3->setItemDelegateForColumn(3, &filterConditionDelegate);
948
 
949
        conditionList.clear();
227 pingvin 950
        conditionList <<"" << "=" << "<" << ">" << "IS NULL" << "IS NOT NULL";
219 pingvin 951
        filterConditionDelegate_1.setItems(conditionList);
952
        ui->tableView_3->setItemDelegateForColumn(5, &filterConditionDelegate_1);
953
 
954
 
227 pingvin 955
 
956
 
228 pingvin 957
        conditionList.clear();
958
        conditionList <<"" << ")";
959
        filterConditionDelegate_2.setItems(conditionList);
960
        ui->tableView_3->setItemDelegateForColumn(7, &filterConditionDelegate_2);
227 pingvin 961
 
224 pingvin 962
        ui->tableView_3->setItemDelegateForColumn(6, &filterValueDelegate);
219 pingvin 963
 
224 pingvin 964
 
965
 
966
 
217 pingvin 967
        ui->pushButton_9->setEnabled(true);
968
        ui->pushButton_10->setEnabled(true);
969
 
215 pingvin 970
        ui->comboBox->setEnabled(false);
971
 
972
 
214 pingvin 973
    }
106 pingvin 974
}
110 pingvin 975
 
125 pingvin 976
QMap <QString, QString> MainWindow::getFieldsList(QString class_id){ //    
110 pingvin 977
 
125 pingvin 978
}
142 pingvin 979
 
980
 
981
void MainWindow::initListModelsTablle(){
149 pingvin 982
    model_for_ListModelsTable = new QSqlTableModel();
142 pingvin 983
 
984
    model_for_ListModelsTable->setTable(tr("ListOfModels"));
146 pingvin 985
 //   model_for_ListModelsTable->setEditStrategy(QSqlTableModel::OnFieldChange);
986
    model_for_ListModelsTable->setEditStrategy(QSqlTableModel::OnManualSubmit);
142 pingvin 987
    ui->tableView_2->setModel(model_for_ListModelsTable);
151 pingvin 988
 
142 pingvin 989
    model_for_ListModelsTable->select();
151 pingvin 990
 
223 pingvin 991
 
151 pingvin 992
    ui->treeWidget->hideColumn(1);
993
    ui->treeWidget->hideColumn(2);
994
    ui->treeWidget->hideColumn(3);
995
    ui->treeWidget->hideColumn(4);
221 pingvin 996
//    ui->treeWidget->hideColumn(5);
215 pingvin 997
    ui->treeWidget->hideColumn(6);
223 pingvin 998
 
151 pingvin 999
    ui->tableView_2->hideColumn(0);
1000
    ui->tableView_2->hideColumn(2);
1001
    ui->tableView_2->hideColumn(3);
1002
    ui->tableView_2->hideColumn(4);
1003
 
1004
    ui->tableView_2->resizeColumnsToContents();
1005
    ui->tableView_2->setAlternatingRowColors(true);
1006
 
146 pingvin 1007
    ui->pushButton_7->setEnabled(false);
1008
    ui->pushButton_8->setEnabled(false);
151 pingvin 1009
 
1010
 
142 pingvin 1011
}
228 pingvin 1012
 
1013
void MainWindow::buildReport(bool advanced){
1014
 
1015
  //  QTreeWidgetItem * hitm;
1016
 
1017
  //   hitm = ui->treeWidget_2->headerItem();
1018
 
1019
  //   int count = root_items_list.count();
1020
 
1021
    //int count = ui->treeWidget_2->rootIndex();
1022
 
229 pingvin 1023
 
228 pingvin 1024
    doc.clear();// 
1025
 
1026
    int list_count;
1027
    if (rootItems.isEmpty()) return;
1028
 
1029
 
1030
 
1031
    list_count = rootItems.count();
1032
 
1033
    for (int i=0; i < list_count; i++){
1034
 
1035
       getReport(rootItems.at(i), advanced);
1036
 
229 pingvin 1037
 
1038
 
228 pingvin 1039
    }
1040
 (bool)QTextDocumentWriter("test.odt").write(&doc);
1041
}
1042
 
1043
 
1044
void MainWindow::getReport(QTreeWidgetItem * model_item, bool advanced){ //     
1045
 
1046
 
1047
 //   QTextDocument doc;
1048
 //   QTextCursor cursor(&doc);
1049
    QTextCharFormat char_fmt;
1050
    bool ok;
1051
 
1052
    /**************
1053
 
1054
    //  char_fmt.setBackground(Qt::red);
1055
    cursor.insertText(tr("1\n"),char_fmt);
1056
    QImage img;
1057
    ok = img.load("./hdd5.png");
1058
     doc.addResource(QTextDocument::ImageResource, QUrl("myimage"), img);
1059
     cursor.insertImage("myimage");
1060
    cursor.insertText(tr(" \n"),char_fmt);
1061
 
1062
    (bool)QTextDocumentWriter("test.odt").write(&doc);
1063
    ***************/
1064
 
1065
    QString model_name;
1066
    QString rootClassID;
1067
    QString rootClassInctance;
1068
    QFont font;
1069
 
1070
    model_name = model_item->text(0);
1071
    if (model_item->checkState(0) == false) return; //     
1072
 
1073
 
229 pingvin 1074
    newPage();
1075
/*******************
1076
    QTextBlockFormat textFormat;
1077
           textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
1078
                        cursor->setBlockFormat(textFormat);
1079
 
1080
                        cursor->insertText(tr(" "));
1081
                        cursor->insertBlock();
1082
 
1083
                        textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto);
1084
                        cursor->setBlockFormat(textFormat);
1085
********************/
1086
 
1087
 
1088
 
228 pingvin 1089
    if (!(model_item->childCount() > 0)) return; //   (  )
1090
 
1091
    rootClassID = model_item->child(0)->text(1);
1092
    rootClassInctance = getClassInctance(rootClassID);
1093
 
1094
    cursor->insertText(model_name);
1095
    cursor->insertText(tr("\n"));
1096
 
1097
    if (model_item->child(0)->checkState(0)) //         ( ), 
1098
        {
1099
         /////   QTreeWidgetItem * item_tmp;
1100
       /////     item_tmp = new QTreeWidgetItem(item);                  //  ,   ,   
1101
       /////     item_tmp->setText(0, model_item->child(0)->text(0));    //   
1102
 
1103
            //showClassObjects(item_tmp, model_item->child(0));  //      
1104
 
1105
            ///// showObjects(item_tmp, model_item->child(0), tr(""));
1106
        printChild(model_item->child(0), tr(""), advanced, 1);
1107
        }
1108
 
1109
 
1110
 
1111
 
1112
}
1113
 
1114
void MainWindow::printChild(QTreeWidgetItem * model_item, QString filtr, bool advanced, int pos){//    
1115
    QString classID; //  
1116
    QString parentClassID; //   
1117
    QString pointerField; //  -   
1118
    QString inctance; //  , 
1119
    QString className; //  
1120
    QString modelID; //  
1121
    QString add_filtr; //  
1122
    int field_ID;
1123
    int icon_field_index;
1124
    bool filtr_empty;
1125
    bool ok;
1126
    QSqlQuery q;
1127
    QString sql_str;
1128
    QString str_tmp;
1129
    QTreeWidgetItem * title_item;
1130
    QFont font;
1131
    QIcon icon;
1132
 
229 pingvin 1133
 
1134
 
1135
 
1136
 
228 pingvin 1137
    font.setBold(true);
1138
    filtr_empty = filtr.isEmpty();
1139
 
1140
    classID = model_item->text(1);
1141
    modelID = model_item->text(6);
1142
    add_filtr = MainWindow::getFiltrString(modelID, classID);
1143
 
1144
 
1145
    icon = model_item->icon(0);
1146
 
1147
    parentClassID = model_item->parent()->text(1);
1148
 
1149
    pointerField = getPointerFieldName(parentClassID, classID);
1150
 
1151
    className = model_item->text(0);
1152
    inctance = getClassInctance(classID);
1153
 
1154
    if  (!model_item->checkState(0)) return;
1155
 
1156
 
229 pingvin 1157
 
1158
 
1159
    QTextCharFormat charFormatItalic, charFormatBase;
1160
    //QFont font;
1161
    font.setBold(true);
1162
    font.setItalic(true);
1163
    //charFormatItalic.setFontItalic(true);
1164
    charFormatItalic.setFont(font);
1165
    //charFormatItalic.setFontWeight(16);
1166
    pos++;
1167
    for(int i=0; i<pos; i++){ cursor->insertText( tr(" "));}//  
1168
    cursor->insertText(className, charFormatItalic);
1169
    cursor->setCharFormat(charFormatBase);
228 pingvin 1170
    cursor->insertText(tr("\n"));
1171
 
229 pingvin 1172
 
1173
 
228 pingvin 1174
    sql_str = tr("select * "
1175
                 " from "       //      -   
1176
                 );
1177
    sql_str.append(inctance);
1178
 
1179
 
1180
    if (filtr.isEmpty() && (!add_filtr.isEmpty())) //  ,    
1181
                            {
1182
                                filtr.append(tr ("where "));
1183
                                filtr.append(add_filtr);
1184
                             }
1185
 
1186
 
1187
    if (!filtr.isEmpty())   { //    
1188
                                 sql_str.append(tr(" "));
1189
                                 sql_str.append(filtr); //    
1190
                            }
1191
 
1192
    q.prepare(sql_str);
1193
 
1194
    ok = q.exec();
1195
 
1196
    if (!ok) {
1197
                            QString debug_str;
1198
                            debug_str.append(tr(" showObjects(): Database Error "));
1199
                            debug_str.append(tr(" : "));
1200
                            debug_str.append(inctance);
1201
                            debug_str.append(tr(" : "));
1202
                            debug_str.append(filtr);
1203
                            debug_str.append(q.lastError().text());
1204
                            QMessageBox::critical( //     .
1205
                                                                            this,                      //  .
1206
                                                                            QObject::tr(" showObjects(): Database Error"),   // .
1207
                                                                            debug_str
1208
                                                                           // q.lastError().text()
1209
                                                                             );          //  .
1210
                                                                            return;
1211
                     }
1212
 
1213
    field_ID = q.record().indexOf(tr("ID"));
1214
 
1215
    icon_field_index = q.record().indexOf(tr("Icon"));
1216
 
229 pingvin 1217
    int k=0;
1218
    QStringList fieldsNamesList;//    
228 pingvin 1219
 
1220
 
1221
 
229 pingvin 1222
 
1223
    while(!q.record().fieldName(k).isEmpty()){//     
1224
        fieldsNamesList.append(q.record().fieldName(k++));
1225
    }
1226
 
1227
 
228 pingvin 1228
    while(q.next()){
1229
                  if (q.record().count() > 1)
1230
                  {
1231
                    QString value_tmp;
1232
                    QString ID_tmp;
1233
                    QString space;
1234
 
1235
                    // // // //                QTreeWidgetItem * itm;
1236
                    ID_tmp = q.value(field_ID).toString(); //   
1237
                    value_tmp = q.value(1).toString(); //    (    )
1238
               //     itm = new QTreeWidgetItem(parent_object_item); //    ,  
1239
 
1240
 
1241
 
1242
 
1243
                    /***************************
1244
                    itm = new QTreeWidgetItem(title_item); //    ,  
1245
                    itm->setText(0, value_tmp);
1246
                    itm->setText(1, tr("object"));
1247
                    itm->setText(2, ID_tmp);
1248
                    ******************************/
1249
 
1250
                    if  (icon_field_index != -1){ //     
1251
 
1252
                        QVariant data;
1253
                        QByteArray bytes;
1254
                        QPixmap pix;
1255
                        QIcon icn;
1256
                        QMap <QString, QPixmap> pixmap_map;
1257
                        QList <QString> id_list;
1258
                        QList <QPixmap> pixmap_list;
1259
                        pixmap_map = MainWindow::getObjectsIcon(inctance);
1260
                        if (!pixmap_map.isEmpty()) {
1261
                            id_list = pixmap_map.keys();
1262
                            pixmap_list =  pixmap_map.values();
1263
                        }
1264
                        if (id_list.indexOf(ID_tmp) != -1) {
1265
                            pix = pixmap_list.at(id_list.indexOf(ID_tmp));
1266
                        }
1267
                      // data = q.record().value(icon_field_index);
1268
                      //  bytes = q.record().value(icon_field_index).toByteArray();
1269
                        // if (data.isValid() && (!data.isNull())) {
1270
                     //   if (!bytes.isEmpty()){
1271
                        // pix.loadFromData(data.toByteArray());
1272
                        // pix.loadFromData(bytes);
1273
 
1274
 
1275
                    if(!pix.isNull())    {
1276
                            if (pix.height() > 128) pix = pix.scaledToHeight(128);
1277
                            QString fname = value_tmp;
1278
                            fname.append(tr(".png"));
1279
 
1280
 
1281
                            pix.toImage().save(fname);
1282
                            doc.addResource(QTextDocument::ImageResource, QUrl(fname), pix.toImage());
1283
 
1284
                        // for(int i=0; i<pos; i++){ cursor->insertText( tr(" "));}//  
1285
 
1286
 
229 pingvin 1287
                            for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}//  
228 pingvin 1288
                            cursor->insertImage(fname);
1289
                          //  cursor->insertText(tr("\n"));
1290
 
1291
                        }
229 pingvin 1292
                            else for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}//  
228 pingvin 1293
 
1294
 
1295
 
1296
 
1297
                        // // // icn.addPixmap(pix);
1298
                        // // // itm->setIcon(0, icn);
1299
                     //  }
1300
 
1301
 
1302
                    }
1303
 
229 pingvin 1304
                    else for(int i=0; i<pos+1; i++){ cursor->insertText( tr(" "));}//  
228 pingvin 1305
                    cursor->insertText( value_tmp);
1306
                    cursor->insertText( tr("\n"));
1307
 
229 pingvin 1308
 
1309
 
1310
 
1311
                    if(advanced){ //   
1312
 
1313
                        sql_str.clear();
1314
 
1315
 
1316
 
1317
                    }
1318
 
1319
 
1320
 
1321
                    /********************************************************
1322
                    textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
1323
                                 cursor->setBlockFormat(textFormat);
1324
 
1325
                                 cursor->insertText(tr("  "));
1326
                                 cursor->insertBlock();
1327
 
1328
                                 textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto);
1329
                                 cursor->setBlockFormat(textFormat);
1330
                    **********************************************************/
1331
 
1332
 
228 pingvin 1333
//                    itm->setIcon(0, icon);
1334
 
1335
 
1336
                    for (int i=0; i < model_item->childCount(); i++) // ,      
1337
                    {
1338
                        QTreeWidgetItem * model_item_tmp;           //  
1339
                        QString pointer_name;
1340
                        QString filtr_tmp;
1341
                        bool pointer_isEmpty;
1342
                        model_item_tmp = model_item->child(i);      //    
1343
                        pointer_name = getPointerFieldName(classID, model_item->child(i)->text(1));
1344
                        // // // // itm->setText(4, pointer_name);
1345
 
1346
                      //  title_item->setText(4, pointer_name);
1347
 
1348
 
1349
                        pointer_isEmpty = pointer_name.isEmpty();
1350
                        filtr_tmp = tr("where ");
1351
                        filtr_tmp.append(tr("`"));
1352
                        filtr_tmp.append(pointer_name);
1353
                        filtr_tmp.append(tr("` = '"));
1354
                        filtr_tmp.append(ID_tmp);
1355
                         filtr_tmp.append(tr("'"));
229 pingvin 1356
 
1357
                         printChild(model_item_tmp, filtr_tmp, advanced,  pos+1);
1358
 
228 pingvin 1359
                        // // // // showObjects(itm,  model_item_tmp, filtr_tmp);
1360
                        //MainWindow::showObjectChildrens(ID_tmp, itm, model_item_tmp);
1361
 
1362
                    }
1363
 
1364
 
1365
                }
1366
 
1367
              }
1368
 
1369
 
1370
 
1371
 
1372
 
1373
 
1374
 
1375
 
1376
 
1377
 
1378
}
1379
 
1380
 
229 pingvin 1381
void  MainWindow::newPage(int page_number){ //    
1382
 
1383
    QTextBlockFormat textFormat;
1384
           textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
1385
                        cursor->setBlockFormat(textFormat);
1386
 
1387
                        cursor->insertText(tr("  %1").arg(page_number));
1388
                        cursor->insertBlock();
1389
 
1390
                        textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto);
1391
                        cursor->setBlockFormat(textFormat);
1392
 
1393
 
1394
}
1395
void  MainWindow::newPage(){ //    
1396
 
1397
    QTextBlockFormat textFormat;
1398
           textFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
1399
                        cursor->setBlockFormat(textFormat);
1400
 
1401
                        //cursor->insertText(tr("  %1").arg(page_number));
1402
                        cursor->insertBlock();
1403
 
1404
                        textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto);
1405
                        cursor->setBlockFormat(textFormat);
1406
 
1407
 
1408
}