1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
#ifndef __PARTCONTROLLER_H__
#define __PARTCONTROLLER_H__
#include "tdevpartcontroller.h"
#include <tqwidget.h>
#include <tqdatetime.h>
#include <tqptrlist.h>
#include <kurl.h>
#include <tqmap.h>
#include <tqguardedptr.h>
#include <tqpair.h>
namespace KParts
{
class Part;
class Factory;
class PartManager;
class ReadOnlyPart;
class ReadWritePart;
}
namespace KTextEditor
{
class Document;
class Editor;
}
namespace Kate { class Document; }
class TQTabWidget;
class TQPopupMenu;
class TDEAction;
class TDEToolBarPopupAction;
class TDERecentFilesAction;
class HTMLDocumentationPart;
class HistoryEntry;
class KDirWatch;
/**
Part controler implementation.
*/
class PartController : public TDevPartController
{
Q_OBJECT
public:
PartController(TQWidget *toplevel);
static void createInstance(TQWidget *parent);
static PartController *getInstance();
///// TDevPartController interface
void setEncoding(const TQString &encoding);
void editDocument(const KURL &inputUrl, int lineNum=-1, int col=-1);
void splitCurrentDocument(const KURL &inputUrl, int lineNum=-1, int col=-1);
void scrollToLineColumn(const KURL &url, int lineNum=-1, int col=-1, bool storeHistory = false );
void editDocumentInternal(const KURL &inputUrl, int lineNum=-1, int col=-1,
bool activate = true, bool addToCurrentBuffer = false );
void integrateTextEditorPart(KTextEditor::Document* doc);
void showDocument(const KURL &url, bool newWin = false);
void showPart( KParts::Part* part, const TQString& name, const TQString& shortDescription );
KParts::ReadOnlyPart *partForURL(const KURL &url);
KParts::ReadOnlyPart *qtDesignerPart();
KParts::Part * partForWidget( const TQWidget * widget );
void activatePart( KParts::Part * part );
bool closePart( KParts::Part * part );
KURL::List openURLs();
bool querySaveFiles();
bool saveAllFiles();
bool saveFiles( const KURL::List & list);
bool saveFile( const KURL & url, bool force = false );
void revertAllFiles();
void revertFiles( const KURL::List & list );
bool closeAllFiles();
bool closeFiles( const KURL::List & list );
DocumentState documentState( KURL const & );
////////////////////////////////////////
bool readyToClose();
bool closeFile( const KURL & );
bool closeAllOthers( const KURL & );
void reloadFile( const KURL & url );
KTextEditor::Editor *openTextDocument( bool activate = true );
KParts::Factory *findPartFactory(const TQString &mimeType,
const TQString &partType,
const TQString &preferredName = TQString() );
public slots:
void slotActivePartChanged( KParts::Part* part );
void slotCloseWindow();
void slotCloseOtherWindows();
void slotCloseAllWindows();
void slotSave();
void slotReload();
protected:
~PartController();
private slots:
void slotWaitForFactoryHack();
void slotDocumentUrlChanged();
void slotSaveAllFiles();
void slotRevertAllFiles();
void slotOpenFile();
void slotOpenRecent(const KURL&);
void slotBack();
void slotForward();
void slotBackAboutToShow();
void slotForwardAboutToShow();
void slotBackPopupActivated( int id );
void slotForwardPopupActivated( int id );
void slotPartAdded( KParts::Part* );
void slotPartRemoved( KParts::Part* );
void slotUploadFinished();
void updateMenuItems();
void slotDocumentDirty( Kate::Document * doc, bool isModified, unsigned char reason );
void slotDocumentDirtyStepTwo( void * );
void slotNewStatus();
void slotNewDesignerStatus(const TQString &formName, int status);
void textChanged();
void gotoLastEditPos();
private:
KURL findURLInProject(const KURL& url);
KParts::Part* findOpenDocument(const KURL& url);
void setupActions();
bool closeFilesDialog( KURL::List const & ignoreList );
bool saveFilesDialog( KURL::List const & ignoreList );
void doEmitState( KURL const & );
KTextEditor::Editor * createEditorPart( bool activate,
bool addToCurrentBuffer = false,
const KURL &url = KURL() );
void integratePart(KParts::Part *part, const KURL &url, TQWidget* widget = 0,
bool isTextEditor=false, bool activate=true,
bool addToCurrentBuffer = false );
// returns a list of modified documents
KURL::List modifiedDocuments();
void clearModified( KURL::List const & filelist );
bool isDirty( KURL const & url );
bool reactToDirty( KURL const & url, unsigned char reason );
KURL storedURLForPart( KParts::ReadOnlyPart * );
void updatePartURL( KParts::ReadOnlyPart * );
bool partURLHasChanged( KParts::ReadOnlyPart * );
static PartController *s_instance;
TDEAction *m_closeWindowAction, *m_saveAllFilesAction, *m_revertAllFilesAction;
TDEAction *m_closeAllWindowsAction, *m_closeOtherWindowsAction;
TDERecentFilesAction *m_openRecentAction;
TQString m_presetEncoding;
TDEToolBarPopupAction* m_backAction;
TDEToolBarPopupAction* m_forwardAction;
TDEAction * m_gotoLastEditPosAction;
bool m_openNextAsText;
TQValueList<KParts::ReadWritePart*> _dirtyDocuments;
TQMap< KParts::ReadOnlyPart*, KURL > _partURLMap; // used to note when a URL changes (a file changes name)
TQGuardedPtr<KParts::Factory> _editorFactory;
struct HistoryEntry
{
HistoryEntry() {}
HistoryEntry( const KURL & url, int line, int col );
KURL url;
int line;
int col;
int id;
};
void addHistoryEntry( KParts::ReadOnlyPart * part = 0 );
HistoryEntry createHistoryEntry( KParts::ReadOnlyPart * part = 0 );
void jumpTo( const HistoryEntry & );
TQValueList<HistoryEntry> m_backHistory;
TQValueList<HistoryEntry> m_forwardHistory;
bool m_isJumping;
struct LastEditPos
{
KURL url;
TQPair<unsigned int,unsigned int> pos;
LastEditPos() : pos( -1, -1) {}
};
LastEditPos m_lastEditPos;
KParts::Part * m_currentActivePart;
bool m_removingActivePart;
};
#endif
|