Changeset View
Changeset View
Standalone View
Standalone View
src/acbf/AcbfJump.cpp
Context not available. | |||||
39 | : QObject(parent) | 39 | : QObject(parent) | ||
---|---|---|---|---|---|
40 | , d(new Private) | 40 | , d(new Private) | ||
41 | { | 41 | { | ||
42 | qRegisterMetaType<Jump*>("Jump*"); | ||||
43 | connect(this, SIGNAL(pointCountChanged()), this, SIGNAL(boundsChanged())); | ||||
42 | } | 44 | } | ||
43 | 45 | | |||
44 | Jump::~Jump() = default; | 46 | Jump::~Jump() = default; | ||
Context not available. | |||||
105 | else { | 107 | else { | ||
106 | d->points.append(point); | 108 | d->points.append(point); | ||
107 | } | 109 | } | ||
110 | emit pointCountChanged(); | ||||
108 | } | 111 | } | ||
109 | 112 | | |||
110 | void Jump::removePoint(const QPoint& point) | 113 | void Jump::removePoint(const QPoint& point) | ||
111 | { | 114 | { | ||
112 | d->points.removeAll(point); | 115 | d->points.removeAll(point); | ||
116 | emit pointCountChanged(); | ||||
113 | } | 117 | } | ||
114 | 118 | | |||
115 | bool Jump::swapPoints(const QPoint& swapThis, const QPoint& withThis) | 119 | bool Jump::swapPoints(const QPoint& swapThis, const QPoint& withThis) | ||
Context not available. | |||||
118 | int index2 = d->points.indexOf(withThis); | 122 | int index2 = d->points.indexOf(withThis); | ||
119 | if(index1 > -1 && index2 > -1) { | 123 | if(index1 > -1 && index2 > -1) { | ||
120 | d->points.swap(index1, index2); | 124 | d->points.swap(index1, index2); | ||
125 | emit pointCountChanged(); | ||||
121 | return true; | 126 | return true; | ||
122 | } | 127 | } | ||
123 | return false; | 128 | return false; | ||
124 | } | 129 | } | ||
125 | 130 | | |||
131 | void Jump::setPointsFromRect(const QPoint &topLeft, const QPoint &bottomRight) | ||||
132 | { | ||||
133 | QRect rect(topLeft, bottomRight); | ||||
134 | d->points.clear(); | ||||
135 | d->points.append(topLeft); | ||||
136 | d->points.append(rect.topRight()); | ||||
137 | d->points.append(rect.bottomRight()); | ||||
138 | d->points.append(rect.bottomLeft()); | ||||
139 | emit pointCountChanged(); | ||||
140 | } | ||||
141 | | ||||
142 | int Jump::pointCount() const | ||||
143 | { | ||||
144 | return d->points.size(); | ||||
145 | } | ||||
146 | | ||||
147 | QRect Jump::bounds() const | ||||
148 | { | ||||
149 | // Would use QPolygon here, but that requires including QTGUI. | ||||
150 | QRect rect(d->points.at(0), d->points.at(1)); | ||||
151 | for (int i = 2; i < d->points.size(); i++) { | ||||
152 | QPoint p = d->points.at(i); | ||||
153 | if (rect.left() > p.x()) { | ||||
154 | rect.setLeft(p.x()); | ||||
155 | } | ||||
156 | if (rect.right() < p.x()) { | ||||
157 | rect.setRight(p.x()); | ||||
158 | } | ||||
159 | if (rect.bottom() < p.y()) { | ||||
160 | rect.setBottom(p.y()); | ||||
161 | } | ||||
162 | if (rect.top() > p.y()) { | ||||
163 | rect.setTop(p.y()); | ||||
164 | } | ||||
165 | } | ||||
166 | return rect; | ||||
167 | } | ||||
168 | | ||||
126 | int Jump::pageIndex() const | 169 | int Jump::pageIndex() const | ||
127 | { | 170 | { | ||
128 | return d->pageIndex; | 171 | return d->pageIndex; | ||
Context not available. | |||||
131 | void Jump::setPageIndex(const int& pageNumber) | 174 | void Jump::setPageIndex(const int& pageNumber) | ||
132 | { | 175 | { | ||
133 | d->pageIndex = pageNumber; | 176 | d->pageIndex = pageNumber; | ||
177 | emit pageIndexChanged(); | ||||
134 | } | 178 | } | ||
Context not available. |