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