kivio

kivio_doc.h
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#ifndef __kivio_doc_h__
20#define __kivio_doc_h__
21
22#include "kivio_grid_data.h"
23
24#include <tqptrlist.h>
25#include <tqobject.h>
26
27#include <KoDocument.h>
28#include <KoMainWindow.h>
29#include <KoGlobal.h>
30
31#include "kivio_config.h"
32#include <koffice_export.h>
33class KivioDoc;
34class KivioView;
35class KivioMap;
36class KivioPage;
37
38class ExportPageDialog;
39class KivioGroupStencil;
40class KivioStencilSpawner;
41class KivioStencilSpawnerSet;
42class KivioStackBar;
43class KivioPainter;
44class KivioStencil;
45
46namespace Kivio {
47 class DragBarButton;
48}
49
50class KoStore;
51class TQDomDocument;
52class DCOPObject;
53class KoCommandHistory;
54
55class TQPainter;
56class KPrinter;
57class KCommand;
58class KoZoomHandler;
59class TQFont;
60
61#define MIME_TYPE "application/x-kivio"
62
63using namespace Kivio;
64
65class KIVIO_EXPORT KivioDoc : public KoDocument
66{
67 TQ_OBJECT
68
69 friend class KivioPage;
70 public:
71 KivioDoc( TQWidget *parentWidget = 0, const char* widgetName = 0, TQObject* parent = 0, const char* name = 0, bool singleViewMode = false );
72 ~KivioDoc();
73
74 virtual DCOPObject* dcopObject();
75
76 virtual TQDomDocument saveXML();
77 virtual bool saveOasis(KoStore* store, KoXmlWriter* manifestWriter);
78
79 virtual bool loadXML( TQIODevice *, const TQDomDocument& doc );
80 virtual bool loadOasis( const TQDomDocument& doc, KoOasisStyles& oasisStyles, const TQDomDocument& settings, KoStore* );
81
82 virtual bool initDoc(InitDocFlags flags, TQWidget* parentWidget=0);
83
84 virtual TQCString mimeType() const { return MIME_TYPE; }
85
89 KivioPage* createPage();
90
98 void addPage( KivioPage* page );
99
104 void addSpawnerSet( const TQString& );
105 void addSpawnerSetDuringLoad(const TQString& dirName, bool hidden);
106 bool removeSpawnerSet( KivioStencilSpawnerSet * );
107
108 TQPtrList<KivioStencilSpawnerSet> *spawnerSets()const { return m_pLstSpawnerSets; }
109
110 KivioStencilSpawner *findStencilSpawner( const TQString& setId, const TQString& stencilId );
111 KivioStencilSpawner *findInternalStencilSpawner( const TQString& title );
112
113 void addInternalStencilSpawner(KivioStencilSpawner* spawner);
114 KivioStencilSpawnerSet* internalSpawnerSet() { return m_pInternalSet; }
115
116 KivioMap* map() const { return m_pMap; }
117
121 bool isLoading()const { return m_bLoading; }
122
123 virtual void paintContent( TQPainter& painter, const TQRect& rect, bool transparent = false, double zoomX = 1.0, double zoomY = 1.0 );
124 void paintContent(KivioPainter& painter, const TQRect& rect, bool transparent, KivioPage* page,
125 TQPoint, KoZoomHandler*, bool, bool);
126
127 void printContent( KPrinter& prn );
128
129 static TQPtrList<KivioDoc>& documents();
130
131 KivioGridData grid() { return Kivio::Config::grid(); }
132
133 void initConfig();
134 void saveConfig();
135 void updateButton();
136 void addCommand( KCommand * cmd );
137
138 int undoRedoLimit() const;
139 void setUndoRedoLimit(int val);
140 KoCommandHistory * commandHistory()const { return m_commandHistory; }
141
142 void insertPage( KivioPage * page );
143 void takePage( KivioPage * page );
144 void resetLayerPanel();
145 void updateProtectPanelCheckBox();
146
147 TQFont defaultFont() const { return m_font; }
148
149 public slots:
150 void updateView(KivioPage*);
151
152 void slotDeleteStencilSet( DragBarButton *, TQWidget *, KivioStackBar * );
153 void slotSelectionChanged();
154
155 void setDefaultFont(const TQFont& f) { m_font = f; }
156
157 void updateGuideLines(KoView* sender);
158 void updateGuideLines(KivioPage* page);
159
160 virtual void initEmpty();
161
162 protected slots:
163 void slotDocumentRestored();
164 void slotCommandExecuted();
165 void loadStencil();
166
167 virtual void openExistingFile( const TQString& file );
168 virtual void openTemplate( const TQString& file );
169
170 signals:
171 void sig_selectionChanged();
172 void sig_addPage(KivioPage*);
173 void sig_addSpawnerSet( KivioStencilSpawnerSet * );
174 void sig_updateView(KivioPage*);
175 void sig_pageNameChanged(KivioPage*, const TQString&);
176 void sig_deleteStencilSet( DragBarButton*, TQWidget *, KivioStackBar * );
177 void sig_updateGrid();
178
179 void initProgress();
180 void progress(int);
181 void endProgress();
182
183 void loadingFinished();
184
185 protected:
186 bool checkStencilsForSpawnerSet(KivioStencilSpawnerSet *);
187 bool checkGroupForSpawnerSet(KivioStencil *, KivioStencilSpawnerSet *);
188 KivioStencilSpawnerSet* findSpawnerSet(const TQString& dirName, const TQString& name);
189
190 void saveOasisSettings( KoXmlWriter &/*settingsWriter*/ );
191 void loadOasisSettings( const TQDomDocument&settingsDoc );
192
193 KoView* createViewInstance( TQWidget* parent, const char* name );
194
198 TQPtrList <KivioStencilSpawnerSet> *m_pLstSpawnerSets;
199
200
204 bool loadStencilSpawnerSet(const TQString &id, bool hidden);
205
209 virtual bool completeLoading( KoStore* );
210
214 KivioMap *m_pMap;
215
221 int m_iPageId;
222
229 TQString m_strFileURL;
230
237 bool m_bLoading;
238
239 static TQPtrList<KivioDoc>* s_docs;
240 static int s_docId;
241
242 KivioStencilSpawnerSet* m_pInternalSet;
243
244 KivioGridData gridData;
245
246 DCOPObject *dcop;
247 KoCommandHistory * m_commandHistory;
248
249 TQFont m_font;
250
251 TQTimer* m_loadTimer;
252 unsigned int m_currentFile;
253 KivioStencilSpawnerSet* m_currentSet;
254 TQValueList<KivioStencilSpawnerSet*> m_stencilSetLoadQueue;
255
256 bool m_docOpened; // Used to for a hack that make kivio not crash if you cancel startup dialog.
257};
258
259#endif
260
static KivioGridData grid()
Returns the grid settings.