katedocmanager.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> 00003 Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef __KATE_DOCMANAGER_H__ 00021 #define __KATE_DOCMANAGER_H__ 00022 00023 #include "katemain.h" 00024 #include "../interfaces/documentmanager.h" 00025 00026 #include <kate/document.h> 00027 00028 #include <tqdatetime.h> 00029 #include <tqguardedptr.h> 00030 #include <tqptrlist.h> 00031 #include <tqobject.h> 00032 #include <tqptrdict.h> 00033 #include <tqintdict.h> 00034 #include <tqmap.h> 00035 #include <tqpair.h> 00036 00037 namespace KParts { class Factory; } 00038 00039 class KConfig; 00040 class DCOPObject; 00041 00042 class KateDocumentInfo 00043 { 00044 public: 00045 KateDocumentInfo () 00046 : modifiedOnDisc (false), 00047 modifiedOnDiscReason (0) 00048 { 00049 } 00050 00051 bool modifiedOnDisc; 00052 unsigned char modifiedOnDiscReason; 00053 }; 00054 00055 typedef QPair<KURL,TQDateTime> TPair; 00056 00057 class KateDocManager : public TQObject 00058 { 00059 Q_OBJECT 00060 00061 public: 00062 KateDocManager (TQObject *parent); 00063 ~KateDocManager (); 00064 00065 static KateDocManager *self (); 00066 00067 Kate::DocumentManager *documentManager () { return m_documentManager; }; 00068 00069 Kate::Document *createDoc (); 00070 void deleteDoc (Kate::Document *doc); 00071 00072 Kate::Document *document (uint n); 00073 00074 Kate::Document *activeDocument (); 00075 void setActiveDocument (Kate::Document *doc); 00076 00077 Kate::Document *firstDocument (); 00078 Kate::Document *nextDocument (); 00079 00080 // search document with right documentNumber() 00081 Kate::Document *documentWithID (uint id); 00082 00083 const KateDocumentInfo *documentInfo (Kate::Document *doc); 00084 00085 int findDocument (Kate::Document *doc); 00087 int findDocument (KURL url); 00088 // Anders: The above is not currently stable ? 00089 Kate::Document *findDocumentByUrl( KURL url ); 00090 00091 bool isOpen(KURL url); 00092 00093 uint documents (); 00094 00095 TQPtrList<Kate::Document> &documentList () { return m_docList; }; 00096 00097 Kate::Document *openURL(const KURL&,const TQString &encoding=TQString::null,uint *id =0,bool isTempFile=false); 00098 00099 bool closeDocument(class Kate::Document *,bool closeURL=true); 00100 bool closeDocument(uint); 00101 bool closeDocumentWithID(uint); 00102 bool closeAllDocuments(bool closeURL=true); 00103 00104 TQPtrList<Kate::Document> modifiedDocumentList(); 00105 bool queryCloseDocuments(KateMainWindow *w); 00106 00107 void saveDocumentList (class KConfig *config); 00108 void restoreDocumentList (class KConfig *config); 00109 00110 DCOPObject *dcopObject () { return m_dcop; }; 00111 00112 inline bool getSaveMetaInfos() { return m_saveMetaInfos; }; 00113 inline void setSaveMetaInfos(bool b) { m_saveMetaInfos = b; }; 00114 00115 inline int getDaysMetaInfos() { return m_daysMetaInfos; }; 00116 inline void setDaysMetaInfos(int i) { m_daysMetaInfos = i; }; 00117 00118 public slots: 00123 void saveAll(); 00124 00125 signals: 00126 void documentCreated (Kate::Document *doc); 00127 void documentDeleted (uint documentNumber); 00128 void documentChanged (); 00129 void initialDocumentReplaced (); 00130 00131 private slots: 00132 void slotModifiedOnDisc (Kate::Document *doc, bool b, unsigned char reason); 00133 void slotModChanged(Kate::Document *doc); 00134 00135 private: 00136 bool loadMetaInfos(Kate::Document *doc, const KURL &url); 00137 void saveMetaInfos(Kate::Document *doc); 00138 bool computeUrlMD5(const KURL &url, TQCString &result); 00139 00140 Kate::DocumentManager *m_documentManager; 00141 TQPtrList<Kate::Document> m_docList; 00142 TQIntDict<Kate::Document> m_docDict; 00143 TQPtrDict<KateDocumentInfo> m_docInfos; 00144 TQMap<uint,TPair> m_tempFiles; 00145 TQGuardedPtr<Kate::Document> m_currentDoc; 00146 KConfig *m_metaInfos; 00147 bool m_saveMetaInfos; 00148 int m_daysMetaInfos; 00149 00150 DCOPObject *m_dcop; 00151 00152 KParts::Factory *m_factory; 00153 00154 }; 00155 00156 #endif 00157 // kate: space-indent on; indent-width 2; replace-tabs on;