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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
/* This file is part of the KDE project
Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __konq_viewmgr_h__
#define __konq_viewmgr_h__
#include "konq_factory.h"
#include <tqnamespace.h>
#include <tqobject.h>
#include <tqmap.h>
#include <tqguardedptr.h>
#include <ktrader.h>
#include <kparts/partmanager.h>
#include "konq_openurlrequest.h"
class TQString;
class TQStringList;
class TQTimer;
class KConfig;
class KonqMainWindow;
class KonqFrameBase;
class KonqFrameContainer;
class KonqFrameContainerBase;
class KonqFrameTabs;
class KonqView;
class BrowserView;
class KActionMenu;
namespace KParts
{
class ReadOnlyPart;
}
class KonqViewManager : public KParts::PartManager
{
Q_OBJECT
public:
KonqViewManager( KonqMainWindow *mainWindow );
~KonqViewManager();
KonqView* Initialize( const TQString &serviceType, const TQString &serviceName );
/**
* Splits the view, depending on orientation, either horizontally or
* vertically. The first of the resulting views will contain the initial
* view, the other will be a new one, constructed from the given
* Service Type.
* If no Service Type was provided it takes the one from the current view.
* Returns the newly created view or 0L if the view couldn't be created.
*
* @param newOneFirst if true, move the new view as the first one (left or top)
*/
KonqView* splitView( Qt::Orientation orientation,
const TQString & serviceType = TQString::null,
const TQString & serviceName = TQString::null,
bool newOneFirst = false, bool forceAutoEmbed = false );
/**
* Does basically the same as splitView() but inserts the new view at the top
* of the view tree.
* Returns the newly created view or 0L if the view couldn't be created.
*
* @param newOneFirst if true, move the new view as the first one (left or top)
*/
KonqView* splitWindow( Qt::Orientation orientation,
const TQString & serviceType = TQString::null,
const TQString & serviceName = TQString::null,
bool newOneFirst = false);
/**
* Converts a Container or View docContainer into a Tabs
*/
void convertDocContainer();
/**
* Adds a tab to m_pMainContainer
*/
KonqView* addTab(const TQString &serviceType = TQString::null,
const TQString &serviceName = TQString::null,
bool passiveMode = false, bool openAfterCurrentPage = false );
/**
* Duplicates the specified tab, or else the current one if none is specified
*/
void duplicateTab( KonqFrameBase* tab = 0L, bool openAfterCurrentPage = false );
/**
* creates a new tab from a history entry
* used for MMB on back/forward
*/
KonqView* addTabFromHistory( int steps, bool openAfterCurrentPage );
/**
* Break the current tab off into a new window,
* if none is specified, the current one is used
*/
void breakOffTab( KonqFrameBase* tab = 0L );
/**
* Guess!:-)
* Also takes care of setting another view as active if @p view was the active view
*/
void removeView( KonqView *view );
/**
* Removes specified tab, if none is specified it remvoe the current tab
* Also takes care of setting another view as active if the active view was in this tab
*/
void removeTab( KonqFrameBase* tab = 0L );
/**
* Removes all, but the specified tab. If no tab is specified every tab, but the current will be removed
* Also takes care of setting the specified tab as active if the active view was not in this tab
*/
void removeOtherTabs( KonqFrameBase* tab = 0L );
/**
* Locates and activates the next tab
*
*/
void activateNextTab();
/**
* Locates and activates the previous tab
*
*/
void activatePrevTab();
/**
* Activate given tab
*
*/
void activateTab(int position);
void moveTabBackward();
void moveTabForward();
void reloadAllTabs();
/**
* Brings the tab specified by @p view to the front of the stack
*
*/
void showTab( KonqView *view );
/**
* Updates favicon pixmaps used in tabs
*
*/
void updatePixmaps();
/**
* Saves the current view tqlayout to a config file.
* Remove config file before saving, especially if saveURLs is false.
* @param cfg the config file
* @param saveURLs whether to save the URLs in the profile
* @param saveWindowSize whether to save the size of the window in the profile
*/
void saveViewProfile( KConfig & cfg, bool saveURLs, bool saveWindowSize );
/**
* Saves the current view tqlayout to a config file.
* Remove config file before saving, especially if saveURLs is false.
* @param fileName the name of the config file
* @param profileName the name of the profile
* @param saveURLs whether to save the URLs in the profile
* @param saveWindowSize whether to save the size of the window in the profile
*/
void saveViewProfile( const TQString & fileName, const TQString & profileName,
bool saveURLs, bool saveWindowSize );
/**
* Loads a view tqlayout from a config file. Removes all views before loading.
* @param cfg the config file
* @param filename if set, remember the file name of the profile (for save settings)
* It has to be under the profiles dir. Otherwise, set to TQString::null
* @param forcedURL if set, the URL to open, whatever the profile says
* @param req attributes related to @p forcedURL
* @param resetWindow if the profile doesn't have attributes like size or toolbar
* settings, they will be reset to the defaults
*/
void loadViewProfile( KConfig &cfg, const TQString & filename,
const KURL & forcedURL = KURL(),
const KonqOpenURLRequest &req = KonqOpenURLRequest(),
bool resetWindow = false, bool openURL = true );
/**
* Loads a view tqlayout from a config file. Removes all views before loading.
* @param path the full path to the config file
* @param filename if set, remember the file name of the profile (for save settings)
* It has to be under the profiles dir. Otherwise, set to TQString::null
* @param forcedURL if set, the URL to open, whatever the profile says
* @param req attributes related to @p forcedURL
* @param resetWindow if the profile doesn't have attributes like size or toolbar
* settings, they will be reset to the defaults
*/
void loadViewProfile( const TQString & path, const TQString & filename,
const KURL & forcedURL = KURL(),
const KonqOpenURLRequest &req = KonqOpenURLRequest(),
bool resetWindow = false, bool openURL = true );
/**
* Return the filename of the last profile that was loaded
* by the view manager. For "save settings".
*/
TQString currentProfile() const { return m_currentProfile; }
/**
* Return the name (i18n'ed) of the last profile that was loaded
* by the view manager. For "save settings".
*/
TQString currentProfileText() const { return m_currentProfileText; }
/**
* Whether we are currently loading a profile
*/
bool isLoadingProfile() const { return m_bLoadingProfile; }
void clear();
KonqView *chooseNextView( KonqView *view );
/**
* Called whenever
* - the total number of views changed
* - the number of views in passive mode changed
* The implementation takes care of showing or hiding the statusbar indicators
*/
void viewCountChanged();
void setProfiles( KActionMenu *profiles );
void profileListDirty( bool broadcast = true );
KonqFrameBase *docContainer() const { return m_pDocContainer; }
void setDocContainer( KonqFrameBase* docContainer ) { m_pDocContainer = docContainer; }
KonqMainWindow *mainWindow() const { return m_pMainWindow; }
/**
* Reimplemented from PartManager
*/
virtual void removePart( KParts::Part * part );
/**
* Reimplemented from PartManager
*/
virtual void setActivePart( KParts::Part *part, TQWidget *widget = 0L );
void setActivePart( KParts::Part *part, bool immediate );
void showProfileDlg( const TQString & preselectProfile );
/**
* The widget is the one which you are referring to.
*/
static TQSize readConfigSize( KConfig &cfg, TQWidget *widget = NULL);
#ifndef NDEBUG
void printFullHierarchy( KonqFrameContainerBase * container );
#endif
void setLoading( KonqView *view, bool loading );
void showHTML(bool b);
TQString profileHomeURL() const { return m_profileHomeURL; }
protected slots:
void emitActivePartChanged();
void slotProfileDlg();
void slotProfileActivated( int id );
void slotProfileListAboutToShow();
void slotPassiveModePartDeleted();
void slotActivePartChanged ( KParts::Part *newPart );
protected:
/**
* Load the config entries for a view.
* @param cfg the config file
* ...
* @param defaultURL the URL to use if the profile doesn't contain urls
* @param openURL whether to open urls at all (from the profile or using @p defaultURL).
* (this is set to false when we have a forcedURL to open)
*/
void loadItem( KConfig &cfg, KonqFrameContainerBase *parent,
const TQString &name, const KURL & defaultURL, bool openURL, bool openAfterCurrentPage = false );
// Disabled - we do it ourselves
virtual void setActiveInstance( KInstance * ) {}
private:
/**
* Creates a new View based on the given ServiceType. If serviceType is empty
* it clones the current view.
* Returns the newly created view.
*/
KonqViewFactory createView( const TQString &serviceType,
const TQString &serviceName,
KService::Ptr &service,
KTrader::OfferList &partServiceOffers,
KTrader::OfferList &appServiceOffers,
bool forceAutoEmbed = false );
/**
* Mainly creates the backend structure(KonqView) for a view and
* connects it
*/
KonqView *setupView( KonqFrameContainerBase *parentContainer,
KonqViewFactory &viewFactory,
const KService::Ptr &service,
const KTrader::OfferList &partServiceOffers,
const KTrader::OfferList &appServiceOffers,
const TQString &serviceType,
bool passiveMode, bool openAfterCurrentPage = false);
#ifndef NDEBUG
//just for debugging
void printSizeInfo( KonqFrameBase* frame,
KonqFrameContainerBase* parent,
const char* msg );
#endif
KonqMainWindow *m_pMainWindow;
KonqFrameBase *m_pDocContainer;
TQGuardedPtr<KActionMenu> m_pamProfiles;
bool m_bProfileListDirty;
bool m_bLoadingProfile;
TQString m_currentProfile;
TQString m_currentProfileText;
TQString m_profileHomeURL;
TQMap<TQString, TQString> m_mapProfileNames;
TQTimer *m_activePartChangedTimer;
};
#endif
|