Редакция 229 | Редакция 231 | К новейшей редакции | Весь файл | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 229 | Редакция 230 | ||
---|---|---|---|
Строка 1035... | Строка 1035... | ||
1035 | getReport(rootItems.at(i), advanced); |
1035 | getReport(rootItems.at(i), advanced); |
1036 | 1036 | ||
1037 | 1037 | ||
1038 | 1038 | ||
1039 | }
|
1039 | }
|
1040 | (bool)QTextDocumentWriter("test.odt").write(&doc); |
1040 | (bool)QTextDocumentWriter("raport.odt").write(&doc); |
1041 | }
|
1041 | }
|
1042 | 1042 | ||
1043 | 1043 | ||
1044 | void MainWindow::getReport(QTreeWidgetItem * model_item, bool advanced){ // ñîçäàåò îò÷åò äëÿ êîíêðåòíîé ìîäåëè |
1044 | void MainWindow::getReport(QTreeWidgetItem * model_item, bool advanced){ // ñîçäàåò îò÷åò äëÿ êîíêðåòíîé ìîäåëè |
1045 | 1045 | ||
Строка 1102... | Строка 1102... | ||
1102 | 1102 | ||
1103 | //showClassObjects(item_tmp, model_item->child(0)); // è âûâîäèì âñå îáúåêòû äàííîãî êëàññà
|
1103 | //showClassObjects(item_tmp, model_item->child(0)); // è âûâîäèì âñå îáúåêòû äàííîãî êëàññà
|
1104 | 1104 | ||
1105 | ///// showObjects(item_tmp, model_item->child(0), tr(""));
|
1105 | ///// showObjects(item_tmp, model_item->child(0), tr(""));
|
1106 | printChild(model_item->child(0), tr(""), advanced, 1); |
1106 | printChild(model_item->child(0), tr(""), advanced, 1); |
- | 1107 | ||
1107 | }
|
1108 | }
|
1108 | 1109 | ||
1109 | 1110 | ||
1110 | 1111 | ||
1111 | 1112 | ||
Строка 1127... | Строка 1128... | ||
1127 | QString sql_str;
|
1128 | QString sql_str;
|
1128 | QString str_tmp;
|
1129 | QString str_tmp;
|
1129 | QTreeWidgetItem * title_item; |
1130 | QTreeWidgetItem * title_item; |
1130 | QFont font;
|
1131 | QFont font;
|
1131 | QIcon icon;
|
1132 | QIcon icon;
|
1132 | - | ||
- | 1133 | QMap<QString, QString> fieldsTypesList;//çäåñü â êà÷åñòâå êëþ÷å áóäåì õðàíèòü èìåíà ïîëåé, çíà÷åíèÿìè áóäóò èõ òèïû |
|
- | 1134 | //QList<TField> FieldsList; //ñïèñîê ïîëåé êëàññà
|
|
1133 | 1135 | ||
1134 | 1136 | ||
1135 | 1137 | ||
1136 | 1138 | ||
1137 | font.setBold(true); |
1139 | font.setBold(true); |
Строка 1214... | Строка 1216... | ||
1214 | 1216 | ||
1215 | icon_field_index = q.record().indexOf(tr("Icon")); |
1217 | icon_field_index = q.record().indexOf(tr("Icon")); |
1216 | 1218 | ||
1217 | int k=0; |
1219 | int k=0; |
1218 | QStringList fieldsNamesList;// ñïèñîê èì¸í ïîëåé òàáëèöû |
1220 | QStringList fieldsNamesList;// ñïèñîê èì¸í ïîëåé òàáëèöû |
- | 1221 | QList<TField> FieldsList; //ñïèñîê ïîëåé êëàññà |
|
- | 1222 | ||
- | 1223 | FieldsList = getFieldList(classID); // ïîëó÷àåì ñïèñîê ïîëåé |
|
- | 1224 | ||
- | 1225 | ||
- | 1226 | if(FieldsList.count()>0){ |
|
- | 1227 | for(int i=0; i < FieldsList.count(); i++){ //ñîñòàâèì ïàðû (èìÿ ïîëÿ-òèï ïîëÿ) |
|
- | 1228 | fieldsTypesList.insert(FieldsList.at(i).FieldName, FieldsList.at(i).FieldType); |
|
- | 1229 | }
|
|
- | 1230 | ||
- | 1231 | // fieldsNamesList = fieldsTypesList.keys(); // ïîëó÷èì ñïèñîê èìåí ïîëåé
|
|
- | 1232 | }
|
|
1219 | 1233 | ||
- | 1234 | // icon_field_index = fieldsNamesList.indexOf(tr("Icon"));//îïðåäåëèì èíäåêñ ïîëÿ ñ èêîíêîé
|
|
1220 | 1235 | ||
1221 | 1236 | ||
1222 | 1237 | ||
1223 | while(!q.record().fieldName(k).isEmpty()){// ïîêà íå ïåðåáåð¸ì âñå ïîëÿ |
1238 | while(!q.record().fieldName(k).isEmpty()){// ïîêà íå ïåðåáåð¸ì âñå ïîëÿ |
1224 | fieldsNamesList.append(q.record().fieldName(k++)); |
1239 | fieldsNamesList.append(q.record().fieldName(k++)); |
1225 | }
|
1240 | }
|
1226 | 1241 | ||
1227 | 1242 | ||
- | 1243 | //icon_field_index = fieldsNamesList.indexOf(tr("Icon"));//îïðåäåëèì èíäåêñ ïîëÿ ñ èêîíêîé
|
|
- | 1244 | ||
- | 1245 | ||
1228 | while(q.next()){ |
1246 | while(q.next()){ |
1229 | if (q.record().count() > 1) |
1247 | if (q.record().count() > 1) |
1230 | {
|
1248 | {
|
1231 | QString value_tmp;
|
1249 | QString value_tmp;
|
1232 | QString ID_tmp;
|
1250 | QString ID_tmp;
|
Строка 1305... | Строка 1323... | ||
1305 | cursor->insertText( value_tmp); |
1323 | cursor->insertText( value_tmp); |
1306 | cursor->insertText( tr("\n")); |
1324 | cursor->insertText( tr("\n")); |
1307 | 1325 | ||
1308 | 1326 | ||
1309 | 1327 | ||
- | 1328 | // q.first();
|
|
- | 1329 | ||
1310 | 1330 | ||
1311 | if(advanced){ // åñëè îò÷åò ðàñøèðåííûé |
1331 | if(advanced && (fieldsNamesList.count()>0)){ // åñëè îò÷åò ðàñøèðåííûé |
1312 | 1332 | ||
- | 1333 | QString tmp_string;
|
|
1313 | sql_str.clear(); |
1334 | sql_str.clear(); |
1314 | 1335 | ||
- | 1336 | QTextTable *table = cursor->insertTable(fieldsNamesList.count()-2, 2);// ñîçäàäèì òàáëèöó äëÿ ïîëåé êëàññà, êðîìå ïåðâûõ äâóõ (ID è íàçâàíèå îáúåêòà) |
|
- | 1337 | ||
- | 1338 | // cursor->insertText(tr("Ïðîâåðêà òàáëèöû"));
|
|
- | 1339 | ||
- | 1340 | ||
- | 1341 | // *cursor = table->cellAt(0,1).firstCursorPosition();
|
|
- | 1342 | // cursor->insertText(tr("Ïðîâåðêà òàáëèöû 2"));
|
|
- | 1343 | // *cursor = table->cellAt(1,1).lastCursorPosition();
|
|
- | 1344 | // cursor->insertText(tr("Ïðîâåðêà òàáëèöû 4"));
|
|
- | 1345 | ||
1315 | 1346 | ||
- | 1347 | // cursor->movePosition(QTextCursor::End);
|
|
1316 | 1348 | ||
- | 1349 | ||
- | 1350 | ||
- | 1351 | //table->cellAt(1,1).firstCursorPosition().insertText(tr("1"));
|
|
- | 1352 | //table->cellAt(1,2).firstCursorPosition().insertText(tr("2"));
|
|
- | 1353 | //table->cellAt(2,1).firstCursorPosition().insertText(tr("3"));
|
|
- | 1354 | ||
- | 1355 | //table->cellAt(2,2).firstCursorPosition().insertText(tr("4"));
|
|
- | 1356 | // cursor->insertText(tr("1 \t 2"));
|
|
- | 1357 | // cursor->insertText(tr("3 \t 4"));
|
|
- | 1358 | ||
- | 1359 | ||
- | 1360 | for(int i=2; i < fieldsNamesList.count(); i++){ // ïðîïóñòèì ïîëÿ: ID è ïîëå, ñîäåðæàùåå èìÿ îáúåêòà (îíî è òàê óæå îòîáðàæåíî) |
|
- | 1361 | // if (i !=icon_field_index) tmp_string = q.record().value(i).asString(); // åñëè ýòî íå èêîíêà, òî ñ÷èòûâàåì çíà÷åíèå êàê ñòðîêó
|
|
- | 1362 | if (i !=icon_field_index) tmp_string = q.record().value(i).asString(); // åñëè ýòî íå èêîíêà, òî ñ÷èòûâàåì çíà÷åíèå êàê ñòðîêó |
|
- | 1363 | ||
- | 1364 | ||
- | 1365 | else tmp_string = tr("íåâîçìîæíî îòîáðàçèòü"); |
|
- | 1366 | //// if (i !=icon_field_index) {
|
|
- | 1367 | for(int i=0; i<pos+2; i++){ cursor->insertText( tr(" "));}// äîáàâëÿåì ïðîáåëû |
|
- | 1368 | *cursor = table->cellAt(i-2,0).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö ïåðâûé |
|
- | 1369 | cursor->insertText( fieldsNamesList.at(i));//ñþäà çàíîñèì èìÿ ïîëÿ |
|
- | 1370 | *cursor = table->cellAt(i-2,1).firstCursorPosition();// ñòðîêà i-òàÿ, ñòîëáåö âòîðîé |
|
- | 1371 | //cursor->insertText( tr(":\t"));
|
|
- | 1372 | ||
- | 1373 | cursor->insertText(tmp_string);//ñþäà çíà÷åíèå ïîëÿ |
|
- | 1374 | // cursor->insertText( tr("\n"));
|
|
- | 1375 | }
|
|
- | 1376 | ||
- | 1377 | //// }
|
|
- | 1378 | cursor->movePosition(QTextCursor::End);//âûõîäèì èç òàáëèöû |
|
- | 1379 | cursor->insertText( tr("\n")); |
|
1317 | }
|
1380 | }
|
1318 | 1381 | ||
1319 | 1382 | ||
1320 | 1383 | ||
1321 | /********************************************************
|
1384 | /********************************************************
|
Строка 1358... | Строка 1421... | ||
1358 | 1421 | ||
1359 | // // // // showObjects(itm, model_item_tmp, filtr_tmp);
|
1422 | // // // // showObjects(itm, model_item_tmp, filtr_tmp);
|
1360 | //MainWindow::showObjectChildrens(ID_tmp, itm, model_item_tmp);
|
1423 | //MainWindow::showObjectChildrens(ID_tmp, itm, model_item_tmp);
|
1361 | 1424 | ||
1362 | }
|
1425 | }
|
1363 | - | ||
- | 1426 | if(pos==2) newPage(); // åñëè ýòî êîðíåâîé êëàññ, âñòàâèì ðàçäåë ñòðàíèöû |
|
1364 | 1427 | ||
1365 | }
|
1428 | }
|
1366 | 1429 | ||
1367 | }
|
1430 | }
|
1368 | 1431 | ||
Строка 1404... | Строка 1467... | ||
1404 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto); |
1467 | textFormat.setPageBreakPolicy(QTextFormat::PageBreak_Auto); |
1405 | cursor->setBlockFormat(textFormat); |
1468 | cursor->setBlockFormat(textFormat); |
1406 | 1469 | ||
1407 | 1470 | ||
1408 | }
|
1471 | }
|
- | 1472 | ||
- | 1473 | QList<TField> MainWindow::getFieldList(QString class_id){// ïîëó÷àåì ñïèñîê ïîëåé êëàññà |
|
- | 1474 | ||
- | 1475 | QSqlQuery q;
|
|
- | 1476 | QString sql_str;
|
|
- | 1477 | QList<TField> result_list; |
|
- | 1478 | ||
- | 1479 | int field_id, field_name, field_alias, field_type, field_default_value, field_classIdentifer, field_comment; |
|
- | 1480 | ||
- | 1481 | bool ok; |
|
- | 1482 | sql_str = tr("select * " |
|
- | 1483 | " from `DescriptionOfClasses` where `DescriptionOfClasses`.`ClassIdentifer` = " //íàõîäèì âñå îáúåêòû êëàññà â òàáëèöå - õðàíèëèùå îáúåêòîâ êëàññà |
|
- | 1484 | ); |
|
- | 1485 | ||
- | 1486 | sql_str.append(tr("'")); |
|
- | 1487 | sql_str.append(class_id); |
|
- | 1488 | sql_str.append(tr("' ")); |
|
- | 1489 | ok = q.prepare(sql_str); |
|
- | 1490 | ||
- | 1491 | ok = q.exec(); |
|
- | 1492 | if (!ok) { |
|
- | 1493 | QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå. |
|
- | 1494 | this, // Ðîäèòåëüñêèé âèäæåò. |
|
- | 1495 | QObject::tr("Database Error"), // Çàãîëîâîê. |
|
- | 1496 | q.lastError().text()); // Òåêñò ñîîáùåíèÿ. |
|
- | 1497 | return result_list; |
|
- | 1498 | }
|
|
- | 1499 | ||
- | 1500 | ||
- | 1501 | field_id = q.record().indexOf(tr("ID")); |
|
- | 1502 | field_name = q.record().indexOf(tr("FieldName")); |
|
- | 1503 | field_alias = q.record().indexOf(tr("FieldAlias")); |
|
- | 1504 | field_type = q.record().indexOf(tr("FieldType")); |
|
- | 1505 | field_default_value = q.record().indexOf(tr("DefaultValue")); |
|
- | 1506 | field_classIdentifer = q.record().indexOf(tr("ClassIdentifer")); |
|
- | 1507 | field_comment = q.record().indexOf(tr("Comment")); |
|
- | 1508 | ||
- | 1509 | while(q.next()){ |
|
- | 1510 | ||
- | 1511 | TField field_tmp;
|
|
- | 1512 | field_tmp.ID = q.value(field_id).toString(); |
|
- | 1513 | field_tmp.FieldName = q.value(field_name).toString(); |
|
- | 1514 | field_tmp.FieldAlias = q.value(field_alias).toString(); |
|
- | 1515 | field_tmp.FieldType = q.value(field_type).toString(); |
|
- | 1516 | field_tmp.DefaultValue = q.value(field_default_value).toString(); |
|
- | 1517 | field_tmp.ClassIdentifer = q.value(field_classIdentifer).toString(); |
|
- | 1518 | field_tmp.Comment = q.value(field_comment).toString(); |
|
- | 1519 | result_list << field_tmp; |
|
- | 1520 | ||
- | 1521 | ||
- | 1522 | ||
- | 1523 | ||
- | 1524 | // parentClassID = q.value(field_default_value).toString();
|
|
- | 1525 | // parentClassInctance = getClassInctance(parentClassID);
|
|
- | 1526 | // result_map.insert(pointerFieldName, parentClassInctance);
|
|
- | 1527 | ||
- | 1528 | ||
- | 1529 | ||
- | 1530 | }
|
|
- | 1531 | ||
- | 1532 | return result_list; |
|
- | 1533 | ||
- | 1534 | }
|