1 /***************************************************************************
2 * Copyright (C) 2004 by Hideki Ikemoto , (c) 2004 by 421 *
3 * ikemo@users.sourceforge.jp *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
11 /* Basic class of Tab widget, Tab bar, and Dock widget. */
13 #include "tabwidgetbase.h"
15 #include "kita_misc.h"
16 #include "parsemisc.h"
17 #include "signalcollection.h"
18 #include "datmanager.h"
20 #include <klibloader.h>
21 #include <kpopupmenu.h>
23 #include <kstdaccel.h>
26 #include <kkeydialog.h>
27 #include <kparts/dockmainwindow.h>
28 #include <kparts/factory.h>
29 #include <kdeversion.h>
32 #include <kstandarddirs.h>
34 #include <qapplication.h>
35 #include <qmessagebox.h>
37 #include <qfontmetrics.h>
40 /*--------------------------------------------------------------*/
43 KitaTabWidgetBase::KitaTabWidgetBase( QWidget* parent, const char* name, WFlags f )
44 : QTabWidget( parent, name, f )
49 /* setup part manager */
50 m_manager = new KParts::PartManager( parent, this, "KitaPartManager" );
51 m_manager->addManagedTopLevelWidget( parent );
55 KitaTabWidgetBase::~KitaTabWidgetBase()
58 if ( m_manager && !( m_manager->parts() ->isEmpty() ) ) {
60 while ( ( part = m_manager->parts() ->getFirst() ) != NULL ) {
61 m_manager->removePart( part );
62 removePage( part->widget() );
66 if ( m_manager ) delete m_manager;
69 /* remove widgets which don't belong to parts */
70 QWidget* view = currentPage();
71 while ( count() > 0 && view ) {
79 /* public */ /* virtual */
80 void KitaTabWidgetBase::addTab( QWidget* w, const QString& label )
82 KitaTabBase * tb = new KitaTabBase( label ); /* KitaTabBase is deleted automatically. */
83 static_cast< KitaTabBarBase* >( tabBar() ) ->adjustTabWidth( tb );
84 QTabWidget::addTab( w, tb );
88 /* public */ /* virtual */
89 void KitaTabWidgetBase::addTab( QWidget* w, const QIconSet & iconset, const QString& label )
91 KitaTabBase * tb = new KitaTabBase( label ); /* KitaTabBase is deleted automatically. */
92 tb->setIconSet( iconset );
93 static_cast< KitaTabBarBase* >( tabBar() ) ->adjustTabWidth( tb );
94 QTabWidget::addTab( w, tb );
98 /* public */ /* virtual */
99 void KitaTabWidgetBase::insertTab( QWidget* w, const QString& label, int index )
101 KitaTabBase * tb = new KitaTabBase( label ); /* KitaTabBase is deleted automatically. */
102 static_cast< KitaTabBarBase* >( tabBar() ) ->adjustTabWidth( tb );
103 QTabWidget::insertTab( w, tb, index );
107 /* public */ /* virtual */
108 void KitaTabWidgetBase::removePage( QWidget* w )
110 QTabWidget::removePage( w );
111 static_cast< KitaTabBarBase* >( tabBar() ) ->adjustTabWidth( NULL );
115 /* public */ /* virtual */
116 void KitaTabWidgetBase::setTabLabel( QWidget * w, const QString & label )
118 int idx = indexOf( w );
119 KitaTabBase* ktb = static_cast < KitaTabBase* >( tabBar() ->tabAt( idx ) );
121 if ( ktb->getFullText() != label ) {
122 ktb->setFullText( label );
123 QTabWidget::setTabLabel( w, label );
124 static_cast< KitaTabBarBase* >( tabBar() ) ->adjustTabWidth( NULL );
130 void KitaTabWidgetBase::slotCurrentChanged( QWidget * w )
132 if ( m_manager == NULL ) return ;
133 if ( w == NULL ) return ;
134 w->setActiveWindow();
137 KParts::Part* part = findPartFromWidget( w );
139 m_manager->setActivePart( part );
144 /* show url with part. */ /* public slot */
145 void KitaTabWidgetBase::slotShowPart( const KURL& url, const QString& libName, const QString& mimetype )
147 if ( m_manager == NULL ) return ;
149 KLibFactory *factory = KLibLoader::self() ->factory( libName );
151 QMessageBox::critical( parentWidget(), i18n( " Load Error" ),
152 QString( i18n( "can't load %1." ) ).arg( libName ) );
156 if ( factory->inherits( "KParts::Factory" ) ) {
158 = static_cast< KParts::Factory* >( factory ) ->createPart( this );
159 m_manager->addPart( part );
160 addTab( part->widget(), url.url() );
161 showPage( part->widget() );
162 setTabToolTip( currentPage(), url.url() );
164 KParts::BrowserExtension *ext = KParts::BrowserExtension::childObject( part );
166 KParts::URLArgs arg( false, 0, 0, mimetype );
167 ext->setURLArgs( arg );
170 static_cast<KParts::ReadOnlyPart*>( part ) ->openURL( url );
175 /* close num-th tab */
176 /* see also customEvent */ /* public slot */
177 void KitaTabWidgetBase::slotCloseTab( int num )
179 CloseTabEvent * e = new CloseTabEvent( num );
180 QApplication::postEvent( this, e ); // Qt will delete it when done
184 /* Calling deleteWidget in the child part will be the
185 cause of crash. So you need to call deleteWidget
186 via custom event. */ /* protected */ /* virtual */
187 void KitaTabWidgetBase::customEvent( QCustomEvent * e )
189 if ( e->type() == EVENT_CloseTab ) {
190 deleteWidget ( page( static_cast< CloseTabEvent* >( e ) ->getIndex() ) );
195 /* protected */ /* virtual */
196 void KitaTabWidgetBase::deleteWidget( QWidget* w )
198 if ( w == NULL ) return ;
201 KParts::Part* part = findPartFromWidget( w );
202 if ( part ) m_manager->removePart( part );
208 KParts::Part* KitaTabWidgetBase::findPartFromWidget( QWidget* w )
210 if ( w == NULL ) return NULL;
211 if ( m_manager == NULL ) return NULL;
212 if ( m_manager->parts() ->isEmpty() ) return NULL;
215 QPtrListIterator<KParts::Part> it( *( m_manager->parts() ) );
216 while ( ( part = ( *it ) ) != NULL ) {
217 if ( part->widget() == w ) return part;
226 void KitaTabWidgetBase::connectSignals()
228 /* connect signals */
229 Kita::SignalCollection * signalCollection = Kita::SignalCollection::getInstance();
231 connect( this, SIGNAL( switchToBoard() ),
232 signalCollection, SIGNAL( switchToBoard() ) );
234 connect( this, SIGNAL( switchToSubject() ),
235 signalCollection, SIGNAL( switchToSubject() ) );
237 connect( this, SIGNAL( switchToThread() ),
238 signalCollection, SIGNAL( switchToThread() ) );
240 connect( this, SIGNAL( switchToKitanavi() ),
241 signalCollection, SIGNAL( switchToKitanavi() ) );
243 connect( this, SIGNAL( switchToImgview() ),
244 signalCollection, SIGNAL( switchToImgview() ) );
246 connect( this, SIGNAL( switchToWritedock() ),
247 signalCollection, SIGNAL( switchToWritedock() ) );
249 connect( this, SIGNAL( currentChanged ( QWidget * ) ),
250 SLOT( slotCurrentChanged ( QWidget * ) ) );
252 connect( this, SIGNAL( setMainStatusbar( const QString& ) ),
253 signalCollection, SIGNAL( setMainStatusbar ( const QString& ) ) );
255 connect( this, SIGNAL( setMainURLLine( const KURL& ) ),
256 signalCollection, SIGNAL( setMainURLLine( const KURL& ) ) );
258 connect( this, SIGNAL( setMainCaption( const QString& ) ),
259 signalCollection, SIGNAL( setMainCaption( const QString& ) ) );
261 connect( this, SIGNAL( openURLRequestExt(
262 const KURL&, const KParts::URLArgs&, QString, int,
264 signalCollection, SIGNAL( openURLRequestExt(
265 const KURL& , const KParts::URLArgs&, QString, int,
270 /*------------------------------------*/
271 /* common tab actions */
275 void KitaTabWidgetBase::setupActions()
277 actionCollection() ->setWidget( this );
280 QString str = i18n( "Configure S&hortcuts..." ) + "(" + QString( name() ) + ")";
284 SLOT( slotConfigureKeys() ),
288 new KAction( i18n( "Activate Next Tab" ),
289 KStdAccel::tabNext(),
291 SLOT( slotNextTab() ),
295 new KAction( i18n( "Activate Previous Tab" ),
296 KStdAccel::tabPrev(),
298 SLOT( slotPrevTab() ),
302 new KAction( i18n( "Close this tab" ),
305 SLOT( slotCloseCurrentTab() ),
309 new KAction( i18n( "Close Other Tabs" ),
312 SLOT( slotCloseOtherTab() ),
314 "tab_closeothertab" );
316 new KAction( i18n( "Close right tabs" ),
319 SLOT( slotCloseRightTab() ),
321 "tab_closerighttab" );
323 new KAction( i18n( "Close left tabs" ),
326 SLOT( slotCloseLeftTab() ),
328 "tab_closelefttab" );
330 new KAction( i18n( "Close all tabs" ),
333 SLOT( slotCloseAllTab() ),
337 new KAction( i18n( "Switch to Board" ),
340 SIGNAL( switchToBoard() ),
344 new KAction( i18n( "Switch to Subject" ),
347 SIGNAL( switchToSubject() ),
351 new KAction( i18n( "Switch to Thread" ),
354 SIGNAL( switchToThread() ),
358 new KAction( i18n( "Switch to KitaNavi" ),
361 SIGNAL( switchToKitanavi() ),
365 new KAction( i18n( "Switch to Imgviewer" ),
368 SIGNAL( switchToImgview() ),
372 new KAction( i18n( "Switch to writedock" ),
375 SIGNAL( switchToWritedock() ),
383 void KitaTabWidgetBase::slotConfigureKeys()
385 QString str = "Tab Actions (" + QString( name() ) + ")";
386 KKeyDialog dlg( TRUE, this );
387 dlg.insert( actionCollection(), str );
393 void KitaTabWidgetBase::slotPrevTab()
396 int curpage = currentPageIndex();
397 if ( max <= 1 ) return ;
399 if ( curpage == 0 ) setCurrentPage( max - 1 );
400 else setCurrentPage( curpage - 1 );
404 void KitaTabWidgetBase::slotNextTab()
407 int curpage = currentPageIndex();
408 if ( max <= 1 ) return ;
410 if ( curpage == max - 1 ) setCurrentPage( 0 );
411 else setCurrentPage( curpage + 1 );
415 /* see also customEvent */ /* public slot */
416 void KitaTabWidgetBase::slotCloseCurrentTab()
418 slotCloseTab( currentPageIndex() );
422 /* see also customEvent */ /* public slot */
423 void KitaTabWidgetBase::slotCloseOtherTab( int idx )
426 if ( max == 0 ) return ;
427 if ( idx == -1 ) idx = currentPageIndex();
431 while ( i < max && i != idx ) {
444 /* see also customEvent */ /* public slot */
445 void KitaTabWidgetBase::slotCloseRightTab( int idx )
448 if ( max == 0 ) return ;
449 if ( idx == -1 ) idx = currentPageIndex();
461 /* see also customEvent */ /* public slot */
462 void KitaTabWidgetBase::slotCloseLeftTab( int idx )
465 if ( max == 0 ) return ;
466 if ( idx == -1 ) idx = currentPageIndex();
470 while ( i < max && i != idx ) {
477 /* see also customEvent */ /* public slot */
478 void KitaTabWidgetBase::slotCloseAllTab()
481 if ( max == 0 ) return ;
495 /*--------------------------------------------------------------------------------*/
496 /*--------------------------------------------------------------------------------*/
497 /*--------------------------------------------------------------------------------*/
502 KitaTabBarBase::KitaTabBarBase( QWidget* parent, const char* name ) : QTabBar( parent, name ) {}
504 KitaTabBarBase::~KitaTabBarBase() {}
507 /* protected */ /* virtual */
508 void KitaTabBarBase::mousePressEvent( QMouseEvent *e )
510 if ( e->button() == RightButton ) {
511 QTab * tab = selectTab( e->pos() );
513 int idx = indexOf( tab->identifier() );
514 showPopupMenu( idx, mapToGlobal( e->pos() ) );
518 QTabBar::mousePressEvent( e );
523 /* private */ /* virtual */
524 void KitaTabBarBase::showPopupMenu( int idx, QPoint global )
533 KitaTabWidgetBase* tabwidget = static_cast<KitaTabWidgetBase*>( parentWidget() );
534 KActionCollection * collection = tabwidget->actionCollection();
536 KPopupMenu* popup = new KPopupMenu( this );
539 popup->insertItem( i18n( "Close this tab" ) , MENU_CLOSE );
540 collection->action( "tab_prevtab" ) ->plug( popup );
541 collection->action( "tab_nexttab" ) ->plug( popup );
542 popup->insertSeparator();
544 popup->insertItem( i18n( "Close Other Tabs" ) , MENU_CLOSEOTHER );
545 popup->insertItem( i18n( "Close right tabs" ) , MENU_CLOSERIGHT );
546 popup->insertItem( i18n( "Close left tabs" ) , MENU_CLOSELEFT );
547 collection->action( "tab_closealltab" ) ->plug( popup );
549 popup->insertSeparator();
550 collection->action( "tab_configkeys" ) ->plug( popup );
552 int ret = popup->exec( global );
556 case MENU_CLOSE: tabwidget->slotCloseTab( idx ); break;
557 case MENU_CLOSEOTHER: tabwidget->slotCloseOtherTab( idx ); break;
558 case MENU_CLOSERIGHT: tabwidget->slotCloseRightTab( idx ); break;
559 case MENU_CLOSELEFT: tabwidget->slotCloseLeftTab( idx ); break;
566 void KitaTabBarBase::adjustTabWidth( KitaTabBase* newTab )
568 if ( count() == 0 ) return ;
569 if ( tabAt( 0 ) ->text().length() == 0 ) return ; /* maybe this is image tab */
571 if ( !shrinkTab( newTab ) ) expandTab();
576 bool KitaTabBarBase::shrinkTab( KitaTabBase* newTab )
578 const int minwidth = 240;
583 bool chgWidth = FALSE;
584 int tabnum = count();
585 if ( newTab ) ++tabnum;
586 unsigned int* lng = new unsigned int[ tabnum ];
587 int* tabwd = new int[ tabnum ];
588 KitaTabBase** ktb = new KitaTabBase * [ tabnum ];
589 int parentWidth = QMAX( minwidth, parentWidget() ->width() - mrg );
590 QFontMetrics fm( parentWidget() ->font() );
591 int tabmrg = tabAt( 0 ) ->rect().width() - fm.width( tabAt( 0 ) ->text() );
593 for ( int i = 0; i < count(); ++i ) ktb[ i ] = static_cast< KitaTabBase* >( tabAt( i ) );
594 if ( newTab ) ktb[ tabnum - 1 ] = newTab;
596 /* get the current width */
597 for ( int i = 0; i < tabnum; ++i ) {
598 lng[ i ] = ktb[ i ] ->text().length();
599 if ( lng[ i ] != ktb[ i ] ->getTextLng() ) lng[ i ] -= 2; /* remove the length of ".." */
600 tabwd[ i ] = fm.width( ktb[ i ] ->text() );
601 beforewd += ( tabwd[ i ] + tabmrg );
603 if ( beforewd <= parentWidth + mrg / 2 ) return FALSE;
611 /* find the tab which has the largest width. */
614 for ( int i = 0; i < tabnum; ++i ) {
615 if ( lng[ i ] > 2 && tabwd[ i ] > maxwd ) {
620 if ( idx == -1 ) break;
623 if ( lng[ idx ] == ktb[ idx ] ->getTextLng() ) lng[ idx ] = ktb[ idx ] ->getTextLng() - 3;
625 afterwd -= tabwd[ idx ];
626 QString text = ktb[ idx ] ->getFullText().left( lng[ idx ] ) + "..";
627 tabwd[ idx ] = fm.width( text );
628 afterwd += tabwd[ idx ];
630 if ( afterwd <= parentWidth ) break;
634 if ( beforewd != afterwd && chgWidth ) {
636 for ( int i = 0; i < tabnum; ++i ) {
638 if ( lng[ i ] != ktb[ i ] ->text().length() ) {
640 QString text = ktb[ i ] ->getFullText().left( lng[ i ] ) + "..";
641 ktb[ i ] ->setText( text );
656 bool KitaTabBarBase::expandTab()
658 const int minwidth = 240;
663 bool chgWidth = FALSE;
664 int tabnum = count();
665 unsigned int* lng = new unsigned int[ tabnum ];
666 int* tabwd = new int[ tabnum ];
667 KitaTabBase** ktb = new KitaTabBase * [ tabnum ];
668 int parentWidth = QMAX( minwidth, parentWidget() ->width() - mrg );
669 QFontMetrics fm( parentWidget() ->font() );
670 int tabmrg = tabAt( 0 ) ->rect().width() - fm.width( tabAt( 0 ) ->text() );
672 for ( int i = 0; i < count(); ++i ) ktb[ i ] = static_cast< KitaTabBase* >( tabAt( i ) );
674 /* get the current width */
675 for ( int i = 0; i < tabnum; ++i ) {
676 lng[ i ] = ktb[ i ] ->text().length();
677 if ( lng[ i ] != ktb[ i ] ->getTextLng() ) lng[ i ] -= 2; /* remove the length of ".." */
678 tabwd[ i ] = fm.width( ktb[ i ] ->text() );
679 beforewd += ( tabwd[ i ] + tabmrg );
681 if ( parentWidth - mrg / 2 <= beforewd ) return FALSE;
689 /* find the tab which has the smallest width. */
692 for ( int i = 0; i < tabnum; ++i ) {
693 if ( lng[ i ] != ktb[ i ] ->getTextLng() && tabwd[ i ] < minwd ) {
698 if ( idx == -1 ) break;
701 if ( lng[ idx ] >= ktb[ idx ] ->getTextLng() - 3 ) lng[ idx ] = ktb[ idx ] ->getTextLng();
703 afterwd -= tabwd[ idx ];
704 QString text = ktb[ idx ] ->getFullText().left( lng[ idx ] );
705 if ( lng[ idx ] != ktb[ idx ] ->getTextLng() ) text += "..";
706 tabwd[ idx ] = fm.width( text );
707 afterwd += tabwd[ idx ];
709 if ( afterwd >= parentWidth ) break;
713 if ( beforewd != afterwd && chgWidth ) {
715 for ( int i = 0; i < tabnum; ++i ) {
717 if ( lng[ i ] != ktb[ i ] ->text().length() ) {
719 QString fullText = ktb[ i ] ->getFullText();
720 if ( lng[ i ] < ktb[ i ] ->getTextLng() ) ktb[ i ] ->setText( fullText.left( lng[ i ] ) + ".." );
721 else ktb[ i ] ->setText( fullText );
734 int KitaTabBarBase::getWidthOfTabs()
737 for ( int i = 0; i < count(); ++i ) {
738 QTab* tb = tabAt( i );
739 wd += tb->rect().width();
747 /*--------------------------------------------------------------------------------*/
748 /*--------------------------------------------------------------------------------*/
749 /*--------------------------------------------------------------------------------*/
752 KitaTabBase::KitaTabBase( const QString & text ) : QTab( text )
757 KitaTabBase::~KitaTabBase() {}
761 QString KitaTabBase::getFullText() const
768 const unsigned int KitaTabBase::getTextLng() const
775 void KitaTabBase::setFullText( const QString& text )
778 m_textlng = text.length();
783 /*--------------------------------------------------------------------------------*/
784 /*--------------------------------------------------------------------------------*/
785 /*--------------------------------------------------------------------------------*/
789 KitaDockWidgetBase::KitaDockWidgetBase( KDockManager* dockManager,
791 const QPixmap &pixmap,
793 const QString& strCaption,
794 const QString& strTabPageLabel,
796 : KDockWidget( dockManager, name, pixmap, parent, strCaption, strTabPageLabel, f )
798 setDockSite( KDockWidget::DockNone );
800 m_parentDock = static_cast< KParts::DockMainWindow* >( parent );
801 m_closeButtonClicked = FALSE;
803 /* connect signals */
804 connect( this, SIGNAL( headerCloseButtonClicked() ), SLOT( slotHeaderCloseButtonClicked() ) );
805 connect( this, SIGNAL( iMBeingClosed() ), SLOT( slotSaveDocStatus() ) );
807 Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
809 /* emit when this widget is deactivated */
810 connect( this, SIGNAL( windowDeactivated() ),
811 signalCollection, SIGNAL( windowDeactivated() ) );
813 /* If this widget is active and receives
814 signal isKitaActive, then emit signal kitaIsActive. */
815 /* see also KitaHTMLPart::slotOnURL */
816 connect( signalCollection, SIGNAL( isKitaActive() ),
817 this, SLOT( slotIsKitaActive() ) );
819 connect( this, SIGNAL( kitaIsActive() ),
820 signalCollection, SIGNAL( kitaIsActive() ) );
824 KitaDockWidgetBase::~KitaDockWidgetBase() {}
828 void KitaDockWidgetBase::slotShowPart( const KURL& url, const QString& libName, const QString& mimetype )
830 slotShowDock( TRUE, TRUE );
832 static_cast<KitaTabWidgetBase*> ( getWidget() ) ->slotShowPart( url, libName, mimetype );
836 /* see also KitaMainWindow::KitaMainWindow() */ /* public */
837 void KitaDockWidgetBase::loadSession()
839 QString cfgPath = locateLocal( "appdata", "session.conf" );
840 KConfig cfg( cfgPath );
841 m_tabbed = cfg.readBoolEntry( name() + QString( "_Tabbed" ), FALSE );
842 m_docked = cfg.readBoolEntry( name() + QString( "_Docked" ), FALSE );
846 /* see also KitaMainWindow::~KitaMainWindow() */ /* public */
847 void KitaDockWidgetBase::saveSession()
849 /* copied from slotSaveDocStatus */
855 if ( parentDockTabGroup() ) m_tabbed = TRUE;
859 QString cfgPath = locateLocal( "appdata", "session.conf" );
860 KConfig cfg( cfgPath );
861 cfg.writeEntry( name() + QString( "_Tabbed" ), m_tabbed );
862 cfg.writeEntry( name() + QString( "_Docked" ), m_docked );
866 /* see also KitaMainWindow::resetWindows() */ /* public */
867 void KitaDockWidgetBase::setSession( bool docked, bool tabbed )
874 /* save the current dock status. */
875 /* This slot is called before this widget is closed. */
876 /* See also slotHeaderCloseButtonClicked(), */
877 /* slotHideDock(), and closeEvent(). */ /* private slot */
878 void KitaDockWidgetBase::slotSaveDocStatus()
883 /* This widget is docked.*/
886 if ( parentDockTabGroup() ) m_tabbed = TRUE; /* This widget is in the tab group.*/
889 emit checkToggleAction( FALSE ); /* to KitaMainWindow. see also KitaMainWindow::setupView() */
893 /* This slot is called when user clicks the close button. */
894 /* m_closeButtonClicked is set to prevent from re-openning */
895 /* the dock. To reset m_closeButtonClicked, call showDock */
896 /* with force = TRUE. See also slotShowDock() and showDock() */ /* private slot */
897 void KitaDockWidgetBase::slotHeaderCloseButtonClicked()
899 m_closeButtonClicked = TRUE;
904 /* show this dock widget later. */
905 /* Usually, call this slot instead of showDock(). */
906 /* See also showDock() and customEvent(). */ /* public slot */
907 void KitaDockWidgetBase::slotShowDock( bool activate, bool force )
909 ShowDockEvent * e = new ShowDockEvent( activate, force );
910 QApplication::postEvent( this, e ); // Qt will delete it when done
914 /* show this dock widget immediately. */
915 /* If activate is TRUE, activate this dock. */
916 /* If force is TRUE, show this anyway. */
917 /* If force is FALSE and tab has no children, */
918 /* this dock is not shown. */ /* public */
919 void KitaDockWidgetBase::showDock( bool activate, bool force )
921 if ( force ) m_closeButtonClicked = FALSE; /* see also slotHeaderCloseButtonClicked() */
922 if ( m_closeButtonClicked ) return ;
924 QWidget* wd = getWidget();
925 KitaTabWidgetBase* w = NULL;
926 if ( wd && wd->inherits( "KitaTabWidgetBase" ) ) w = static_cast<KitaTabWidgetBase*> ( wd );
927 if ( !force && w && w->count() == 0 ) return ;
929 if ( !isVisible() ) {
931 if ( m_docked ) { /* This dock was docked to the other dock. */
933 /* Sometimes the dock widget loses the former brother DockWidget.
934 because the brogher widget had transformed. So, find and set new brogher widget here. */
936 /* find new brother dock widget */
937 KDockWidget * newBrsDock = dockManager() ->getDockWidgetFromName( "Thread" );
941 if ( !m_tabbed ) { /* This dock was not tabbed */
943 /* Is thread dock on the tab? */
944 QWidget * tmpwidget = newBrsDock->parentDockTabGroup();
946 tmpwidget = tmpwidget->parentWidget();
947 if ( tmpwidget->inherits( "KDockWidget" ) )
948 newBrsDock = static_cast< KDockWidget* >( tmpwidget );
952 setFormerBrotherDockWidget( newBrsDock );
958 if ( !activate ) return ;
960 if ( isMinimized() ) showNormal();
961 topLevelWidget() ->raise();
964 emit checkToggleAction( TRUE ); /* to KitaMainWindow */
966 /* activate child Part */
967 if ( w ) w->slotCurrentChanged( w->currentPage() );
969 wd->setActiveWindow();
976 void KitaDockWidgetBase::slotHideDock()
980 m_parentDock->makeDockInvisible( this );
986 void KitaDockWidgetBase::slotToggleShowHide()
988 if ( !isVisible() ) slotShowDock( TRUE, TRUE );
993 /* when this widget is deactivated, emit signal
994 to popup vie SignalCollection. */ /* protected */
995 void KitaDockWidgetBase::windowActivationChange ( bool )
997 if ( !isActiveWindow() ) emit windowDeactivated();
1002 void KitaDockWidgetBase::closeEvent( QCloseEvent* e )
1004 slotSaveDocStatus();
1005 KDockWidget::closeEvent( e );
1009 /* protected */ /* virtual */
1010 void KitaDockWidgetBase::customEvent( QCustomEvent * e )
1012 if ( e->type() == EVENT_ShowDock ) {
1013 ShowDockEvent * sde = static_cast< ShowDockEvent* >( e );
1014 showDock( sde->getActivate(), sde->getForce() );
1019 /* see also KitaHTMLPart::slotOnURL */ /* private slot */
1020 void KitaDockWidgetBase::slotIsKitaActive()
1022 if ( isActiveWindow() ) emit kitaIsActive();