forked from avartak/TkCommissioner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmdbtag.h
71 lines (54 loc) · 1.77 KB
/
frmdbtag.h
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
#ifndef TAGCREATOR_H
#define TAGCREATOR_H
// Qt includes
#include <QValidator>
#include <QRegExpValidator>
#include <QRegExp>
#include <QMessageBox>
#include <QTextStream>
#include <QString>
#include <QPushButton>
#include <QDialogButtonBox>
#include <QtSql/QSqlQuery>
// Debug output
#include "Debug.h"
#include "DbConnection.h"
// UI file
#include "ui_frmdbtag.h"
class TagCreator : public QDialog, private Ui::TagCreator {
Q_OBJECT
public:
TagCreator(QWidget *parent = 0) {
Q_UNUSED(parent);
setupUi(this);
btnBox->button( QDialogButtonBox::Ok )->setEnabled(false);
QRegExp rx( "^[a-z0-9\\s]{1,99}$" );
rx.setCaseSensitivity(Qt::CaseInsensitive);
QValidator* validator = new QRegExpValidator( rx, this );
tagLine->setValidator( validator );
connect(btnBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(btnBox, SIGNAL(rejected()), this, SLOT(reject()));
}
~TagCreator() {
}
public Q_SLOTS:
void on_tagLine_textChanged(const QString &) {
QString t = tagLine->text();
int p = 0;
bool on = (tagLine->validator()->validate(t, p) == QValidator::Acceptable);
btnBox->button( QDialogButtonBox::Ok )->setEnabled(on);
}
void accept() {
if (Debug::Inst()->getEnabled()) qDebug() << "Creating new DB Tag";
QString squery;
QTextStream myQuery(&squery);
myQuery << "BEGIN PkgTkAnalysisLog.addTagDescription('" << tagLine->text() << "'); END;";
QSqlQuery query;
query.prepare(squery);
query.exec();
}
void reject() {
done(0);
}
};
#endif