1
// vim: set tabstop=4 shiftwidth=4 noexpandtab
3
Gwenview - A simple image viewer for KDE
4
Copyright 2000-2004 Aur�lien G�teau
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of the GNU General Public License
8
as published by the Free Software Foundation; either version 2
9
of the License, or (at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34
#include "gvimageutils.h"
35
#include "gvbusylevelmanager.h"
37
class GVDocumentPrivate;
40
namespace KIO { class Job; }
42
* The application document.
43
* It knows what the current url is.
45
class GVDocument : public QObject {
48
enum ModifiedBehavior { ASK=0, SAVE_SILENTLY=1, DISCARD_CHANGES=2 };
49
enum CommentState { NONE=0, READ_ONLY=1, VALID=READ_ONLY, WRITABLE=3 };
55
const QImage& image() const;
57
const KURL& dirURL() const;
58
const QString& filename() const;
59
const char* imageFormat() const;
62
// Convenience methods
63
bool isNull() const { return image().isNull(); }
64
int width() const { return image().width(); }
65
int height() const { return image().height(); }
67
void setModifiedBehavior(ModifiedBehavior);
68
ModifiedBehavior modifiedBehavior() const;
70
GVDocument::CommentState commentState() const;
71
QString comment() const;
72
void setComment(const QString&);
75
void setURL(const KURL&);
76
void setDirURL(const KURL&);
77
void setFilename(const QString&);
81
* Save to the current file.
82
* Returns false if failed.
87
/** print the selected file */
88
void print(KPrinter *pPrinter);
91
* If the image has been modified, prompt the user to save the changes.
92
* Returns true if it's safe to switch to another image.
94
bool saveBeforeClosing();
96
// "Image manipulation"
97
void modify(GVImageUtils::Orientation);
101
* Emitted when the class starts to load the image.
106
* Emitted when the class has finished loading the image.
107
* Also emitted if the image could not be loaded.
109
void loaded(const KURL& dirURL,const QString& filename);
112
* Emitted when the image has been modified.
117
* Emitted when the image has been saved on disk.
119
void saved(const KURL& url);
122
* Emitted when the image has been reloaded.
124
void reloaded(const KURL& url);
127
* Emitted during loading to show a part of the image must be refreshed
129
void rectUpdated(const QRect& rect);
132
* Emitted during loading, when the size is known
134
void sizeUpdated(int width, int height);
137
void slotStatResult(KIO::Job*);
138
void slotFinished(bool success);
141
void slotBusyLevelChanged(GVBusyLevel level);
144
friend class GVDocumentImpl;
146
GVDocumentPrivate* d;
148
// These methods are used by GVDocumentImpl and derived
149
void switchToImpl(GVDocumentImpl*);
150
void setImage(QImage);
151
void setImageFormat(const char*);
152
void setFileSize(int);
156
bool saveInternal(const KURL&,const char* format);
157
void doPaint(KPrinter *pPrinter, QPainter *p);