Changeset View
Changeset View
Standalone View
Standalone View
document/kpDocument.cpp
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | 141 | { | |||
---|---|---|---|---|---|
143 | m_isFromURL = isFromURL; | 143 | m_isFromURL = isFromURL; | ||
144 | } | 144 | } | ||
145 | 145 | | |||
146 | //--------------------------------------------------------------------- | 146 | //--------------------------------------------------------------------- | ||
147 | 147 | | |||
148 | // public | 148 | // public | ||
149 | bool kpDocument::isFromURL (bool checkURLStillExists) const | 149 | bool kpDocument::isFromURL (bool checkURLStillExists) const | ||
150 | { | 150 | { | ||
151 | if (!m_isFromURL) | 151 | if (!m_isFromURL) { | ||
152 | return false; | 152 | return false; | ||
153 | } | ||||
153 | 154 | | |||
154 | if (!checkURLStillExists) | 155 | if (!checkURLStillExists) { | ||
155 | return true; | 156 | return true; | ||
157 | } | ||||
156 | 158 | | |||
157 | return (!m_url.isEmpty () && | 159 | return (!m_url.isEmpty () && | ||
158 | KIO::NetAccess::exists (m_url, KIO::NetAccess::SourceSide/*open*/, | 160 | KIO::NetAccess::exists (m_url, KIO::NetAccess::SourceSide/*open*/, | ||
159 | d->environ->dialogParent ())); | 161 | d->environ->dialogParent ())); | ||
160 | } | 162 | } | ||
161 | 163 | | |||
162 | //--------------------------------------------------------------------- | 164 | //--------------------------------------------------------------------- | ||
163 | 165 | | |||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
210 | //--------------------------------------------------------------------- | 212 | //--------------------------------------------------------------------- | ||
211 | 213 | | |||
212 | /* | 214 | /* | ||
213 | * Properties | 215 | * Properties | ||
214 | */ | 216 | */ | ||
215 | 217 | | |||
216 | void kpDocument::setModified (bool yes) | 218 | void kpDocument::setModified (bool yes) | ||
217 | { | 219 | { | ||
218 | if (yes == m_modified) | 220 | if (yes == m_modified) { | ||
219 | return; | 221 | return; | ||
222 | } | ||||
220 | 223 | | |||
221 | m_modified = yes; | 224 | m_modified = yes; | ||
222 | 225 | | |||
223 | if (yes) | 226 | if (yes) { | ||
224 | emit documentModified (); | 227 | emit documentModified (); | ||
225 | } | 228 | } | ||
229 | } | ||||
226 | 230 | | |||
227 | //--------------------------------------------------------------------- | 231 | //--------------------------------------------------------------------- | ||
228 | 232 | | |||
229 | bool kpDocument::isModified () const | 233 | bool kpDocument::isModified () const | ||
230 | { | 234 | { | ||
231 | return m_modified; | 235 | return m_modified; | ||
232 | } | 236 | } | ||
233 | 237 | | |||
Show All 10 Lines | |||||
244 | { | 248 | { | ||
245 | return m_constructorWidth; | 249 | return m_constructorWidth; | ||
246 | } | 250 | } | ||
247 | 251 | | |||
248 | //--------------------------------------------------------------------- | 252 | //--------------------------------------------------------------------- | ||
249 | 253 | | |||
250 | int kpDocument::width (bool ofSelection) const | 254 | int kpDocument::width (bool ofSelection) const | ||
251 | { | 255 | { | ||
252 | if (ofSelection && m_selection) | 256 | return (ofSelection && m_selection) ? m_selection->width() : m_image->width(); | ||
253 | return m_selection->width (); | | |||
254 | else | | |||
255 | return m_image->width (); | | |||
256 | } | 257 | } | ||
257 | 258 | | |||
258 | //--------------------------------------------------------------------- | 259 | //--------------------------------------------------------------------- | ||
259 | 260 | | |||
260 | int kpDocument::oldWidth () const | 261 | int kpDocument::oldWidth () const | ||
261 | { | 262 | { | ||
262 | return m_oldWidth; | 263 | return m_oldWidth; | ||
263 | } | 264 | } | ||
Show All 11 Lines | |||||
275 | { | 276 | { | ||
276 | return m_constructorHeight; | 277 | return m_constructorHeight; | ||
277 | } | 278 | } | ||
278 | 279 | | |||
279 | //--------------------------------------------------------------------- | 280 | //--------------------------------------------------------------------- | ||
280 | 281 | | |||
281 | int kpDocument::height (bool ofSelection) const | 282 | int kpDocument::height (bool ofSelection) const | ||
282 | { | 283 | { | ||
283 | if (ofSelection && m_selection) | 284 | return (ofSelection && m_selection) ? m_selection->height() : m_image->height(); | ||
284 | return m_selection->height (); | | |||
285 | else | | |||
286 | return m_image->height (); | | |||
287 | } | 285 | } | ||
288 | 286 | | |||
289 | //--------------------------------------------------------------------- | 287 | //--------------------------------------------------------------------- | ||
290 | 288 | | |||
291 | int kpDocument::oldHeight () const | 289 | int kpDocument::oldHeight () const | ||
292 | { | 290 | { | ||
293 | return m_oldHeight; | 291 | return m_oldHeight; | ||
294 | } | 292 | } | ||
295 | 293 | | |||
296 | //--------------------------------------------------------------------- | 294 | //--------------------------------------------------------------------- | ||
297 | 295 | | |||
298 | void kpDocument::setHeight (int h, const kpColor &backgroundColor) | 296 | void kpDocument::setHeight (int h, const kpColor &backgroundColor) | ||
299 | { | 297 | { | ||
300 | resize (width (), h, backgroundColor); | 298 | resize (width (), h, backgroundColor); | ||
301 | } | 299 | } | ||
302 | 300 | | |||
303 | //--------------------------------------------------------------------- | 301 | //--------------------------------------------------------------------- | ||
304 | 302 | | |||
305 | QRect kpDocument::rect (bool ofSelection) const | 303 | QRect kpDocument::rect (bool ofSelection) const | ||
306 | { | 304 | { | ||
307 | if (ofSelection && m_selection) | 305 | return (ofSelection && m_selection) ? m_selection->boundingRect() : m_image->rect(); | ||
308 | return m_selection->boundingRect (); | | |||
309 | else | | |||
310 | return m_image->rect (); | | |||
311 | } | 306 | } | ||
312 | 307 | | |||
313 | //--------------------------------------------------------------------- | 308 | //--------------------------------------------------------------------- | ||
314 | 309 | | |||
315 | // public | 310 | // public | ||
316 | kpImage kpDocument::getImageAt (const QRect &rect) const | 311 | kpImage kpDocument::getImageAt (const QRect &rect) const | ||
317 | { | 312 | { | ||
318 | return kpPixmapFX::getPixmapAt (*m_image, rect); | 313 | return kpPixmapFX::getPixmapAt (*m_image, rect); | ||
319 | } | 314 | } | ||
320 | 315 | | |||
321 | //--------------------------------------------------------------------- | 316 | //--------------------------------------------------------------------- | ||
322 | 317 | | |||
323 | // public | 318 | // public | ||
324 | void kpDocument::setImageAt (const kpImage &image, const QPoint &at) | 319 | void kpDocument::setImageAt (const kpImage &image, const QPoint &at) | ||
325 | { | 320 | { | ||
326 | qCDebug(kpLogDocument) << "kpDocument::setImageAt (image (w=" | 321 | qCDebug(kpLogDocument) << "kpDocument::setImageAt (image (w=" | ||
327 | << image.width () | 322 | << image.width () | ||
328 | << ",h=" << image.height () | 323 | << ",h=" << image.height () | ||
329 | << "), x=" << at.x () | 324 | << "), x=" << at.x () | ||
330 | << ",y=" << at.y () | 325 | << ",y=" << at.y (); | ||
331 | << endl; | | |||
332 | 326 | | |||
333 | kpPixmapFX::setPixmapAt (m_image, at, image); | 327 | kpPixmapFX::setPixmapAt (m_image, at, image); | ||
334 | slotContentsChanged (QRect (at.x (), at.y (), image.width (), image.height ())); | 328 | slotContentsChanged (QRect (at.x (), at.y (), image.width (), image.height ())); | ||
335 | } | 329 | } | ||
336 | 330 | | |||
337 | //--------------------------------------------------------------------- | 331 | //--------------------------------------------------------------------- | ||
338 | 332 | | |||
339 | // public | 333 | // public | ||
340 | kpImage kpDocument::image (bool ofSelection) const | 334 | kpImage kpDocument::image (bool ofSelection) const | ||
341 | { | 335 | { | ||
342 | kpImage ret; | 336 | kpImage ret; | ||
343 | 337 | | |||
344 | if (ofSelection) | 338 | if (ofSelection) | ||
345 | { | 339 | { | ||
346 | kpAbstractImageSelection *imageSel = imageSelection (); | 340 | kpAbstractImageSelection *imageSel = imageSelection (); | ||
347 | Q_ASSERT (imageSel); | 341 | Q_ASSERT (imageSel); | ||
348 | 342 | | |||
349 | ret = imageSel->baseImage (); | 343 | ret = imageSel->baseImage (); | ||
350 | } | 344 | } | ||
351 | else | 345 | else { | ||
352 | ret = *m_image; | 346 | ret = *m_image; | ||
347 | } | ||||
353 | 348 | | |||
354 | return ret; | 349 | return ret; | ||
355 | } | 350 | } | ||
356 | 351 | | |||
357 | //--------------------------------------------------------------------- | 352 | //--------------------------------------------------------------------- | ||
358 | 353 | | |||
359 | // public | 354 | // public | ||
360 | kpImage *kpDocument::imagePointer () const | 355 | kpImage *kpDocument::imagePointer () const | ||
361 | { | 356 | { | ||
362 | return m_image; | 357 | return m_image; | ||
363 | } | 358 | } | ||
364 | 359 | | |||
365 | //--------------------------------------------------------------------- | 360 | //--------------------------------------------------------------------- | ||
366 | 361 | | |||
367 | // public | 362 | // public | ||
368 | void kpDocument::setImage (const kpImage &image) | 363 | void kpDocument::setImage (const kpImage &image) | ||
369 | { | 364 | { | ||
370 | m_oldWidth = width (); | 365 | m_oldWidth = width (); | ||
371 | m_oldHeight = height (); | 366 | m_oldHeight = height (); | ||
372 | 367 | | |||
373 | *m_image = image; | 368 | *m_image = image; | ||
374 | 369 | | |||
375 | if (m_oldWidth == width () && m_oldHeight == height ()) | 370 | if (m_oldWidth == width () && m_oldHeight == height ()) { | ||
376 | slotContentsChanged (image.rect ()); | 371 | slotContentsChanged (image.rect ()); | ||
377 | else | 372 | } | ||
373 | else { | ||||
378 | slotSizeChanged (QSize (width (), height ())); | 374 | slotSizeChanged (QSize (width (), height ())); | ||
379 | } | 375 | } | ||
376 | } | ||||
380 | 377 | | |||
381 | //--------------------------------------------------------------------- | 378 | //--------------------------------------------------------------------- | ||
382 | 379 | | |||
383 | // public | 380 | // public | ||
384 | void kpDocument::setImage (bool ofSelection, const kpImage &image) | 381 | void kpDocument::setImage (bool ofSelection, const kpImage &image) | ||
385 | { | 382 | { | ||
386 | if (ofSelection) | 383 | if (ofSelection) | ||
387 | { | 384 | { | ||
388 | kpAbstractImageSelection *imageSel = imageSelection (); | 385 | kpAbstractImageSelection *imageSel = imageSelection (); | ||
389 | 386 | | |||
390 | // Have to have an image selection in order to set its pixmap. | 387 | // Have to have an image selection in order to set its pixmap. | ||
391 | Q_ASSERT (imageSel); | 388 | Q_ASSERT (imageSel); | ||
392 | 389 | | |||
393 | imageSel->setBaseImage (image); | 390 | imageSel->setBaseImage (image); | ||
394 | } | 391 | } | ||
395 | else | 392 | else { | ||
396 | setImage (image); | 393 | setImage (image); | ||
397 | } | 394 | } | ||
395 | } | ||||
398 | 396 | | |||
399 | //--------------------------------------------------------------------- | 397 | //--------------------------------------------------------------------- | ||
400 | 398 | | |||
401 | void kpDocument::fill (const kpColor &color) | 399 | void kpDocument::fill (const kpColor &color) | ||
402 | { | 400 | { | ||
403 | qCDebug(kpLogDocument) << "kpDocument::fill ()"; | 401 | qCDebug(kpLogDocument) << "kpDocument::fill ()"; | ||
404 | 402 | | |||
405 | m_image->fill(color.toQRgb()); | 403 | m_image->fill(color.toQRgb()); | ||
406 | slotContentsChanged (m_image->rect ()); | 404 | slotContentsChanged (m_image->rect ()); | ||
407 | } | 405 | } | ||
408 | 406 | | |||
409 | //--------------------------------------------------------------------- | 407 | //--------------------------------------------------------------------- | ||
410 | 408 | | |||
411 | void kpDocument::resize (int w, int h, const kpColor &backgroundColor) | 409 | void kpDocument::resize (int w, int h, const kpColor &backgroundColor) | ||
412 | { | 410 | { | ||
413 | qCDebug(kpLogDocument) << "kpDocument::resize (" << w << "," << h << ")"; | 411 | qCDebug(kpLogDocument) << "kpDocument::resize (" << w << "," << h << ")"; | ||
414 | 412 | | |||
415 | m_oldWidth = width (); | 413 | m_oldWidth = width (); | ||
416 | m_oldHeight = height (); | 414 | m_oldHeight = height (); | ||
417 | 415 | | |||
418 | qCDebug(kpLogDocument) << "\toldWidth=" << m_oldWidth | 416 | qCDebug(kpLogDocument) << "\toldWidth=" << m_oldWidth | ||
419 | << " oldHeight=" << m_oldHeight | 417 | << " oldHeight=" << m_oldHeight; | ||
420 | << endl; | | |||
421 | 418 | | |||
422 | if (w == m_oldWidth && h == m_oldHeight) | 419 | if (w == m_oldWidth && h == m_oldHeight) { | ||
423 | return; | 420 | return; | ||
421 | } | ||||
424 | 422 | | |||
425 | kpPixmapFX::resize (m_image, w, h, backgroundColor); | 423 | kpPixmapFX::resize (m_image, w, h, backgroundColor); | ||
426 | 424 | | |||
427 | slotSizeChanged (QSize (width (), height ())); | 425 | slotSizeChanged (QSize (width (), height ())); | ||
428 | } | 426 | } | ||
429 | 427 | | |||
430 | //--------------------------------------------------------------------- | 428 | //--------------------------------------------------------------------- | ||
431 | 429 | | |||
Show All 19 Lines |