Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

page.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   DrawPad - a drawing program for Opie Environment                      *
00004  *                                                                         *
00005  *   (C) 2002 by S. Prud'homme <prudhomme@laposte.net>                     *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 #include "page.h"
00015 
00016 const int PAGE_BACKUPS = 9;
00017 
00018 Page::Page()
00019 {
00020     m_title = "";
00021     m_lastModified = QDateTime::currentDateTime();
00022     m_pPixmap = new QPixmap();
00023 
00024     m_backHistory.setAutoDelete(true);
00025     m_forwardHistory.setAutoDelete(true);
00026 }
00027 
00028 Page::Page(QString title, int w, int h)
00029 {
00030     m_title = title;
00031     m_lastModified = QDateTime::currentDateTime();
00032     m_pPixmap = new QPixmap(w, h);
00033 
00034     m_backHistory.setAutoDelete(true);
00035     m_forwardHistory.setAutoDelete(true);
00036 }
00037 
00038 Page::Page(QString title, const QSize& size)
00039 {
00040     m_title = title;
00041     m_lastModified = QDateTime::currentDateTime();
00042     m_pPixmap = new QPixmap(size);
00043 
00044     m_backHistory.setAutoDelete(true);
00045     m_forwardHistory.setAutoDelete(true);
00046 }
00047 
00048 Page::~Page()
00049 {
00050     delete m_pPixmap;
00051 }
00052 
00053 QString Page::title() const
00054 {
00055     return m_title;
00056 }
00057 
00058 QDateTime Page::lastModified() const
00059 {
00060     return m_lastModified;
00061 }
00062 
00063 QPixmap* Page::pixmap() const
00064 
00065 {
00066     return m_pPixmap;
00067 }
00068 
00069 void Page::setTitle(QString title)
00070 {
00071     m_title = title;
00072 }
00073 
00074 void Page::setLastModified(QDateTime lastModified)
00075 {
00076     m_lastModified = lastModified;
00077 }
00078 
00079 bool Page::undoEnabled()
00080 {
00081     return (!m_backHistory.isEmpty());
00082 }
00083 
00084 bool Page::redoEnabled()
00085 {
00086     return (!m_forwardHistory.isEmpty());
00087 }
00088 
00089 void Page::backup()
00090 {
00091     setLastModified(QDateTime::currentDateTime());
00092 
00093     while (m_backHistory.count() >= (PAGE_BACKUPS + 1)) {
00094         m_backHistory.removeFirst();
00095     }
00096 
00097     m_backHistory.append(new QPixmap(*m_pPixmap));
00098     m_forwardHistory.clear();
00099 }
00100 
00101 void Page::undo()
00102 {
00103     m_forwardHistory.append(new QPixmap(*m_pPixmap));
00104     m_pPixmap = new QPixmap(*(m_backHistory.last()));
00105     m_backHistory.removeLast();
00106 }
00107 
00108 void Page::redo()
00109 {
00110     m_backHistory.append(new QPixmap(*m_pPixmap));
00111     m_pPixmap = new QPixmap(*(m_forwardHistory.last()));
00112     m_forwardHistory.removeLast();
00113 }

Generated on Sat Nov 5 16:17:29 2005 for OPIE by  doxygen 1.4.2