Редакция 67 | Редакция 69 | К новейшей редакции | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 67 | Редакция 68 | ||
---|---|---|---|
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); |
181 | modelForDescription = new ModelForDescriptionTable(this); |
182 | 182 | ||
183 | 183 | ||
184 | /////////////////model->setTable(tr("ListOfClasses"));
|
184 | /////////////////model->setTable(tr("ListOfClasses"));
|
185 | mymodel->setTable(tr("ListOfClasses")); |
185 | mymodel->setTable(tr("ListOfClasses")); |
186 | modelForDescription->setTable(tr("DescriptionOfClasses")); |
186 | modelForDescription->setTable(tr("DescriptionOfClasses")); |
187 | modelForDescription->setEditStrategy(QSqlTableModel::OnFieldChange); |
187 | modelForDescription->setEditStrategy(QSqlTableModel::OnFieldChange); |
188 | 188 | ||
189 | /////model->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
189 | /////model->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
190 | 190 | ||
191 | /*
|
191 | /*
|
192 | model->setEditStrategy(QSqlTableModel::OnFieldChange);
|
192 | model->setEditStrategy(QSqlTableModel::OnFieldChange);
|
193 | mymodel->setEditStrategy(QSqlTableModel::OnFieldChange);
|
193 | mymodel->setEditStrategy(QSqlTableModel::OnFieldChange);
|
194 | */
|
194 | */
|
195 | 195 | ||
196 | 196 | ||
197 | //////////////////model->setSort(0, Qt::AscendingOrder);
|
197 | //////////////////model->setSort(0, Qt::AscendingOrder);
|
198 | mymodel->setSort(0, Qt::AscendingOrder); |
198 | mymodel->setSort(0, Qt::AscendingOrder); |
199 | modelForDescription->setSort(0, Qt::AscendingOrder); |
199 | modelForDescription->setSort(0, Qt::AscendingOrder); |
200 | 200 | ||
201 | 201 | ||
202 | // model->setFilter(tr("Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = '7' and Èíâåíòàðíûé_íîìåð = 'i09090909'"));
|
202 | // model->setFilter(tr("Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = '7' and Èíâåíòàðíûé_íîìåð = 'i09090909'"));
|
203 | ////////////////////model->select();
|
203 | ////////////////////model->select();
|
204 | mymodel->select(); |
204 | mymodel->select(); |
205 | modelForDescription->setFilter(tr("ClassIdentifer = 1")); |
- | |
206 | modelForDescription->select(); |
- | |
- | 205 | ||
- | 206 | ||
207 | 207 | ||
208 | 208 | ||
209 | /////////////////////////model->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà"));
|
209 | /////////////////////////model->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà"));
|
210 | mymodel->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà")); |
210 | mymodel->setHeaderData(1, Qt::Horizontal, tr("Èìÿ êëàññà")); |
211 | 211 | ||
212 | 212 | ||
213 | 213 | ||
214 | ////////////////////////model->setHeaderData(2, Qt::Horizontal, tr("Ïñåâäîíèì êëàññà"));
|
214 | ////////////////////////model->setHeaderData(2, Qt::Horizontal, tr("Ïñåâäîíèì êëàññà"));
|
215 | mymodel->setHeaderData(2, Qt::Horizontal, tr("Ïñåâäîíèì êëàññà")); |
215 | mymodel->setHeaderData(2, Qt::Horizontal, tr("Ïñåâäîíèì êëàññà")); |
216 | mymodel->setHeaderData(4, Qt::Horizontal, tr("Êîìåíòàðèé")); |
216 | mymodel->setHeaderData(4, Qt::Horizontal, tr("Êîìåíòàðèé")); |
217 | 217 | ||
218 | 218 | ||
219 | //ui->tableView->setModel(model);
|
219 | //ui->tableView->setModel(model);
|
220 | ui->tableView->setModel(mymodel); |
220 | ui->tableView->setModel(mymodel); |
221 | //tableForDescription = new QTableView();
|
221 | //tableForDescription = new QTableView();
|
222 | ui->tableView_2->setModel(modelForDescription); |
222 | ui->tableView_2->setModel(modelForDescription); |
223 | ui->tableView_2->setAlternatingRowColors(true); |
223 | ui->tableView_2->setAlternatingRowColors(true); |
224 | ui->tableView_2->resizeColumnsToContents(); |
224 | ui->tableView_2->resizeColumnsToContents(); |
225 | //tableForDescription->show();
|
225 | //tableForDescription->show();
|
226 | 226 | ||
227 | 227 | ||
228 | ui->tableView->setAlternatingRowColors(true); |
228 | ui->tableView->setAlternatingRowColors(true); |
229 | ui->tableView->resizeColumnsToContents(); |
229 | ui->tableView->resizeColumnsToContents(); |
230 | 230 | ||
231 | ui->tableView->hideColumn(0); |
231 | ui->tableView->hideColumn(0); |
232 | ui->tableView->hideColumn(3); |
232 | ui->tableView->hideColumn(3); |
233 | ui->tableView->hideColumn(2); |
233 | ui->tableView->hideColumn(2); |
234 | 234 | ||
235 | /*
|
235 | /*
|
236 | ui->tableView_2->hideColumn(0);
|
236 | ui->tableView_2->hideColumn(0);
|
237 | ui->tableView_2->hideColumn(5);
|
237 | ui->tableView_2->hideColumn(5);
|
238 | ui->tableView_2->hideColumn(2);
|
238 | ui->tableView_2->hideColumn(2);
|
239 | */
|
239 | */
|
240 | ui->tableView_2->setItemDelegateForColumn(3, &classTableDelegate); |
240 | ui->tableView_2->setItemDelegateForColumn(3, &classTableDelegate); |
241 | 241 | ||
242 | currIndexOfClassesTable = modelForDescription->index(0, 1); |
242 | currIndexOfClassesTable = modelForDescription->index(0, 1); |
243 | QModelIndex index_temp;
|
243 | QModelIndex index_temp;
|
244 | 244 | ||
245 | currClassID = mymodel->data(mymodel->index(0,0)).toString(); |
245 | currClassID = mymodel->data(mymodel->index(0,0)).toString(); |
246 | QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
246 | QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
247 | 247 | ||
248 | QModelIndex topLeft;
|
248 | QModelIndex topLeft;
|
249 | QModelIndex bottomRight;
|
249 | QModelIndex bottomRight;
|
250 | 250 | ||
251 | topLeft = mymodel->index(0, 0, QModelIndex()); |
251 | topLeft = mymodel->index(0, 0, QModelIndex()); |
252 | bottomRight = mymodel->index(0, 1, QModelIndex()); |
252 | bottomRight = mymodel->index(0, 1, QModelIndex()); |
253 | 253 | ||
254 | QItemSelection selection(topLeft, bottomRight); |
254 | QItemSelection selection(topLeft, bottomRight); |
255 | selectionModel->select(selection, QItemSelectionModel::Select); |
255 | selectionModel->select(selection, QItemSelectionModel::Select); |
256 | 256 | ||
257 | 257 | ||
- | 258 | QString class_indx;
|
|
- | 259 | QString str_fltr = tr("ClassIdentifer = "); |
|
- | 260 | class_indx = mymodel->data(mymodel->index(0,0)).toString(); |
|
- | 261 | str_fltr.append(class_indx); |
|
- | 262 | ||
- | 263 | modelForDescription->setFilter(str_fltr); |
|
- | 264 | modelForDescription->select(); |
|
- | 265 | ||
- | 266 | ||
258 | 267 | ||
259 | //connect(ui->tableView, SIGNAL(clicked(const QModelIndex)), this, SLOT(on_tableView_clicked(const QModelIndex)));
|
268 | //connect(ui->tableView, SIGNAL(clicked(const QModelIndex)), this, SLOT(on_tableView_clicked(const QModelIndex)));
|
260 | connect(mymodel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_myModel_dataChanged(QModelIndex,QModelIndex))); |
269 | connect(mymodel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_myModel_dataChanged(QModelIndex,QModelIndex))); |
261 | connect(modelForDescription, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_modelForDescription_dataChanged(QModelIndex,QModelIndex))); |
270 | connect(modelForDescription, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_modelForDescription_dataChanged(QModelIndex,QModelIndex))); |
262 | connect(ui->newClassAction, SIGNAL(triggered(bool)), this, SLOT(on_pushButton_clicked(bool))); |
271 | connect(ui->newClassAction, SIGNAL(triggered(bool)), this, SLOT(on_pushButton_clicked(bool))); |
263 | connect(ui->action_ID, SIGNAL(triggered(bool)), this, SLOT(on_action_ID_triggered(bool))); |
272 | connect(ui->action_ID, SIGNAL(triggered(bool)), this, SLOT(on_action_ID_triggered(bool))); |
264 | connect(ui->action_showAlias, SIGNAL(triggered(bool)), this, SLOT(on_action_showAlias_triggered(bool))); |
273 | connect(ui->action_showAlias, SIGNAL(triggered(bool)), this, SLOT(on_action_showAlias_triggered(bool))); // ïîêàçûâàòü ïñåâäîíèìû |
265 | connect(ui->action_showInstance, SIGNAL(triggered(bool)), this, SLOT(on_action_showInstance_triggered(bool))); |
274 | connect(ui->action_showInstance, SIGNAL(triggered(bool)), this, SLOT(on_action_showInstance_triggered(bool))); // ïîêàçûâàòü õðàíèëèùà îáúåêòîâ |
- | 275 | connect(ui->action_removeSelectedFields, SIGNAL(triggered()), this, SLOT(on_pushButton_4_clicked())); // óäàëèòü âûäåëåííûå ïîëÿ |
|
- | 276 | connect(ui->action_removeAllFields, SIGNAL(triggered()), this, SLOT(on_pushButton_5_clicked())); // óäàëèòü âñå ïîëÿ |
|
- | 277 | connect(ui->action_removeSelectedClasses, SIGNAL(triggered()), this, SLOT(on_pushButton_2_clicked())); // óäàëèòü âûäåëåííûå êëàññû |
|
- | 278 | connect(ui->action_removeAllClasses, SIGNAL(triggered()), this, SLOT(on_action_removeAllClasses())); // óäàëèòü âûäåëåííûå êëàññû |
|
266 | }
|
279 | }
|
267 | 280 | ||
268 | 281 | ||
269 | 282 | ||
270 | 283 | ||
271 | 284 | ||
272 | 285 | ||
273 | 286 | ||
274 | 287 | ||
275 | 288 | ||
276 | 289 | ||
277 | 290 | ||
278 | ClassEditor::~ClassEditor() |
291 | ClassEditor::~ClassEditor() |
279 | {
|
292 | {
|
280 | delete ui; |
293 | delete ui; |
281 | // delete field;
|
294 | // delete field;
|
282 | // delete settdialog;
|
295 | // delete settdialog;
|
283 | }
|
296 | }
|
284 | 297 | ||
285 | void ClassEditor::changeEvent(QEvent *e) |
298 | void ClassEditor::changeEvent(QEvent *e) |
286 | {
|
299 | {
|
287 | QMainWindow::changeEvent(e); |
300 | QMainWindow::changeEvent(e); |
288 | switch (e->type()) { |
301 | switch (e->type()) { |
289 | case QEvent::LanguageChange: |
302 | case QEvent::LanguageChange: |
290 | ui->retranslateUi(this); |
303 | ui->retranslateUi(this); |
291 | break; |
304 | break; |
292 | default: |
305 | default: |
293 | break; |
306 | break; |
294 | }
|
307 | }
|
295 | }
|
308 | }
|
296 | 309 | ||
297 | 310 | ||
298 | 311 | ||
299 | void ClassEditor::addNewClass(){ |
312 | void ClassEditor::addNewClass(){ |
300 | 313 | ||
301 | int row = model->rowCount(); |
314 | int row = model->rowCount(); |
302 | 315 | ||
303 | model->insertRows(row, 1); |
316 | model->insertRows(row, 1); |
304 | model->setData(model->index(row, 1), tr("New class")); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà" |
317 | model->setData(model->index(row, 1), tr("New class")); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà" |
305 | 318 | ||
306 | 319 | ||
307 | // model->setData(model->index(row, 1), tr("Âàñÿ Ïóïê èí"));
|
320 | // model->setData(model->index(row, 1), tr("Âàñÿ Ïóïê èí"));
|
308 | // model->setData(model->index(row, 2) , tr("Ìóõîñðà íñê, Çàæîïèíñêèå âûñåëêè ä 1"));
|
321 | // model->setData(model->index(row, 2) , tr("Ìóõîñðà íñê, Çàæîïèíñêèå âûñåëêè ä 1"));
|
309 | 322 | ||
310 | 323 | ||
311 | model->submitAll(); |
324 | model->submitAll(); |
312 | 325 | ||
313 | row = model->rowCount(); |
326 | row = model->rowCount(); |
314 | QString tmp_str;
|
327 | QString tmp_str;
|
315 | int i_tmp; |
328 | int i_tmp; |
316 | i_tmp = model->data(model->index(row-1, 0)).toInt(); |
329 | i_tmp = model->data(model->index(row-1, 0)).toInt(); |
317 | tmp_str = model->data(model->index(row-1, 0)).toString(); // ãåíåðèì èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ êëàññà |
330 | tmp_str = model->data(model->index(row-1, 0)).toString(); // ãåíåðèì èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ êëàññà |
318 | 331 | ||
319 | tmp_str.append(tr("_Inctance")); |
332 | tmp_str.append(tr("_Inctance")); |
320 | model->setData(model->index(row-1, 3), tmp_str ); // è çàíîñèì çíà÷åíèå â òàáëèöó |
333 | model->setData(model->index(row-1, 3), tmp_str ); // è çàíîñèì çíà÷åíèå â òàáëèöó |
321 | 334 | ||
322 | model->submitAll(); |
335 | model->submitAll(); |
323 | mymodel->select(); |
336 | mymodel->select(); |
324 | 337 | ||
325 | 338 | ||
326 | }
|
339 | }
|
327 | 340 | ||
328 | 341 | ||
329 | void ClassEditor::addNewClass_new(){ |
342 | void ClassEditor::addNewClass_new(){ |
330 | 343 | ||
331 | int row = mymodel->rowCount(); |
344 | int row = mymodel->rowCount(); |
332 | 345 | ||
333 | mymodel->insertRows(row, 1); |
346 | mymodel->insertRows(row, 1); |
334 | mymodel->setData(mymodel->index(row, 1), QVariant(tr("New classs")), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà" |
347 | mymodel->setData(mymodel->index(row, 1), QVariant(tr("New classs")), Qt::EditRole); // ïðèñâàèâàåì íîâîå çíà÷åíèå ïîëþ "èìÿ êëàññà" |
335 | 348 | ||
336 | mymodel->submitAll(); |
349 | mymodel->submitAll(); |
337 | 350 | ||
338 | row = mymodel->rowCount(); |
351 | row = mymodel->rowCount(); |
339 | QString tmp_str1;
|
352 | QString tmp_str1;
|
340 | int i_tmp1; |
353 | int i_tmp1; |
341 | i_tmp1 = mymodel->data(mymodel->index(row-1, 0)).toInt(); |
354 | i_tmp1 = mymodel->data(mymodel->index(row-1, 0)).toInt(); |
342 | tmp_str1 = mymodel->data(mymodel->index(row-1, 0)).toString(); // ãåíåðèì èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ êëàññà |
355 | tmp_str1 = mymodel->data(mymodel->index(row-1, 0)).toString(); // ãåíåðèì èìÿ òàáëèöû-õðàíèëèùà îáúåêòîâ êëàññà |
343 | 356 | ||
344 | tmp_str1.append(tr("_Inctance")); |
357 | tmp_str1.append(tr("_Inctance")); |
345 | mymodel->setData(mymodel->index(row-1, 3), QVariant(tmp_str1), Qt::EditRole); // è çàíîñèì çíà÷åíèå â òàáëèöó |
358 | mymodel->setData(mymodel->index(row-1, 3), QVariant(tmp_str1), Qt::EditRole); // è çàíîñèì çíà÷åíèå â òàáëèöó |
346 | 359 | ||
347 | // model->setData(model->index(row, 1), tr("Âàñÿ Ïóïê èí"));
|
360 | // model->setData(model->index(row, 1), tr("Âàñÿ Ïóïê èí"));
|
348 | // model->setData(model->index(row, 2) , tr("Ìóõîñðà íñê, Çàæîïèíñêèå âûñåëêè ä 1"));
|
361 | // model->setData(model->index(row, 2) , tr("Ìóõîñðà íñê, Çàæîïèíñêèå âûñåëêè ä 1"));
|
349 | 362 | ||
350 | 363 | ||
351 | //mymodel->submitAll();
|
364 | //mymodel->submitAll();
|
352 | 365 | ||
353 | //row = mymodel->rowCount();
|
366 | //row = mymodel->rowCount();
|
354 | 367 | ||
355 | 368 | ||
356 | //mymodel->select();
|
369 | //mymodel->select();
|
357 | 370 | ||
358 | 371 | ||
359 | }
|
372 | }
|
360 | 373 | ||
361 | 374 | ||
362 | void ClassEditor::addNewField(){ |
375 | void ClassEditor::addNewField(){ |
363 | // QSqlRecord rec = mymodel->record(1);
|
376 | // QSqlRecord rec = mymodel->record(1);
|
364 | //bool ok;
|
377 | //bool ok;
|
365 | //ok = rec.isEmpty();
|
378 | //ok = rec.isEmpty();
|
366 | //QString currientClassID;
|
379 | //QString currientClassID;
|
367 | //currientClassID = rec.value(1).toString();
|
380 | //currientClassID = rec.value(1).toString();
|
368 | int row = modelForDescription->rowCount(); |
381 | int row = modelForDescription->rowCount(); |
369 | modelForDescription->insertRows(row, 1); |
382 | modelForDescription->insertRows(row, 1); |
370 | modelForDescription->setData(modelForDescription->index(row, 5), QVariant(currClassID), Qt::EditRole); |
383 | modelForDescription->setData(modelForDescription->index(row, 5), QVariant(currClassID), Qt::EditRole); |
371 | modelForDescription->setData(modelForDescription->index(row, 4), QVariant(tr("NULL")), Qt::EditRole); |
384 | modelForDescription->setData(modelForDescription->index(row, 4), QVariant(tr("NULL")), Qt::EditRole); |
372 | 385 | ||
373 | modelForDescription->submitAll(); |
386 | modelForDescription->submitAll(); |
374 | }
|
387 | }
|
375 | 388 | ||
376 | 389 | ||
377 | 390 | ||
378 | 391 | ||
379 | 392 | ||
380 | 393 | ||
381 | 394 | ||
382 | 395 | ||
383 | 396 | ||
384 | 397 | ||
385 | - | ||
- | 398 | // äîáàâëÿåì íîâûé êëàññ
|
|
386 | void ClassEditor::on_pushButton_clicked(){ |
399 | void ClassEditor::on_pushButton_clicked(){ |
387 | //int i;
|
400 | //int i;
|
388 | //i++;
|
401 | //i++;
|
389 | /////ClassEditor::addNewClass();
|
402 | /////ClassEditor::addNewClass();
|
390 | ClassEditor::addNewClass_new(); |
403 | ClassEditor::addNewClass_new(); |
391 | mymodel->select(); |
404 | mymodel->select(); |
392 | //ui->tableView->setModel(mymodel);
|
405 | //ui->tableView->setModel(mymodel);
|
393 | 406 | ||
394 | }
|
407 | }
|
395 | 408 | ||
396 | void ClassEditor::on_tableView_clicked(const QModelIndex & index ){ |
409 | void ClassEditor::on_tableView_clicked(const QModelIndex & index ){ |
397 | int i, row, column; |
410 | int i, row, column; |
398 | i++; |
411 | i++; |
399 | row = index.row(); |
412 | row = index.row(); |
400 | column = index.column(); |
413 | column = index.column(); |
401 | currIndexOfClassesTable = index; |
414 | currIndexOfClassesTable = index; |
402 | QModelIndex index_tmp;
|
415 | QModelIndex index_tmp;
|
403 | QString tmp_str, filter_str;
|
416 | QString tmp_str, filter_str;
|
404 | index_tmp = ui->tableView->model()->index(row, 0); |
417 | index_tmp = ui->tableView->model()->index(row, 0); |
405 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
418 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
406 | currClassID = tmp_str; |
419 | currClassID = tmp_str; |
407 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString());
|
420 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString());
|
408 | filter_str = tr("ClassIdentifer = "); |
421 | filter_str = tr("ClassIdentifer = "); |
409 | filter_str.append(tmp_str); |
422 | filter_str.append(tmp_str); |
410 | modelForDescription->setFilter(filter_str); |
423 | modelForDescription->setFilter(filter_str); |
- | 424 | modelForDescription->select(); |
|
411 | ui->tableView_2->resizeColumnsToContents(); |
425 | ui->tableView_2->resizeColumnsToContents(); |
412 | i++; |
426 | i++; |
413 | }
|
427 | }
|
414 | 428 | ||
415 | 429 | ||
416 | 430 | ||
417 | void ClassEditor::on_pushButton_2_clicked(){ |
431 | void ClassEditor::on_pushButton_2_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïðêè "Óäàëèòü êëàññ" |
- | 432 | QModelIndex model_index;
|
|
- | 433 | QItemSelectionModel *selectionModel = ui->tableView->selectionModel(); |
|
- | 434 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
|
- | 435 | QList<int> selectedRows; |
|
- | 436 | selectedRows.clear(); |
|
- | 437 | foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê |
|
- | 438 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå |
|
- | 439 | ||
418 | int i; |
440 | }
|
- | 441 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // ñîðòèðóåì â îáðàòíîì ïîðÿäêå |
|
- | 442 | ||
- | 443 | ||
- | 444 | for (int m =0; m < selectedRows.size(); ++m){ |
|
- | 445 | ||
- | 446 | ClassEditor::removeClass(selectedRows.at(m)); |
|
- | 447 | ||
- | 448 | ||
- | 449 | ||
419 | i++; |
450 | }
|
- | 451 | mymodel->submitAll(); |
|
- | 452 | ClassEditor::modelForDescription->select(); |
|
420 | 453 | ||
421 | }
|
454 | }
|
422 | 455 | ||
423 | void ClassEditor::on_pushButton_3_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Íîâîå ïîëå" |
456 | void ClassEditor::on_pushButton_3_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Íîâîå ïîëå" |
424 | int i; |
457 | int i; |
425 | i++; |
458 | i++; |
426 | ClassEditor::addNewField(); |
459 | ClassEditor::addNewField(); |
427 | ClassEditor::modelForDescription->select(); |
460 | ClassEditor::modelForDescription->select(); |
428 | ui->tableView_2->resizeColumnsToContents(); |
461 | ui->tableView_2->resizeColumnsToContents(); |
429 | }
|
462 | }
|
- | 463 | ||
- | 464 | ||
430 | void ClassEditor::on_pushButton_4_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü ïîëå" |
465 | void ClassEditor::on_pushButton_4_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü ïîëå" |
431 | int i; |
466 | int i; |
432 | i++; |
467 | i++; |
433 | QModelIndex model_index;
|
468 | QModelIndex model_index;
|
434 | QItemSelectionModel *selectionModel = ui->tableView_2->selectionModel(); |
469 | QItemSelectionModel *selectionModel = ui->tableView_2->selectionModel(); |
435 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
470 | QModelIndexList indexes = selectionModel->selectedIndexes(); |
436 | QModelIndexList indexes_fo_first_col; // èíäåêñû äëÿ ïåðâîãî ñòîëáöà (èìåíà êëàññîâ) |
471 | QModelIndexList indexes_fo_first_col; // èíäåêñû äëÿ ïåðâîãî ñòîëáöà (èìåíà êëàññîâ) |
437 | //model_index = mymodel->selec;
|
472 | //model_index = mymodel->selec;
|
438 | //modelList = ui->tableView->SelectItems;
|
473 | //modelList = ui->tableView->SelectItems;
|
439 | i = indexes.size(); |
474 | i = indexes.size(); |
440 | QList<int> selectedRows; |
475 | QList<int> selectedRows; |
441 | indexes_fo_first_col.clear(); |
476 | indexes_fo_first_col.clear(); |
442 | foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê |
477 | foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê |
443 | if (!indexes_fo_first_col.contains(model_index) && (model_index.column()==1)) indexes_fo_first_col.append(model_index); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå |
478 | if (!indexes_fo_first_col.contains(model_index) && (model_index.column()==1)) indexes_fo_first_col.append(model_index); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå |
444 | 479 | ||
445 | }
|
480 | }
|
446 | 481 | ||
447 | selectedRows.clear(); |
482 | selectedRows.clear(); |
448 | foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê |
483 | foreach (model_index, indexes){ // ñïèñîê âñåõ âûäåëåííûõ ñòðîê |
449 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå |
484 | if (!selectedRows.contains(model_index.row()) && (model_index.column()==1)) selectedRows.append(model_index.row()); // îñòàâëÿåì â ñïèñêå òîëüêî âûáðàííûå â ïåðâîé êîëîíêå |
450 | 485 | ||
451 | }
|
486 | }
|
452 | 487 | ||
453 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // ñîðòèðóåì â îáðàòíîì ïîðÿäêå |
488 | qSort(selectedRows.begin(),selectedRows.end(), qGreater<int>()); // ñîðòèðóåì â îáðàòíîì ïîðÿäêå |
454 | 489 | ||
455 | 490 | ||
456 | for (int m =0; m < selectedRows.size(); ++m){ |
491 | for (int m =0; m < selectedRows.size(); ++m){ |
457 | 492 | ||
458 | modelForDescription->removeRow(selectedRows.at(m)); |
493 | modelForDescription->removeRow(selectedRows.at(m)); |
459 | }
|
494 | }
|
460 | 495 | ||
461 | i = selectedRows.size(); |
496 | i = selectedRows.size(); |
462 | 497 | ||
463 | if (i > 0) model_index = indexes.at(0); |
498 | if (i > 0) model_index = indexes.at(0); |
464 | i++; |
499 | i++; |
465 | }
|
500 | }
|
466 | 501 | ||
467 | 502 | ||
468 | void ClassEditor::on_pushButton_5_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü âñå ïîëÿ" |
503 | void ClassEditor::on_pushButton_5_clicked(){ // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü âñå ïîëÿ" |
469 | int row; |
504 | int row; |
470 | row = ClassEditor::modelForDescription->rowCount(); |
505 | row = ClassEditor::modelForDescription->rowCount(); |
471 | ClassEditor::modelForDescription->removeRows(0, row); |
506 | ClassEditor::modelForDescription->removeRows(0, row); |
472 | ClassEditor::modelForDescription->submitAll(); |
507 | ClassEditor::modelForDescription->submitAll(); |
473 | }
|
508 | }
|
474 | 509 | ||
475 | void ClassEditor::on_myModel_dataChanged( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
510 | void ClassEditor::on_myModel_dataChanged( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
476 | int i; |
511 | int i; |
477 | i++; |
512 | i++; |
478 | ui->tableView->resizeColumnsToContents(); |
513 | ui->tableView->resizeColumnsToContents(); |
479 | }
|
514 | }
|
480 | 515 | ||
481 | void ClassEditor::on_modelForDescription_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
516 | void ClassEditor::on_modelForDescription_dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ){ |
482 | ui->tableView_2->resizeColumnsToContents(); |
517 | ui->tableView_2->resizeColumnsToContents(); |
483 | }
|
518 | }
|
484 | 519 | ||
485 | void ClassEditor::on_action_ID_triggered(bool is_checked){ // îáðàáàòûâàåì âûáîð â ìåíþ "Ïîêàçûâàòü ID" |
520 | void ClassEditor::on_action_ID_triggered(bool is_checked){ // îáðàáàòûâàåì âûáîð â ìåíþ "Ïîêàçûâàòü ID" |
486 | if (is_checked) ui->tableView->showColumn(0); |
521 | if (is_checked) ui->tableView->showColumn(0); |
487 | else ui->tableView->hideColumn(0); |
522 | else ui->tableView->hideColumn(0); |
488 | ui->tableView->resizeColumnsToContents(); |
523 | ui->tableView->resizeColumnsToContents(); |
489 | }
|
524 | }
|
490 | 525 | ||
491 | void ClassEditor::on_action_showAlias_triggered(bool is_checked){ // îáðàáàòûâàåì âûáîð â ìåíþ "Ïîêàçûâàòü ïñåâäîíèì" |
526 | void ClassEditor::on_action_showAlias_triggered(bool is_checked){ // îáðàáàòûâàåì âûáîð â ìåíþ "Ïîêàçûâàòü ïñåâäîíèì" |
492 | if (is_checked) ui->tableView->showColumn(2); |
527 | if (is_checked) ui->tableView->showColumn(2); |
493 | else ui->tableView->hideColumn(2); |
528 | else ui->tableView->hideColumn(2); |
494 | ui->tableView->resizeColumnsToContents(); |
529 | ui->tableView->resizeColumnsToContents(); |
495 | }
|
530 | }
|
496 | 531 | ||
497 | void ClassEditor::on_action_showInstance_triggered(bool is_checked){ |
532 | void ClassEditor::on_action_showInstance_triggered(bool is_checked){ // îáðàáàòûâàåì âûáîð â ìåíþ "Ïîêàçûâàòü õðàíèëèùà îáúåêòîâ" |
498 | if (is_checked) ui->tableView->showColumn(3); |
533 | if (is_checked) ui->tableView->showColumn(3); |
499 | else ui->tableView->hideColumn(3); |
534 | else ui->tableView->hideColumn(3); |
500 | ui->tableView->resizeColumnsToContents(); |
535 | ui->tableView->resizeColumnsToContents(); |
501 | }
|
536 | }
|
- | 537 | ||
- | 538 | ||
- | 539 | ||
- | 540 | void ClassEditor::on_action_removeAllClasses(){ // îáðàáàòûâàåì âûáîð â ìåíþ "Óäàëèòü âñå êëàññû" |
|
- | 541 | int row; |
|
- | 542 | row = ClassEditor::mymodel->rowCount(); |
|
- | 543 | for (int m=0; m < row; ++m){ |
|
- | 544 | ClassEditor::removeClass(0); |
|
- | 545 | //ClassEditor::mymodel->removeRows(0, row);
|
|
- | 546 | }
|
|
- | 547 | ClassEditor::mymodel->submitAll(); |
|
- | 548 | ClassEditor::modelForDescription->select(); |
|
- | 549 | }
|
|
- | 550 | ||
- | 551 | void ClassEditor::removeClass(int class_row){ // ôóíêöèÿ óäàëÿåò êëàññ, íàõîäÿùèéñÿ â ñòðîêå ñ íîìåðîì class_row |
|
- | 552 | QModelIndex index_tmp;
|
|
- | 553 | QString tmp_str, filter_str;
|
|
- | 554 | index_tmp = ui->tableView->model()->index(class_row, 0); |
|
- | 555 | tmp_str = ui->tableView->model()->data(index_tmp).toString(); |
|
- | 556 | currClassID = tmp_str; |
|
- | 557 | // ui->label->setText(QVariant(currIndexOfClassesTable.row()).toString());
|
|
- | 558 | filter_str = tr("ClassIdentifer = "); |
|
- | 559 | filter_str.append(tmp_str); |
|
- | 560 | modelForDescription->setFilter(filter_str); // îáíîâëÿåì òàáëèöó ïîëåé |
|
- | 561 | ClassEditor::on_pushButton_5_clicked(); // ñíà÷àëà óäàëèì âñå ïîëÿ êëàññà |
|
- | 562 | mymodel->removeRow(class_row); // òåïåðü óäàëÿåì ñàì êëàññ |
|
- | 563 | mymodel->submitAll(); // ôèêñèðóåì èçìåíåíèÿ |
|
- | 564 | ui->tableView->resizeColumnsToContents(); |
|
- | 565 | ui->tableView_2->resizeColumnsToContents(); |
|
- | 566 | ||
- | 567 | }
|
|
502 | 568 |