docmanager.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 DOCMANAGER_H
00012 #define DOCMANAGER_H
00013 
00014 #include <kurl.h>
00015 #include <qguardedptr.h>
00016 
00017 class CircuitDocument;
00018 class DocManager;
00019 class DocManagerIface;
00020 class Document;
00021 class FlowCodeDocument;
00022 class KTechlab;
00023 class MechanicsDocument;
00024 class TextDocument;
00025 class View;
00026 class ViewArea;
00027 
00028 class KAction;
00029 
00030 typedef QValueList<Document*> DocumentList;
00031 typedef QMap< KURL, Document* > URLDocumentMap;
00032 typedef QValueList<KAction*> KActionList;
00033 
00037 class DocManager : public QObject
00038 {
00039 Q_OBJECT
00040 public:
00041         static DocManager * self( KTechlab * ktechlab = 0 );
00042         ~DocManager();
00043         
00047         bool closeAll();
00051         void gotoTextLine( const KURL &url, int line );
00056         Document* openURL( const KURL &url, ViewArea *viewArea = 0 );
00060         View *getFocusedView() const { return p_focusedView; }
00064         Document *getFocusedDocument() const;
00070         QString untitledName( int type );
00076         Document *findDocument( const KURL &url ) const;
00083         void associateDocument( const KURL &url, Document *document );
00088         void giveDocumentFocus( Document * toFocus, ViewArea * viewAreaForNew = 0 );
00089         void removeDocumentAssociations( Document *document );
00090         void disableContextActions();
00091         
00092 public slots:
00096         TextDocument *createTextDocument();
00101         CircuitDocument *createCircuitDocument();
00106         FlowCodeDocument *createFlowCodeDocument();
00111         MechanicsDocument *createMechanicsDocument();
00112         
00113 signals:
00117         void fileOpened( const KURL &url );
00118         
00119 protected slots:
00123         void slotViewFocused( View *view );
00127         void slotViewUnfocused();
00128         void documentDestroyed( QObject *obj );
00129         
00130 protected:
00135         void handleNewDocument( Document *document, ViewArea *viewArea = 0 );
00140         View *createNewView( Document *document, ViewArea *viewArea = 0 );
00141         CircuitDocument *openCircuitFile( const KURL &url, ViewArea *viewArea = 0 );
00142         FlowCodeDocument *openFlowCodeFile( const KURL &url, ViewArea *viewArea = 0 );
00143         MechanicsDocument *openMechanicsFile( const KURL &url, ViewArea *viewArea = 0 );
00144         TextDocument *openTextFile( const KURL &url, ViewArea *viewArea = 0 );
00145         
00146         DocumentList m_documentList;
00147         URLDocumentMap m_associatedDocuments;
00148         
00149         // Keeps track of how many 
00150         // new files have been made
00151         // for the purpose of making 
00152         // titles of the form Untitled (n)
00153         int m_countCircuit;
00154         int m_countFlowCode;
00155         int m_countMechanics;
00156         int m_countOther;
00157         
00158         KTechlab * const p_ktechlab;
00159         QGuardedPtr<View> p_focusedView;
00160         QGuardedPtr<Document> p_connectedDocument;
00161         DocManagerIface *m_pIface;
00162         unsigned m_nextDocumentID;
00163         
00164 private:
00165         DocManager( KTechlab *ktechlab );
00166         static DocManager * m_pSelf;
00167 };
00168 
00169 #endif

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