• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

akonadi/contact

smsdialog.cpp

00001 /*
00002     This file is part of Akonadi Contact.
00003 
00004     Copyright (c) 2010 Felix Mauch (felix_mauch@web.de)
00005 
00006     This library is free software; you can redistribute it and/or modify it
00007     under the terms of the GNU Library General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or (at your
00009     option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful, but WITHOUT
00012     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014     License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to the
00018     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019     02110-1301, USA.
00020 */ 
00021 
00022 #include "smsdialog.h"
00023 
00024 #include <kabc/phonenumber.h>
00025 #include <klocale.h>
00026 #include <kmessagebox.h>
00027 #include <ktextedit.h>
00028 
00029 #include <QtGui/QLabel>
00030 #include <QtGui/QPushButton>
00031 #include <QtGui/QVBoxLayout>
00032 
00033 static const unsigned int s_messageSize = 160;
00034 
00035 SmsDialog::SmsDialog( const KABC::PhoneNumber &number )
00036   : mNumber( number.number() )
00037 {
00038   initUI();
00039 }
00040 
00041 SmsDialog::~SmsDialog()
00042 {
00043 }
00044 
00045 QString SmsDialog::message() const
00046 {
00047   return mText;
00048 }
00049 
00050 void SmsDialog::initUI()
00051 {
00052   setCaption( i18n( "SMS text" ) );
00053   setButtons( Ok | Cancel );
00054   setDefaultButton( Ok );
00055   showButtonSeparator( true );
00056 
00057   QWidget *page = new QWidget( this );
00058   setMainWidget( page );
00059   page->setFixedWidth( 300 );
00060 
00061   QVBoxLayout *topLayout = new QVBoxLayout( page );
00062   topLayout->setSpacing( spacingHint() );
00063   topLayout->setMargin( 0 );
00064 
00065 
00066   QLabel *label = new QLabel( i18n( "Please insert SMS text for an SMS to the following number: %1", mNumber ), page );
00067   topLayout->addWidget( label );
00068   label->setWordWrap( true );
00069 
00070   mSmsTextEdit = new KTextEdit( page );
00071   mSmsTextEdit->setAcceptRichText( false );
00072   label->setBuddy( mSmsTextEdit );
00073   topLayout->addWidget( mSmsTextEdit );
00074 
00075   connect( mSmsTextEdit, SIGNAL( textChanged() ), SLOT( updateCounter() ) );
00076 
00077   mLengthLabel = new QLabel( QLatin1String("-") , page );
00078   topLayout->addWidget( mLengthLabel );
00079 
00080   mSmsTextEdit->setFocus();
00081   updateCounter();
00082 }
00083 
00084 void SmsDialog::updateCounter()
00085 {
00086   mText = mSmsTextEdit->toPlainText();
00087 
00088   int size = mText.size();
00089   int numberSms = ( size - ( size % s_messageSize ) ) / s_messageSize + 1;
00090   int numberChars = s_messageSize * numberSms;
00091 
00092   mLengthLabel->setText( i18n( "%1/%2 (%3 SMS)", size, numberChars, numberSms ) );
00093 }

akonadi/contact

Skip menu "akonadi/contact"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.3
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