TDE base libraries and programs
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_frame.cc 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /* This file is part of the KDE project
  2. Copyright (C) 1998, 1999 Michael Reiher <michael.reiher@gmx.de>
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (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 GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. Boston, MA 02110-1301, USA.
  15. */
  16. #include <math.h>
  17. #include <tqpainter.h>
  18. #include <tqlayout.h>
  19. #include <tqwhatsthis.h>
  20. #include <tqtoolbutton.h>
  21. #include <tqtabbar.h>
  22. #include <tqptrlist.h>
  23. #include <tqpopupmenu.h>
  24. #include <tqkeysequence.h>
  25. #include <tdeapplication.h>
  26. #include <kdebug.h>
  27. #include <tdeglobalsettings.h>
  28. #include <kiconloader.h>
  29. #include <kprogress.h>
  30. #include <tdelocale.h>
  31. #include <ksqueezedtextlabel.h>
  32. #include <networkstatusindicator.h>
  33. #include "konq_events.h"
  34. #include "konq_frame.h"
  35. #include "konq_tabs.h"
  36. #include "konq_view.h"
  37. #include "konq_viewmgr.h"
  38. #include <konq_pixmapprovider.h>
  39. #include <tdestdaccel.h>
  40. #include <assert.h>
  41. #define DEFAULT_HEADER_HEIGHT 13
  42. void KonqCheckBox::drawButton( TQPainter *p )
  43. {
  44. //static TQPixmap indicator_anchor( UserIcon( "indicator_anchor" ) );
  45. static TQPixmap indicator_connect( UserIcon( "indicator_connect" ) );
  46. static TQPixmap indicator_noconnect( UserIcon( "indicator_noconnect" ) );
  47. if (isOn() || isDown())
  48. p->drawPixmap(0,0,indicator_connect);
  49. else
  50. p->drawPixmap(0,0,indicator_noconnect);
  51. }
  52. KonqFrameStatusBar::KonqFrameStatusBar( KonqFrame *_parent, const char *_name )
  53. : KStatusBar( _parent, _name ),
  54. m_pParentKonqFrame( _parent )
  55. {
  56. setSizeGripEnabled( false );
  57. m_led = new TQLabel( this );
  58. m_led->setAlignment( Qt::AlignCenter );
  59. m_led->setSizePolicy(TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ));
  60. addWidget( m_led, 0, false ); // led (active view indicator)
  61. m_led->hide();
  62. m_pStatusLabel = new KSqueezedTextLabel( this );
  63. m_pStatusLabel->setMinimumSize( 0, 0 );
  64. m_pStatusLabel->setSizePolicy(TQSizePolicy( TQSizePolicy::Ignored, TQSizePolicy::Fixed ));
  65. m_pStatusLabel->installEventFilter(this);
  66. addWidget( m_pStatusLabel, 1 /*stretch*/, false ); // status label
  67. m_pLinkedViewCheckBox = new KonqCheckBox( this, "m_pLinkedViewCheckBox" );
  68. m_pLinkedViewCheckBox->setFocusPolicy(TQ_NoFocus);
  69. m_pLinkedViewCheckBox->setSizePolicy(TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ));
  70. TQWhatsThis::add( m_pLinkedViewCheckBox,
  71. i18n("Checking this box on at least two views sets those views as 'linked'. "
  72. "Then, when you change directories in one view, the other views "
  73. "linked with it will automatically update to show the current directory. "
  74. "This is especially useful with different types of views, such as a "
  75. "directory tree with an icon view or detailed view, and possibly a "
  76. "terminal emulator window." ) );
  77. addWidget( m_pLinkedViewCheckBox, 0, true /*permanent->right align*/ );
  78. connect( m_pLinkedViewCheckBox, TQT_SIGNAL(toggled(bool)),
  79. this, TQT_SIGNAL(linkedViewClicked(bool)) );
  80. m_progressBar = new KProgress( this );
  81. m_progressBar->setMaximumHeight(fontMetrics().height());
  82. m_progressBar->hide();
  83. addWidget( m_progressBar, 0, true /*permanent->right align*/ );
  84. // // FIXME: This was added by OpenSUSE; someone needs to figure out what it does and how to fix it!
  85. // StatusBarNetworkStatusIndicator * indicator = new StatusBarNetworkStatusIndicator( this, "networkstatusindicator" );
  86. // addWidget( indicator, 0, false );
  87. // indicator->init();
  88. fontChange(TQFont());
  89. installEventFilter( this );
  90. }
  91. KonqFrameStatusBar::~KonqFrameStatusBar()
  92. {
  93. }
  94. void KonqFrameStatusBar::fontChange(const TQFont & /* oldFont */)
  95. {
  96. int h = fontMetrics().height();
  97. if ( h < DEFAULT_HEADER_HEIGHT ) h = DEFAULT_HEADER_HEIGHT;
  98. m_led->setFixedHeight( h + 2 );
  99. m_progressBar->setFixedHeight( h + 2 );
  100. // This one is important. Otherwise richtext messages make it grow in height.
  101. m_pStatusLabel->setFixedHeight( h + 2 );
  102. }
  103. void KonqFrameStatusBar::resizeEvent( TQResizeEvent* ev )
  104. {
  105. //m_progressBar->setGeometry( width()-160, 0, 140, height() );
  106. //m_pLinkedViewCheckBox->move( width()-15, m_yOffset ); // right justify
  107. KStatusBar::resizeEvent( ev );
  108. }
  109. // I don't think this code _ever_ gets called!
  110. // I don't want to remove it, though. :-)
  111. void KonqFrameStatusBar::mousePressEvent( TQMouseEvent* event )
  112. {
  113. TQWidget::mousePressEvent( event );
  114. if ( !m_pParentKonqFrame->childView()->isPassiveMode() )
  115. {
  116. emit clicked();
  117. update();
  118. }
  119. //Blocks menu of custom status bar entries
  120. //if (event->button()==RightButton)
  121. // splitFrameMenu();
  122. }
  123. void KonqFrameStatusBar::splitFrameMenu()
  124. {
  125. KonqMainWindow * mw = m_pParentKonqFrame->childView()->mainWindow();
  126. // We have to ship the remove view action ourselves,
  127. // since this may not be the active view (passive view)
  128. TDEAction actRemoveView(i18n("Close View"), "view_remove", 0, TQT_TQOBJECT(m_pParentKonqFrame), TQT_SLOT(slotRemoveView()), (TQObject*)0, "removethisview");
  129. //KonqView * nextView = mw->viewManager()->chooseNextView( m_pParentKonqFrame->childView() );
  130. actRemoveView.setEnabled( mw->mainViewsCount() > 1 || m_pParentKonqFrame->childView()->isToggleView() || m_pParentKonqFrame->childView()->isPassiveMode() );
  131. // For the rest, we borrow them from the main window
  132. // ###### might be not right for passive views !
  133. TDEActionCollection *actionColl = mw->actionCollection();
  134. TQPopupMenu menu;
  135. actionColl->action( "splitviewh" )->plug( &menu );
  136. actionColl->action( "splitviewv" )->plug( &menu );
  137. menu.insertSeparator();
  138. actionColl->action( "lock" )->plug( &menu );
  139. actRemoveView.plug( &menu );
  140. menu.exec(TQCursor::pos());
  141. }
  142. bool KonqFrameStatusBar::eventFilter(TQObject* o, TQEvent *e)
  143. {
  144. if (TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(m_pStatusLabel) && e->type()==TQEvent::MouseButtonPress)
  145. {
  146. emit clicked();
  147. update();
  148. if ( TQT_TQMOUSEEVENT(e)->button() == Qt::RightButton)
  149. splitFrameMenu();
  150. return true;
  151. }
  152. else if ( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(this) && e->type() == TQEvent::ApplicationPaletteChange )
  153. {
  154. unsetPalette();
  155. updateActiveStatus();
  156. return true;
  157. }
  158. return false;
  159. }
  160. void KonqFrameStatusBar::message( const TQString &msg )
  161. {
  162. // We don't use the message()/clear() mechanism of TQStatusBar because
  163. // it really looks ugly (the label border goes away, the active-view indicator
  164. // is hidden...)
  165. TQString saveMsg = m_savedMessage;
  166. slotDisplayStatusText( msg );
  167. m_savedMessage = saveMsg;
  168. }
  169. void KonqFrameStatusBar::slotDisplayStatusText(const TQString& text)
  170. {
  171. //kdDebug(1202)<<"KonqFrameHeader::slotDisplayStatusText("<<text<<")"<<endl;
  172. //m_pStatusLabel->resize(fontMetrics().width(text),fontMetrics().height()+2);
  173. m_pStatusLabel->setText(text);
  174. m_savedMessage = text;
  175. }
  176. void KonqFrameStatusBar::slotClear()
  177. {
  178. slotDisplayStatusText( m_savedMessage );
  179. }
  180. void KonqFrameStatusBar::slotLoadingProgress( int percent )
  181. {
  182. if ( percent != -1 && percent != 100 ) // hide on 100 too
  183. {
  184. if ( !m_progressBar->isVisible() )
  185. m_progressBar->show();
  186. }
  187. else
  188. m_progressBar->hide();
  189. m_progressBar->setValue( percent );
  190. }
  191. void KonqFrameStatusBar::slotSpeedProgress( int bytesPerSecond )
  192. {
  193. TQString sizeStr;
  194. if ( bytesPerSecond > 0 )
  195. sizeStr = i18n( "%1/s" ).arg( TDEIO::convertSize( bytesPerSecond ) );
  196. else
  197. sizeStr = i18n( "Stalled" );
  198. slotDisplayStatusText( sizeStr ); // let's share the same label...
  199. }
  200. void KonqFrameStatusBar::slotConnectToNewView(KonqView *, KParts::ReadOnlyPart *,KParts::ReadOnlyPart *newOne)
  201. {
  202. if (newOne!=0)
  203. connect(newOne,TQT_SIGNAL(setStatusBarText(const TQString &)),this,TQT_SLOT(slotDisplayStatusText(const TQString&)));
  204. slotDisplayStatusText( TQString::null );
  205. }
  206. void KonqFrameStatusBar::showActiveViewIndicator( bool b )
  207. {
  208. m_led->setShown( b );
  209. updateActiveStatus();
  210. }
  211. void KonqFrameStatusBar::showLinkedViewIndicator( bool b )
  212. {
  213. m_pLinkedViewCheckBox->setShown( b );
  214. }
  215. void KonqFrameStatusBar::setLinkedView( bool b )
  216. {
  217. m_pLinkedViewCheckBox->blockSignals( true );
  218. m_pLinkedViewCheckBox->setChecked( b );
  219. m_pLinkedViewCheckBox->blockSignals( false );
  220. }
  221. void KonqFrameStatusBar::updateActiveStatus()
  222. {
  223. if ( !m_led->isShown() )
  224. {
  225. unsetPalette();
  226. return;
  227. }
  228. bool hasFocus = m_pParentKonqFrame->isActivePart();
  229. const TQColorGroup& activeCg = kapp->palette().active();
  230. setPaletteBackgroundColor( hasFocus ? activeCg.midlight() : activeCg.mid() );
  231. static TQPixmap indicator_viewactive( UserIcon( "indicator_viewactive" ) );
  232. static TQPixmap indicator_empty( UserIcon( "indicator_empty" ) );
  233. m_led->setPixmap( hasFocus ? indicator_viewactive : indicator_empty );
  234. }
  235. //###################################################################
  236. void KonqFrameBase::printFrameInfo(const TQString& spaces)
  237. {
  238. kdDebug(1202) << spaces << "KonqFrameBase " << this << " printFrameInfo not implemented in derived class!" << endl;
  239. }
  240. //###################################################################
  241. KonqFrame::KonqFrame( TQWidget* parent, KonqFrameContainerBase *parentContainer, const char *name )
  242. :TQWidget(parent,name)
  243. {
  244. //kdDebug(1202) << "KonqFrame::KonqFrame()" << endl;
  245. m_pLayout = 0L;
  246. m_pView = 0L;
  247. // the frame statusbar
  248. m_pStatusBar = new KonqFrameStatusBar( this, "KonquerorFrameStatusBar");
  249. m_pStatusBar->setSizePolicy(TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
  250. connect(m_pStatusBar, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotStatusBarClicked()));
  251. connect( m_pStatusBar, TQT_SIGNAL( linkedViewClicked( bool ) ), this, TQT_SLOT( slotLinkedViewClicked( bool ) ) );
  252. m_separator = 0;
  253. m_pParentContainer = parentContainer;
  254. }
  255. KonqFrame::~KonqFrame()
  256. {
  257. //kdDebug(1202) << "KonqFrame::~KonqFrame() " << this << endl;
  258. }
  259. bool KonqFrame::isActivePart()
  260. {
  261. return ( m_pView &&
  262. static_cast<KonqView*>(m_pView) == m_pView->mainWindow()->currentView() );
  263. }
  264. void KonqFrame::listViews( ChildViewList *viewList )
  265. {
  266. viewList->append( childView() );
  267. }
  268. void KonqFrame::saveConfig( TDEConfig* config, const TQString &prefix, bool saveURLs, KonqFrameBase* docContainer, int /*id*/, int /*depth*/ )
  269. {
  270. if (saveURLs)
  271. config->writePathEntry( TQString::fromLatin1( "URL" ).prepend( prefix ),
  272. childView()->url().url() );
  273. config->writeEntry( TQString::fromLatin1( "ServiceType" ).prepend( prefix ), childView()->serviceType() );
  274. config->writeEntry( TQString::fromLatin1( "ServiceName" ).prepend( prefix ), childView()->service()->desktopEntryName() );
  275. config->writeEntry( TQString::fromLatin1( "PassiveMode" ).prepend( prefix ), childView()->isPassiveMode() );
  276. config->writeEntry( TQString::fromLatin1( "LinkedView" ).prepend( prefix ), childView()->isLinkedView() );
  277. config->writeEntry( TQString::fromLatin1( "ToggleView" ).prepend( prefix ), childView()->isToggleView() );
  278. config->writeEntry( TQString::fromLatin1( "LockedLocation" ).prepend( prefix ), childView()->isLockedLocation() );
  279. //config->writeEntry( TQString::fromLatin1( "ShowStatusBar" ).prepend( prefix ), statusbar()->isVisible() );
  280. if (this == docContainer) config->writeEntry( TQString::fromLatin1( "docContainer" ).prepend( prefix ), true );
  281. KonqConfigEvent ev( config, prefix+"_", true/*save*/);
  282. TQApplication::sendEvent( childView()->part(), &ev );
  283. }
  284. void KonqFrame::copyHistory( KonqFrameBase *other )
  285. {
  286. assert( other->frameType() == "View" );
  287. childView()->copyHistory( static_cast<KonqFrame *>( other )->childView() );
  288. }
  289. void KonqFrame::printFrameInfo( const TQString& spaces )
  290. {
  291. TQString className = "NoPart";
  292. if (part()) className = part()->widget()->className();
  293. kdDebug(1202) << spaces << "KonqFrame " << this << " visible=" << TQString("%1").arg(isVisible()) << " containing view "
  294. << childView() << " visible=" << TQString("%1").arg(isVisible())
  295. << " and part " << part() << " whose widget is a " << className << endl;
  296. }
  297. KParts::ReadOnlyPart *KonqFrame::attach( const KonqViewFactory &viewFactory )
  298. {
  299. KonqViewFactory factory( viewFactory );
  300. // Note that we set the parent to 0.
  301. // We don't want that deleting the widget deletes the part automatically
  302. // because we already have that taken care of in KParts...
  303. m_pPart = factory.create( this, "view widget", 0, "" );
  304. assert( m_pPart->widget() );
  305. attachInternal();
  306. m_pStatusBar->slotConnectToNewView(0, 0,m_pPart);
  307. return m_pPart;
  308. }
  309. void KonqFrame::attachInternal()
  310. {
  311. //kdDebug(1202) << "KonqFrame::attachInternal()" << endl;
  312. delete m_pLayout;
  313. m_pLayout = new TQVBoxLayout( this, 0, -1, "KonqFrame's TQVBoxLayout" );
  314. m_pLayout->addWidget( m_pPart->widget(), 1 );
  315. m_pLayout->addWidget( m_pStatusBar, 0 );
  316. m_pPart->widget()->show();
  317. m_pLayout->activate();
  318. m_pPart->widget()->installEventFilter(this);
  319. }
  320. bool KonqFrame::eventFilter(TQObject* /*obj*/, TQEvent *ev)
  321. {
  322. if (ev->type()==TQEvent::KeyPress)
  323. {
  324. TQKeyEvent * keyEv = TQT_TQKEYEVENT(ev);
  325. if ((keyEv->key()==Key_Tab) && (keyEv->state()==ControlButton))
  326. {
  327. emit ((KonqFrameContainer*)parent())->ctrlTabPressed();
  328. return true;
  329. }
  330. }
  331. return false;
  332. }
  333. void KonqFrame::insertTopWidget( TQWidget * widget )
  334. {
  335. assert(m_pLayout);
  336. m_pLayout->insertWidget( 0, widget );
  337. if (widget!=0)
  338. widget->installEventFilter(this);
  339. }
  340. void KonqFrame::setView( KonqView* child )
  341. {
  342. m_pView = child;
  343. if (m_pView)
  344. {
  345. connect(m_pView,TQT_SIGNAL(sigPartChanged(KonqView *, KParts::ReadOnlyPart *,KParts::ReadOnlyPart *)),
  346. m_pStatusBar,TQT_SLOT(slotConnectToNewView(KonqView *, KParts::ReadOnlyPart *,KParts::ReadOnlyPart *)));
  347. }
  348. }
  349. void KonqFrame::setTitle( const TQString &title , TQWidget* /*sender*/)
  350. {
  351. //kdDebug(1202) << "KonqFrame::setTitle( " << title << " )" << endl;
  352. m_title = title;
  353. if (m_pParentContainer) m_pParentContainer->setTitle( title , this);
  354. }
  355. void KonqFrame::setTabIcon( const KURL &url, TQWidget* /*sender*/ )
  356. {
  357. //kdDebug(1202) << "KonqFrame::setTabIcon( " << url << " )" << endl;
  358. if (m_pParentContainer) m_pParentContainer->setTabIcon( url, this );
  359. }
  360. void KonqFrame::reparentFrame( TQWidget* parent, const TQPoint & p, bool showIt )
  361. {
  362. TQWidget::reparent( parent, p, showIt );
  363. }
  364. void KonqFrame::slotStatusBarClicked()
  365. {
  366. if ( !isActivePart() && m_pView && !m_pView->isPassiveMode() )
  367. m_pView->mainWindow()->viewManager()->setActivePart( part() );
  368. }
  369. void KonqFrame::slotLinkedViewClicked( bool mode )
  370. {
  371. if ( m_pView->mainWindow()->linkableViewsCount() == 2 )
  372. m_pView->mainWindow()->slotLinkView();
  373. else
  374. m_pView->setLinkedView( mode );
  375. }
  376. void
  377. KonqFrame::paintEvent( TQPaintEvent* )
  378. {
  379. #ifdef USE_QT4
  380. #warning [INFO] Repaint call disabled in Qt4 to prevent recursive repaint (which otherwise occurs for unknown reasons)
  381. #else // USE_QT4
  382. m_pStatusBar->repaint();
  383. #endif // USE_QT4
  384. }
  385. void KonqFrame::slotRemoveView()
  386. {
  387. m_pView->mainWindow()->viewManager()->removeView( m_pView );
  388. }
  389. void KonqFrame::activateChild()
  390. {
  391. if (m_pView && !m_pView->isPassiveMode() )
  392. m_pView->mainWindow()->viewManager()->setActivePart( part() );
  393. }
  394. //###################################################################
  395. void KonqFrameContainerBase::printFrameInfo(const TQString& spaces)
  396. {
  397. kdDebug(1202) << spaces << "KonqFrameContainerBase " << this << ", this shouldn't happen!" << endl;
  398. }
  399. //###################################################################
  400. KonqFrameContainer::KonqFrameContainer( Orientation o,
  401. TQWidget* parent,
  402. KonqFrameContainerBase* parentContainer,
  403. const char * name)
  404. : TQSplitter( o, parent, name ), m_bAboutToBeDeleted(false)
  405. {
  406. m_pParentContainer = parentContainer;
  407. m_pFirstChild = 0L;
  408. m_pSecondChild = 0L;
  409. m_pActiveChild = 0L;
  410. setOpaqueResize( TDEGlobalSettings::opaqueResize() );
  411. }
  412. KonqFrameContainer::~KonqFrameContainer()
  413. {
  414. //kdDebug(1202) << "KonqFrameContainer::~KonqFrameContainer() " << this << " - " << className() << endl;
  415. delete m_pFirstChild;
  416. delete m_pSecondChild;
  417. }
  418. void KonqFrameContainer::listViews( ChildViewList *viewList )
  419. {
  420. if( m_pFirstChild )
  421. m_pFirstChild->listViews( viewList );
  422. if( m_pSecondChild )
  423. m_pSecondChild->listViews( viewList );
  424. }
  425. void KonqFrameContainer::saveConfig( TDEConfig* config, const TQString &prefix, bool saveURLs, KonqFrameBase* docContainer, int id, int depth )
  426. {
  427. int idSecond = id + (int)pow( 2.0, depth );
  428. //write children sizes
  429. config->writeEntry( TQString::fromLatin1( "SplitterSizes" ).prepend( prefix ), sizes() );
  430. //write children
  431. TQStringList strlst;
  432. if( firstChild() )
  433. strlst.append( TQString::fromLatin1( firstChild()->frameType() ) + TQString::number(idSecond - 1) );
  434. if( secondChild() )
  435. strlst.append( TQString::fromLatin1( secondChild()->frameType() ) + TQString::number( idSecond ) );
  436. config->writeEntry( TQString::fromLatin1( "Children" ).prepend( prefix ), strlst );
  437. //write orientation
  438. TQString o;
  439. if( orientation() == Qt::Horizontal )
  440. o = TQString::fromLatin1("Horizontal");
  441. else if( orientation() == Qt::Vertical )
  442. o = TQString::fromLatin1("Vertical");
  443. config->writeEntry( TQString::fromLatin1( "Orientation" ).prepend( prefix ), o );
  444. //write docContainer
  445. if (this == docContainer) config->writeEntry( TQString::fromLatin1( "docContainer" ).prepend( prefix ), true );
  446. if (m_pSecondChild == m_pActiveChild) config->writeEntry( TQString::fromLatin1( "activeChildIndex" ).prepend( prefix ), 1 );
  447. else config->writeEntry( TQString::fromLatin1( "activeChildIndex" ).prepend( prefix ), 0 );
  448. //write child configs
  449. if( firstChild() ) {
  450. TQString newPrefix = TQString::fromLatin1( firstChild()->frameType() ) + TQString::number(idSecond - 1);
  451. newPrefix.append( '_' );
  452. firstChild()->saveConfig( config, newPrefix, saveURLs, docContainer, id, depth + 1 );
  453. }
  454. if( secondChild() ) {
  455. TQString newPrefix = TQString::fromLatin1( secondChild()->frameType() ) + TQString::number( idSecond );
  456. newPrefix.append( '_' );
  457. secondChild()->saveConfig( config, newPrefix, saveURLs, docContainer, idSecond, depth + 1 );
  458. }
  459. }
  460. void KonqFrameContainer::copyHistory( KonqFrameBase *other )
  461. {
  462. assert( other->frameType() == "Container" );
  463. if ( firstChild() )
  464. firstChild()->copyHistory( static_cast<KonqFrameContainer *>( other )->firstChild() );
  465. if ( secondChild() )
  466. secondChild()->copyHistory( static_cast<KonqFrameContainer *>( other )->secondChild() );
  467. }
  468. KonqFrameBase* KonqFrameContainer::otherChild( KonqFrameBase* child )
  469. {
  470. if( firstChild() == child )
  471. return secondChild();
  472. else if( secondChild() == child )
  473. return firstChild();
  474. return 0L;
  475. }
  476. void KonqFrameContainer::printFrameInfo( const TQString& spaces )
  477. {
  478. kdDebug(1202) << spaces << "KonqFrameContainer " << this << " visible=" << TQString("%1").arg(isVisible())
  479. << " activeChild=" << m_pActiveChild << endl;
  480. if (!m_pActiveChild)
  481. kdDebug(1202) << "WARNING: " << this << " has a null active child!" << endl;
  482. KonqFrameBase* child = firstChild();
  483. if (child != 0L)
  484. child->printFrameInfo(spaces + " ");
  485. else
  486. kdDebug(1202) << spaces << " Null child" << endl;
  487. child = secondChild();
  488. if (child != 0L)
  489. child->printFrameInfo(spaces + " ");
  490. else
  491. kdDebug(1202) << spaces << " Null child" << endl;
  492. }
  493. void KonqFrameContainer::reparentFrame( TQWidget* parent, const TQPoint & p, bool showIt )
  494. {
  495. TQWidget::reparent( parent, p, showIt );
  496. }
  497. void KonqFrameContainer::swapChildren()
  498. {
  499. KonqFrameBase *firstCh = m_pFirstChild;
  500. m_pFirstChild = m_pSecondChild;
  501. m_pSecondChild = firstCh;
  502. }
  503. void KonqFrameContainer::setTitle( const TQString &title , TQWidget* sender)
  504. {
  505. //kdDebug(1202) << "KonqFrameContainer::setTitle( " << title << " , " << sender << " )" << endl;
  506. if (m_pParentContainer && activeChild() && (sender == activeChild()->widget()))
  507. m_pParentContainer->setTitle( title , this);
  508. }
  509. void KonqFrameContainer::setTabIcon( const KURL &url, TQWidget* sender )
  510. {
  511. //kdDebug(1202) << "KonqFrameContainer::setTabIcon( " << url << " , " << sender << " )" << endl;
  512. if (m_pParentContainer && activeChild() && (sender == activeChild()->widget()))
  513. m_pParentContainer->setTabIcon( url, this );
  514. }
  515. void KonqFrameContainer::insertChildFrame( KonqFrameBase* frame, int /*index*/ )
  516. {
  517. //kdDebug(1202) << "KonqFrameContainer " << this << ": insertChildFrame " << frame << endl;
  518. if (frame)
  519. {
  520. if( !m_pFirstChild )
  521. {
  522. m_pFirstChild = frame;
  523. frame->setParentContainer(this);
  524. //kdDebug(1202) << "Setting as first child" << endl;
  525. }
  526. else if( !m_pSecondChild )
  527. {
  528. m_pSecondChild = frame;
  529. frame->setParentContainer(this);
  530. //kdDebug(1202) << "Setting as second child" << endl;
  531. }
  532. else
  533. kdWarning(1202) << this << " already has two children..."
  534. << m_pFirstChild << " and " << m_pSecondChild << endl;
  535. } else
  536. kdWarning(1202) << "KonqFrameContainer " << this << ": insertChildFrame(0L) !" << endl;
  537. }
  538. void KonqFrameContainer::removeChildFrame( KonqFrameBase * frame )
  539. {
  540. //kdDebug(1202) << "KonqFrameContainer::RemoveChildFrame " << this << ". Child " << frame << " removed" << endl;
  541. if( m_pFirstChild == frame )
  542. {
  543. m_pFirstChild = m_pSecondChild;
  544. m_pSecondChild = 0L;
  545. }
  546. else if( m_pSecondChild == frame )
  547. m_pSecondChild = 0L;
  548. else
  549. kdWarning(1202) << this << " Can't find this child:" << frame << endl;
  550. }
  551. void KonqFrameContainer::childEvent( TQChildEvent *c )
  552. {
  553. // Child events cause layout changes. These are unnecassery if we are going
  554. // to be deleted anyway.
  555. if (!m_bAboutToBeDeleted)
  556. TQSplitter::childEvent(c);
  557. }
  558. void KonqFrameContainer::setRubberband( int pos )
  559. {
  560. emit setRubberbandCalled();
  561. TQSplitter::setRubberband( pos );
  562. }
  563. #include "konq_frame.moc"