• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

akonadi/contact

  • akonadi
  • contact
  • actions
smsdialog.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  Copyright (c) 2010 Felix Mauch (felix_mauch@web.de)
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #include "smsdialog.h"
23 
24 #include <kabc/phonenumber.h>
25 #include <klocale.h>
26 #include <kmessagebox.h>
27 #include <ktextedit.h>
28 
29 #include <QLabel>
30 #include <QPushButton>
31 #include <QVBoxLayout>
32 
33 SmsDialog::SmsDialog( const KABC::PhoneNumber &number )
34  : mNumber( number.number() )
35 {
36  initUI();
37 }
38 
39 SmsDialog::~SmsDialog()
40 {
41 }
42 
43 QString SmsDialog::message() const
44 {
45  return mText;
46 }
47 
48 void SmsDialog::initUI()
49 {
50  setCaption( i18n( "SMS text" ) );
51  setButtons( Ok | Cancel );
52  setDefaultButton( Ok );
53  showButtonSeparator( true );
54 
55  QWidget *page = new QWidget( this );
56  setMainWidget( page );
57  page->setFixedWidth( 300 );
58 
59  QVBoxLayout *topLayout = new QVBoxLayout( page );
60  topLayout->setSpacing( spacingHint() );
61  topLayout->setMargin( 0 );
62 
63 
64  QLabel *label = new QLabel( i18n( "Please insert SMS text for an SMS to the following number: %1", mNumber ), page );
65  topLayout->addWidget( label );
66  label->setWordWrap( true );
67 
68  mSmsTextEdit = new KTextEdit( page );
69  mSmsTextEdit->setAcceptRichText( false );
70  label->setBuddy( mSmsTextEdit );
71  topLayout->addWidget( mSmsTextEdit );
72 
73  connect( mSmsTextEdit, SIGNAL(textChanged()), SLOT(updateCounter()) );
74 
75  mLengthLabel = new QLabel( QLatin1String( "-" ) , page );
76  topLayout->addWidget( mLengthLabel );
77 
78  mSmsTextEdit->setFocus();
79  updateCounter();
80 }
81 
82 void SmsDialog::updateCounter()
83 {
84  mText = mSmsTextEdit->toPlainText();
85  unsigned int messageSize = 160;
86 
87  const int size = mText.length();
88  for ( int i = 0; i <size; ++i ) {
89  if ( mText[i].row() > 0 ) {
90  messageSize = 70;
91  break;
92  }
93  }
94  const int numberSms = ( size - ( size % messageSize ) ) / messageSize + 1;
95  const int numberChars = messageSize * numberSms;
96 
97  mLengthLabel->setText( i18n( "%1/%2 (%3 SMS)", size, numberChars, numberSms ) );
98 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:28:43 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi/contact

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

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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