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/orientation.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 and will emit signals when
44
* loading/loaded/modified...
46
* The ordering of loading() and loaded() signals is:
47
* - setURL() is called
49
* - loading() is emitted (may be skipped if no loading is needed, e.g. wrong URL)
50
* - image is being loaded
51
* - loaded() is emitted
53
class GVDocument : public QObject {
56
enum ModifiedBehavior { ASK=0, SAVE_SILENTLY=1, DISCARD_CHANGES=2 };
57
enum CommentState { NONE=0, READ_ONLY=1, VALID=READ_ONLY, WRITABLE=3 };
63
const QImage& image() const;
66
QString filename() const;
67
const QCString& imageFormat() const;
70
// Convenience methods
71
bool isNull() const { return image().isNull(); }
72
int width() const { return image().width(); }
73
int height() const { return image().height(); }
75
void setModifiedBehavior(ModifiedBehavior);
76
ModifiedBehavior modifiedBehavior() const;
78
GVDocument::CommentState commentState() const;
79
QString comment() const;
80
void setComment(const QString&);
83
void setURL(const KURL&);
84
void setDirURL(const KURL&);
88
* Save to the current file.
93
/** print the selected file */
94
void print(KPrinter *pPrinter);
97
* If the image has been modified, prompt the user to save the changes.
98
* Returns true if it's safe to switch to another image.
100
bool saveBeforeClosing();
102
// "Image manipulation"
103
void transform(GVImageUtils::Orientation);
107
* Emitted when the class starts to load the image.
112
* Emitted when the class has finished loading the image.
113
* Also emitted if the image could not be loaded.
115
void loaded(const KURL& url);
118
* Emitted when the image has been modified.
123
* Emitted when the image has been saved on disk.
125
void saved(const KURL& url);
128
* Emitted when the image has been reloaded.
130
void reloaded(const KURL& url);
133
* Emitted to show a part of the image must be refreshed
135
void rectUpdated(const QRect& rect);
138
* Emitted when the size is known (or when it has changed)
140
void sizeUpdated(int width, int height);
143
* Emitted when something goes wrong, like when save fails
145
void errorHappened(const QString& message);
148
void slotStatResult(KIO::Job*);
149
void slotFinished(bool success);
152
void slotBusyLevelChanged(GVBusyLevel level);
155
friend class GVDocumentImpl;
156
friend class GVDocumentPrivate;
158
GVDocumentPrivate* d;
160
// These methods are used by GVDocumentImpl and derived
161
void switchToImpl(GVDocumentImpl*);
162
// update == true triggers also sizeUpdated() and rectUpdated()
163
void setImage(QImage, bool update);
164
void setImageFormat(const QCString&);
165
void setFileSize(int);
169
void doPaint(KPrinter *pPrinter, QPainter *p);
172
* The returned string is null if the image was successfully saved,
173
* otherwise it's the translated error message.
175
QString saveInternal(const KURL& url, const QCString& format);
177
GVDocument(const GVDocument&);
178
GVDocument &operator=(const GVDocument&);