00001 /* -*- c++ -*- (for Emacs) 00002 * 00003 * doc.h 00004 * Digest 00005 * 00006 * Imported into Digest by Aidan Lane on Thu Jun 9 2005. 00007 * Modifications Copyright (c) 2005 Optimisation and Constraint Solving Group, 00008 * Monash University. All rights reserved. 00009 * 00010 * Nodal file: 00011 * 00012 * project.h 00013 * Nodal 00014 * 00015 * Imported into Nodal by Aidan Lane on Thu Feb 24 2005. 00016 * Modifications Copyright (c) 2005 CEMA, Monash University. All rights reserved. 00017 * 00018 * Original file: 00019 * 00020 * project.h 00021 * EverGreen 00022 * 00023 * Created by Aidan Lane on Wed Jul 14 2004. 00024 * Copyright (c) 2004 Aidan Lane. All rights reserved. 00025 * 00026 * This program is free software; you can redistribute it and/or modify 00027 * it under the terms of the GNU General Public License as published by 00028 * the Free Software Foundation; either version 2 of the License, or 00029 * (at your option) any later version. 00030 * 00031 * This program is distributed in the hope that it will be useful, 00032 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00033 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00034 * GNU General Public License for more details. 00035 * 00036 * You should have received a copy of the GNU General Public License 00037 * along with this program; if not, write to the Free Software 00038 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00039 */ 00040 00041 00042 //TODO: re-write the following doc for Digest: 00043 /* 00044 * This is the "model" in the "model-view-controller" design. 00045 * 00046 * Changes are to be performed via derivitives of ProjectEvent being posted to an instance of this. 00047 * This allows for cleaner interaction, events to be logged and most of all an undo/redo feature. 00048 * Thread-safe as long as postEvent is used. TODO: is this entirely true??? 00049 * 00050 * Currently this is both the model (aka. project or doc) AND the controller 00051 * (the controller ensures that data structures and views keep in sync and correct 00052 * to some rules). 00053 */ 00054 00055 #ifndef DOC_H 00056 #define DOC_H 00057 00058 00059 #include <QObject> 00060 #include "abstractmodel.h" 00061 #include "domaccessiblestate.h" 00062 00063 #include <QPointer> 00064 00065 #include "docevents.h" 00066 00067 00068 class DocController; 00069 00070 00078 class Doc : public QObject, 00079 public AbstractModel, 00080 public DomAccessibleState { 00081 00082 Q_OBJECT 00083 00084 public: 00085 Doc( QObject* parent ); 00086 Doc( const QString& name, QObject* parent ); 00087 00088 DocController* docController() const; 00089 00090 const QString& name() const { return m_name; } 00091 const QString& filename() const { return m_filename; } 00092 00098 bool isModified() const { return m_modified; } 00099 00100 static const QByteArray& classKey(); 00101 virtual const QByteArray& key() const { return classKey(); } 00102 00103 virtual QDomElement domElement( QDomDocument& doc ) const; 00104 virtual void initFromDomElement( const QDomElement& e, InitModeFlags modeFlags ); 00105 00106 00107 protected: 00108 inline virtual void customEvent( QEvent* e ) { 00109 MEvent* me = dynamic_cast<MEvent*>(e); // slow :-( 00110 if ( me != 0 ) dispatchEvent(me); 00111 } 00112 virtual void dispatchEvent( MEvent* ); 00113 00114 virtual void changeControllerEvent( MChangeControllerEvent* ); 00115 00116 virtual void renameEvent( MRenameEvent* ); 00117 virtual void changeFilenameEvent( MChangeFilenameEvent* ); 00118 virtual void changeModifiedStateEvent( MChangeModifiedStateEvent* ); 00119 00120 00121 private: 00122 // Persistent state (use domElement() and initFromDOMElement()): 00123 QString m_name; 00124 00125 // Temporary state: 00126 QString m_filename; 00127 bool m_modified; 00128 00129 // Temporary caches: 00130 QPointer<DocController> c_docController; 00131 }; 00132 00133 00134 #endif // ! PROJECT_H
1.5.2