KDevelop API Documentation

partcontroller.h

Go to the documentation of this file.
00001 #ifndef __PARTCONTROLLER_H__
00002 #define __PARTCONTROLLER_H__
00003 
00004 #include "kdevpartcontroller.h"
00005 
00006 #include <qwidget.h>
00007 #include <qdatetime.h>
00008 #include <qptrlist.h>
00009 #include <kurl.h>
00010 #include <qmap.h>
00011 #include <qguardedptr.h>
00012 
00013 namespace KParts
00014 {
00015   class Part;
00016   class Factory;
00017   class PartManager;
00018   class ReadOnlyPart;
00019   class ReadWritePart;
00020 }
00021 
00022 namespace KTextEditor 
00023 { 
00024   class Document;
00025   class Editor; 
00026 }
00027 
00028 namespace Kate { class Document; }
00029 
00030 class QTabWidget;
00031 class QPopupMenu;
00032 class KAction;
00033 class KToolBarPopupAction;
00034 class KRecentFilesAction;
00035 class DocumentationPart;
00036 class HistoryEntry;
00037 class KDirWatch;
00038 
00039 class PartController : public KDevPartController
00040 {
00041   Q_OBJECT
00042 
00043 public:
00044 
00045   PartController(QWidget *toplevel);
00046   static void createInstance(QWidget *parent);
00047   static PartController *getInstance();
00048 
00050   
00051   void setEncoding(const QString &encoding);
00052   void editDocument(const KURL &inputUrl, int lineNum=-1, int col=-1);
00053   void editDocumentInternal(const KURL &inputUrl, int lineNum=-1, int col=-1, bool activate = true);
00054   void integrateTextEditorPart(KTextEditor::Document* doc);
00055   
00056   void showDocument(const KURL &url, bool newWin = false);
00057   void showPart( KParts::Part* part, const QString& name, const QString& shortDescription );
00058 
00059   KParts::ReadOnlyPart *partForURL(const KURL &url);
00060   KParts::ReadOnlyPart *qtDesignerPart();
00061   KParts::Part * partForWidget( const QWidget * widget );
00062   
00063   void activatePart( KParts::Part * part );
00064   bool closePart( KParts::Part * part );
00065 
00066   KURL::List openURLs();
00067 
00068   bool querySaveFiles();
00069   
00070   void saveAllFiles();
00071   void saveFiles( const KURL::List & list);
00072   bool saveFile( const KURL & url, bool force = false );
00073   
00074   void revertAllFiles();
00075   void revertFiles( const KURL::List & list );
00076   
00077   bool closeAllFiles();
00078   bool closeFiles( const KURL::List & list );
00079   
00080   DocumentState documentState( KURL const & );
00081   
00083   
00084   bool readyToClose();
00085 
00086   bool closeFile( const KURL & );
00087   bool closeAllOthers( const KURL & );
00088   void reloadFile( const KURL &, bool force = false );
00089 
00090 public slots:
00091 
00092   void slotActivePartChanged( KParts::Part* part );
00093   void slotCloseWindow();
00094   void slotCloseOtherWindows();
00095   void slotCloseAllWindows();
00096 
00097   void slotSave();
00098   void slotReload();
00099 
00100 protected:
00101 
00102   ~PartController();
00103 
00104 private slots:
00105   
00106   void slotWaitForFactoryHack();
00107 
00108   void slotSaveAllFiles();
00109   void slotRevertAllFiles();
00110 
00111   void slotOpenFile();
00112   void slotOpenRecent(const KURL&);
00113 
00114   void slotBack();
00115   void slotForward();
00116   void slotBackAboutToShow();
00117   void slotForwardAboutToShow();
00118   void slotPopupActivated( int id );
00119   
00120   void slotSwitchTo();
00121   
00122   void slotPartAdded( KParts::Part* );
00123   void slotPartRemoved( KParts::Part* );
00124 
00125   void slotUploadFinished();
00126 
00127   void updateMenuItems();
00128 
00129   void slotDocumentDirty( Kate::Document * doc, bool isModified, unsigned char reason );
00130   void slotNewStatus();
00131 
00132 private:
00133   KURL findURLInProject(const KURL& url);
00134   KParts::Part* findOpenDocument(const KURL& url);
00135 
00136   void setupActions();
00137 
00138   bool closeFilesDialog( KURL::List const & ignoreList );
00139   bool saveFilesDialog( KURL::List const & ignoreList );
00140   
00141   void doEmitState( KURL const & );
00142 
00143   KParts::Factory *findPartFactory(const QString &mimeType, const QString &partType, const QString &preferredName = QString::null );
00144   KTextEditor::Editor * createEditorPart(bool activate);
00145 
00146   void integratePart(KParts::Part *part, const KURL &url, QWidget* widget = 0, bool isTextEditor=false, bool activate=true );
00147 
00148   // returns a list of modified documents
00149   KURL::List modifiedDocuments();
00150   void clearModified( KURL::List const & filelist );
00151   
00152   bool isDirty( KURL const & url );
00153   bool reactToDirty( KURL const & url );
00154     
00155   KURL storedURLForPart( KParts::ReadOnlyPart * );
00156   void updatePartURL( KParts::ReadOnlyPart * );
00157   bool partURLHasChanged( KParts::ReadOnlyPart * );
00158   
00159   static PartController *s_instance;
00160 
00161   KAction *m_closeWindowAction, *m_saveAllFilesAction, *m_revertAllFilesAction;
00162   KAction *m_closeAllWindowsAction, *m_closeOtherWindowsAction, *m_switchToAction;
00163   KRecentFilesAction *m_openRecentAction;
00164   QString m_presetEncoding;
00165 
00166   KToolBarPopupAction* m_backAction;
00167   KToolBarPopupAction* m_forwardAction;
00168   
00169   bool m_openNextAsText;
00170   
00171   QValueList<KParts::ReadWritePart*> _dirtyDocuments;
00172   
00173   QMap< KParts::ReadOnlyPart*, KURL > _partURLMap;  // used to note when a URL changes (a file changes name)
00174   
00175   QGuardedPtr<KParts::Factory> _editorFactory;
00176     
00177     struct HistoryEntry 
00178     {
00179         HistoryEntry() {}
00180         HistoryEntry( const KURL & url, int line, int col );
00181         
00182         KURL url;
00183         int line;
00184         int col;
00185         int id;
00186     };
00187 
00188     void addHistoryEntry(const KURL & url, int line = -1, int col = -1 );
00189     void jumpTo( const HistoryEntry & );
00190         
00191     QValueList<HistoryEntry> m_history;
00192     QValueList<HistoryEntry>::Iterator m_Current;
00193     bool m_isJumping;
00194     QGuardedPtr<KParts::ReadOnlyPart> m_latestPart;
00195   
00196 };
00197 
00198 
00199 
00200 #endif
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:43 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003