00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <qlabel.h>
00023 #include <qlayout.h>
00024 #include <qtextedit.h>
00025
00026 #include <klocale.h>
00027
00028 #include "sendsmsdialog.h"
00029
00030 SendSMSDialog::SendSMSDialog( const QString &recipientName, QWidget *parent, const char *name )
00031 : KDialogBase( Plain, i18n( "Send SMS" ), Ok | Cancel, Ok, parent, name, true, true )
00032 {
00033 QWidget *page = plainPage();
00034
00035 QGridLayout *layout = new QGridLayout( page, 3, 3, marginHint(), spacingHint() );
00036
00037 layout->addWidget( new QLabel( i18n( "Message" ), page ), 0, 0 );
00038
00039 mMessageLength = new QLabel( "0/160", page );
00040 mMessageLength->setAlignment( Qt::AlignRight );
00041 layout->addWidget( mMessageLength, 0, 2 );
00042
00043 mText = new QTextEdit( page );
00044 layout->addMultiCellWidget( mText, 1, 1, 0, 2 );
00045
00046 layout->addWidget( new QLabel( i18n( "Recipient:" ), page ), 2, 0 );
00047 layout->addWidget( new QLabel( recipientName, page ), 2, 2 );
00048
00049 setButtonText( Ok, i18n( "Send" ) );
00050
00051 connect( mText, SIGNAL( textChanged() ),
00052 this, SLOT( updateMessageLength() ) );
00053 connect( mText, SIGNAL( textChanged() ),
00054 this, SLOT( updateButtons() ) );
00055
00056 updateButtons();
00057
00058 mText->setFocus();
00059 }
00060
00061 QString SendSMSDialog::text() const
00062 {
00063 return mText->text();
00064 }
00065
00066 void SendSMSDialog::updateMessageLength()
00067 {
00068 int length = mText->length();
00069
00070 if( length > 480 )
00071 mMessageLength->setText( QString( "%1/%2 (%3)" ).arg( length ).arg( 500 ).arg( 4 ) );
00072 else if( length > 320 )
00073 mMessageLength->setText( QString( "%1/%2 (%3)" ).arg( length ).arg( 480 ).arg( 3 ) );
00074 else if( length > 160 )
00075 mMessageLength->setText( QString( "%1/%2 (%3)" ).arg( length ).arg( 320 ).arg( 2 ) );
00076 else
00077 mMessageLength->setText( QString( "%1/%2" ).arg( length ).arg( 160 ) );
00078 }
00079
00080 void SendSMSDialog::updateButtons()
00081 {
00082 enableButton( Ok, mText->length() > 0 );
00083 }
00084
00085 #include "sendsmsdialog.moc"