~ubuntu-branches/ubuntu/warty/gwenview/warty

« back to all changes in this revision

Viewing changes to src/gvdocument.h

  • Committer: Bazaar Package Importer
  • Author(s): Christopher Martin
  • Date: 2004-06-13 18:55:04 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040613185504-net8ekxoswwvyxs9
Tags: 1.1.3-1
New upstream release. Translations now included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// vim: set tabstop=4 shiftwidth=4 noexpandtab
 
2
/*
 
3
Gwenview - A simple image viewer for KDE
 
4
Copyright 2000-2004 Aur�lien G�teau
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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.
 
19
 
 
20
*/
 
21
#ifndef GVDOCUMENT_H
 
22
#define GVDOCUMENT_H
 
23
 
 
24
// Qt 
 
25
#include <qcstring.h>
 
26
#include <qobject.h>
 
27
#include <qimage.h>
 
28
 
 
29
// KDE 
 
30
#include <kurl.h>
 
31
#include <kprinter.h>
 
32
 
 
33
// Local 
 
34
#include "gvimageutils.h"
 
35
#include "gvbusylevelmanager.h"
 
36
 
 
37
class GVDocumentPrivate;
 
38
class GVDocumentImpl;
 
39
 
 
40
namespace KIO { class Job; }
 
41
/**
 
42
 * The application document.
 
43
 * It knows what the current url is.
 
44
 */
 
45
class GVDocument : public QObject {
 
46
Q_OBJECT
 
47
public:
 
48
        enum ModifiedBehavior { ASK=0, SAVE_SILENTLY=1, DISCARD_CHANGES=2 };
 
49
        enum CommentState { NONE=0, READ_ONLY=1, VALID=READ_ONLY, WRITABLE=3 };
 
50
        
 
51
        GVDocument(QObject*);
 
52
        ~GVDocument();
 
53
 
 
54
        // Properties
 
55
        const QImage& image() const;
 
56
        KURL url() const;
 
57
        const KURL& dirURL() const;
 
58
        const QString& filename() const;
 
59
        const char* imageFormat() const;
 
60
        int fileSize() const;
 
61
 
 
62
        // Convenience methods
 
63
        bool isNull() const { return image().isNull(); }
 
64
        int width() const { return image().width(); }
 
65
        int height() const { return image().height(); }
 
66
 
 
67
        void setModifiedBehavior(ModifiedBehavior);
 
68
        ModifiedBehavior modifiedBehavior() const;
 
69
 
 
70
        GVDocument::CommentState commentState() const;
 
71
        QString comment() const;
 
72
        void setComment(const QString&);
 
73
        
 
74
public slots:
 
75
        void setURL(const KURL&);
 
76
        void setDirURL(const KURL&);
 
77
        void setFilename(const QString&);
 
78
        void reload();
 
79
 
 
80
        /**
 
81
         * Save to the current file.
 
82
         * Returns false if failed.
 
83
         */
 
84
        bool save();
 
85
        void saveAs();
 
86
        
 
87
        /** print the selected file */
 
88
        void print(KPrinter *pPrinter);
 
89
        
 
90
        /**
 
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.
 
93
         */
 
94
        bool saveBeforeClosing();
 
95
 
 
96
        // "Image manipulation"
 
97
        void modify(GVImageUtils::Orientation);
 
98
 
 
99
signals:
 
100
        /**
 
101
         * Emitted when the class starts to load the image.
 
102
         */
 
103
        void loading();
 
104
 
 
105
        /**
 
106
         * Emitted when the class has finished loading the image.
 
107
         * Also emitted if the image could not be loaded.
 
108
         */
 
109
        void loaded(const KURL& dirURL,const QString& filename);
 
110
 
 
111
        /**
 
112
         * Emitted when the image has been modified.
 
113
         */
 
114
        void modified();
 
115
 
 
116
        /**
 
117
         * Emitted when the image has been saved on disk.
 
118
         */
 
119
        void saved(const KURL& url);
 
120
 
 
121
        /**
 
122
         * Emitted when the image has been reloaded.
 
123
         */ 
 
124
        void reloaded(const KURL& url);
 
125
 
 
126
        /**
 
127
         * Emitted during loading to show a part of the image must be refreshed
 
128
         */
 
129
        void rectUpdated(const QRect& rect);
 
130
 
 
131
        /**
 
132
         * Emitted during loading, when the size is known
 
133
         */
 
134
        void sizeUpdated(int width, int height);
 
135
 
 
136
private slots:
 
137
        void slotStatResult(KIO::Job*); 
 
138
        void slotFinished(bool success);
 
139
        void slotLoading();
 
140
        void slotLoaded();
 
141
        void slotBusyLevelChanged(GVBusyLevel level);
 
142
        
 
143
private:
 
144
        friend class GVDocumentImpl;
 
145
 
 
146
        GVDocumentPrivate* d;
 
147
 
 
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); 
 
153
        
 
154
        void reset();
 
155
        void load();
 
156
        bool saveInternal(const KURL&,const char* format);
 
157
        void doPaint(KPrinter *pPrinter, QPainter *p); 
 
158
};
 
159
 
 
160
 
 
161
#endif