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

KDEUI

  • sources
  • kde-4.12
  • kdelibs
  • kdeui
  • actions
ktoolbarspaceraction.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2006 Hamish Rodda <rodda@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include "ktoolbarspaceraction.h"
20 
21 #include <QToolBar>
22 
23 class KToolBarSpacerAction::Private
24 {
25  public:
26  Private()
27  : width( 0 ),
28  minimumWidth( -1 ),
29  maximumWidth( -1 )
30  {
31  }
32 
33  void _k_spacerDestroyed( QObject* spacer )
34  {
35  spacers.removeAll( static_cast<QWidget*>( spacer ) );
36  }
37 
38  int width, minimumWidth, maximumWidth;
39  QList<QWidget*> spacers;
40 };
41 
42 KToolBarSpacerAction::KToolBarSpacerAction(QObject *parent)
43  : KAction(parent),
44  d( new Private )
45 {
46 }
47 
48 KToolBarSpacerAction::~KToolBarSpacerAction()
49 {
50  delete d;
51 }
52 
53 int KToolBarSpacerAction::width() const
54 {
55  return d->width;
56 }
57 
58 void KToolBarSpacerAction::setWidth( int width )
59 {
60  if ( d->width == width )
61  return;
62 
63  d->width = width;
64 
65  foreach ( QWidget* spacer, d->spacers )
66  spacer->resize( width, spacer->height() );
67 }
68 
69 int KToolBarSpacerAction::minimumWidth() const
70 {
71  return d->minimumWidth;
72 }
73 
74 void KToolBarSpacerAction::setMinimumWidth( int width )
75 {
76  if ( d->minimumWidth == width )
77  return;
78 
79  d->minimumWidth = width;
80 
81  foreach ( QWidget* spacer, d->spacers )
82  spacer->setMinimumWidth( width );
83 }
84 
85 int KToolBarSpacerAction::maximumWidth( ) const
86 {
87  return d->maximumWidth;
88 }
89 
90 void KToolBarSpacerAction::setMaximumWidth( int width )
91 {
92  if ( d->maximumWidth == width )
93  return;
94 
95  d->maximumWidth = width;
96 
97  foreach ( QWidget* spacer, d->spacers )
98  spacer->setMaximumWidth( width );
99 }
100 
101 QWidget * KToolBarSpacerAction::createWidget( QWidget * _parent )
102 {
103  QToolBar *parent = qobject_cast<QToolBar *>(_parent);
104  if (!_parent)
105  return KAction::createWidget(_parent);
106  QWidget* spacer = new QWidget( parent );
107  spacer->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
108 
109  d->spacers.append( spacer );
110  connect( spacer, SIGNAL(destroyed(QObject*)),
111  SLOT(_k_spacerDestroyed(QObject*)) );
112 
113  return spacer;
114 }
115 
116 void KToolBarSpacerAction::deleteWidget(QWidget *widget)
117 {
118  d->spacers.removeAll(widget);
119  KAction::deleteWidget(widget);
120 }
121 
122 #include "ktoolbarspaceraction.moc"
KToolBarSpacerAction::KToolBarSpacerAction
KToolBarSpacerAction(QObject *parent)
Creates a new toolbar spacer action.
Definition: ktoolbarspaceraction.cpp:42
KToolBarSpacerAction::~KToolBarSpacerAction
~KToolBarSpacerAction()
Definition: ktoolbarspaceraction.cpp:48
QWidget
KToolBarSpacerAction::width
int width() const
Returns the width of the spacer item.
QObject
KToolBarSpacerAction::setMaximumWidth
void setMaximumWidth(int width)
Sets the maximum.
Definition: ktoolbarspaceraction.cpp:90
ktoolbarspaceraction.h
KToolBarSpacerAction::maximumWidth
int maximumWidth() const
Returns the maximum width of the spacer item.
QToolBar
KToolBarSpacerAction::minimumWidth
int minimumWidth() const
Returns the minimum width of the spacer item.
KToolBarSpacerAction::createWidget
virtual QWidget * createWidget(QWidget *parent)
Reimplemented from.
Definition: ktoolbarspaceraction.cpp:101
KToolBarSpacerAction::deleteWidget
virtual void deleteWidget(QWidget *widget)
Reimplemented from.
Definition: ktoolbarspaceraction.cpp:116
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:216
KToolBarSpacerAction::setWidth
void setWidth(int width)
Sets the.
Definition: ktoolbarspaceraction.cpp:58
KToolBarSpacerAction::setMinimumWidth
void setMinimumWidth(int width)
Sets the minimum.
Definition: ktoolbarspaceraction.cpp:74
QList< QWidget * >
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:16 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal