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

tdeprint

sizewidget.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2002 Michael Goffioul <tdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "sizewidget.h"
00021 
00022 #include <tqcombobox.h>
00023 #include <tqspinbox.h>
00024 #include <tqlayout.h>
00025 #include <tqregexp.h>
00026 #include <tdelocale.h>
00027 
00028 SizeWidget::SizeWidget( TQWidget *parent, const char *name )
00029     : TQWidget( parent, name )
00030 {
00031     m_size = new TQSpinBox( 0, 9999, 1, this );
00032     m_unit = new TQComboBox( this );
00033 
00034     m_unit->insertItem( i18n( "KB" ) );
00035     m_unit->insertItem( i18n( "MB" ) );
00036     m_unit->insertItem( i18n( "GB" ) );
00037     m_unit->insertItem( i18n( "Tiles" ) );
00038     m_unit->setCurrentItem( 1 );
00039     m_size->setSpecialValueText( i18n( "Unlimited" ) );
00040 
00041     TQHBoxLayout *l0 = new TQHBoxLayout( this, 0, 5 );
00042     l0->addWidget( m_size, 1 );
00043     l0->addWidget( m_unit, 0 );
00044 }
00045 
00046 void SizeWidget::setSizeString( const TQString& sz )
00047 {
00048     int p = sz.find( TQRegExp( "\\D" ) );
00049     m_size->setValue( sz.left( p ).toInt() );
00050     switch( sz[ p ].latin1() )
00051     {
00052         case 'k': p = 0; break;
00053         default:
00054         case 'm': p = 1; break;
00055         case 'g': p = 2; break;
00056         case 't': p = 3; break;
00057     }
00058     m_unit->setCurrentItem( p );
00059 }
00060 
00061 TQString SizeWidget::sizeString() const
00062 {
00063     TQString result = TQString::number( m_size->value() );
00064     switch ( m_unit->currentItem() )
00065     {
00066         case 0: result.append( "k" ); break;
00067         case 1: result.append( "m" ); break;
00068         case 2: result.append( "g" ); break;
00069         case 3: result.append( "t" ); break;
00070     }
00071     return result;
00072 }
00073 
00074 void SizeWidget::setValue( int value )
00075 {
00076     m_size->setValue( value );
00077     m_unit->setCurrentItem( 1 );
00078 }
00079 
00080 int SizeWidget::value() const
00081 {
00082     return m_size->value();
00083 }

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
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.7.1
This website is maintained by Timothy Pearson.