Menu

[efa3d9]: / src / tmp-parent-container.cpp  Maximize  Restore  History

Download this file

105 lines (83 with data), 3.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#include <QDebug>
#include "heading-container.h"
#include "tmp-parent-container.h"
#include "branch-container.h"
#define qdbg() qDebug().nospace().noquote()
TmpParentContainer::TmpParentContainer()
{
// qDebug() << "* Const TmpParentContainer begin this = " << this;
init();
}
void TmpParentContainer::init()
{
// General defaults, also used by BranchContainer
orientation = UndefinedOrientation;
tmpLinkedParentContainer = nullptr;
originalParentBranchContainer = nullptr;
// setPen(QPen(Qt::green)); // Uncomment for testing
// TmpParentContainer defaults, should be overridden from MapDesign later
containerType = Container::TmpParent;
setLayout(Container::FloatingReservedSpace);
branchesContainer = new Container ();
branchesContainer->setContainerType(Container::BranchesContainer);
branchesContainer->setParentItem(this); // Different for BranchItem!
}
void TmpParentContainer::addToBranchesContainer(BranchContainer *bc)
{
QPointF sp = bc->getHeadingContainer()->mapToScene(QPoint(0,0));
branchesContainer->addContainer(bc);
// keep position
bc->setPos(branchesContainer->sceneTransform().inverted().map(sp));
}
void TmpParentContainer::createImagesContainer()
{
imagesContainer = new Container ();
imagesContainer->setContainerType(ImagesContainer);
imagesContainer->setLayout(Container::FloatingFree);
}
void TmpParentContainer::addToImagesContainer(Container *c)
{
if (!imagesContainer) {
createImagesContainer();
imagesContainer->setParentItem(this); // Different for BranchItem!
}
QPointF sp = c->scenePos();
imagesContainer->addContainer(c, Z_IMAGE);
// For TmpParentContainer keep position
c->setPos(imagesContainer->sceneTransform().inverted().map(sp));
}
void TmpParentContainer::reposition()
{
//qdbg() << ind() << "TPC::reposition tpc=" << info() << " orient=" << orientation;
/*
if (pbc)
qdbg() << ind() << " pbc=" << pbc->info();
else
qdbg() << ind() << " pbc=0";
qdbg() << ind() << " pbc->orientation=" << pbc->orientation;
*/
switch (orientation) {
case LeftOfParent:
setHorizontalDirection(RightToLeft);
branchesContainer->setHorizontalAlignment(HorAlignedRight);
break;
case RightOfParent:
setHorizontalDirection(LeftToRight);
branchesContainer->setHorizontalAlignment(HorAlignedLeft);
break;
case UndefinedOrientation:
qWarning() << "TPC::reposition tPC - UndefinedOrientation in " << info();
break;
default:
qWarning() << "TPC::reposition tPC - Unknown orientation " << orientation << " in " << info();
break;
}
Container::reposition();
// Update links of children
if (branchesContainer && branchCount() > 0) {
foreach (Container *c, branchesContainer->childContainers()) {
BranchContainer *bc = (BranchContainer*) c;
bc->updateUpLink();
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.