/
kf.cpp
121 lines (112 loc) · 3.22 KB
/
kf.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//========
//function window
#include "d.h"
#include "kf.h"
#include "ui_kf.h"
//=========
#include "ksetup.h"
//#include "kwaterplant.h"
//=========
kf::kf(QWidget *parent) :
QDialog(parent),
ui(new Ui::kf){
init=true;
ctadd(tf,ctf);
ui->setupUi(this);
setWindowTitle(parent->windowTitle());
setWindowFlags(windowFlags()|Qt::WindowMinMaxButtonsHint);
ui->ggf->gorow(0);
}
//=========
kf::~kf(){
delete ui;
ctdel(tf,ctf);
}
//fill kf with data
void kf::kfinit(){
if (init) {
//load connection type
int li=dsi("select data from setup where id=1");
if (ui->cbc->count()>li) {ui->cbc->setCurrentIndex(li);}
init=false;
//when debug to skip menu
QTimer::singleShot(500,this,SLOT(kopen()));
}
}
//open function window
void kf::kopen(){
int li=ui->ggf->currentIndex().row();
QDialog *lf=0;
if (li>=0) {lf=tf->r[ui->ggf->m->gri(li)].f;}
if (lf) {
lf->activateWindow();
} else {
uint lf_i=tf->r[ui->ggf->m->gri(li)].f_i;
setDisabled(true);
//==============
QWidget * lp = static_cast<QWidget *>(this->parent());
switch (lf_i) {
//!!just comment line if you won't compile or use punkt menu
case 0: lf=new ksetup(lp,lf_i);break;
// case 1: lf=new kwaterplant(lp,lf_i);break;
default: {
setDisabled(false);
activateWindow();
ui->etf->setFocus();
return;
}
}
//===============
//ui->ggf->saveopen(lf);
if (li>=0) {tf->r[ui->ggf->m->gri(li)].f=lf;}
lf->setAttribute(Qt::WA_DeleteOnClose);
lf->setWindowTitle(
ui->ggf->model()->data(
ui->ggf->model()->index(ui->ggf->selectionModel()->currentIndex().row(),0)
).toString()
);
lf->setWindowFlags(lf->windowFlags()|Qt::WindowMinMaxButtonsHint);
//
connect(lf,SIGNAL(markzero(uint)),this,SLOT(markzero(uint)));
connect(lf,SIGNAL(kfshow()),this,SLOT(kfshow()));
//show centered and maximized
lf->showMaximized();
setDisabled(false);
}
//sp(itos(ui->dgfmenu->selectionModel()->currentIndex().row()));
}
//mark zero when window closed
void kf::markzero(uint lf_i){
//ui->ggf->markzero(lf_i);
//find row with lf_i and make f=0
int lj=tf->rows;int li=-1;
for(std::vector<ctf::rs>::iterator it = tf->r.begin(); ++li<lj; ++it) {
if ((*it).f_i==lf_i) {(*it).f=0;break;}
}
}
void kf::etfsetfocus(){ui->etf->setFocus();}
void kf::ksavecon(int li){
if (!init) {du("update setup set data=? where id="+itos(1),li);}
}
void kf::etfchanged(QString ls){
//etf changed -> find similar
if (ui->ggf->m) {
//sp(ls);
int lr=0;
int li=ls.length();
if (li>0) {
li=0;
ls=ls.toLower();
int ln=ui->ggf->m->rowCount();
while (li<ln){
QString ls1=tf->r[ui->ggf->m->gri(li)].f_name;
if (ls1.indexOf(ls,0,Qt::CaseInsensitive)==0){
lr=li;
break;
}
li++;
}
}
ui->ggf->gorow(lr);
}
}