Diffstat (limited to 'noncore/graphics/drawpad/drawpadcanvas.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 5437068..05dd408 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -301,96 +301,109 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c | |||
301 | docLnk.setName(name + QString::number(i)); | 301 | docLnk.setName(name + QString::number(i)); |
302 | docLnk.setType(mimeType.id()); | 302 | docLnk.setType(mimeType.id()); |
303 | 303 | ||
304 | FileManager fileManager; | 304 | FileManager fileManager; |
305 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 305 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
306 | QImageIO imageIO(ioDevice, format); | 306 | QImageIO imageIO(ioDevice, format); |
307 | 307 | ||
308 | QImage image = m_pages.at(i - 1)->convertToImage(); | 308 | QImage image = m_pages.at(i - 1)->convertToImage(); |
309 | imageIO.setImage(image); | 309 | imageIO.setImage(image); |
310 | imageIO.write(); | 310 | imageIO.write(); |
311 | delete ioDevice; | 311 | delete ioDevice; |
312 | } | 312 | } |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | Page* DrawPadCanvas::currentPage() | 316 | Page* DrawPadCanvas::currentPage() |
317 | { | 317 | { |
318 | return m_pages.current(); | 318 | return m_pages.current(); |
319 | } | 319 | } |
320 | 320 | ||
321 | QList<Page> DrawPadCanvas::pages() | 321 | QList<Page> DrawPadCanvas::pages() |
322 | { | 322 | { |
323 | return m_pages; | 323 | return m_pages; |
324 | } | 324 | } |
325 | 325 | ||
326 | uint DrawPadCanvas::pagePosition() | 326 | uint DrawPadCanvas::pagePosition() |
327 | { | 327 | { |
328 | return (m_pages.at() + 1); | 328 | return (m_pages.at() + 1); |
329 | } | 329 | } |
330 | 330 | ||
331 | uint DrawPadCanvas::pageCount() | 331 | uint DrawPadCanvas::pageCount() |
332 | { | 332 | { |
333 | return m_pages.count(); | 333 | return m_pages.count(); |
334 | } | 334 | } |
335 | 335 | ||
336 | void DrawPadCanvas::selectPage(Page* page) | 336 | void DrawPadCanvas::selectPage(Page* page) |
337 | { | 337 | { |
338 | m_pages.findRef(page); | 338 | m_pages.findRef(page); |
339 | m_pageBackups.clear(); | 339 | m_pageBackups.clear(); |
340 | m_pageBackups.append(new Page(*(m_pages.current()))); | 340 | m_pageBackups.append(new Page(*(m_pages.current()))); |
341 | 341 | ||
342 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 342 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
343 | viewport()->update(); | 343 | viewport()->update(); |
344 | 344 | ||
345 | emit pagesChanged(); | 345 | emit pagesChanged(); |
346 | emit pageBackupsChanged(); | 346 | emit pageBackupsChanged(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void DrawPadCanvas::selectPage(uint pagePosition) | ||
350 | { | ||
351 | m_pages.at(pagePosition - 1); | ||
352 | m_pageBackups.clear(); | ||
353 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
354 | |||
355 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
356 | viewport()->update(); | ||
357 | |||
358 | emit pagesChanged(); | ||
359 | emit pageBackupsChanged(); | ||
360 | } | ||
361 | |||
349 | void DrawPadCanvas::backupPage() | 362 | void DrawPadCanvas::backupPage() |
350 | { | 363 | { |
351 | m_pages.current()->setLastModified(QDateTime::currentDateTime()); | 364 | m_pages.current()->setLastModified(QDateTime::currentDateTime()); |
352 | 365 | ||
353 | Page* currentBackup = m_pageBackups.current(); | 366 | Page* currentBackup = m_pageBackups.current(); |
354 | while (m_pageBackups.last() != currentBackup) { | 367 | while (m_pageBackups.last() != currentBackup) { |
355 | m_pageBackups.removeLast(); | 368 | m_pageBackups.removeLast(); |
356 | } | 369 | } |
357 | 370 | ||
358 | while (m_pageBackups.count() >= (PAGE_BACKUPS + 1)) { | 371 | while (m_pageBackups.count() >= (PAGE_BACKUPS + 1)) { |
359 | m_pageBackups.removeFirst(); | 372 | m_pageBackups.removeFirst(); |
360 | } | 373 | } |
361 | 374 | ||
362 | m_pageBackups.append(new Page(*(m_pages.current()))); | 375 | m_pageBackups.append(new Page(*(m_pages.current()))); |
363 | 376 | ||
364 | emit pageBackupsChanged(); | 377 | emit pageBackupsChanged(); |
365 | } | 378 | } |
366 | 379 | ||
367 | void DrawPadCanvas::deleteAll() | 380 | void DrawPadCanvas::deleteAll() |
368 | { | 381 | { |
369 | m_pages.clear(); | 382 | m_pages.clear(); |
370 | 383 | ||
371 | m_pages.append(new Page("", contentsRect().size())); | 384 | m_pages.append(new Page("", contentsRect().size())); |
372 | m_pages.current()->fill(Qt::white); | 385 | m_pages.current()->fill(Qt::white); |
373 | 386 | ||
374 | m_pageBackups.clear(); | 387 | m_pageBackups.clear(); |
375 | m_pageBackups.append(new Page(*(m_pages.current()))); | 388 | m_pageBackups.append(new Page(*(m_pages.current()))); |
376 | 389 | ||
377 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 390 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
378 | viewport()->update(); | 391 | viewport()->update(); |
379 | 392 | ||
380 | emit pagesChanged(); | 393 | emit pagesChanged(); |
381 | emit pageBackupsChanged(); | 394 | emit pageBackupsChanged(); |
382 | } | 395 | } |
383 | 396 | ||
384 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) | 397 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) |
385 | { | 398 | { |
386 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); | 399 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); |
387 | m_pages.current()->fill(color); | 400 | m_pages.current()->fill(color); |
388 | 401 | ||
389 | m_pageBackups.clear(); | 402 | m_pageBackups.clear(); |
390 | m_pageBackups.append(new Page(*(m_pages.current()))); | 403 | m_pageBackups.append(new Page(*(m_pages.current()))); |
391 | 404 | ||
392 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 405 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
393 | viewport()->update(); | 406 | viewport()->update(); |
394 | 407 | ||
395 | emit pagesChanged(); | 408 | emit pagesChanged(); |
396 | emit pageBackupsChanged(); | 409 | emit pageBackupsChanged(); |