Редакция 39 | Редакция 41 | К новейшей редакции | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 39 | Редакция 40 | ||
---|---|---|---|
1 | #include "classeditor.h"
|
1 | #include "classeditor.h"
|
2 | #include "ui_classeditor.h"
|
2 | #include "ui_classeditor.h"
|
3 | 3 | ||
4 | ClassEditor::ClassEditor(QWidget *parent) : |
4 | ClassEditor::ClassEditor(QWidget *parent) : |
5 | QMainWindow(parent), |
5 | QMainWindow(parent), |
6 | ui(new Ui::ClassEditor) |
6 | ui(new Ui::ClassEditor) |
7 | {
|
7 | {
|
8 | ui->setupUi(this); |
8 | ui->setupUi(this); |
9 | // settdialog = new SettingsDialog(this);
|
9 | // settdialog = new SettingsDialog(this);
|
10 | settdialog.show(); |
10 | settdialog.show(); |
11 | sql.setDatabaseName(tr("an_db")); |
11 | sql.setDatabaseName(tr("an_db")); |
12 | field = new TableField(tr("Ñîòðóäíèêè"), this); |
12 | field = new TableField(tr("Ñîòðóäíèêè"), this); |
13 | field->setNotNull(true); |
13 | field->setNotNull(true); |
14 | field->setDefaultValue(tr("ñîòðóäíèê")); |
14 | field->setDefaultValue(tr("ñîòðóäíèê")); |
15 | 15 | ||
16 | table = new SqlTable (tr("NewTable"), this); |
16 | table = new SqlTable (tr("NewTable"), this); |
17 | table->setName(tr("NewTable")); |
17 | table->setName(tr("NewTable")); |
18 | table->fields().at(0)->setNotNull(true); |
18 | table->fields().at(0)->setNotNull(true); |
19 | if (!(table->setPrimaryKey(tr("ID")))) { |
19 | if (!(table->setPrimaryKey(tr("ID")))) { |
20 | ui->label_3->setText(table->lastError()); |
20 | ui->label_3->setText(table->lastError()); |
21 | }
|
21 | }
|
22 | else ui->label_3->setText(table->primaryKey()); |
22 | else ui->label_3->setText(table->primaryKey()); |
23 | table->append(field); |
23 | table->append(field); |
24 | 24 | ||
25 | field = new TableField(tr("Êîìïüþòåðû"), this); |
25 | field = new TableField(tr("Êîìïüþòåðû"), this); |
26 | field->setNotNull(true); |
26 | field->setNotNull(true); |
27 | field->setDefaultValue(tr("êîìïüþòåð")); |
27 | field->setDefaultValue(tr("êîìïüþòåð")); |
28 | table->append(field); |
28 | table->append(field); |
29 | 29 | ||
- | 30 | field = new TableField(tr("Ìîíèòîðû"), this); |
|
- | 31 | field->setNotNull(true); |
|
- | 32 | field->setDefaultValue(tr("ìîíèòîð")); |
|
- | 33 | table->append(field); |
|
- | 34 | ||
- | 35 | field = new TableField(tr("Êîëè÷åñòâî (øòóê)"), this); |
|
- | 36 | field->setNotNull(true); |
|
- | 37 | field->setType(tr("INTEGER")); |
|
- | 38 | field->setDefaultValue(tr("1")); |
|
- | 39 | table->append(field); |
|
- | 40 | ||
- | 41 | field = new TableField(tr("Äåíü ðîæäåíèÿ"), this); |
|
- | 42 | field->setNotNull(false); |
|
- | 43 | field->setType(tr("DATE")); |
|
- | 44 | field->setDefaultValue(tr("NULL")); |
|
- | 45 | table->append(field); |
|
- | 46 | ||
30 | ui->label_2->setText(table->name()); |
47 | ui->label_2->setText(table->name()); |
31 | ui->label->setText(table->fields().at(0)->sqlString()); |
48 | ui->label->setText(table->fields().at(0)->sqlString()); |
32 | ui->label_4->setText(table->sqlString()); |
49 | ui->label_4->setText(table->sqlString()); |
33 | ui->lineEdit->insert(table->sqlString()); |
50 | ////// ui->lineEdit->insert(table->sqlString());
|
- | 51 | ||
- | 52 | QTextDocument *document; |
|
- | 53 | // = ui->textEdit->document();
|
|
- | 54 | QTextCursor *cursor; |
|
- | 55 | document = ui->textEdit->document(); |
|
- | 56 | cursor = new QTextCursor(document); |
|
- | 57 | cursor->movePosition(QTextCursor::Start); |
|
- | 58 | QTextCharFormat format(cursor->charFormat()); |
|
- | 59 | //format.setFontFamily("Courier");
|
|
- | 60 | format.setFontFamily("Arial"); |
|
- | 61 | //format.setFontItalic(false);
|
|
- | 62 | ||
- | 63 | format.setFontWeight(QFont::Normal); |
|
- | 64 | QTextCharFormat boldFormat = format; |
|
- | 65 | boldFormat.setFontWeight(QFont::Bold); |
|
- | 66 | ||
- | 67 | QTextCharFormat italicFormat = format; |
|
- | 68 | //format.setFontFamily("Courier");
|
|
- | 69 | // format.setFontFamily("Arial");
|
|
- | 70 | italicFormat.setFontItalic(true); |
|
34 | 71 | ||
- | 72 | cursor->insertText(table->sqlString(), format); |
|
35 | }
|
73 | }
|
36 | 74 | ||
37 | ClassEditor::~ClassEditor() |
75 | ClassEditor::~ClassEditor() |
38 | {
|
76 | {
|
39 | delete ui; |
77 | delete ui; |
40 | // delete field;
|
78 | // delete field;
|
41 | // delete settdialog;
|
79 | // delete settdialog;
|
42 | }
|
80 | }
|
43 | 81 | ||
44 | void ClassEditor::changeEvent(QEvent *e) |
82 | void ClassEditor::changeEvent(QEvent *e) |
45 | {
|
83 | {
|
46 | QMainWindow::changeEvent(e); |
84 | QMainWindow::changeEvent(e); |
47 | switch (e->type()) { |
85 | switch (e->type()) { |
48 | case QEvent::LanguageChange: |
86 | case QEvent::LanguageChange: |
49 | ui->retranslateUi(this); |
87 | ui->retranslateUi(this); |
50 | break; |
88 | break; |
51 | default: |
89 | default: |
52 | break; |
90 | break; |
53 | }
|
91 | }
|
54 | }
|
92 | }
|
55 | 93 |