File indexing completed on 2024-04-28 04:31:57

0001 /*
0002  * Copyright (C) 2010-2015 by Stephen Allewell
0003  * steve.allewell@gmail.com
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2 of the License, or
0008  * (at your option) any later version.
0009  */
0010 
0011 #ifndef Document_H
0012 #define Document_H
0013 
0014 #include <QPolygon>
0015 #include <QUndoStack>
0016 #include <QUrl>
0017 
0018 #include "BackgroundImages.h"
0019 #include "Exceptions.h"
0020 #include "Pattern.h"
0021 #include "PrinterConfiguration.h"
0022 #include "configuration.h"
0023 
0024 class Editor;
0025 class Palette;
0026 class Preview;
0027 
0028 class Document
0029 {
0030 public:
0031     Document();
0032     ~Document();
0033 
0034     void initialiseNew();
0035 
0036     void readKXStitch(QDataStream &);
0037     void readPCStitch(QDataStream &);
0038     void write(QDataStream &);
0039 
0040     void setUrl(const QUrl &);
0041     QUrl url() const;
0042 
0043     void addView(Editor *);
0044     void addView(Palette *);
0045     void addView(Preview *);
0046 
0047     Editor *editor() const;
0048     Palette *palette() const;
0049     Preview *preview() const;
0050 
0051     QVariant property(const QString &) const;
0052     void setProperty(const QString &, const QVariant &);
0053 
0054     QUndoStack &undoStack();
0055 
0056     BackgroundImages &backgroundImages();
0057     Pattern *pattern();
0058     const PrinterConfiguration &printerConfiguration() const;
0059     void setPrinterConfiguration(const PrinterConfiguration &);
0060 
0061 private:
0062     void readPCStitch5File(QDataStream &);
0063     void readPCStitch6File(QDataStream &);
0064     void readPCStitch7File(QDataStream &);
0065     QString readPCStitchString(QDataStream &);
0066 
0067     void readKXStitchV2File(QDataStream &);
0068     void readKXStitchV3File(QDataStream &);
0069     void readKXStitchV4File(QDataStream &);
0070     void readKXStitchV5File(QDataStream &);
0071     void readKXStitchV6File(QDataStream &);
0072     void readKXStitchV7File(QDataStream &);
0073 
0074     static const int version = 104;
0075 
0076     QMap<QString, QVariant> m_properties;
0077 
0078     QUrl m_url;
0079 
0080     QUndoStack m_undoStack;
0081 
0082     Editor *m_editor;
0083     Palette *m_palette;
0084     Preview *m_preview;
0085 
0086     BackgroundImages m_backgroundImages;
0087     Pattern *m_pattern;
0088     PrinterConfiguration m_printerConfiguration;
0089 };
0090 
0091 #endif // Document_H