document.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by David Saxton                                    *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #ifndef DOCUMENT_H
00012 #define DOCUMENT_H
00013 
00014 #include <kurl.h>
00015 #include <qguardedptr.h>
00016 
00017 class DCOPObject;
00018 class Document;
00019 class DocumentIface;
00020 class KTechlab;
00021 class View;
00022 class ViewContainer;
00023 
00024 typedef QValueList<QGuardedPtr<View> > ViewList;
00025 
00029 class Document : public QObject
00030 {
00031 Q_OBJECT
00032 public:
00033         enum DocumentType
00034         {
00035                 dt_none, // Used to denote document type not known / specified / etc, when appropriate
00036                 dt_flowcode,
00037                 dt_circuit,
00038                 dt_mechanics,
00039                 dt_text,
00040                 dt_pinMapEditor
00041         };
00042         Document( const QString &caption, KTechlab *ktechlab, const char *name = 0 );
00043         virtual ~Document();
00050         void setAddToProjectOnSave( bool add ) { m_bAddToProjectOnSave = add; }
00054         QString caption() const { return m_caption; }
00059         void setCaption( const QString &caption );
00063         DCOPObject * dcopObject() const;
00068         unsigned dcopID() const { return m_dcopID; }
00073         void setDCOPID( unsigned id );
00077         View *activeView() const { return p_activeView; }
00078         ViewList viewList() const { return m_viewList; }
00083         DocumentType type() const { return m_type; }
00087         uint numberOfViews() const { return m_viewList.size(); }
00093         virtual View *createView( ViewContainer *viewContainer, uint viewAreaId, const char *name = 0 ) = 0;
00097         const KURL& url() const { return m_url; }
00102         bool getURL( const QString &types );
00107         virtual bool openURL( const KURL &url ) = 0;
00111         void setURL( const KURL &url );
00116         virtual void setModified( bool modified );
00120         virtual bool isModified() const { return b_modified; }
00124         virtual bool isUndoAvailable() const { return false; }
00128         virtual bool isRedoAvailable() const { return false; }
00132         virtual void fileSaveAs() = 0;
00138         virtual bool fileClose();
00142         virtual void fileSave() = 0;
00146         virtual void print() {};
00150         virtual void cut() {};
00154         virtual void copy() {};
00158         virtual void paste() {};
00162         virtual void undo() {};
00166         virtual void redo() {};
00170         virtual void selectAll() {};
00171 
00172         virtual void convertToMicrobe() {};
00173         virtual void convertToHex() {};
00174         virtual void convertToPIC() {};
00175         virtual void convertToAssembly() {};
00176         virtual void debugRun() {};
00177         virtual void debugInterrupt() {};
00178         virtual void debugStop() {};
00179         virtual void debugStep() {};
00180         KTechlab *ktechlab() const { return p_ktechlab; }
00181         bool isDeleted() const { return m_bDeleted; }
00182 
00183 protected slots:
00187         virtual void slotUpdateConfiguration() {};
00188         
00189 #define protected public
00190 signals:
00196         void undoRedoStateChanged();
00197 #undef protected
00198         
00199 signals:
00204         void modifiedStateChanged();
00209         void fileNameChanged( const KURL &url );
00210         
00211         void viewFocused( View *view );
00212         void viewUnfocused();
00213         
00214 private slots:
00215         void slotViewDestroyed( QObject *obj );
00216         void slotViewFocused( View *view );
00217         
00218 protected:
00222         virtual void handleNewView( View *view );
00223         
00224         bool b_modified;
00225         KTechlab *p_ktechlab;
00226         QGuardedPtr<View> p_activeView;
00227         DocumentType m_type;
00228         ViewList m_viewList;
00229         QString m_caption;
00230         bool m_bAddToProjectOnSave;
00231         DocumentIface * m_pDocumentIface;
00232         unsigned m_dcopID;
00233         unsigned m_nextViewID;
00234         
00235         // Set to true by the document et subclasses destructors, used to avoid
00236         // doing stuff that might lead to crash when being deleted.
00237         bool m_bDeleted; 
00238         
00239 private:
00240         KURL m_url;
00241 };
00242 
00243 #endif

Generated on Tue May 8 17:05:29 2007 for KTechLab by  doxygen 1.5.1