Редакция 227 | Редакция 229 | К новейшей редакции | Весь файл | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 227 | Редакция 228 | ||
---|---|---|---|
Строка 117... | Строка 117... | ||
117 | iconDelegate = new IconDelegate(this); |
117 | iconDelegate = new IconDelegate(this); |
118 | fileDelegate = new FileDelegate(this); |
118 | fileDelegate = new FileDelegate(this); |
119 | 119 | ||
120 | // fileForm.show();
|
120 | // fileForm.show();
|
121 | 121 | ||
- | 122 | ||
- | 123 | cursor = new QTextCursor(&doc); |
|
- | 124 | buildReport(true); |
|
- | 125 | ||
- | 126 | ||
122 | }
|
127 | }
|
123 | 128 | ||
124 | MainWindow::~MainWindow() |
129 | MainWindow::~MainWindow() |
125 | {
|
130 | {
|
126 | delete sql_mogel; |
131 | delete sql_mogel; |
Строка 947... | Строка 952... | ||
947 | ui->tableView_3->setItemDelegateForColumn(5, &filterConditionDelegate_1); |
952 | ui->tableView_3->setItemDelegateForColumn(5, &filterConditionDelegate_1); |
948 | 953 | ||
949 | 954 | ||
950 | 955 | ||
951 | 956 | ||
952 | - | ||
953 | - | ||
- | 957 | conditionList.clear(); |
|
- | 958 | conditionList <<"" << ")"; |
|
- | 959 | filterConditionDelegate_2.setItems(conditionList); |
|
- | 960 | ui->tableView_3->setItemDelegateForColumn(7, &filterConditionDelegate_2); |
|
954 | 961 | ||
955 | ui->tableView_3->setItemDelegateForColumn(6, &filterValueDelegate); |
962 | ui->tableView_3->setItemDelegateForColumn(6, &filterValueDelegate); |
956 | 963 | ||
957 | 964 | ||
958 | 965 | ||
Строка 1000... | Строка 1007... | ||
1000 | ui->pushButton_7->setEnabled(false); |
1007 | ui->pushButton_7->setEnabled(false); |
1001 | ui->pushButton_8->setEnabled(false); |
1008 | ui->pushButton_8->setEnabled(false); |
1002 | 1009 | ||
1003 | 1010 | ||
1004 | }
|
1011 | }
|
- | 1012 | ||
- | 1013 | void MainWindow::buildReport(bool advanced){ |
|
- | 1014 | ||
- | 1015 | // QTreeWidgetItem * hitm;
|
|
- | 1016 | ||
- | 1017 | // hitm = ui->treeWidget_2->headerItem();
|
|
- | 1018 | ||
- | 1019 | // int count = root_items_list.count();
|
|
- | 1020 | ||
- | 1021 | //int count = ui->treeWidget_2->rootIndex();
|
|
- | 1022 | ||
- | 1023 | doc.clear();//î÷èùàåì äîêóìåíò |
|
- | 1024 | ||
- | 1025 | int list_count; |
|
- | 1026 | if (rootItems.isEmpty()) return; |
|
- | 1027 | ||
- | 1028 | ||
- | 1029 | ||
- | 1030 | list_count = rootItems.count(); |
|
- | 1031 | ||
- | 1032 | for (int i=0; i < list_count; i++){ |
|
- | 1033 | ||
- | 1034 | getReport(rootItems.at(i), advanced); |
|
- | 1035 | ||
- | 1036 | }
|
|
- | 1037 | (bool)QTextDocumentWriter("test.odt").write(&doc); |
|
- | 1038 | }
|
|
- | 1039 | ||
- | 1040 | ||
- | 1041 | void MainWindow::getReport(QTreeWidgetItem * model_item, bool advanced){ // ñîçäàåò îò÷åò äëÿ êîíêðåòíîé ìîäåëè |
|
- | 1042 | ||
- | 1043 | ||
- | 1044 | // QTextDocument doc;
|
|
- | 1045 | // QTextCursor cursor(&doc);
|
|
- | 1046 | QTextCharFormat char_fmt;
|
|
- | 1047 | bool ok; |
|
- | 1048 | ||
- | 1049 | /**************
|
|
- | 1050 | ||
- | 1051 | // char_fmt.setBackground(Qt::red);
|
|
- | 1052 | cursor.insertText(tr("Ì1\n"),char_fmt);
|
|
- | 1053 | QImage img;
|
|
- | 1054 | ok = img.load("./hdd5.png");
|
|
- | 1055 | doc.addResource(QTextDocument::ImageResource, QUrl("myimage"), img);
|
|
- | 1056 | cursor.insertImage("myimage");
|
|
- | 1057 | cursor.insertText(tr("Æåñòêèé äèñê\n"),char_fmt);
|
|
- | 1058 | ||
- | 1059 | (bool)QTextDocumentWriter("test.odt").write(&doc);
|
|
- | 1060 | ***************/
|
|
- | 1061 | ||
- | 1062 | QString model_name;
|
|
- | 1063 | QString rootClassID;
|
|
- | 1064 | QString rootClassInctance;
|
|
- | 1065 | QFont font;
|
|
- | 1066 | ||
- | 1067 | model_name = model_item->text(0); |
|
- | 1068 | if (model_item->checkState(0) == false) return; // ìîäåëü íå âûäåëåíà äëÿ îòîáðàæåíèÿ |
|
- | 1069 | ||
- | 1070 | ||
- | 1071 | if (!(model_item->childCount() > 0)) return; // ìîäåëü ïóñòà (íå ñîäåðæèò êëàññîâ) |
|
- | 1072 | ||
- | 1073 | rootClassID = model_item->child(0)->text(1); |
|
- | 1074 | rootClassInctance = getClassInctance(rootClassID); |
|
- | 1075 | ||
- | 1076 | cursor->insertText(model_name); |
|
- | 1077 | cursor->insertText(tr("\n")); |
|
- | 1078 | ||
- | 1079 | if (model_item->child(0)->checkState(0)) // åñëè â ìîäåëè êîðíåâîé êëàññ âûáðàí äëÿ îòîáðàæåíèÿ (ñòîèò ãàëî÷êà), òî |
|
- | 1080 | {
|
|
- | 1081 | ///// QTreeWidgetItem * item_tmp;
|
|
- | 1082 | ///// item_tmp = new QTreeWidgetItem(item); // â äåðåâå, îòîáðàæàþùåì îáúåêòû êëàññîâ, ñîçäàåì íîâûé óçåë
|
|
- | 1083 | ///// item_tmp->setText(0, model_item->child(0)->text(0)); // ñ íàçâàíèåì êëàññà
|
|
- | 1084 | ||
- | 1085 | //showClassObjects(item_tmp, model_item->child(0)); // è âûâîäèì âñå îáúåêòû äàííîãî êëàññà
|
|
- | 1086 | ||
- | 1087 | ///// showObjects(item_tmp, model_item->child(0), tr(""));
|
|
- | 1088 | printChild(model_item->child(0), tr(""), advanced, 1); |
|
- | 1089 | }
|
|
- | 1090 | ||
- | 1091 | ||
- | 1092 | ||
- | 1093 | ||
- | 1094 | }
|
|
- | 1095 | ||
- | 1096 | void MainWindow::printChild(QTreeWidgetItem * model_item, QString filtr, bool advanced, int pos){//â ðàïîðò äîáàâëÿåì äî÷åðíèå êëàññû |
|
- | 1097 | QString classID; // èäåíòèôèêàòîð êëàññà |
|
- | 1098 | QString parentClassID; // èäåíòèôèêàòîð ðîäèòåëüñêîãî êëàññà |
|
- | 1099 | QString pointerField; // èìÿ ïîëÿ-óêàçàòåëÿ íà ðîäèòåëüñêèé êëàññ |
|
- | 1100 | QString inctance; // èìÿ òàáëèöû, õðàíèëèùà |
|
- | 1101 | QString className; // èìÿ êëàññà |
|
- | 1102 | QString modelID; // èäåíòèôèêàòîð ìîäåëè |
|
- | 1103 | QString add_filtr; // äîïîëíèòåëüíûé ôèëüòð |
|
- | 1104 | int field_ID; |
|
- | 1105 | int icon_field_index; |
|
- | 1106 | bool filtr_empty; |
|
- | 1107 | bool ok; |
|
- | 1108 | QSqlQuery q;
|
|
- | 1109 | QString sql_str;
|
|
- | 1110 | QString str_tmp;
|
|
- | 1111 | QTreeWidgetItem * title_item; |
|
- | 1112 | QFont font;
|
|
- | 1113 | QIcon icon;
|
|
- | 1114 | ||
- | 1115 | font.setBold(true); |
|
- | 1116 | filtr_empty = filtr.isEmpty(); |
|
- | 1117 | ||
- | 1118 | classID = model_item->text(1); |
|
- | 1119 | modelID = model_item->text(6); |
|
- | 1120 | add_filtr = MainWindow::getFiltrString(modelID, classID); |
|
- | 1121 | ||
- | 1122 | ||
- | 1123 | icon = model_item->icon(0); |
|
- | 1124 | ||
- | 1125 | parentClassID = model_item->parent()->text(1); |
|
- | 1126 | ||
- | 1127 | pointerField = getPointerFieldName(parentClassID, classID); |
|
- | 1128 | ||
- | 1129 | className = model_item->text(0); |
|
- | 1130 | inctance = getClassInctance(classID); |
|
- | 1131 | ||
- | 1132 | if (!model_item->checkState(0)) return; |
|
- | 1133 | ||
- | 1134 | ||
- | 1135 | cursor->insertText(className); |
|
- | 1136 | cursor->insertText(tr("\n")); |
|
- | 1137 | ||
- | 1138 | sql_str = tr("select * " |
|
- | 1139 | " from " //íàõîäèì âñå îáúåêòû êëàññà â òàáëèöå - õðàíèëèùå îáúåêòîâ êëàññà |
|
- | 1140 | ); |
|
- | 1141 | sql_str.append(inctance); |
|
- | 1142 | ||
- | 1143 | ||
- | 1144 | if (filtr.isEmpty() && (!add_filtr.isEmpty())) // ôèëüòð ïóñòîé, äîïîëíèòåëüíûé ôèëüòð íå ïóñòîé |
|
- | 1145 | {
|
|
- | 1146 | filtr.append(tr ("where ")); |
|
- | 1147 | filtr.append(add_filtr); |
|
- | 1148 | }
|
|
- | 1149 | ||
- | 1150 | ||
- | 1151 | if (!filtr.isEmpty()) { // åñëè ôèëüòð íå ïóñòîé |
|
- | 1152 | sql_str.append(tr(" ")); |
|
- | 1153 | sql_str.append(filtr); // äîáàâëÿåì â çàïðîñ ôèëüòð |
|
- | 1154 | }
|
|
- | 1155 | ||
- | 1156 | q.prepare(sql_str); |
|
- | 1157 | ||
- | 1158 | ok = q.exec(); |
|
- | 1159 | ||
- | 1160 | if (!ok) { |
|
- | 1161 | QString debug_str;
|
|
- | 1162 | debug_str.append(tr("ôóí showObjects(): Database Error ")); |
|
- | 1163 | debug_str.append(tr(" õð: ")); |
|
- | 1164 | debug_str.append(inctance); |
|
- | 1165 | debug_str.append(tr(" ô: ")); |
|
- | 1166 | debug_str.append(filtr); |
|
- | 1167 | debug_str.append(q.lastError().text()); |
|
- | 1168 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
|
- | 1169 | this, // Ðîäèòåëüñêèé âèäæåò. |
|
- | 1170 | QObject::tr("ôóíêöèÿ showObjects(): Database Error"), // Çàãîëîâîê. |
|
- | 1171 | debug_str |
|
- | 1172 | // q.lastError().text()
|
|
- | 1173 | ); // Òåêñò ñîîáùåíèÿ. |
|
- | 1174 | return; |
|
- | 1175 | }
|
|
- | 1176 | ||
- | 1177 | field_ID = q.record().indexOf(tr("ID")); |
|
- | 1178 | ||
- | 1179 | icon_field_index = q.record().indexOf(tr("Icon")); |
|
- | 1180 | ||
- | 1181 | ||
- | 1182 | ||
- | 1183 | ||
- | 1184 | while(q.next()){ |
|
- | 1185 | if (q.record().count() > 1) |
|
- | 1186 | {
|
|
- | 1187 | QString value_tmp;
|
|
- | 1188 | QString ID_tmp;
|
|
- | 1189 | QString space;
|
|
- | 1190 | ||
- | 1191 | // // // // QTreeWidgetItem * itm;
|
|
- | 1192 | ID_tmp = q.value(field_ID).toString(); // îïðåäåëÿåì èäåíòèôèêàòîð îáúåêòà |
|
- | 1193 | value_tmp = q.value(1).toString(); // îïðåäåëÿåì èìÿ îáúåêòà (äîëæíî õðàíèòüñÿ â ïåðâîì ïîëå) |
|
- | 1194 | // itm = new QTreeWidgetItem(parent_object_item); // äîáàâëÿåì â äåðåâî óçåë, ñîîòâåòñòâóþùèé îáúåêòó
|
|
- | 1195 | ||
- | 1196 | ||
- | 1197 | ||
- | 1198 | ||
- | 1199 | /***************************
|
|
- | 1200 | itm = new QTreeWidgetItem(title_item); // äîáàâëÿåì â äåðåâî óçåë, ñîîòâåòñòâóþùèé îáúåêòó
|
|
- | 1201 | itm->setText(0, value_tmp);
|
|
- | 1202 | itm->setText(1, tr("object"));
|
|
- | 1203 | itm->setText(2, ID_tmp);
|
|
- | 1204 | ******************************/
|
|
- | 1205 | ||
- | 1206 | if (icon_field_index != -1){ // åñëè èìååòñÿ ïîëå ñ èêîíêàìè |
|
- | 1207 | ||
- | 1208 | QVariant data;
|
|
- | 1209 | QByteArray bytes;
|
|
- | 1210 | QPixmap pix;
|
|
- | 1211 | QIcon icn;
|
|
- | 1212 | QMap <QString, QPixmap> pixmap_map; |
|
- | 1213 | QList <QString> id_list; |
|
- | 1214 | QList <QPixmap> pixmap_list; |
|
- | 1215 | pixmap_map = MainWindow::getObjectsIcon(inctance); |
|
- | 1216 | if (!pixmap_map.isEmpty()) { |
|
- | 1217 | id_list = pixmap_map.keys(); |
|
- | 1218 | pixmap_list = pixmap_map.values(); |
|
- | 1219 | }
|
|
- | 1220 | if (id_list.indexOf(ID_tmp) != -1) { |
|
- | 1221 | pix = pixmap_list.at(id_list.indexOf(ID_tmp)); |
|
- | 1222 | }
|
|
- | 1223 | // data = q.record().value(icon_field_index);
|
|
- | 1224 | // bytes = q.record().value(icon_field_index).toByteArray();
|
|
- | 1225 | // if (data.isValid() && (!data.isNull())) {
|
|
- | 1226 | // if (!bytes.isEmpty()){
|
|
- | 1227 | // pix.loadFromData(data.toByteArray());
|
|
- | 1228 | // pix.loadFromData(bytes);
|
|
- | 1229 | ||
- | 1230 | ||
- | 1231 | if(!pix.isNull()) { |
|
- | 1232 | if (pix.height() > 128) pix = pix.scaledToHeight(128); |
|
- | 1233 | QString fname = value_tmp; |
|
- | 1234 | fname.append(tr(".png")); |
|
- | 1235 | ||
- | 1236 | ||
- | 1237 | pix.toImage().save(fname); |
|
- | 1238 | doc.addResource(QTextDocument::ImageResource, QUrl(fname), pix.toImage()); |
|
- | 1239 | ||
- | 1240 | // for(int i=0; i<pos; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû
|
|
- | 1241 | ||
- | 1242 | ||
- | 1243 | for(int i=0; i<pos; i++){ cursor->insertText( tr("\t"));}// äîáàâëÿåì ïðîáåëû |
|
- | 1244 | cursor->insertImage(fname); |
|
- | 1245 | // cursor->insertText(tr("\n"));
|
|
- | 1246 | ||
- | 1247 | }
|
|
- | 1248 | ||
- | 1249 | ||
- | 1250 | ||
- | 1251 | ||
- | 1252 | // // // icn.addPixmap(pix);
|
|
- | 1253 | // // // itm->setIcon(0, icn);
|
|
- | 1254 | // }
|
|
- | 1255 | ||
- | 1256 | ||
- | 1257 | ||
- | 1258 | }
|
|
- | 1259 | ||
- | 1260 | for(int i=0; i<pos; i++){ cursor->insertText( tr("\t"));}// äîáàâëÿåì ïðîáåëû |
|
- | 1261 | ||
- | 1262 | cursor->insertText( value_tmp); |
|
- | 1263 | cursor->insertText( tr("\n")); |
|
- | 1264 | ||
- | 1265 | // itm->setIcon(0, icon);
|
|
- | 1266 | ||
- | 1267 | ||
- | 1268 | for (int i=0; i < model_item->childCount(); i++) // ïðîâåðÿåì, åñòü ëè ó êëàññà äî÷åðíèå êëàññû |
|
- | 1269 | {
|
|
- | 1270 | QTreeWidgetItem * model_item_tmp; // åñëè åñòü |
|
- | 1271 | QString pointer_name;
|
|
- | 1272 | QString filtr_tmp;
|
|
- | 1273 | bool pointer_isEmpty; |
|
- | 1274 | model_item_tmp = model_item->child(i); // îòîáðàæàåì îáúåêòû äî÷åðíèõ êëàññîâ |
|
- | 1275 | pointer_name = getPointerFieldName(classID, model_item->child(i)->text(1)); |
|
- | 1276 | // // // // itm->setText(4, pointer_name);
|
|
- | 1277 | ||
- | 1278 | // title_item->setText(4, pointer_name);
|
|
- | 1279 | ||
- | 1280 | ||
- | 1281 | pointer_isEmpty = pointer_name.isEmpty(); |
|
- | 1282 | filtr_tmp = tr("where "); |
|
- | 1283 | filtr_tmp.append(tr("`")); |
|
- | 1284 | filtr_tmp.append(pointer_name); |
|
- | 1285 | filtr_tmp.append(tr("` = '")); |
|
- | 1286 | filtr_tmp.append(ID_tmp); |
|
- | 1287 | filtr_tmp.append(tr("'")); |
|
- | 1288 | // // // // showObjects(itm, model_item_tmp, filtr_tmp);
|
|
- | 1289 | //MainWindow::showObjectChildrens(ID_tmp, itm, model_item_tmp);
|
|
- | 1290 | ||
- | 1291 | }
|
|
- | 1292 | ||
- | 1293 | ||
- | 1294 | }
|
|
- | 1295 | ||
- | 1296 | }
|
|
- | 1297 | ||
- | 1298 | ||
- | 1299 | ||
- | 1300 | ||
- | 1301 | ||
- | 1302 | ||
- | 1303 | ||
- | 1304 | ||
- | 1305 | ||
- | 1306 | ||
- | 1307 | }
|
|
- | 1308 | ||
- | 1309 |