-
Notifications
You must be signed in to change notification settings - Fork 0
/
InsertLineForm.cpp
112 lines (97 loc) · 3.15 KB
/
InsertLineForm.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
/**
* @file InsertLineForm.cpp
* @author Anil Kumar
* @date 7-11-2023
* @brief This InsertLineForm class, It's UI of table column name and its value.
*/
#include "InsertLineForm.h"
#include "ui_InsertLineForm.h"
/**
* @brief InsertLineForm::InsertLineForm
* @param parent
* @param str
* @param typ
* @param limit
*/
InsertLineForm::InsertLineForm(QWidget *parent,QString str,QString typ, int limit) :
QWidget(parent),
ui(new Ui::InsertLineForm)
{
ui->setupUi(this);
ui->label_Tag->setText(str);
// str_type = typ;
if(typ.toLower()=="varchar"||typ.toLower()=="char")
{
QRegExp rx("([A-Za-z0-9@. -/:]){"+QString::number(limit)+"}");
ui->lineEdit_Value->setValidator(new QRegExpValidator(rx, this));
ui->lineEdit_Value->setPlaceholderText("Max. Char("+QString::number(limit)+")");
}
else if(typ.toLower()=="int")
{
QRegExp rx("([0-9]){"+QString::number(limit)+"}");
ui->lineEdit_Value->setValidator(new QRegExpValidator(rx, this));
ui->lineEdit_Value->setPlaceholderText("Max. int("+QString::number(limit)+")");
}
else if(typ.toLower()=="tinyint")
{
QRegExp rx("([0-9]){1}");
ui->lineEdit_Value->setValidator(new QRegExpValidator(rx, this));
ui->lineEdit_Value->setPlaceholderText("Max. tinyint("+QString::number(limit)+")");
}
else if(typ.toLower()=="float")
{
QRegExp rx("([0-9.]){"+QString::number(limit)+"}");
ui->lineEdit_Value->setValidator(new QRegExpValidator(rx, this));
ui->lineEdit_Value->setPlaceholderText("Max. float("+QString::number(limit)+")");
}
else if(typ=="enum('N','Y')")
{
QRegExp rx("([NnYy]){"+QString::number(limit)+"}");
ui->lineEdit_Value->setValidator(new QRegExpValidator(rx, this));
ui->lineEdit_Value->setPlaceholderText("Only (Y/N)("+QString::number(limit)+")");
}
else if(typ.toLower()=="timestamp")
{
QRegExp rx("([0-9]){"+QString::number(limit)+"}");
ui->lineEdit_Value->setValidator(new QRegExpValidator(rx, this));
ui->lineEdit_Value->setPlaceholderText("Max. timestamp("+QString::number(limit)+")");
}
else if(typ.toLower()=="smallint")
{
QRegExp rx("([0-9]){"+QString::number(limit)+"}");
ui->lineEdit_Value->setValidator(new QRegExpValidator(rx, this));
ui->lineEdit_Value->setPlaceholderText("Max. smallint("+QString::number(limit)+")");
}
else if(typ.toLower()=="bigint")
{
QRegExp rx("([0-9]){"+QString::number(limit)+"}");
ui->lineEdit_Value->setValidator(new QRegExpValidator(rx, this));
ui->lineEdit_Value->setPlaceholderText("Max. bigint("+QString::number(limit)+")");
}
}
/**
* @brief InsertLineForm::~InsertLineForm
*/
InsertLineForm::~InsertLineForm()
{
delete ui;
}
/**
* @brief InsertLineForm::m_GetcNameValue
* @return
*/
QString InsertLineForm::m_GetcNameValue()
{
return ui->label_Tag->text();
}
/**
* @brief InsertLineForm::m_GetTypeValue
* @return
*/
QString InsertLineForm::m_GetTypeValue()
{
if(ui->lineEdit_Value->text().size())
return ui->lineEdit_Value->text();
else
return "0";
}