kmdi Library: kmdidocumentviewtabwidget.cpp Source File (kmdi Library)

| # kmdi Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kmdidocumentviewtabwidget.cpp

    00001 //----------------------------------------------------------------------------
    00002 //
    00003 //    This program is free software; you can redistribute it and/or modify
    00004 //    it under the terms of the GNU Library General Public License as
    00005 //    published by the Free Software Foundation; either version 2 of the
    00006 //    License, or (at your option) any later version.
    00007 //
    00008 //----------------------------------------------------------------------------
    00009
    00010 #include <ktabbar.h>
    00011 #include <kpopupmenu.h>
    00012 #include "kmdidocumentviewtabwidget.h"
    00013
    00014 KMdiDocumentViewTabWidget::KMdiDocumentViewTabWidget( QWidget* parent, const char* name ) : KTabWidget( parent, name )
    00015 {
    00016     m_visibility = KMdi::ShowWhenMoreThanOneTab;
    00017     tabBar() ->hide();
    00018 #ifndef Q_WS_WIN //todo
    00019
    00020     setHoverCloseButton( true );
    00021 #endif
    00022
    00023     connect( this, SIGNAL( closeRequest( QWidget* ) ), this, SLOT( closeTab( QWidget* ) ) );
    00024 }
    00025
    00026 KMdiDocumentViewTabWidget::~KMdiDocumentViewTabWidget()
    00027 {}
    00028
    00029 void KMdiDocumentViewTabWidget::closeTab( QWidget* w )
    00030 {
    00031     w->close();
    00032 }
    00033 void KMdiDocumentViewTabWidget::addTab ( QWidget * child, const QString & label )
    00034 {
    00035     KTabWidget::addTab( child, label );
    00036     showPage( child );
    00037     maybeShow();
    00038 }
    00039
    00040 void KMdiDocumentViewTabWidget::addTab ( QWidget * child, const QIconSet & iconset, const QString & label )
    00041 {
    00042     KTabWidget::addTab( child, iconset, label );
    00043     showPage( child );
    00044     maybeShow();
    00045 }
    00046
    00047 void KMdiDocumentViewTabWidget::addTab ( QWidget * child, QTab * tab )
    00048 {
    00049     KTabWidget::addTab( child, tab );
    00050     showPage( child );
    00051     maybeShow();
    00052 }
    00053
    00054 void KMdiDocumentViewTabWidget::insertTab ( QWidget * child, const QString & label, int index )
    00055 {
    00056     KTabWidget::insertTab( child, label, index );
    00057     showPage( child );
    00058     maybeShow();
    00059     tabBar() ->repaint();
    00060 }
    00061
    00062 void KMdiDocumentViewTabWidget::insertTab ( QWidget * child, const QIconSet & iconset, const QString & label, int index )
    00063 {
    00064     KTabWidget::insertTab( child, iconset, label, index );
    00065     showPage( child );
    00066     maybeShow();
    00067     tabBar() ->repaint();
    00068 }
    00069
    00070 void KMdiDocumentViewTabWidget::insertTab ( QWidget * child, QTab * tab, int index )
    00071 {
    00072     KTabWidget::insertTab( child, tab, index );
    00073     showPage( child );
    00074     maybeShow();
    00075     tabBar() ->repaint();
    00076 }
    00077
    00078 void KMdiDocumentViewTabWidget::removePage ( QWidget * w )
    00079 {
    00080     KTabWidget::removePage( w );
    00081     maybeShow();
    00082 }
    00083
    00084 void KMdiDocumentViewTabWidget::updateIconInView( QWidget *w, QPixmap icon )
    00085 {
    00086     changeTab( w, icon, tabLabel( w ) );
    00087 }
    00088
    00089 void KMdiDocumentViewTabWidget::updateCaptionInView( QWidget *w, const QString &caption )
    00090 {
    00091     changeTab( w, caption );
    00092 }
    00093
    00094 void KMdiDocumentViewTabWidget::maybeShow()
    00095 {
    00096     if ( m_visibility == KMdi::AlwaysShowTabs )
    00097     {
    00098         tabBar() ->show();
    00099         if ( cornerWidget() )
    00100         {
    00101             if ( count() == 0 )
    00102                 cornerWidget() ->hide();
    00103             else
    00104                 cornerWidget() ->show();
    00105         }
    00106     }
    00107
    00108     if ( m_visibility == KMdi::ShowWhenMoreThanOneTab )
    00109     {
    00110         if ( count() < 2 )
    00111             tabBar() ->hide();
    00112         if ( count() > 1 )
    00113             tabBar() ->show();
    00114         if ( cornerWidget() )
    00115         {
    00116             if ( count() < 2 )
    00117                 cornerWidget() ->hide();
    00118             else
    00119                 cornerWidget() ->show();
    00120         }
    00121     }
    00122
    00123     if ( m_visibility == KMdi::NeverShowTabs )
    00124     {
    00125         tabBar() ->hide();
    00126     }
    00127 }
    00128
    00129 void KMdiDocumentViewTabWidget::setTabWidgetVisibility( KMdi::TabWidgetVisibility visibility )
    00130 {
    00131     m_visibility = visibility;
    00132     maybeShow();
    00133 }
    00134
    00135 void KMdiDocumentViewTabWidget::moveTab( int from, int to )
    00136 {
    00137   emit initiateTabMove( from, to );
    00138   KTabWidget::moveTab( from, to );
    00139 }
    00140
    00141 KMdi::TabWidgetVisibility KMdiDocumentViewTabWidget::tabWidgetVisibility( )
    00142 {
    00143     return m_visibility;
    00144 }
    00145
    00146
    00147 #ifndef NO_INCLUDE_MOCFILES
    00148 #include "kmdidocumentviewtabwidget.moc"
    00149 #endif
    00150
    00151 // kate: space-indent off; tab-width 4; replace-tabs off; indent-mode csands;
    00152

This file is part of the documentation for kmdi Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:32:06 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003