Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesigner.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
69 | // a simple class to hold/hide data in the ReportHandler class | 69 | // a simple class to hold/hide data in the ReportHandler class | ||
70 | // | 70 | // | ||
71 | class ReportWriterSectionData | 71 | class ReportWriterSectionData | ||
72 | { | 72 | { | ||
73 | public: | 73 | public: | ||
74 | ReportWriterSectionData() { | 74 | ReportWriterSectionData() { | ||
75 | selected_x_offset = 0; | 75 | selected_x_offset = 0; | ||
76 | selected_y_offset = 0; | 76 | selected_y_offset = 0; | ||
77 | mouseAction = ReportWriterSectionData::MA_None; | 77 | mouseAction = MouseAction::None; | ||
78 | } | 78 | } | ||
79 | virtual ~ReportWriterSectionData() { | 79 | virtual ~ReportWriterSectionData() { | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | enum MouseAction { | 82 | enum class MouseAction { | ||
83 | MA_None = 0, | 83 | None = 0, | ||
84 | MA_Insert = 1, | 84 | Insert = 1, | ||
85 | MA_Grab = 2, | 85 | Grab = 2, | ||
86 | MA_MoveStartPoint, | 86 | MoveStartPoint, | ||
87 | MA_MoveEndPoint, | 87 | MoveEndPoint, | ||
88 | MA_ResizeNW = 8, | 88 | ResizeNW = 8, | ||
89 | MA_ResizeN, | 89 | ResizeN, | ||
90 | MA_ResizeNE, | 90 | ResizeNE, | ||
91 | MA_ResizeE, | 91 | ResizeE, | ||
92 | MA_ResizeSE, | 92 | ResizeSE, | ||
93 | MA_ResizeS, | 93 | ResizeS, | ||
94 | MA_ResizeSW, | 94 | ResizeSW, | ||
95 | MA_ResizeW | 95 | ResizeW | ||
96 | }; | 96 | }; | ||
97 | 97 | | |||
98 | int selected_x_offset; | 98 | int selected_x_offset; | ||
99 | int selected_y_offset; | 99 | int selected_y_offset; | ||
100 | 100 | | |||
101 | MouseAction mouseAction; | 101 | MouseAction mouseAction; | ||
102 | QString itemToInsert; | 102 | QString itemToInsert; | ||
103 | 103 | | |||
▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Line(s) | 378 | #endif | |||
411 | KReportUtils::setAttribute(&pagestyle, QLatin1String("fo:margin-right"), d->rightMargin->value().toDouble()); | 411 | KReportUtils::setAttribute(&pagestyle, QLatin1String("fo:margin-right"), d->rightMargin->value().toDouble()); | ||
412 | KReportUtils::setAttribute(&pagestyle, QLatin1String("fo:margin-left"), d->leftMargin->value().toDouble()); | 412 | KReportUtils::setAttribute(&pagestyle, QLatin1String("fo:margin-left"), d->leftMargin->value().toDouble()); | ||
413 | 413 | | |||
414 | content.appendChild(pagestyle); | 414 | content.appendChild(pagestyle); | ||
415 | 415 | | |||
416 | QDomElement body = doc.createElement(QLatin1String("report:body")); | 416 | QDomElement body = doc.createElement(QLatin1String("report:body")); | ||
417 | QDomElement domsection; | 417 | QDomElement domsection; | ||
418 | 418 | | |||
419 | for (int i = KReportSectionData::PageHeaderFirst; i <= KReportSectionData::PageFooterAny; ++i) { | 419 | for (int i = static_cast<int>(KReportSectionData::Type::PageHeaderFirst); | ||
420 | KReportDesignerSection *sec = section((KReportSectionData::Section)i); | 420 | i <= static_cast<int>(KReportSectionData::Type::PageFooterAny); ++i) | ||
421 | { | ||||
422 | KReportDesignerSection *sec = section(static_cast<KReportSectionData::Type>(i)); | ||||
421 | if (sec) { | 423 | if (sec) { | ||
422 | domsection = doc.createElement(QLatin1String("report:section")); | 424 | domsection = doc.createElement(QLatin1String("report:section")); | ||
423 | domsection.setAttribute(QLatin1String("report:section-type"), KReportSectionData::sectionTypeString(KReportSectionData::Section(i))); | 425 | domsection.setAttribute( | ||
426 | QLatin1String("report:section-type"), | ||||
427 | KReportSectionData::sectionTypeString(static_cast<KReportSectionData::Type>(i))); | ||||
424 | sec->buildXML(&doc, &domsection); | 428 | sec->buildXML(&doc, &domsection); | ||
425 | body.appendChild(domsection); | 429 | body.appendChild(domsection); | ||
426 | } | 430 | } | ||
427 | } | 431 | } | ||
428 | 432 | | |||
429 | QDomElement detail = doc.createElement(QLatin1String("report:detail")); | 433 | QDomElement detail = doc.createElement(QLatin1String("report:detail")); | ||
430 | d->detail->buildXML(&doc, &detail); | 434 | d->detail->buildXML(&doc, &detail); | ||
431 | body.appendChild(detail); | 435 | body.appendChild(detail); | ||
Show All 23 Lines | |||||
455 | 459 | | |||
456 | #ifdef KREPORT_SCRIPTING | 460 | #ifdef KREPORT_SCRIPTING | ||
457 | void KReportDesigner::setScriptSource(KReportScriptSource* source) | 461 | void KReportDesigner::setScriptSource(KReportScriptSource* source) | ||
458 | { | 462 | { | ||
459 | d->scriptSource = source; | 463 | d->scriptSource = source; | ||
460 | } | 464 | } | ||
461 | #endif | 465 | #endif | ||
462 | 466 | | |||
463 | KReportDesignerSection * KReportDesigner::section(KReportSectionData::Section s) const | 467 | KReportDesignerSection * KReportDesigner::section(KReportSectionData::Type type) const | ||
464 | { | 468 | { | ||
465 | KReportDesignerSection *sec; | 469 | KReportDesignerSection *sec; | ||
466 | switch (s) { | 470 | switch (type) { | ||
467 | case KReportSectionData::PageHeaderAny: | 471 | case KReportSectionData::Type::PageHeaderAny: | ||
468 | sec = d->pageHeaderAny; | 472 | sec = d->pageHeaderAny; | ||
469 | break; | 473 | break; | ||
470 | case KReportSectionData::PageHeaderEven: | 474 | case KReportSectionData::Type::PageHeaderEven: | ||
471 | sec = d->pageHeaderEven; | 475 | sec = d->pageHeaderEven; | ||
472 | break; | 476 | break; | ||
473 | case KReportSectionData::PageHeaderOdd: | 477 | case KReportSectionData::Type::PageHeaderOdd: | ||
474 | sec = d->pageHeaderOdd; | 478 | sec = d->pageHeaderOdd; | ||
475 | break; | 479 | break; | ||
476 | case KReportSectionData::PageHeaderFirst: | 480 | case KReportSectionData::Type::PageHeaderFirst: | ||
477 | sec = d->pageHeaderFirst; | 481 | sec = d->pageHeaderFirst; | ||
478 | break; | 482 | break; | ||
479 | case KReportSectionData::PageHeaderLast: | 483 | case KReportSectionData::Type::PageHeaderLast: | ||
480 | sec = d->pageHeaderLast; | 484 | sec = d->pageHeaderLast; | ||
481 | break; | 485 | break; | ||
482 | case KReportSectionData::PageFooterAny: | 486 | case KReportSectionData::Type::PageFooterAny: | ||
483 | sec = d->pageFooterAny; | 487 | sec = d->pageFooterAny; | ||
484 | break; | 488 | break; | ||
485 | case KReportSectionData::PageFooterEven: | 489 | case KReportSectionData::Type::PageFooterEven: | ||
486 | sec = d->pageFooterEven; | 490 | sec = d->pageFooterEven; | ||
487 | break; | 491 | break; | ||
488 | case KReportSectionData::PageFooterOdd: | 492 | case KReportSectionData::Type::PageFooterOdd: | ||
489 | sec = d->pageFooterOdd; | 493 | sec = d->pageFooterOdd; | ||
490 | break; | 494 | break; | ||
491 | case KReportSectionData::PageFooterFirst: | 495 | case KReportSectionData::Type::PageFooterFirst: | ||
492 | sec = d->pageFooterFirst; | 496 | sec = d->pageFooterFirst; | ||
493 | break; | 497 | break; | ||
494 | case KReportSectionData::PageFooterLast: | 498 | case KReportSectionData::Type::PageFooterLast: | ||
495 | sec = d->pageFooterLast; | 499 | sec = d->pageFooterLast; | ||
496 | break; | 500 | break; | ||
497 | case KReportSectionData::ReportHeader: | 501 | case KReportSectionData::Type::ReportHeader: | ||
498 | sec = d->reportHeader; | 502 | sec = d->reportHeader; | ||
499 | break; | 503 | break; | ||
500 | case KReportSectionData::ReportFooter: | 504 | case KReportSectionData::Type::ReportFooter: | ||
501 | sec = d->reportFooter; | 505 | sec = d->reportFooter; | ||
502 | break; | 506 | break; | ||
503 | default: | 507 | default: | ||
504 | sec = nullptr; | 508 | sec = nullptr; | ||
505 | } | 509 | } | ||
506 | return sec; | 510 | return sec; | ||
507 | } | 511 | } | ||
508 | 512 | | |||
509 | KReportDesignerSection* KReportDesigner::createSection() | 513 | KReportDesignerSection* KReportDesigner::createSection() | ||
510 | { | 514 | { | ||
511 | return new KReportDesignerSection(this, d->zoomHandler); | 515 | return new KReportDesignerSection(this, d->zoomHandler); | ||
512 | } | 516 | } | ||
513 | 517 | | |||
514 | void KReportDesigner::removeSection(KReportSectionData::Section s) | 518 | void KReportDesigner::removeSection(KReportSectionData::Type type) | ||
515 | { | 519 | { | ||
516 | KReportDesignerSection* sec = section(s); | 520 | KReportDesignerSection* sec = section(type); | ||
517 | if (sec) { | 521 | if (sec) { | ||
518 | delete sec; | 522 | delete sec; | ||
519 | 523 | | |||
520 | switch (s) { | 524 | switch (type) { | ||
521 | case KReportSectionData::PageHeaderAny: | 525 | case KReportSectionData::Type::PageHeaderAny: | ||
522 | d->pageHeaderAny = nullptr; | 526 | d->pageHeaderAny = nullptr; | ||
523 | break; | 527 | break; | ||
524 | case KReportSectionData::PageHeaderEven: | 528 | case KReportSectionData::Type::PageHeaderEven: | ||
525 | sec = d->pageHeaderEven = nullptr; | 529 | sec = d->pageHeaderEven = nullptr; | ||
526 | break; | 530 | break; | ||
527 | case KReportSectionData::PageHeaderOdd: | 531 | case KReportSectionData::Type::PageHeaderOdd: | ||
528 | d->pageHeaderOdd = nullptr; | 532 | d->pageHeaderOdd = nullptr; | ||
529 | break; | 533 | break; | ||
530 | case KReportSectionData::PageHeaderFirst: | 534 | case KReportSectionData::Type::PageHeaderFirst: | ||
531 | d->pageHeaderFirst = nullptr; | 535 | d->pageHeaderFirst = nullptr; | ||
532 | break; | 536 | break; | ||
533 | case KReportSectionData::PageHeaderLast: | 537 | case KReportSectionData::Type::PageHeaderLast: | ||
534 | d->pageHeaderLast = nullptr; | 538 | d->pageHeaderLast = nullptr; | ||
535 | break; | 539 | break; | ||
536 | case KReportSectionData::PageFooterAny: | 540 | case KReportSectionData::Type::PageFooterAny: | ||
537 | d->pageFooterAny = nullptr; | 541 | d->pageFooterAny = nullptr; | ||
538 | break; | 542 | break; | ||
539 | case KReportSectionData::PageFooterEven: | 543 | case KReportSectionData::Type::PageFooterEven: | ||
540 | d->pageFooterEven = nullptr; | 544 | d->pageFooterEven = nullptr; | ||
541 | break; | 545 | break; | ||
542 | case KReportSectionData::PageFooterOdd: | 546 | case KReportSectionData::Type::PageFooterOdd: | ||
543 | d->pageFooterOdd = nullptr; | 547 | d->pageFooterOdd = nullptr; | ||
544 | break; | 548 | break; | ||
545 | case KReportSectionData::PageFooterFirst: | 549 | case KReportSectionData::Type::PageFooterFirst: | ||
546 | d->pageFooterFirst = nullptr; | 550 | d->pageFooterFirst = nullptr; | ||
547 | break; | 551 | break; | ||
548 | case KReportSectionData::PageFooterLast: | 552 | case KReportSectionData::Type::PageFooterLast: | ||
549 | d->pageFooterLast = nullptr; | 553 | d->pageFooterLast = nullptr; | ||
550 | break; | 554 | break; | ||
551 | case KReportSectionData::ReportHeader: | 555 | case KReportSectionData::Type::ReportHeader: | ||
552 | d->reportHeader = nullptr; | 556 | d->reportHeader = nullptr; | ||
553 | break; | 557 | break; | ||
554 | case KReportSectionData::ReportFooter: | 558 | case KReportSectionData::Type::ReportFooter: | ||
555 | d->reportFooter = nullptr; | 559 | d->reportFooter = nullptr; | ||
556 | break; | 560 | break; | ||
557 | default: | 561 | default: | ||
558 | sec = nullptr; | 562 | sec = nullptr; | ||
559 | } | 563 | } | ||
560 | 564 | | |||
561 | setModified(true); | 565 | setModified(true); | ||
562 | adjustSize(); | 566 | adjustSize(); | ||
563 | } | 567 | } | ||
564 | } | 568 | } | ||
565 | 569 | | |||
566 | void KReportDesigner::insertSection(KReportSectionData::Section s) | 570 | void KReportDesigner::insertSection(KReportSectionData::Type type) | ||
567 | { | 571 | { | ||
568 | KReportDesignerSection* sec = section(s); | 572 | KReportDesignerSection* sec = section(type); | ||
569 | if (!sec) { | 573 | if (!sec) { | ||
570 | int idx = 0; | 574 | int idx = 0; | ||
571 | for (int i = 1; i <= s; ++i) { | 575 | for (int i = static_cast<int>(KReportSectionData::Type::None) + 1; | ||
572 | if (section((KReportSectionData::Section)i)) | 576 | i <= static_cast<int>(type); ++i) | ||
577 | { | ||||
578 | if (section(static_cast<KReportSectionData::Type>(i))) | ||||
573 | idx++; | 579 | idx++; | ||
574 | } | 580 | } | ||
575 | if (s > KReportSectionData::ReportHeader) | 581 | if (type > KReportSectionData::Type::ReportHeader) | ||
576 | idx++; | 582 | idx++; | ||
577 | //kreportDebug() << idx; | 583 | //kreportDebug() << idx; | ||
578 | KReportDesignerSection *rs = createSection(); | 584 | KReportDesignerSection *rs = createSection(); | ||
579 | d->vboxlayout->insertWidget(idx, rs); | 585 | d->vboxlayout->insertWidget(idx, rs); | ||
580 | 586 | | |||
581 | switch (s) { | 587 | switch (type) { | ||
582 | case KReportSectionData::PageHeaderAny: | 588 | case KReportSectionData::Type::PageHeaderAny: | ||
583 | rs->setTitle(tr("Page Header (Any)")); | 589 | rs->setTitle(tr("Page Header (Any)")); | ||
584 | d->pageHeaderAny = rs; | 590 | d->pageHeaderAny = rs; | ||
585 | break; | 591 | break; | ||
586 | case KReportSectionData::PageHeaderEven: | 592 | case KReportSectionData::Type::PageHeaderEven: | ||
587 | rs->setTitle(tr("Page Header (Even)")); | 593 | rs->setTitle(tr("Page Header (Even)")); | ||
588 | d->pageHeaderEven = rs; | 594 | d->pageHeaderEven = rs; | ||
589 | break; | 595 | break; | ||
590 | case KReportSectionData::PageHeaderOdd: | 596 | case KReportSectionData::Type::PageHeaderOdd: | ||
591 | rs->setTitle(tr("Page Header (Odd)")); | 597 | rs->setTitle(tr("Page Header (Odd)")); | ||
592 | d->pageHeaderOdd = rs; | 598 | d->pageHeaderOdd = rs; | ||
593 | break; | 599 | break; | ||
594 | case KReportSectionData::PageHeaderFirst: | 600 | case KReportSectionData::Type::PageHeaderFirst: | ||
595 | rs->setTitle(tr("Page Header (First)")); | 601 | rs->setTitle(tr("Page Header (First)")); | ||
596 | d->pageHeaderFirst = rs; | 602 | d->pageHeaderFirst = rs; | ||
597 | break; | 603 | break; | ||
598 | case KReportSectionData::PageHeaderLast: | 604 | case KReportSectionData::Type::PageHeaderLast: | ||
599 | rs->setTitle(tr("Page Header (Last)")); | 605 | rs->setTitle(tr("Page Header (Last)")); | ||
600 | d->pageHeaderLast = rs; | 606 | d->pageHeaderLast = rs; | ||
601 | break; | 607 | break; | ||
602 | case KReportSectionData::PageFooterAny: | 608 | case KReportSectionData::Type::PageFooterAny: | ||
603 | rs->setTitle(tr("Page Footer (Any)")); | 609 | rs->setTitle(tr("Page Footer (Any)")); | ||
604 | d->pageFooterAny = rs; | 610 | d->pageFooterAny = rs; | ||
605 | break; | 611 | break; | ||
606 | case KReportSectionData::PageFooterEven: | 612 | case KReportSectionData::Type::PageFooterEven: | ||
607 | rs->setTitle(tr("Page Footer (Even)")); | 613 | rs->setTitle(tr("Page Footer (Even)")); | ||
608 | d->pageFooterEven = rs; | 614 | d->pageFooterEven = rs; | ||
609 | break; | 615 | break; | ||
610 | case KReportSectionData::PageFooterOdd: | 616 | case KReportSectionData::Type::PageFooterOdd: | ||
611 | rs->setTitle(tr("Page Footer (Odd)")); | 617 | rs->setTitle(tr("Page Footer (Odd)")); | ||
612 | d->pageFooterOdd = rs; | 618 | d->pageFooterOdd = rs; | ||
613 | break; | 619 | break; | ||
614 | case KReportSectionData::PageFooterFirst: | 620 | case KReportSectionData::Type::PageFooterFirst: | ||
615 | rs->setTitle(tr("Page Footer (First)")); | 621 | rs->setTitle(tr("Page Footer (First)")); | ||
616 | d->pageFooterFirst = rs; | 622 | d->pageFooterFirst = rs; | ||
617 | break; | 623 | break; | ||
618 | case KReportSectionData::PageFooterLast: | 624 | case KReportSectionData::Type::PageFooterLast: | ||
619 | rs->setTitle(tr("Page Footer (Last)")); | 625 | rs->setTitle(tr("Page Footer (Last)")); | ||
620 | d->pageFooterLast = rs; | 626 | d->pageFooterLast = rs; | ||
621 | break; | 627 | break; | ||
622 | case KReportSectionData::ReportHeader: | 628 | case KReportSectionData::Type::ReportHeader: | ||
623 | rs->setTitle(tr("Report Header")); | 629 | rs->setTitle(tr("Report Header")); | ||
624 | d->reportHeader = rs; | 630 | d->reportHeader = rs; | ||
625 | break; | 631 | break; | ||
626 | case KReportSectionData::ReportFooter: | 632 | case KReportSectionData::Type::ReportFooter: | ||
627 | rs->setTitle(tr("Report Footer")); | 633 | rs->setTitle(tr("Report Footer")); | ||
628 | d->reportFooter = rs; | 634 | d->reportFooter = rs; | ||
629 | break; | 635 | break; | ||
630 | //These sections cannot be inserted this way | 636 | //These sections cannot be inserted this way | ||
631 | case KReportSectionData::None: | 637 | case KReportSectionData::Type::None: | ||
632 | case KReportSectionData::GroupHeader: | 638 | case KReportSectionData::Type::GroupHeader: | ||
633 | case KReportSectionData::GroupFooter: | 639 | case KReportSectionData::Type::GroupFooter: | ||
634 | case KReportSectionData::Detail: | 640 | case KReportSectionData::Type::Detail: | ||
635 | break; | 641 | break; | ||
636 | } | 642 | } | ||
637 | 643 | | |||
638 | rs->show(); | 644 | rs->show(); | ||
639 | setModified(true); | 645 | setModified(true); | ||
640 | adjustSize(); | 646 | adjustSize(); | ||
641 | emit pagePropertyChanged(d->set); | 647 | emit pagePropertyChanged(d->set); | ||
642 | } | 648 | } | ||
▲ Show 20 Lines • Show All 336 Lines • ▼ Show 20 Line(s) | 983 | if (d->releaseY >= v->scene()->height()) { | |||
979 | end.setY(v->scene()->height()); | 985 | end.setY(v->scene()->height()); | ||
980 | } | 986 | } | ||
981 | 987 | | |||
982 | if (d->releaseX >= v->scene()->width()) { | 988 | if (d->releaseX >= v->scene()->width()) { | ||
983 | d->releaseX = v->scene()->width(); | 989 | d->releaseX = v->scene()->width(); | ||
984 | end.setX(v->scene()->width()); | 990 | end.setX(v->scene()->width()); | ||
985 | } | 991 | } | ||
986 | 992 | | |||
987 | if (d->sectionData.mouseAction == ReportWriterSectionData::MA_Insert) { | 993 | if (d->sectionData.mouseAction == ReportWriterSectionData::MouseAction::Insert) { | ||
988 | QGraphicsItem * item = nullptr; | 994 | QGraphicsItem * item = nullptr; | ||
989 | QString classString; | 995 | QString classString; | ||
990 | QString iconName; | 996 | QString iconName; | ||
991 | if (d->sectionData.itemToInsert == QLatin1String("org.kde.kreport.line")) { | 997 | if (d->sectionData.itemToInsert == QLatin1String("org.kde.kreport.line")) { | ||
992 | item = new KReportDesignerItemLine(v->designer(), v->scene(), pos, end); | 998 | item = new KReportDesignerItemLine(v->designer(), v->scene(), pos, end); | ||
993 | classString = tr("Line", "Report line element"); | 999 | classString = tr("Line", "Report line element"); | ||
994 | iconName = QLatin1String("kreport-line-element"); | 1000 | iconName = QLatin1String("kreport-line-element"); | ||
995 | } | 1001 | } | ||
Show All 23 Lines | 1021 | if (baseReportItem) { | |||
1019 | changeSet(set); | 1025 | changeSet(set); | ||
1020 | if (v && v->designer()) { | 1026 | if (v && v->designer()) { | ||
1021 | v->designer()->setModified(true); | 1027 | v->designer()->setModified(true); | ||
1022 | } | 1028 | } | ||
1023 | emit itemInserted(d->sectionData.itemToInsert); | 1029 | emit itemInserted(d->sectionData.itemToInsert); | ||
1024 | } | 1030 | } | ||
1025 | } | 1031 | } | ||
1026 | 1032 | | |||
1027 | d->sectionData.mouseAction = ReportWriterSectionData::MA_None; | 1033 | d->sectionData.mouseAction = ReportWriterSectionData::MouseAction::None; | ||
1028 | d->sectionData.itemToInsert.clear(); | 1034 | d->sectionData.itemToInsert.clear(); | ||
1029 | unsetSectionCursor(); | 1035 | unsetSectionCursor(); | ||
1030 | } | 1036 | } | ||
1031 | } | 1037 | } | ||
1032 | } | 1038 | } | ||
1033 | 1039 | | |||
1034 | unsigned int KReportDesigner::selectionCount() const | 1040 | unsigned int KReportDesigner::selectionCount() const | ||
1035 | { | 1041 | { | ||
Show All 17 Lines | |||||
1053 | 1059 | | |||
1054 | // | 1060 | // | ||
1055 | // Actions | 1061 | // Actions | ||
1056 | // | 1062 | // | ||
1057 | 1063 | | |||
1058 | void KReportDesigner::slotItem(const QString &entity) | 1064 | void KReportDesigner::slotItem(const QString &entity) | ||
1059 | { | 1065 | { | ||
1060 | //kreportDebug() << entity; | 1066 | //kreportDebug() << entity; | ||
1061 | d->sectionData.mouseAction = ReportWriterSectionData::MA_Insert; | 1067 | d->sectionData.mouseAction = ReportWriterSectionData::MouseAction::Insert; | ||
1062 | d->sectionData.itemToInsert = entity; | 1068 | d->sectionData.itemToInsert = entity; | ||
1063 | setSectionCursor(QCursor(Qt::CrossCursor)); | 1069 | setSectionCursor(QCursor(Qt::CrossCursor)); | ||
1064 | } | 1070 | } | ||
1065 | 1071 | | |||
1066 | void KReportDesigner::slotEditDelete() | 1072 | void KReportDesigner::slotEditDelete() | ||
1067 | { | 1073 | { | ||
1068 | QGraphicsItem * item = nullptr; | 1074 | QGraphicsItem * item = nullptr; | ||
1069 | bool modified = false; | 1075 | bool modified = false; | ||
1070 | while (selectionCount() > 0) { | 1076 | while (selectionCount() > 0) { | ||
1071 | item = activeScene()->selectedItems().value(0); | 1077 | item = activeScene()->selectedItems().value(0); | ||
1072 | if (item) { | 1078 | if (item) { | ||
1073 | QGraphicsScene * scene = item->scene(); | 1079 | QGraphicsScene * scene = item->scene(); | ||
1074 | delete item; | 1080 | delete item; | ||
1075 | scene->update(); | 1081 | scene->update(); | ||
1076 | d->sectionData.mouseAction = ReportWriterSectionData::MA_None; | 1082 | d->sectionData.mouseAction = ReportWriterSectionData::MouseAction::None; | ||
1077 | modified = true; | 1083 | modified = true; | ||
1078 | } | 1084 | } | ||
1079 | } | 1085 | } | ||
1080 | activeScene()->selectedItems().clear(); | 1086 | activeScene()->selectedItems().clear(); | ||
1081 | 1087 | | |||
1082 | /*! @todo temporary: clears cut and copy lists to make sure we do not crash | 1088 | /*! @todo temporary: clears cut and copy lists to make sure we do not crash | ||
1083 | if weve deleted something in the list | 1089 | if weve deleted something in the list | ||
1084 | should really check if an item is in the list first | 1090 | should really check if an item is in the list first | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 1152 | { | |||
1148 | // paste a new item of the copy we have in the specified location | 1154 | // paste a new item of the copy we have in the specified location | ||
1149 | if (!d->sectionData.copy_list.isEmpty()) { | 1155 | if (!d->sectionData.copy_list.isEmpty()) { | ||
1150 | QList<QGraphicsItem*> activeItems = canvas->selectedItems(); | 1156 | QList<QGraphicsItem*> activeItems = canvas->selectedItems(); | ||
1151 | QGraphicsItem *activeItem = nullptr; | 1157 | QGraphicsItem *activeItem = nullptr; | ||
1152 | if (activeItems.count() == 1) { | 1158 | if (activeItems.count() == 1) { | ||
1153 | activeItem = activeItems.first(); | 1159 | activeItem = activeItems.first(); | ||
1154 | } | 1160 | } | ||
1155 | canvas->clearSelection(); | 1161 | canvas->clearSelection(); | ||
1156 | d->sectionData.mouseAction = ReportWriterSectionData::MA_None; | 1162 | d->sectionData.mouseAction = ReportWriterSectionData::MouseAction::None; | ||
1157 | 1163 | | |||
1158 | //! @todo this code sucks :) | 1164 | //! @todo this code sucks :) | ||
1159 | //! The setPos calls only work AFTER the name has been set ?!?!? | 1165 | //! The setPos calls only work AFTER the name has been set ?!?!? | ||
1160 | 1166 | | |||
1161 | foreach(KReportDesignerItemBase *item, d->sectionData.copy_list) { | 1167 | foreach(KReportDesignerItemBase *item, d->sectionData.copy_list) { | ||
1162 | KReportItemBase *obj = dynamic_cast<KReportItemBase*>(item); | 1168 | KReportItemBase *obj = dynamic_cast<KReportItemBase*>(item); | ||
1163 | const QString type = obj ? obj->typeName() : QLatin1String("object"); | 1169 | const QString type = obj ? obj->typeName() : QLatin1String("object"); | ||
1164 | //kreportDebug() << type; | 1170 | //kreportDebug() << type; | ||
1165 | KReportDesignerItemBase *ent = item->clone(); | 1171 | KReportDesignerItemBase *ent = item->clone(); | ||
1166 | KReportItemBase *new_obj = dynamic_cast<KReportItemBase*>(ent); | 1172 | KReportItemBase *new_obj = dynamic_cast<KReportItemBase*>(ent); | ||
1167 | if (new_obj) { | 1173 | if (new_obj) { | ||
1168 | new_obj->setEntityName(suggestEntityName(type)); | 1174 | new_obj->setEntityName(suggestEntityName(type)); | ||
1169 | if (activeItem) { | 1175 | if (activeItem) { | ||
1170 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(activeItem->x() + 10, activeItem->y() + 10))); | 1176 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(activeItem->x() + 10, activeItem->y() + 10))); | ||
1171 | } else { | 1177 | } else { | ||
1172 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(0, 0))); | 1178 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(0, 0))); | ||
1173 | } | 1179 | } | ||
1174 | changeSet(new_obj->propertySet()); | 1180 | changeSet(new_obj->propertySet()); | ||
1175 | } | 1181 | } | ||
1176 | QGraphicsItem *pasted_ent = dynamic_cast<QGraphicsItem*>(ent); | 1182 | QGraphicsItem *pasted_ent = dynamic_cast<QGraphicsItem*>(ent); | ||
1177 | if (pasted_ent) { | 1183 | if (pasted_ent) { | ||
1178 | pasted_ent->setSelected(true); | 1184 | pasted_ent->setSelected(true); | ||
1179 | canvas->addItem(pasted_ent); | 1185 | canvas->addItem(pasted_ent); | ||
1180 | pasted_ent->show(); | 1186 | pasted_ent->show(); | ||
1181 | d->sectionData.mouseAction = ReportWriterSectionData::MA_Grab; | 1187 | d->sectionData.mouseAction = ReportWriterSectionData::MouseAction::Grab; | ||
1182 | setModified(true); | 1188 | setModified(true); | ||
1183 | } | 1189 | } | ||
1184 | } | 1190 | } | ||
1185 | } | 1191 | } | ||
1186 | } | 1192 | } | ||
1187 | void KReportDesigner::slotRaiseSelected() | 1193 | void KReportDesigner::slotRaiseSelected() | ||
1188 | { | 1194 | { | ||
1189 | dynamic_cast<KReportDesignerSectionScene*>(activeScene())->raiseSelected(); | 1195 | dynamic_cast<KReportDesignerSectionScene*>(activeScene())->raiseSelected(); | ||
Show All 18 Lines | 1209 | { | |||
1208 | //Trigger an update so that the last scene redraws its title; | 1214 | //Trigger an update so that the last scene redraws its title; | ||
1209 | update(); | 1215 | update(); | ||
1210 | } | 1216 | } | ||
1211 | 1217 | | |||
1212 | QString KReportDesigner::suggestEntityName(const QString &name) const | 1218 | QString KReportDesigner::suggestEntityName(const QString &name) const | ||
1213 | { | 1219 | { | ||
1214 | KReportDesignerSection *sec; | 1220 | KReportDesignerSection *sec; | ||
1215 | int itemCount = 0; | 1221 | int itemCount = 0; | ||
1216 | //Count items in the main sections | 1222 | // Count items in the main sections | ||
1217 | for (int i = 1; i <= KReportSectionData::PageFooterAny; i++) { | 1223 | for (int i = static_cast<int>(KReportSectionData::Type::None) + 1; | ||
1218 | sec = section((KReportSectionData::Section) i); | 1224 | i <= static_cast<int>(KReportSectionData::Type::GroupFooter); i++) | ||
staniek: Same question here - PageFooterAny? | |||||
piggz: yes, should be fixed. | |||||
1225 | { | ||||
1226 | sec = section(static_cast<KReportSectionData::Type>(i)); | ||||
1219 | if (sec) { | 1227 | if (sec) { | ||
1220 | const QGraphicsItemList l = sec->items(); | 1228 | const QGraphicsItemList l = sec->items(); | ||
1221 | itemCount += l.count(); | 1229 | itemCount += l.count(); | ||
1222 | } | 1230 | } | ||
1223 | } | 1231 | } | ||
1224 | 1232 | | |||
1225 | if (d->detail) { | 1233 | if (d->detail) { | ||
1226 | //Count items in the group headers/footers | 1234 | //Count items in the group headers/footers | ||
Show All 23 Lines | |||||
1250 | return name + QString::number(itemCount); | 1258 | return name + QString::number(itemCount); | ||
1251 | } | 1259 | } | ||
1252 | 1260 | | |||
1253 | bool KReportDesigner::isEntityNameUnique(const QString &name, KReportItemBase* ignore) const | 1261 | bool KReportDesigner::isEntityNameUnique(const QString &name, KReportItemBase* ignore) const | ||
1254 | { | 1262 | { | ||
1255 | KReportDesignerSection *sec; | 1263 | KReportDesignerSection *sec; | ||
1256 | bool unique = true; | 1264 | bool unique = true; | ||
1257 | 1265 | | |||
1258 | //Check items in the main sections | 1266 | // Check items in the main sections | ||
1259 | for (int i = 1; i <= KReportSectionData::PageFooterAny; i++) { | 1267 | for (int i = static_cast<int>(KReportSectionData::Type::None); | ||
1260 | sec = section((KReportSectionData::Section)i); | 1268 | i <= static_cast<int>(KReportSectionData::Type::GroupFooter); i++) | ||
staniek: Same question here - GroupFooter ? | |||||
piggz: yes, should be fixed. | |||||
1269 | { | ||||
1270 | sec = section(static_cast<KReportSectionData::Type>(i)); | ||||
1261 | if (sec) { | 1271 | if (sec) { | ||
1262 | const QGraphicsItemList l = sec->items(); | 1272 | const QGraphicsItemList l = sec->items(); | ||
1263 | for (QGraphicsItemList::const_iterator it = l.constBegin(); it != l.constEnd(); ++it) { | 1273 | for (QGraphicsItemList::const_iterator it = l.constBegin(); it != l.constEnd(); ++it) { | ||
1264 | KReportItemBase* itm = dynamic_cast<KReportItemBase*>(*it); | 1274 | KReportItemBase* itm = dynamic_cast<KReportItemBase*>(*it); | ||
1265 | if (itm && itm->entityName() == name && itm != ignore) { | 1275 | if (itm && itm->entityName() == name && itm != ignore) { | ||
1266 | unique = false; | 1276 | unique = false; | ||
1267 | break; | 1277 | break; | ||
1268 | } | 1278 | } | ||
▲ Show 20 Lines • Show All 274 Lines • Show Last 20 Lines |
Same question here - PageFooterAny?