Редакция 60 | Редакция 62 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 60 | Редакция 61 | ||
---|---|---|---|
1 | #include "classeditor.h"
|
1 | #include "classeditor.h"
|
2 | #include "ui_classeditor.h"
|
2 | #include "ui_classeditor.h"
|
3 | 3 | ||
4 | 4 | ||
5 | ClassEditor::ClassEditor(QWidget *parent) : |
5 | ClassEditor::ClassEditor(QWidget *parent) : |
6 | QMainWindow(parent), |
6 | QMainWindow(parent), |
7 | ui(new Ui::ClassEditor) |
7 | ui(new Ui::ClassEditor) |
8 | {
|
8 | {
|
9 | ui->setupUi(this); |
9 | ui->setupUi(this); |
10 | 10 | ||
11 | 11 | ||
12 | 12 | ||
13 | // settdialog = new SettingsDialog(this);
|
13 | // settdialog = new SettingsDialog(this);
|
14 | ///////////////////////////////////////////////////// settdialog.show();
|
14 | ///////////////////////////////////////////////////// settdialog.show();
|
15 | sql.setDatabaseName(tr("an_db")); |
15 | sql.setDatabaseName(tr("an_db")); |
16 | 16 | ||
17 | /*
|
17 | /*
|
18 | field = new TableField(tr("Ñîòðóäíèêè"), this);
|
18 | field = new TableField(tr("Ñîòðóäíèêè"), this);
|
19 | field->setNotNull(true);
|
19 | field->setNotNull(true);
|
20 | field->setDefaultValue(tr("ñîòðóäíèê"));
|
20 | field->setDefaultValue(tr("ñîòðóäíèê"));
|
21 | 21 | ||
22 | table = new SqlTable (tr("NewTable"), this);
|
22 | table = new SqlTable (tr("NewTable"), this);
|
23 | table->setName(tr("NewTable"));
|
23 | table->setName(tr("NewTable"));
|
24 | table->fields().at(0)->setNotNull(true);
|
24 | table->fields().at(0)->setNotNull(true);
|
25 | if (!(table->setPrimaryKey(tr("ID")))) {
|
25 | if (!(table->setPrimaryKey(tr("ID")))) {
|
26 | ui->label_3->setText(table->lastError());
|
26 | ui->label_3->setText(table->lastError());
|
27 | }
|
27 | }
|
28 | else ui->label_3->setText(table->primaryKey());
|
28 | else ui->label_3->setText(table->primaryKey());
|
29 | table->append(field);
|
29 | table->append(field);
|
30 | 30 | ||
31 | field = new TableField(tr("Êîìïüþòåðû"), this);
|
31 | field = new TableField(tr("Êîìïüþòåðû"), this);
|
32 | field->setNotNull(true);
|
32 | field->setNotNull(true);
|
33 | field->setDefaultValue(tr("êîìïüþòåð"));
|
33 | field->setDefaultValue(tr("êîìïüþòåð"));
|
34 | table->append(field);
|
34 | table->append(field);
|
35 | 35 | ||
36 | field = new TableField(tr("Ìîíèòîðû"), this);
|
36 | field = new TableField(tr("Ìîíèòîðû"), this);
|
37 | field->setNotNull(true);
|
37 | field->setNotNull(true);
|
38 | field->setDefaultValue(tr("ìîíèòîð"));
|
38 | field->setDefaultValue(tr("ìîíèòîð"));
|
39 | table->append(field);
|
39 | table->append(field);
|
40 | 40 | ||
41 | field = new TableField(tr("Êîëè÷åñòâî (øòóê)"), this);
|
41 | field = new TableField(tr("Êîëè÷åñòâî (øòóê)"), this);
|
42 | field->setNotNull(true);
|
42 | field->setNotNull(true);
|
43 | field->setType(tr("INTEGER"));
|
43 | field->setType(tr("INTEGER"));
|
44 | field->setDefaultValue(tr("1"));
|
44 | field->setDefaultValue(tr("1"));
|
45 | table->append(field);
|
45 | table->append(field);
|
46 | 46 | ||
47 | field = new TableField(tr("Äåíü ðîæäåíèÿ"), this);
|
47 | field = new TableField(tr("Äåíü ðîæäåíèÿ"), this);
|
48 | field->setNotNull(false);
|
48 | field->setNotNull(false);
|
49 | field->setType(tr("DATE"));
|
49 | field->setType(tr("DATE"));
|
50 | field->setDefaultValue(tr("NULL"));
|
50 | field->setDefaultValue(tr("NULL"));
|
51 | table->append(field);
|
51 | table->append(field);
|
52 | 52 | ||
53 | ui->label_2->setText(table->name());
|
53 | ui->label_2->setText(table->name());
|
54 | ui->label->setText(table->fields().at(0)->sqlString());
|
54 | ui->label->setText(table->fields().at(0)->sqlString());
|
55 | ui->label_4->setText(table->sqlString());
|
55 | ui->label_4->setText(table->sqlString());
|
56 | ////// ui->lineEdit->insert(table->sqlString());
|
56 | ////// ui->lineEdit->insert(table->sqlString());
|
57 | 57 | ||
58 | */
|
58 | */
|
59 | /**********************************************
|
59 | /**********************************************
|
60 | 60 | ||
61 | QTextDocument *document;
|
61 | QTextDocument *document;
|
62 | // = ui->textEdit->document();
|
62 | // = ui->textEdit->document();
|
63 | QTextCursor *cursor;
|
63 | QTextCursor *cursor;
|
64 | 64 | ||
65 | document = ui->textEdit->document();
|
65 | document = ui->textEdit->document();
|
66 | cursor = new QTextCursor(document);
|
66 | cursor = new QTextCursor(document);
|
67 | cursor->movePosition(QTextCursor::Start);
|
67 | cursor->movePosition(QTextCursor::Start);
|
68 | QTextCharFormat format(cursor->charFormat());
|
68 | QTextCharFormat format(cursor->charFormat());
|
69 | //format.setFontFamily("Courier");
|
69 | //format.setFontFamily("Courier");
|
70 | format.setFontFamily("Arial");
|
70 | format.setFontFamily("Arial");
|
71 | //format.setFontItalic(false);
|
71 | //format.setFontItalic(false);
|
72 | 72 | ||
73 | format.setFontWeight(QFont::Normal);
|
73 | format.setFontWeight(QFont::Normal);
|
74 | QTextCharFormat boldFormat = format;
|
74 | QTextCharFormat boldFormat = format;
|
75 | boldFormat.setFontWeight(QFont::Bold);
|
75 | boldFormat.setFontWeight(QFont::Bold);
|
76 | 76 | ||
77 | QTextCharFormat italicFormat = format;
|
77 | QTextCharFormat italicFormat = format;
|
78 | //format.setFontFamily("Courier");
|
78 | //format.setFontFamily("Courier");
|
79 | // format.setFontFamily("Arial");
|
79 | // format.setFontFamily("Arial");
|
80 | italicFormat.setFontItalic(true);
|
80 | italicFormat.setFontItalic(true);
|
81 | 81 | ||
82 | cursor->insertText(table->sqlString(), format);
|
82 | cursor->insertText(table->sqlString(), format);
|
83 | 83 | ||
84 | ****************************************************/
|
84 | ****************************************************/
|
85 | 85 | ||
86 | QString errorString;
|
86 | QString errorString;
|
87 | 87 | ||
88 | sql.setDatabaseName(tr("an_db")); |
88 | sql.setDatabaseName(tr("an_db")); |
89 | sql.setHostName(tr("localhost")); |
89 | sql.setHostName(tr("localhost")); |
90 | sql.setUserName(tr("an")); |
90 | sql.setUserName(tr("an")); |
91 | sql.setPassword(tr("393939")); |
91 | sql.setPassword(tr("393939")); |
92 | 92 | ||
93 | bool ok; |
93 | bool ok; |
94 | ok = sql.connect(); |
94 | ok = sql.connect(); |
95 | if (!ok) { |
95 | if (!ok) { |
96 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
96 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
97 | this, // Ðîäèòåëüñêèé âèäæåò. |
97 | this, // Ðîäèòåëüñêèé âèäæåò. |
98 | QObject::tr("Database Error"), // Çàãîëîâîê. |
98 | QObject::tr("Database Error"), // Çàãîëîâîê. |
99 | sql.lasError()); // Òåêñò ñîîáùåíèÿ. |
99 | sql.lasError()); // Òåêñò ñîîáùåíèÿ. |
100 | 100 | ||
101 | }
|
101 | }
|
102 | else { |
102 | else { |
103 | 103 | ||
104 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
104 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
105 | this, // Ðîäèòåëüñêèé âèäæåò. |
105 | this, // Ðîäèòåëüñêèé âèäæåò. |
106 | QObject::tr("Database Connect"), // Çàãîëîâîê. |
106 | QObject::tr("Database Connect"), // Çàãîëîâîê. |
107 | QObject::tr("Ñîåäèíåíèå ñ áàçîé äàííûõ óñïåøíî óñòàíîâëåíî.")); // Òåêñò ñîîáùåíèÿ. |
107 | QObject::tr("Ñîåäèíåíèå ñ áàçîé äàííûõ óñïåøíî óñòàíîâëåíî.")); // Òåêñò ñîîáùåíèÿ. |
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | }
|
113 | }
|
114 | 114 | ||
115 | /*
|
115 | /*
|
116 | ok = sql.createTable(table);
|
116 | ok = sql.createTable(table);
|
117 | if (!ok) {
|
117 | if (!ok) {
|
118 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
118 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
119 | this, // Ðîäèòåëüñêèé âèäæåò.
|
119 | this, // Ðîäèòåëüñêèé âèäæåò.
|
120 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
120 | QObject::tr("Database Error"), // Çàãîëîâîê.
|
121 | sql.lasError()); // Òåêñò ñîîáùåíèÿ.
|
121 | sql.lasError()); // Òåêñò ñîîáùåíèÿ.
|
122 | }
|
122 | }
|
123 | else {
|
123 | else {
|
124 | 124 | ||
125 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
125 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
|
126 | this, // Ðîäèòåëüñêèé âèäæåò.
|
126 | this, // Ðîäèòåëüñêèé âèäæåò.
|
127 | QObject::tr("Database Connect"), // Çàãîëîâîê.
|
127 | QObject::tr("Database Connect"), // Çàãîëîâîê.
|
128 | QObject::tr("Òàáëèöà â áàçå äàííûõ óñïåøíî ñîçäàíà.")); // Òåêñò ñîîáùåíèÿ.
|
128 | QObject::tr("Òàáëèöà â áàçå äàííûõ óñïåøíî ñîçäàíà.")); // Òåêñò ñîîáùåíèÿ.
|
129 | }
|
129 | }
|
130 | 130 | ||
131 | 131 | ||
132 | 132 | ||
133 | */
|
133 | */
|
134 | 134 | ||
135 | ok = sql.createListOfClassesTable(); |
135 | ok = sql.createListOfClassesTable(); |
136 | 136 | ||
137 | if (!ok) { |
137 | if (!ok) { |
138 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
138 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
139 | this, // Ðîäèòåëüñêèé âèäæåò. |
139 | this, // Ðîäèòåëüñêèé âèäæåò. |
140 | QObject::tr("Database Error"), // Çàãîëîâîê. |
140 | QObject::tr("Database Error"), // Çàãîëîâîê. |
141 | sql.lasError()); // Òåêñò ñîîáùåíèÿ. |
141 | sql.lasError()); // Òåêñò ñîîáùåíèÿ. |
142 | 142 | ||
143 | }
|
143 | }
|
144 | else { |
144 | else { |
145 | 145 | ||
146 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
146 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
147 | this, // Ðîäèòåëüñêèé âèäæåò. |
147 | this, // Ðîäèòåëüñêèé âèäæåò. |
148 | QObject::tr("Database Create"), // Çàãîëîâîê. |
148 | QObject::tr("Database Create"), // Çàãîëîâîê. |
149 | QObject::tr("Áàçà äàííûõ óñïåøíî ñîçäàíà.")); // Òåêñò ñîîáùåíèÿ. |
149 | QObject::tr("Áàçà äàííûõ óñïåøíî ñîçäàíà.")); // Òåêñò ñîîáùåíèÿ. |
150 | }
|
150 | }
|
151 | 151 | ||
152 | 152 | ||
153 | 153 | ||
154 | 154 | ||
155 | ok = sql.createDescriptionOfClassesTable(); |
155 | ok = sql.createDescriptionOfClassesTable(); |
156 | 156 | ||
157 | if (!ok) { |
157 | if (!ok) { |
158 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
158 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
159 | this, // Ðîäèòåëüñêèé âèäæåò. |
159 | this, // Ðîäèòåëüñêèé âèäæåò. |
160 | QObject::tr("Database Error"), // Çàãîëîâîê. |
160 | QObject::tr("Database Error"), // Çàãîëîâîê. |
161 | sql.lasError()); // Òåêñò ñîîáùåíèÿ. |
161 | sql.lasError()); // Òåêñò ñîîáùåíèÿ. |
162 | 162 | ||
163 | }
|
163 | }
|
164 | else { |
164 | else { |
165 | 165 | ||
166 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
166 | QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
167 | this, // Ðîäèòåëüñêèé âèäæåò. |
167 | this, // Ðîäèòåëüñêèé âèäæåò. |
168 | QObject::tr("Database Create"), // Çàãîëîâîê. |
168 | QObject::tr("Database Create"), // Çàãîëîâîê. |
169 | QObject::tr("Áàçà äàííûõ óñïåøíî ñîçäàíà.")); // Òåêñò ñîîáùåíèÿ. |
169 | QObject::tr("Áàçà äàííûõ óñïåøíî ñîçäàíà.")); // Òåêñò ñîîáùåíèÿ. |
170 | }
|
170 | }
|
171 | 171 | ||
172 | 172 | ||
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | ||
177 | 177 | ||
178 | /////////////////model = new QSqlTableModel(this);
|
178 | /////////////////model = new QSqlTableModel(this);
|
179 | mymodel = new MyModel(this); |
179 | mymodel = new MyModel(this); |
180 | modelForDescription = new QSqlTableModel(this); |
180 | //modelForDescription = new QSqlTableModel(this);
|
- | 181 | modelForDescription = new ModelForDescriptionTable(this); |
|
- | 182 | ||
181 | 183 | ||
182 | /////////////////model->setTable(tr("ListOfClasses"));
|
184 | /////////////////model->setTable(tr("ListOfClasses"));
|
183 | mymodel->setTable(tr("ListOfClasses")); |
185 | mymodel->setTable(tr("ListOfClasses")); |
184 | modelForDescription->setTable(tr("DescriptionOfClasses")); |
186 | modelForDescription->setTable(tr("DescriptionOfClasses")); |
185 | modelForDescription->setEditStrategy(QSqlTableModel::OnFieldChange); |
187 | modelForDescription->setEditStrategy(QSqlTableModel::OnFieldChange); |
186 | 188 | ||
187 | /////model->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
189 | /////model->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
188 | 190 | ||
189 | /*
|
191 | /*
|
190 | model->setEditStrategy(QSqlTableModel::OnFieldChange);
|
192 | model->setEditStrategy(QSqlTableModel::OnFieldChange);
|
191 | mymodel->setEditStrategy(QSqlTableModel::OnFieldChange);
|
193 | mymodel->setEditStrategy(QSqlTableModel::OnFieldChange);
|
192 | */
|
194 | */
|
193 | 195 | ||
194 | 196 | ||
195 | //////////////////model->setSort(0, Qt::AscendingOrder);
|
197 | //////////////////model->setSort(0, Qt::AscendingOrder);
|
196 | mymodel->setSort(0, Qt::AscendingOrder); |
198 | mymodel->setSort(0, Qt::AscendingOrder); |
197 | modelForDescription->setSort(0, Qt::AscendingOrder); |
199 | modelForDescription->setSort(0, Qt::AscendingOrder); |
198 | 200 | ||
199 | 201 | ||
200 | // model->setFilter(tr("Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = '7' and Èíâåíòàðíûé_íîìåð = 'i09090909'"));
|
202 | // model->setFilter(tr("Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = '7' and Èíâåíòàðíûé_íîìåð = 'i09090909'"));
|
201 | ////////////////////model->select();
|
203 | ////////////////////model->select();
|
202 | mymodel->select(); |
204 | mymodel->select(); |
203 | modelForDescription->setFilter(tr("ClassIdentifer = 1")); |
205 | modelForDescription->setFilter(tr("ClassIdentifer = 1")); |
204 | modelForDescription->select(); |
206 | modelForDescription->select(); |
205 | 207 | ||
206 | 208 | ||
207 | /////////////////////////model->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà"));
|
209 | /////////////////////////model->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà"));
|
208 | mymodel->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà")); |
210 | mymodel->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà")); |
209 | 211 | ||
210 | 212 | ||
211 | 213 | ||
212 | ////////////////////////model->setHeaderData(2, Qt::Horizontal, tr("Ïñåâäîíèì êëàññà"));
|
214 | ////////////////////////model->setHeaderData(2, Qt::Horizontal, tr("Ïñåâäîíèì êëàññà"));
|
213 | mymodel->setHeaderData(2, Qt::Horizontal, tr("Ïñåâäîíèì êëàññà")); |
215 | mymodel->setHeaderData(2, Qt::Horizontal, tr("Ïñåâäîíèì êëàññà")); |
214 | mymodel->setHeaderData(4, Qt::Horizontal, tr("Êîìåíòàðèé")); |
216 | mymodel->setHeaderData(4, Qt::Horizontal, tr("Êîìåíòàðèé")); |
215 | 217 | ||
216 | //ui->tableView->setModel(model);
|
218 | //ui->tableView->setModel(model);
|
217 | ui->tableView->setModel(mymodel); |
219 | ui->tableView->setModel(mymodel); |
218 | //tableForDescription = new QTableView();
|
220 | //tableForDescription = new QTableView();
|
219 | ui->tableView_2->setModel(modelForDescription); |
221 | ui->tableView_2->setModel(modelForDescription); |
220 | ui->tableView_2->setAlternatingRowColors(true); |
222 | ui->tableView_2->setAlternatingRowColors(true); |
221 | ui->tableView_2->resizeColumnsToContents(); |
223 | ui->tableView_2->resizeColumnsToContents(); |
222 | //tableForDescription->show();
|
224 | //tableForDescription->show();
|
223 | 225 | ||
224 | 226 | ||
225 | ui->tableView->setAlternatingRowColors(true); |
227 | ui->tableView->setAlternatingRowColors(true); |
226 | ui->tableView->resizeColumnsToContents(); |
228 | ui->tableView->resizeColumnsToContents(); |
227 | ui->tableView->hideColumn(0); |
229 | ui->tableView->hideColumn(0); |
228 | ui->tableView->hideColumn(3); |
230 | ui->tableView->hideColumn(3); |
229 | ui->tableView->hideColumn(2); |
231 | ui->tableView->hideColumn(2); |
230 | 232 | ||
231 | 233 | ||
232 | //connect(ui->tableView, SIGNAL(clicked(const QModelIndex)), this, SLOT(on_tableView_clicked(const QModelIndex)));
|
234 | //connect(ui->tableView, SIGNAL(clicked(const QModelIndex)), this, SLOT(on_tableView_clicked(const QModelIndex)));
|
233 | }
|
235 | }
|
234 | 236 | ||
235 | 237 | ||
236 | 238 | ||
237 | 239 | ||
238 | 240 | ||
239 | 241 | ||
240 | 242 | ||
241 | 243 | ||
242 | 244 | ||
243 | 245 | ||
244 | 246 | ||
245 | ClassEditor::~ClassEditor() |
247 | ClassEditor::~ClassEditor() |
246 | {
|
248 | {
|
247 | delete ui; |
249 | delete ui; |
248 | // delete field;
|
250 | // delete field;
|
249 | // delete settdialog;
|
251 | // delete settdialog;
|
250 | }
|
252 | }
|
251 | 253 | ||
252 | void ClassEditor::changeEvent(QEvent *e) |
254 | void ClassEditor::changeEvent(QEvent *e) |
253 | {
|
255 | {
|
254 | QMainWindow::changeEvent(e); |
256 | QMainWindow::changeEvent(e); |
255 | switch (e->type()) { |
257 | switch (e->type()) { |
256 | case QEvent::LanguageChange: |
258 | case QEvent::LanguageChange: |
257 | ui->retranslateUi(this); |
259 | ui->retranslateUi(this); |
258 | break; |
260 | break; |
259 | default: |
261 | default: |
260 | break; |
262 | break; |
261 | }
|
263 | }
|
262 | }
|
264 | }
|
263 | 265 | ||
264 | 266 | ||
265 | 267 | ||
266 | void ClassEditor::addNewClass(){ |
268 | void ClassEditor::addNewClass(){ |
267 | 269 | ||
268 | int row = model->rowCount(); |
270 | int row = model->rowCount(); |
269 | 271 | ||
270 | model->insertRows(row, 1); |
272 | model->insertRows(row, 1); |
271 | model->setData(model->index(row, 1), tr("New class")); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà" |
273 | model->setData(model->index(row, 1), tr("New class")); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà" |
272 | 274 | ||
273 | 275 | ||
274 | // model->setData(model->index(row, 1), tr("Âàñÿ Ïóïê èí"));
|
276 | // model->setData(model->index(row, 1), tr("Âàñÿ Ïóïê èí"));
|
275 | // model->setData(model->index(row, 2) , tr("Ìóõîñðà íñê, Çàæîïèíñêèå âûñåëêè ä 1"));
|
277 | // model->setData(model->index(row, 2) , tr("Ìóõîñðà íñê, Çàæîïèíñêèå âûñåëêè ä 1"));
|
276 | 278 | ||
277 | 279 | ||
278 | model->submitAll(); |
280 | model->submitAll(); |
279 | 281 | ||
280 | row = model->rowCount(); |
282 | row = model->rowCount(); |
281 | QString tmp_str;
|
283 | QString tmp_str;
|
282 | int i_tmp; |
284 | int i_tmp; |
283 | i_tmp = model->data(model->index(row-1, 0)).toInt(); |
285 | i_tmp = model->data(model->index(row-1, 0)).toInt(); |
284 | tmp_str = model->data(model->index(row-1, 0)).toString(); // ãåíåðèì èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ êëàññà |
286 | tmp_str = model->data(model->index(row-1, 0)).toString(); // ãåíåðèì èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ êëàññà |
285 | 287 | ||
286 | tmp_str.append(tr("_Inctance")); |
288 | tmp_str.append(tr("_Inctance")); |
287 | model->setData(model->index(row-1, 3), tmp_str ); // è çàíîñèì çíà÷åíèå â òàáëèöó |
289 | model->setData(model->index(row-1, 3), tmp_str ); // è çàíîñèì çíà÷åíèå â òàáëèöó |
288 | 290 | ||
289 | model->submitAll(); |
291 | model->submitAll(); |
290 | mymodel->select(); |
292 | mymodel->select(); |
291 | 293 | ||
292 | 294 | ||
293 | }
|
295 | }
|
294 | 296 | ||
295 | 297 | ||
296 | void ClassEditor::addNewClass_new(){ |
298 | void ClassEditor::addNewClass_new(){ |
297 | 299 | ||
298 | int row = mymodel->rowCount(); |
300 | int row = mymodel->rowCount(); |
299 | 301 | ||
300 | mymodel->insertRows(row, 1); |
302 | mymodel->insertRows(row, 1); |
301 | mymodel->setData(mymodel->index(row, 1), QVariant(tr("New classs")), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà" |
303 | mymodel->setData(mymodel->index(row, 1), QVariant(tr("New classs")), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà" |
302 | 304 | ||
303 | mymodel->submitAll(); |
305 | mymodel->submitAll(); |
304 | 306 | ||
305 | row = mymodel->rowCount(); |
307 | row = mymodel->rowCount(); |
306 | QString tmp_str1;
|
308 | QString tmp_str1;
|
307 | int i_tmp1; |
309 | int i_tmp1; |
308 | i_tmp1 = mymodel->data(mymodel->index(row-1, 0)).toInt(); |
310 | i_tmp1 = mymodel->data(mymodel->index(row-1, 0)).toInt(); |
309 | tmp_str1 = mymodel->data(mymodel->index(row-1, 0)).toString(); // ãåíåðèì èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ êëàññà |
311 | tmp_str1 = mymodel->data(mymodel->index(row-1, 0)).toString(); // ãåíåðèì èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ êëàññà |
310 | 312 | ||
311 | tmp_str1.append(tr("_Inctance")); |
313 | tmp_str1.append(tr("_Inctance")); |
312 | mymodel->setData(mymodel->index(row-1, 3), QVariant(tmp_str1), Qt::EditRole); // è çàíîñèì çíà÷åíèå â òàáëèöó |
314 | mymodel->setData(mymodel->index(row-1, 3), QVariant(tmp_str1), Qt::EditRole); // è çàíîñèì çíà÷åíèå â òàáëèöó |
313 | 315 | ||
314 | // model->setData(model->index(row, 1), tr("Âàñÿ Ïóïê èí"));
|
316 | // model->setData(model->index(row, 1), tr("Âàñÿ Ïóïê èí"));
|
315 | // model->setData(model->index(row, 2) , tr("Ìóõîñðà íñê, Çàæîïèíñêèå âûñåëêè ä 1"));
|
317 | // model->setData(model->index(row, 2) , tr("Ìóõîñðà íñê, Çàæîïèíñêèå âûñåëêè ä 1"));
|
316 | 318 | ||
317 | 319 | ||
318 | //mymodel->submitAll();
|
320 | //mymodel->submitAll();
|
319 | 321 | ||
320 | //row = mymodel->rowCount();
|
322 | //row = mymodel->rowCount();
|
321 | 323 | ||
322 | 324 | ||
323 | //mymodel->select();
|
325 | //mymodel->select();
|
324 | 326 | ||
325 | 327 | ||
326 | }
|
328 | }
|
327 | 329 | ||
328 | 330 | ||
329 | void ClassEditor::on_pushButton_clicked(){ |
331 | void ClassEditor::on_pushButton_clicked(){ |
330 | //int i;
|
332 | //int i;
|
331 | //i++;
|
333 | //i++;
|
332 | /////ClassEditor::addNewClass();
|
334 | /////ClassEditor::addNewClass();
|
333 | ClassEditor::addNewClass_new(); |
335 | ClassEditor::addNewClass_new(); |
334 | mymodel->select(); |
336 | mymodel->select(); |
335 | //ui->tableView->setModel(mymodel);
|
337 | //ui->tableView->setModel(mymodel);
|
336 | 338 | ||
337 | }
|
339 | }
|
338 | 340 | ||
339 | void ClassEditor::on_tableView_clicked(const QModelIndex & index ){ |
341 | void ClassEditor::on_tableView_clicked(const QModelIndex & index ){ |
340 | int i, row, column; |
342 | int i, row, column; |
341 | i++; |
343 | i++; |
342 | row = index.row(); |
344 | row = index.row(); |
343 | column = index.column(); |
345 | column = index.column(); |
344 | QModelIndex index_tmp;
|
346 | QModelIndex index_tmp;
|
345 | QString tmp_str, filter_str;
|
347 | QString tmp_str, filter_str;
|
346 | index_tmp = ui->tableView->model()->index(row, 0); |
348 | index_tmp = ui->tableView->model()->index(row, 0); |
347 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
349 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
348 | //ui->label->setText(tmp_str);
|
350 | //ui->label->setText(tmp_str);
|
349 | filter_str = tr("ClassIdentifer = "); |
351 | filter_str = tr("ClassIdentifer = "); |
350 | filter_str.append(tmp_str); |
352 | filter_str.append(tmp_str); |
351 | modelForDescription->setFilter(filter_str); |
353 | modelForDescription->setFilter(filter_str); |
352 | i++; |
354 | i++; |
353 | }
|
355 | }
|
354 | 356 | ||
355 | 357 | ||
356 | 358 | ||
357 | void ClassEditor::on_pushButton_2_clicked(){ |
359 | void ClassEditor::on_pushButton_2_clicked(){ |
358 | int i; |
360 | int i; |
359 | i++; |
361 | i++; |
360 | 362 | ||
361 | }
|
363 | }
|
362 | 364 | ||
363 | void ClassEditor::on_pushButton_3_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Íîâîå ïîëå" |
365 | void ClassEditor::on_pushButton_3_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Íîâîå ïîëå" |
364 | int i; |
366 | int i; |
365 | i++; |
367 | i++; |
366 | }
|
368 | }
|
367 | void ClassEditor::on_pushButton_4_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü ïîëå" |
369 | void ClassEditor::on_pushButton_4_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü ïîëå" |
368 | int i; |
370 | int i; |
369 | i++; |
371 | i++; |
370 | }
|
372 | }
|
371 | 373 |