use kDebug
[kdegraphics.git] / kolourpaint / document / kpDocumentSaveOptions.h
blob83ef396b9c34958356f5ae3e351b676813080f5f
2 /*
3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
4 All rights reserved.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef KP_DOCUMENT_SAVE_OPTIONS_H
30 #define KP_DOCUMENT_SAVE_OPTIONS_H
33 class QPixmap;
34 class QString;
36 class KConfigGroup;
39 class kpDocumentSaveOptions
41 public:
42 kpDocumentSaveOptions ();
43 kpDocumentSaveOptions (const kpDocumentSaveOptions &rhs);
44 kpDocumentSaveOptions (QString mimeType, int colorDepth, bool dither, int quality);
45 virtual ~kpDocumentSaveOptions ();
47 bool operator== (const kpDocumentSaveOptions &rhs) const;
48 bool operator!= (const kpDocumentSaveOptions &rhs) const;
50 kpDocumentSaveOptions &operator= (const kpDocumentSaveOptions &rhs);
53 void printDebug (const QString &prefix) const;
56 QString mimeType () const;
57 void setMimeType (const QString &mimeType);
59 static QString invalidMimeType ();
60 static bool mimeTypeIsInvalid (const QString &mimeType);
61 bool mimeTypeIsInvalid () const;
64 int colorDepth () const;
65 void setColorDepth (int depth);
67 static int invalidColorDepth ();
68 static bool colorDepthIsInvalid (int colorDepth);
69 bool colorDepthIsInvalid () const;
72 bool dither () const;
73 void setDither (bool dither);
75 static int initialDither ();
78 int quality () const;
79 void setQuality (int quality);
81 static int invalidQuality ();
82 static bool qualityIsInvalid (int quality);
83 bool qualityIsInvalid () const;
86 // (All assume that <config>'s group has been set)
87 // (None of them call KConfigBase::reparseConfig() nor KConfigBase::sync())
89 static QString defaultMimeType (const KConfigGroup &config);
90 static void saveDefaultMimeType (KConfigGroup &config, const QString &mimeType);
92 static int defaultColorDepth (const KConfigGroup &config);
93 static void saveDefaultColorDepth (KConfigGroup &config, int colorDepth);
95 static int defaultDither (const KConfigGroup &config);
96 static void saveDefaultDither (KConfigGroup &config, bool dither);
98 static int defaultQuality (const KConfigGroup &config);
99 static void saveDefaultQuality (KConfigGroup &config, int quality);
102 static kpDocumentSaveOptions defaultDocumentSaveOptions (const KConfigGroup &config);
103 // (returns true if it encountered a difference (and saved it to <config>))
104 static bool saveDefaultDifferences (KConfigGroup &config,
105 const kpDocumentSaveOptions &oldDocInfo,
106 const kpDocumentSaveOptions &newDocInfo);
109 public:
110 // (purely for informational purposes - not enforced by this class)
111 static int mimeTypeMaximumColorDepth (const QString &mimeType);
112 int mimeTypeMaximumColorDepth () const;
115 static bool mimeTypeHasConfigurableColorDepth (const QString &mimeType);
116 bool mimeTypeHasConfigurableColorDepth () const;
118 static bool mimeTypeHasConfigurableQuality (const QString &mimeType);
119 bool mimeTypeHasConfigurableQuality () const;
122 // TODO: checking for mask loss due to format e.g. BMP
123 enum LossyType
125 LossLess = 0,
127 // mimeTypeMaximumColorDepth() < <pixmap>.depth()
128 MimeTypeMaximumColorDepthLow = 1,
129 // i.e. colorDepth() < <pixmap>.depth() ||
130 // colorDepth() < 32 && <pixmap>.mask()
131 ColorDepthLow = 2,
132 // i.e. mimeTypeHasConfigurableQuality()
133 Quality = 4
136 // Returns whether saving <pixmap> with these options will result in
137 // loss of information. Returned value is the bitwise OR of
138 // LossType enum possiblities.
139 int isLossyForSaving (const QPixmap &pixmap) const;
142 private:
143 // There is no need to maintain binary compatibility at this stage.
144 // The d-pointer is just so that you can experiment without recompiling
145 // the kitchen sink.
146 class kpDocumentSaveOptionsPrivate *d;
150 #endif // KP_DOCUMENT_SAVE_OPTIONS_H