tdebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

konq_viewmgr.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /* This file is part of the KDE project
  2. Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. */
  15. #ifndef __konq_viewmgr_h__
  16. #define __konq_viewmgr_h__
  17. #include "konq_factory.h"
  18. #include <tqnamespace.h>
  19. #include <tqobject.h>
  20. #include <tqmap.h>
  21. #include <tqguardedptr.h>
  22. #include <ktrader.h>
  23. #include <tdeparts/partmanager.h>
  24. #include "konq_openurlrequest.h"
  25. class TQString;
  26. class TQStringList;
  27. class TQTimer;
  28. class TDEConfig;
  29. class KonqMainWindow;
  30. class KonqFrameBase;
  31. class KonqFrameContainer;
  32. class KonqFrameContainerBase;
  33. class KonqFrameTabs;
  34. class KonqView;
  35. class BrowserView;
  36. class TDEActionMenu;
  37. namespace KParts
  38. {
  39. class ReadOnlyPart;
  40. }
  41. class KonqViewManager : public KParts::PartManager
  42. {
  43. Q_OBJECT
  44. public:
  45. KonqViewManager( KonqMainWindow *mainWindow );
  46. ~KonqViewManager();
  47. KonqView* Initialize( const TQString &serviceType, const TQString &serviceName );
  48. /**
  49. * Splits the view, depending on orientation, either horizontally or
  50. * vertically. The first of the resulting views will contain the initial
  51. * view, the other will be a new one, constructed from the given
  52. * Service Type.
  53. * If no Service Type was provided it takes the one from the current view.
  54. * Returns the newly created view or 0L if the view couldn't be created.
  55. *
  56. * @param newOneFirst if true, move the new view as the first one (left or top)
  57. */
  58. KonqView* splitView( Qt::Orientation orientation,
  59. const TQString & serviceType = TQString::null,
  60. const TQString & serviceName = TQString::null,
  61. bool newOneFirst = false, bool forceAutoEmbed = false );
  62. /**
  63. * Does basically the same as splitView() but inserts the new view at the top
  64. * of the view tree.
  65. * Returns the newly created view or 0L if the view couldn't be created.
  66. *
  67. * @param newOneFirst if true, move the new view as the first one (left or top)
  68. */
  69. KonqView* splitWindow( Qt::Orientation orientation,
  70. const TQString & serviceType = TQString::null,
  71. const TQString & serviceName = TQString::null,
  72. bool newOneFirst = false);
  73. /**
  74. * Converts a Container or View docContainer into a Tabs
  75. */
  76. void convertDocContainer();
  77. /**
  78. * Adds a tab to m_pMainContainer
  79. */
  80. KonqView* addTab(const TQString &serviceType = TQString::null,
  81. const TQString &serviceName = TQString::null,
  82. bool passiveMode = false, bool openAfterCurrentPage = false );
  83. /**
  84. * Duplicates the specified tab, or else the current one if none is specified
  85. */
  86. void duplicateTab( KonqFrameBase* tab = 0L, bool openAfterCurrentPage = false );
  87. /**
  88. * creates a new tab from a history entry
  89. * used for MMB on back/forward
  90. */
  91. KonqView* addTabFromHistory( int steps, bool openAfterCurrentPage );
  92. /**
  93. * Break the current tab off into a new window,
  94. * if none is specified, the current one is used
  95. */
  96. void breakOffTab( KonqFrameBase* tab = 0L );
  97. /**
  98. * Guess!:-)
  99. * Also takes care of setting another view as active if @p view was the active view
  100. */
  101. void removeView( KonqView *view );
  102. /**
  103. * Removes specified tab, if none is specified it remvoe the current tab
  104. * Also takes care of setting another view as active if the active view was in this tab
  105. */
  106. void removeTab( KonqFrameBase* tab = 0L );
  107. /**
  108. * Removes all, but the specified tab. If no tab is specified every tab, but the current will be removed
  109. * Also takes care of setting the specified tab as active if the active view was not in this tab
  110. */
  111. void removeOtherTabs( KonqFrameBase* tab = 0L );
  112. /**
  113. * Locates and activates the next tab
  114. *
  115. */
  116. void activateNextTab();
  117. /**
  118. * Locates and activates the previous tab
  119. *
  120. */
  121. void activatePrevTab();
  122. /**
  123. * Activate given tab
  124. *
  125. */
  126. void activateTab(int position);
  127. void moveTabBackward();
  128. void moveTabForward();
  129. void reloadAllTabs();
  130. /**
  131. * Brings the tab specified by @p view to the front of the stack
  132. *
  133. */
  134. void showTab( KonqView *view );
  135. /**
  136. * Updates favicon pixmaps used in tabs
  137. *
  138. */
  139. void updatePixmaps();
  140. /**
  141. * Saves the current view layout to a config file.
  142. * Remove config file before saving, especially if saveURLs is false.
  143. * @param cfg the config file
  144. * @param saveURLs whether to save the URLs in the profile
  145. * @param saveWindowSize whether to save the size of the window in the profile
  146. */
  147. void saveViewProfile( TDEConfig & cfg, bool saveURLs, bool saveWindowSize );
  148. /**
  149. * Saves the current view layout to a config file.
  150. * Remove config file before saving, especially if saveURLs is false.
  151. * @param fileName the name of the config file
  152. * @param profileName the name of the profile
  153. * @param saveURLs whether to save the URLs in the profile
  154. * @param saveWindowSize whether to save the size of the window in the profile
  155. */
  156. void saveViewProfile( const TQString & fileName, const TQString & profileName,
  157. bool saveURLs, bool saveWindowSize );
  158. /**
  159. * Loads a view layout from a config file. Removes all views before loading.
  160. * @param cfg the config file
  161. * @param filename if set, remember the file name of the profile (for save settings)
  162. * It has to be under the profiles dir. Otherwise, set to TQString::null
  163. * @param forcedURL if set, the URL to open, whatever the profile says
  164. * @param req attributes related to @p forcedURL
  165. * @param resetWindow if the profile doesn't have attributes like size or toolbar
  166. * settings, they will be reset to the defaults
  167. */
  168. void loadViewProfile( TDEConfig &cfg, const TQString & filename,
  169. const KURL & forcedURL = KURL(),
  170. const KonqOpenURLRequest &req = KonqOpenURLRequest(),
  171. bool resetWindow = false, bool openURL = true );
  172. /**
  173. * Loads a view layout from a config file. Removes all views before loading.
  174. * @param path the full path to the config file
  175. * @param filename if set, remember the file name of the profile (for save settings)
  176. * It has to be under the profiles dir. Otherwise, set to TQString::null
  177. * @param forcedURL if set, the URL to open, whatever the profile says
  178. * @param req attributes related to @p forcedURL
  179. * @param resetWindow if the profile doesn't have attributes like size or toolbar
  180. * settings, they will be reset to the defaults
  181. */
  182. void loadViewProfile( const TQString & path, const TQString & filename,
  183. const KURL & forcedURL = KURL(),
  184. const KonqOpenURLRequest &req = KonqOpenURLRequest(),
  185. bool resetWindow = false, bool openURL = true );
  186. /**
  187. * Return the filename of the last profile that was loaded
  188. * by the view manager. For "save settings".
  189. */
  190. TQString currentProfile() const { return m_currentProfile; }
  191. /**
  192. * Return the name (i18n'ed) of the last profile that was loaded
  193. * by the view manager. For "save settings".
  194. */
  195. TQString currentProfileText() const { return m_currentProfileText; }
  196. /**
  197. * Whether we are currently loading a profile
  198. */
  199. bool isLoadingProfile() const { return m_bLoadingProfile; }
  200. void clear();
  201. KonqView *chooseNextView( KonqView *view );
  202. /**
  203. * Called whenever
  204. * - the total number of views changed
  205. * - the number of views in passive mode changed
  206. * The implementation takes care of showing or hiding the statusbar indicators
  207. */
  208. void viewCountChanged();
  209. void setProfiles( TDEActionMenu *profiles );
  210. void profileListDirty( bool broadcast = true );
  211. KonqFrameBase *docContainer() const { return m_pDocContainer; }
  212. void setDocContainer( KonqFrameBase* docContainer ) { m_pDocContainer = docContainer; }
  213. KonqMainWindow *mainWindow() const { return m_pMainWindow; }
  214. /**
  215. * Reimplemented from PartManager
  216. */
  217. virtual void removePart( KParts::Part * part );
  218. /**
  219. * Reimplemented from PartManager
  220. */
  221. virtual void setActivePart( KParts::Part *part, TQWidget *widget = 0L );
  222. void setActivePart( KParts::Part *part, bool immediate );
  223. void showProfileDlg( const TQString & preselectProfile );
  224. /**
  225. * The widget is the one which you are referring to.
  226. */
  227. static TQSize readConfigSize( TDEConfig &cfg, TQWidget *widget = NULL);
  228. #ifndef NDEBUG
  229. void printFullHierarchy( KonqFrameContainerBase * container );
  230. #endif
  231. void setLoading( KonqView *view, bool loading );
  232. void showHTML(bool b);
  233. TQString profileHomeURL() const { return m_profileHomeURL; }
  234. //Update options
  235. void reparseConfiguration();
  236. protected slots:
  237. void emitActivePartChanged();
  238. void slotProfileDlg();
  239. void slotProfileActivated( int id );
  240. void slotProfileListAboutToShow();
  241. void slotPassiveModePartDeleted();
  242. void slotActivePartChanged ( KParts::Part *newPart );
  243. protected:
  244. /**
  245. * Load the config entries for a view.
  246. * @param cfg the config file
  247. * ...
  248. * @param defaultURL the URL to use if the profile doesn't contain urls
  249. * @param openURL whether to open urls at all (from the profile or using @p defaultURL).
  250. * (this is set to false when we have a forcedURL to open)
  251. */
  252. void loadItem( TDEConfig &cfg, KonqFrameContainerBase *parent,
  253. const TQString &name, const KURL & defaultURL, bool openURL, bool openAfterCurrentPage = false );
  254. // Disabled - we do it ourselves
  255. virtual void setActiveInstance( TDEInstance * ) {}
  256. private:
  257. /**
  258. * Creates a new View based on the given ServiceType. If serviceType is empty
  259. * it clones the current view.
  260. * Returns the newly created view.
  261. */
  262. KonqViewFactory createView( const TQString &serviceType,
  263. const TQString &serviceName,
  264. KService::Ptr &service,
  265. TDETrader::OfferList &partServiceOffers,
  266. TDETrader::OfferList &appServiceOffers,
  267. bool forceAutoEmbed = false );
  268. /**
  269. * Mainly creates the backend structure(KonqView) for a view and
  270. * connects it
  271. */
  272. KonqView *setupView( KonqFrameContainerBase *parentContainer,
  273. KonqViewFactory &viewFactory,
  274. const KService::Ptr &service,
  275. const TDETrader::OfferList &partServiceOffers,
  276. const TDETrader::OfferList &appServiceOffers,
  277. const TQString &serviceType,
  278. bool passiveMode, bool openAfterCurrentPage = false);
  279. #ifndef NDEBUG
  280. //just for debugging
  281. void printSizeInfo( KonqFrameBase* frame,
  282. KonqFrameContainerBase* parent,
  283. const char* msg );
  284. #endif
  285. KonqMainWindow *m_pMainWindow;
  286. KonqFrameBase *m_pDocContainer;
  287. TQGuardedPtr<TDEActionMenu> m_pamProfiles;
  288. bool m_bProfileListDirty;
  289. bool m_bLoadingProfile;
  290. TQString m_currentProfile;
  291. TQString m_currentProfileText;
  292. TQString m_profileHomeURL;
  293. TQMap<TQString, TQString> m_mapProfileNames;
  294. TQTimer *m_activePartChangedTimer;
  295. };
  296. #endif