• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

ktoolbarspaceraction.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2006 Hamish Rodda <rodda@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "ktoolbarspaceraction.h"
00020 
00021 #include <QToolBar>
00022 
00023 class KToolBarSpacerAction::Private
00024 {
00025   public:
00026     Private()
00027       : width( 0 ),
00028         minimumWidth( -1 ),
00029         maximumWidth( -1 )
00030     {
00031     }
00032 
00033     void _k_spacerDestroyed( QObject* spacer )
00034     {
00035       spacers.removeAll( static_cast<QWidget*>( spacer ) );
00036     }
00037 
00038     int width, minimumWidth, maximumWidth;
00039     QList<QWidget*> spacers;
00040 };
00041 
00042 KToolBarSpacerAction::KToolBarSpacerAction(QObject *parent)
00043   : KAction(parent),
00044     d( new Private )
00045 {
00046 }
00047 
00048 KToolBarSpacerAction::~KToolBarSpacerAction()
00049 {
00050     delete d;
00051 }
00052 
00053 int KToolBarSpacerAction::width() const
00054 {
00055   return d->width;
00056 }
00057 
00058 void KToolBarSpacerAction::setWidth( int width )
00059 {
00060   if ( d->width == width )
00061     return;
00062 
00063   d->width = width;
00064 
00065   foreach ( QWidget* spacer, d->spacers )
00066     spacer->resize( width, spacer->height() );
00067 }
00068 
00069 int KToolBarSpacerAction::minimumWidth() const
00070 {
00071   return d->minimumWidth;
00072 }
00073 
00074 void KToolBarSpacerAction::setMinimumWidth( int width )
00075 {
00076   if ( d->minimumWidth == width )
00077     return;
00078 
00079   d->minimumWidth = width;
00080 
00081   foreach ( QWidget* spacer, d->spacers )
00082     spacer->setMinimumWidth( width );
00083 }
00084 
00085 int KToolBarSpacerAction::maximumWidth( ) const
00086 {
00087   return d->maximumWidth;
00088 }
00089 
00090 void KToolBarSpacerAction::setMaximumWidth( int width )
00091 {
00092   if ( d->maximumWidth == width )
00093     return;
00094 
00095   d->maximumWidth = width;
00096 
00097   foreach ( QWidget* spacer, d->spacers )
00098     spacer->setMaximumWidth( width );
00099 }
00100 
00101 QWidget * KToolBarSpacerAction::createWidget( QWidget * _parent )
00102 {
00103   QToolBar *parent = qobject_cast<QToolBar *>(_parent);
00104   if (!_parent)
00105     return KAction::createWidget(_parent);
00106   QWidget* spacer = new QWidget( parent );
00107   spacer->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
00108 
00109   d->spacers.append( spacer );
00110   connect( spacer, SIGNAL( destroyed( QObject* ) ),
00111            SLOT( _k_spacerDestroyed( QObject* ) ) );
00112 
00113   return spacer;
00114 }
00115 
00116 void KToolBarSpacerAction::deleteWidget(QWidget *widget)
00117 {
00118     d->spacers.removeAll(widget);
00119     KAction::deleteWidget(widget);
00120 }
00121 
00122 #include "ktoolbarspaceraction.moc"

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal