Changeset View
Changeset View
Standalone View
Standalone View
layers/selections/text/kpTextSelection.cpp
Show First 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | |||||
162 | int kpTextSelection::MinimumHeightForTextStyle (const kpTextStyle &) | 162 | int kpTextSelection::MinimumHeightForTextStyle (const kpTextStyle &) | ||
163 | { | 163 | { | ||
164 | return (kpTextSelection::TextBorderSize () * 2 + 5); | 164 | return (kpTextSelection::TextBorderSize () * 2 + 5); | ||
165 | } | 165 | } | ||
166 | 166 | | |||
167 | // public static | 167 | // public static | ||
168 | QSize kpTextSelection::MinimumSizeForTextStyle (const kpTextStyle &textStyle) | 168 | QSize kpTextSelection::MinimumSizeForTextStyle (const kpTextStyle &textStyle) | ||
169 | { | 169 | { | ||
170 | return QSize (kpTextSelection::MinimumWidthForTextStyle (textStyle), | 170 | return {kpTextSelection::MinimumWidthForTextStyle (textStyle), | ||
171 | kpTextSelection::MinimumHeightForTextStyle (textStyle)); | 171 | kpTextSelection::MinimumHeightForTextStyle (textStyle)}; | ||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | 174 | | |||
175 | // public virtual [kpAbstractSelection] | 175 | // public virtual [kpAbstractSelection] | ||
176 | int kpTextSelection::minimumWidth () const | 176 | int kpTextSelection::minimumWidth () const | ||
177 | { | 177 | { | ||
178 | return kpTextSelection::MinimumWidthForTextStyle (textStyle ()); | 178 | return kpTextSelection::MinimumWidthForTextStyle (textStyle ()); | ||
179 | } | 179 | } | ||
Show All 28 Lines | 205 | { | |||
208 | 208 | | |||
209 | return qMax (kpTextSelection::MinimumHeightForTextStyle (textStyle), | 209 | return qMax (kpTextSelection::MinimumHeightForTextStyle (textStyle), | ||
210 | qMin (150, preferredMinHeight)); | 210 | qMin (150, preferredMinHeight)); | ||
211 | } | 211 | } | ||
212 | 212 | | |||
213 | // public static | 213 | // public static | ||
214 | QSize kpTextSelection::PreferredMinimumSizeForTextStyle (const kpTextStyle &textStyle) | 214 | QSize kpTextSelection::PreferredMinimumSizeForTextStyle (const kpTextStyle &textStyle) | ||
215 | { | 215 | { | ||
216 | return QSize (kpTextSelection::PreferredMinimumWidthForTextStyle (textStyle), | 216 | return {kpTextSelection::PreferredMinimumWidthForTextStyle (textStyle), | ||
217 | kpTextSelection::PreferredMinimumHeightForTextStyle (textStyle)); | 217 | kpTextSelection::PreferredMinimumHeightForTextStyle (textStyle)}; | ||
218 | } | 218 | } | ||
219 | 219 | | |||
220 | 220 | | |||
221 | // public static | 221 | // public static | ||
222 | int kpTextSelection::TextBorderSize () | 222 | int kpTextSelection::TextBorderSize () | ||
223 | { | 223 | { | ||
224 | return 1; | 224 | return 1; | ||
225 | } | 225 | } | ||
226 | 226 | | |||
227 | // public | 227 | // public | ||
228 | QRect kpTextSelection::textAreaRect () const | 228 | QRect kpTextSelection::textAreaRect () const | ||
229 | { | 229 | { | ||
230 | return QRect (x () + kpTextSelection::TextBorderSize (), | 230 | return {x () + kpTextSelection::TextBorderSize (), | ||
231 | y () + kpTextSelection::TextBorderSize (), | 231 | y () + kpTextSelection::TextBorderSize (), | ||
232 | width () - kpTextSelection::TextBorderSize () * 2, | 232 | width () - kpTextSelection::TextBorderSize () * 2, | ||
233 | height () - kpTextSelection::TextBorderSize () * 2); | 233 | height () - kpTextSelection::TextBorderSize () * 2}; | ||
234 | } | 234 | } | ||
235 | 235 | | |||
236 | 236 | | |||
237 | // public virtual [kpAbstractSelection] | 237 | // public virtual [kpAbstractSelection] | ||
238 | QPolygon kpTextSelection::calculatePoints () const | 238 | QPolygon kpTextSelection::calculatePoints () const | ||
239 | { | 239 | { | ||
240 | return kpAbstractSelection::CalculatePointsForRectangle (boundingRect ()); | 240 | return kpAbstractSelection::CalculatePointsForRectangle (boundingRect ()); | ||
241 | } | 241 | } | ||
Show All 23 Lines | |||||
265 | bool kpTextSelection::hasContent () const | 265 | bool kpTextSelection::hasContent () const | ||
266 | { | 266 | { | ||
267 | return !d->textLines.isEmpty (); | 267 | return !d->textLines.isEmpty (); | ||
268 | } | 268 | } | ||
269 | 269 | | |||
270 | // public virtual [kpAbstractSelection] | 270 | // public virtual [kpAbstractSelection] | ||
271 | void kpTextSelection::deleteContent () | 271 | void kpTextSelection::deleteContent () | ||
272 | { | 272 | { | ||
273 | if (!hasContent ()) | 273 | if (!hasContent ()) { | ||
274 | return; | 274 | return; | ||
275 | } | ||||
275 | 276 | | |||
276 | setTextLines (QList <QString> ()); | 277 | setTextLines (QList <QString> ()); | ||
277 | } | 278 | } | ||
278 | 279 | | |||
279 | 280 | | |||
280 | // public | 281 | // public | ||
281 | QList <QString> kpTextSelection::textLines () const | 282 | QList <QString> kpTextSelection::textLines () const | ||
282 | { | 283 | { | ||
283 | return d->textLines; | 284 | return d->textLines; | ||
284 | } | 285 | } | ||
285 | 286 | | |||
286 | // public | 287 | // public | ||
287 | void kpTextSelection::setTextLines (const QList <QString> &textLines_) | 288 | void kpTextSelection::setTextLines (const QList <QString> &textLines_) | ||
288 | { | 289 | { | ||
289 | d->textLines = textLines_; | 290 | d->textLines = textLines_; | ||
290 | 291 | | |||
291 | emit changed (boundingRect ()); | 292 | emit changed (boundingRect ()); | ||
292 | } | 293 | } | ||
293 | 294 | | |||
294 | 295 | | |||
295 | // public static | 296 | // public static | ||
296 | QString kpTextSelection::TextForTextLines (const QList <QString> &textLines) | 297 | QString kpTextSelection::TextForTextLines (const QList <QString> &textLines) | ||
297 | { | 298 | { | ||
298 | if (textLines.isEmpty ()) | 299 | if (textLines.isEmpty ()) { | ||
299 | return QString (); | 300 | return {}; | ||
301 | } | ||||
300 | 302 | | |||
301 | QString bigString = textLines [0]; | 303 | QString bigString = textLines [0]; | ||
302 | 304 | | |||
303 | for (QList <QString>::const_iterator it = textLines.begin () + 1; | 305 | for (QList <QString>::const_iterator it = textLines.begin () + 1; | ||
304 | it != textLines.end (); | 306 | it != textLines.end (); | ||
305 | ++it) | 307 | ++it) | ||
306 | { | 308 | { | ||
307 | bigString += QLatin1String ("\n"); | 309 | bigString += QLatin1String ("\n"); | ||
Show All 38 Lines |