kivio

kivio_doc.h

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 #ifndef __kivio_doc_h__
00020 #define __kivio_doc_h__
00021 
00022 #include "kivio_grid_data.h"
00023 
00024 #include <qptrlist.h>
00025 #include <qobject.h>
00026 
00027 #include <KoDocument.h>
00028 #include <KoMainWindow.h>
00029 #include <KoGlobal.h>
00030 
00031 #include "kivio_config.h"
00032 #include <koffice_export.h>
00033 class KivioDoc;
00034 class KivioView;
00035 class KivioMap;
00036 class KivioPage;
00037 
00038 class ExportPageDialog;
00039 class KivioGroupStencil;
00040 class KivioStencilSpawner;
00041 class KivioStencilSpawnerSet;
00042 class KivioStackBar;
00043 class KivioPainter;
00044 class KivioStencil;
00045 
00046 namespace Kivio {
00047   class DragBarButton;
00048 }
00049 
00050 class KoStore;
00051 class QDomDocument;
00052 class DCOPObject;
00053 class KoCommandHistory;
00054 
00055 class QPainter;
00056 class KPrinter;
00057 class KCommand;
00058 class KoZoomHandler;
00059 class QFont;
00060 
00061 #define MIME_TYPE "application/x-kivio"
00062 
00063 using namespace Kivio;
00064 
00065 class KIVIO_EXPORT KivioDoc : public KoDocument
00066 {
00067   Q_OBJECT
00068   friend class KivioPage;
00069   public:
00070     KivioDoc( QWidget *parentWidget = 0, const char* widgetName = 0, QObject* parent = 0, const char* name = 0, bool singleViewMode = false );
00071     ~KivioDoc();
00072 
00073     virtual DCOPObject* dcopObject();
00074 
00075     virtual QDomDocument saveXML();
00076     virtual bool saveOasis(KoStore* store, KoXmlWriter* manifestWriter);
00077 
00078     virtual bool loadXML( QIODevice *, const QDomDocument& doc );
00079     virtual bool loadOasis( const QDomDocument& doc, KoOasisStyles& oasisStyles, const QDomDocument& settings, KoStore* );
00080 
00081     virtual bool initDoc(InitDocFlags flags, QWidget* parentWidget=0);
00082 
00083     virtual QCString mimeType() const { return MIME_TYPE; }
00084 
00088     KivioPage* createPage();
00089 
00097     void addPage( KivioPage* page );
00098 
00103     void addSpawnerSet( const QString& );
00104     void addSpawnerSetDuringLoad(const QString& dirName, bool hidden);
00105     bool removeSpawnerSet( KivioStencilSpawnerSet * );
00106 
00107     QPtrList<KivioStencilSpawnerSet> *spawnerSets()const { return m_pLstSpawnerSets; }
00108 
00109     KivioStencilSpawner *findStencilSpawner( const QString& setId, const QString& stencilId );
00110     KivioStencilSpawner *findInternalStencilSpawner( const QString& title );
00111 
00112     void addInternalStencilSpawner(KivioStencilSpawner* spawner);
00113     KivioStencilSpawnerSet* internalSpawnerSet() { return m_pInternalSet; }
00114 
00115     KivioMap* map() const { return m_pMap; }
00116 
00120     bool isLoading()const { return m_bLoading; }
00121 
00122     virtual void paintContent( QPainter& painter, const QRect& rect, bool transparent = false, double zoomX = 1.0, double zoomY = 1.0 );
00123     void paintContent(KivioPainter& painter, const QRect& rect, bool transparent, KivioPage* page,
00124                       QPoint, KoZoomHandler*, bool, bool);
00125 
00126     void printContent( KPrinter& prn );
00127 
00128     static QPtrList<KivioDoc>& documents();
00129 
00130     KivioGridData grid() { return Kivio::Config::grid(); }
00131 
00132     void initConfig();
00133     void saveConfig();
00134     void updateButton();
00135     void addCommand( KCommand * cmd );
00136 
00137     int undoRedoLimit() const;
00138     void setUndoRedoLimit(int val);
00139     KoCommandHistory * commandHistory()const { return m_commandHistory; }
00140 
00141     void insertPage( KivioPage * page );
00142     void takePage( KivioPage * page );
00143     void resetLayerPanel();
00144     void updateProtectPanelCheckBox();
00145 
00146     QFont defaultFont() const { return m_font; }
00147 
00148   public slots:
00149     void updateView(KivioPage*);
00150 
00151     void slotDeleteStencilSet( DragBarButton *, QWidget *, KivioStackBar * );
00152     void slotSelectionChanged();
00153 
00154     void setDefaultFont(const QFont& f) { m_font = f; }
00155 
00156     void updateGuideLines(KoView* sender);
00157     void updateGuideLines(KivioPage* page);
00158 
00159     virtual void initEmpty();
00160 
00161   protected slots:
00162     void slotDocumentRestored();
00163     void slotCommandExecuted();
00164     void loadStencil();
00165 
00166     virtual void openExistingFile( const QString& file );
00167     virtual void openTemplate( const QString& file );
00168 
00169   signals:
00170     void sig_selectionChanged();
00171     void sig_addPage(KivioPage*);
00172     void sig_addSpawnerSet( KivioStencilSpawnerSet * );
00173     void sig_updateView(KivioPage*);
00174     void sig_pageNameChanged(KivioPage*, const QString&);
00175     void sig_deleteStencilSet( DragBarButton*, QWidget *, KivioStackBar * );
00176     void sig_updateGrid();
00177 
00178     void initProgress();
00179     void progress(int);
00180     void endProgress();
00181 
00182     void loadingFinished();
00183 
00184   protected:
00185     bool checkStencilsForSpawnerSet(KivioStencilSpawnerSet *);
00186     bool checkGroupForSpawnerSet(KivioStencil *, KivioStencilSpawnerSet *);
00187     KivioStencilSpawnerSet* findSpawnerSet(const QString& dirName, const QString& name);
00188 
00189     void saveOasisSettings( KoXmlWriter &/*settingsWriter*/ );
00190     void loadOasisSettings( const QDomDocument&settingsDoc );
00191 
00192     KoView* createViewInstance( QWidget* parent, const char* name );
00193 
00197     QPtrList <KivioStencilSpawnerSet> *m_pLstSpawnerSets;
00198 
00199 
00203     bool loadStencilSpawnerSet(const QString &id, bool hidden);
00204 
00208     virtual bool completeLoading( KoStore* );
00209 
00213     KivioMap *m_pMap;
00214 
00220     int m_iPageId;
00221 
00228     QString m_strFileURL;
00229 
00236     bool m_bLoading;
00237 
00238     static QPtrList<KivioDoc>* s_docs;
00239     static int s_docId;
00240 
00241     KivioStencilSpawnerSet* m_pInternalSet;
00242 
00243     KivioGridData gridData;
00244 
00245     DCOPObject *dcop;
00246     KoCommandHistory * m_commandHistory;
00247 
00248     QFont m_font;
00249 
00250     QTimer* m_loadTimer;
00251     unsigned int m_currentFile;
00252     KivioStencilSpawnerSet* m_currentSet;
00253     QValueList<KivioStencilSpawnerSet*> m_stencilSetLoadQueue;
00254 
00255     bool m_docOpened; // Used to for a hack that make kivio not crash if you cancel startup dialog.
00256 };
00257 
00258 #endif
00259 
KDE Home | KDE Accessibility Home | Description of Access Keys