00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KIS_DOC_H_
00021 #define KIS_DOC_H_
00022
00023 #include <kdebug.h>
00024
00025 #include <KoDocument.h>
00026
00027 #include "kis_types.h"
00028 #include "kis_undo_adapter.h"
00029
00030 #include <koffice_export.h>
00031
00032 class QImage;
00033 class QString;
00034
00035 class DCOPObject;
00036 class KCommand;
00037
00038 class KoCommandHistory;
00039 class KMacroCommand;
00040
00041 class KisProfile;
00042 class KisView;
00043 class KisNameServer;
00044 class KisChildDoc;
00045 class KisColorSpace;
00046 class KisColor;
00047 class KisCompositeOp;
00048
00049 class KRITACORE_EXPORT KisDoc : public KoDocument, private KisUndoAdapter {
00050
00051 typedef KoDocument super;
00052 Q_OBJECT
00053
00054 public:
00055 KisDoc(QWidget *parentWidget = 0, const char *widgetName = 0, QObject* parent = 0, const char* name = 0, bool singleViewMode = false);
00056 virtual ~KisDoc();
00057
00058 public:
00059
00060 virtual bool wantExportConfirmation() const { return false; };
00061 virtual bool completeLoading(KoStore *store);
00062 virtual bool completeSaving(KoStore*);
00063 virtual DCOPObject* dcopObject();
00064 virtual bool initDoc(InitDocFlags flags, QWidget* parentWidget=0);
00065 virtual bool loadOasis( const QDomDocument&, KoOasisStyles&, const QDomDocument&, KoStore* );
00066 virtual bool saveOasis( KoStore*, KoXmlWriter* );
00067 virtual bool loadChildren( KoStore* store);
00068 virtual bool loadXML(QIODevice *, const QDomDocument& doc);
00069 virtual QCString mimeType() const;
00070 virtual QWidget* createCustomDocumentWidget(QWidget *parent);
00071 virtual KoDocument* hitTest(const QPoint &pos, const QWMatrix& matrix = QWMatrix());
00072
00080 virtual void paintContent(QPainter& painter, const QRect& rect, bool , double , double );
00081
00082 virtual QDomDocument saveXML();
00083
00084 public slots:
00085
00086
00091 virtual void initEmpty();
00092
00093 private:
00094
00095 virtual void setCommandHistoryListener(const KisCommandHistoryListener *);
00096 virtual void removeCommandHistoryListener(const KisCommandHistoryListener *);
00097
00098 virtual KCommand * presentCommand();
00099 virtual void addCommand(KCommand *cmd);
00100 virtual void setUndo(bool undo);
00101 virtual bool undo() const;
00102 virtual void beginMacro(const QString& macroName);
00103 virtual void endMacro();
00104
00105
00106 public:
00107
00108
00109 Q_INT32 undoLimit() const;
00110 void setUndoLimit(Q_INT32 limit);
00111
00112 Q_INT32 redoLimit() const;
00113 void setRedoLimit(Q_INT32 limit);
00114
00119 bool newImage(const QString& name, Q_INT32 width, Q_INT32 height, KisColorSpace * cs, const KisColor &bgColor, const QString &imgDescription, const double imgResolution);
00120
00125 KisImageSP newImage(const QString& name, Q_INT32 width, Q_INT32 height, KisColorSpace * colorstrategy);
00126
00127 void renameImage(const QString& oldName, const QString& newName);
00128
00129
00135 KisChildDoc * createChildDoc( const QRect& rect, KoDocument* childDoc );
00136
00140 void prepareForImport();
00141
00142 KisImageSP currentImage();
00143
00147 void setCurrentImage(KisImageSP image);
00148
00149 KisUndoAdapter * undoAdapter() { return this; }
00150
00151 public slots:
00152 void slotImageUpdated();
00153 void slotImageUpdated(const QRect& rect);
00154 void slotDocumentRestored();
00155 void slotCommandExecuted(KCommand *command);
00156
00157 signals:
00158 void docUpdated();
00159 void docUpdated(QRect rect);
00160 void loadingFinished();
00161
00162
00163
00164
00165
00166 void sigCommandExecuted();
00167
00168 protected:
00169
00170 virtual KoView* createViewInstance(QWidget *parent, const char *name);
00171
00172 protected slots:
00173
00174 virtual void openExistingFile(const QString& file);
00175 virtual void openTemplate(const QString& file);
00176
00177 private slots:
00178 void slotUpdate(KisImageSP img, Q_UINT32 x, Q_UINT32 y, Q_UINT32 w, Q_UINT32 h);
00179 void slotIOProgress(Q_INT8 percentage);
00180
00181 private:
00182
00183 QDomElement saveImage(QDomDocument& doc, KisImageSP img);
00184 KisImageSP loadImage(const QDomElement& elem);
00185 void loadLayers(const QDomElement& element, KisImageSP img, KisGroupLayerSP parent);
00186 KisLayerSP loadLayer(const QDomElement& elem, KisImageSP img);
00187 KisLayerSP loadPaintLayer(const QDomElement& elem, KisImageSP img,
00188 QString name, Q_INT32 x, Q_INT32 y, Q_INT32 opacity, bool visible, bool locked,
00189 KisCompositeOp compositeOp);
00190 KisGroupLayerSP loadGroupLayer(const QDomElement& elem, KisImageSP img,
00191 QString name, Q_INT32 x, Q_INT32 y, Q_INT32 opacity, bool visible, bool locked,
00192 KisCompositeOp compositeOp);
00193 KisAdjustmentLayerSP loadAdjustmentLayer(const QDomElement& elem, KisImageSP img,
00194 QString name, Q_INT32 x, Q_INT32 y, Q_INT32 opacity, bool visible, bool locked,
00195 KisCompositeOp compositeOp);
00196 KisPartLayerSP loadPartLayer(const QDomElement& elem, KisImageSP img,
00197 QString name, Q_INT32 x, Q_INT32 y, Q_INT32 opacity,
00198 bool visible, bool locked, KisCompositeOp compositeOp);
00199 bool init();
00200
00201 void setIOSteps(Q_INT32 nsteps);
00202 void IOCompletedStep();
00203 void IODone();
00204
00205 private:
00206
00207 bool m_undo;
00208 KoCommandHistory *m_cmdHistory;
00209 QPtrList<KisCommandHistoryListener> m_undoListeners;
00210 KisImageSP m_currentImage;
00211 DCOPObject *m_dcop;
00212 KisNameServer *m_nserver;
00213 KMacroCommand *m_currentMacro;
00214 Q_INT32 m_macroNestDepth;
00215 Q_INT32 m_conversionDepth;
00216 int m_ioProgressTotalSteps;
00217 int m_ioProgressBase;
00218 QMap<KisLayerSP, QString> m_layerFilenames;
00219
00220 };
00221
00222 #endif // KIS_DOC_H_
00223