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

akonadi/contact

  • sources
  • kde-4.14
  • kdepimlibs
  • 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 <klocalizedstring.h>
26 #include <kmessagebox.h>
27 #include <ktextedit.h>
28 
29 #include <QLabel>
30 #include <QVBoxLayout>
31 
32 SmsDialog::SmsDialog(const KABC::PhoneNumber &number)
33  : mNumber(number.number())
34 {
35  initUI();
36 }
37 
38 SmsDialog::~SmsDialog()
39 {
40 }
41 
42 QString SmsDialog::message() const
43 {
44  return mText;
45 }
46 
47 void SmsDialog::initUI()
48 {
49  setCaption(i18n("SMS text"));
50  setButtons(Ok | Cancel);
51  setDefaultButton(Ok);
52  showButtonSeparator(true);
53 
54  QWidget *page = new QWidget(this);
55  setMainWidget(page);
56  page->setFixedWidth(300);
57 
58  QVBoxLayout *topLayout = new QVBoxLayout(page);
59  topLayout->setSpacing(spacingHint());
60  topLayout->setMargin(0);
61 
62  QLabel *label = new QLabel(i18n("Please insert SMS text for an SMS to the following number: %1", mNumber), page);
63  topLayout->addWidget(label);
64  label->setWordWrap(true);
65 
66  mSmsTextEdit = new KTextEdit(page);
67  mSmsTextEdit->setAcceptRichText(false);
68  label->setBuddy(mSmsTextEdit);
69  topLayout->addWidget(mSmsTextEdit);
70 
71  connect(mSmsTextEdit, SIGNAL(textChanged()), SLOT(updateCounter()));
72 
73  mLengthLabel = new QLabel(QLatin1String("-") , page);
74  topLayout->addWidget(mLengthLabel);
75 
76  mSmsTextEdit->setFocus();
77  updateCounter();
78 }
79 
80 void SmsDialog::updateCounter()
81 {
82  mText = mSmsTextEdit->toPlainText();
83  unsigned int messageSize = 160;
84 
85  const int size = mText.length();
86  for (int i = 0; i < size; ++i) {
87  if (mText[i].row() > 0) {
88  messageSize = 70;
89  break;
90  }
91  }
92  const int numberSms = (size - (size % messageSize)) / messageSize + 1;
93  const int numberChars = messageSize * numberSms;
94 
95  mLengthLabel->setText(i18n("%1/%2 (%3 SMS)", size, numberChars, numberSms));
96 }
QWidget
QWidget::setFixedWidth
void setFixedWidth(int w)
QLabel::setBuddy
void setBuddy(QWidget *buddy)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QVBoxLayout
QString
QLayout::setMargin
void setMargin(int margin)
QLatin1String
QLabel
QLabel::setWordWrap
void setWordWrap(bool on)
QBoxLayout::setSpacing
void setSpacing(int spacing)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:19 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs 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

Search



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