• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
  • cups
  • cupsdconf2
sizewidget.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2002 Michael Goffioul <tdeprint@swing.be>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #include "sizewidget.h"
21 
22 #include <tqcombobox.h>
23 #include <tqspinbox.h>
24 #include <tqlayout.h>
25 #include <tqregexp.h>
26 #include <tdelocale.h>
27 
28 SizeWidget::SizeWidget( TQWidget *parent, const char *name )
29  : TQWidget( parent, name )
30 {
31  m_size = new TQSpinBox( 0, 9999, 1, this );
32  m_unit = new TQComboBox( this );
33 
34  m_unit->insertItem( i18n( "KB" ) );
35  m_unit->insertItem( i18n( "MB" ) );
36  m_unit->insertItem( i18n( "GB" ) );
37  m_unit->insertItem( i18n( "Tiles" ) );
38  m_unit->setCurrentItem( 1 );
39  m_size->setSpecialValueText( i18n( "Unlimited" ) );
40 
41  TQHBoxLayout *l0 = new TQHBoxLayout( this, 0, 5 );
42  l0->addWidget( m_size, 1 );
43  l0->addWidget( m_unit, 0 );
44 }
45 
46 void SizeWidget::setSizeString( const TQString& sz )
47 {
48  int p = sz.find( TQRegExp( "\\D" ) );
49  m_size->setValue( sz.left( p ).toInt() );
50  switch( sz[ p ].latin1() )
51  {
52  case 'k': p = 0; break;
53  default:
54  case 'm': p = 1; break;
55  case 'g': p = 2; break;
56  case 't': p = 3; break;
57  }
58  m_unit->setCurrentItem( p );
59 }
60 
61 TQString SizeWidget::sizeString() const
62 {
63  TQString result = TQString::number( m_size->value() );
64  switch ( m_unit->currentItem() )
65  {
66  case 0: result.append( "k" ); break;
67  case 1: result.append( "m" ); break;
68  case 2: result.append( "g" ); break;
69  case 3: result.append( "t" ); break;
70  }
71  return result;
72 }
73 
74 void SizeWidget::setValue( int value )
75 {
76  m_size->setValue( value );
77  m_unit->setCurrentItem( 1 );
78 }
79 
80 int SizeWidget::value() const
81 {
82  return m_size->value();
83 }

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.8.8
This website is maintained by Timothy Pearson.