• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kleopatra

adduseriddialog.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset:4 -*-
00002     dialogs/adduseriddialog.cpp
00003 
00004     This file is part of Kleopatra, the KDE keymanager
00005     Copyright (c) 2008 Klarälvdalens Datakonsult AB
00006 
00007     Kleopatra is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     Kleopatra is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021     In addition, as a special exception, the copyright holders give
00022     permission to link the code of this program with any edition of
00023     the Qt library by Trolltech AS, Norway (or with modified versions
00024     of Qt that use the same license as Qt), and distribute linked
00025     combinations including the two.  You must obey the GNU General
00026     Public License in all respects for all of the code used other than
00027     Qt.  If you modify this file, you may extend this exception to
00028     your version of the file, but you are not obligated to do so.  If
00029     you do not wish to do so, delete this exception statement from
00030     your version.
00031 */
00032 
00033 #include <config-kleopatra.h>
00034 
00035 #include "adduseriddialog.h"
00036 
00037 #include "ui_adduseriddialog.h"
00038 
00039 #include <utils/validation.h>
00040 
00041 #include <QString>
00042 #include <QStringList>
00043 #include <QPushButton>
00044 
00045 #include <cassert>
00046 
00047 using namespace Kleo;
00048 using namespace Kleo::Dialogs;
00049 
00050 class AddUserIDDialog::Private {
00051     friend class ::Kleo::Dialogs::AddUserIDDialog;
00052     AddUserIDDialog * const q;
00053 public:
00054     explicit Private( AddUserIDDialog * qq )
00055         : q( qq ),
00056           ui( q )
00057     {
00058 
00059     }
00060 
00061 private:
00062     void slotUserIDChanged();
00063 
00064 private:
00065     struct UI : public Ui_AddUserIDDialog {
00066         explicit UI( AddUserIDDialog * qq )
00067             : Ui_AddUserIDDialog()
00068         {
00069             setupUi( qq );
00070 
00071             nameLE->setValidator( Validation::pgpName( nameLE ) );
00072             emailLE->setValidator( Validation::email( emailLE ) );
00073             commentLE->setValidator( Validation::pgpComment( commentLE ) );
00074         }
00075 
00076         QPushButton * okPB() const {
00077             return buttonBox->button( QDialogButtonBox::Ok );
00078         }
00079     } ui;
00080 };
00081 
00082 AddUserIDDialog::AddUserIDDialog( QWidget * p, Qt::WindowFlags f )
00083     : QDialog( p, f ), d( new Private( this ) )
00084 {
00085 
00086 }
00087 
00088 AddUserIDDialog::~AddUserIDDialog() {}
00089 
00090 
00091 void AddUserIDDialog::setName( const QString & name ) {
00092     d->ui.nameLE->setText( name );
00093 }
00094 
00095 QString AddUserIDDialog::name() const {
00096     return d->ui.nameLE->text().trimmed();
00097 }
00098 
00099 void AddUserIDDialog::setEmail( const QString & email ) {
00100     d->ui.emailLE->setText( email );
00101 }
00102 
00103 QString AddUserIDDialog::email() const {
00104     return d->ui.emailLE->text().trimmed();
00105 }
00106 
00107 void AddUserIDDialog::setComment( const QString & comment ) {
00108     d->ui.commentLE->setText( comment );
00109 }
00110 
00111 QString AddUserIDDialog::comment() const {
00112     return d->ui.commentLE->text().trimmed();
00113 }
00114 
00115 
00116 void AddUserIDDialog::Private::slotUserIDChanged() {
00117 
00118     bool ok = false;
00119     QString error;
00120 
00121     if ( !ui.nameLE->hasAcceptableInput() )
00122         error = i18nc("@info", "<interface>Real name</interface> must be at least 5 characters long.");
00123     else if ( !ui.emailLE->hasAcceptableInput() )
00124         error = i18nc("@info", "<interface>EMail address</interface> is invalid.");
00125     else if ( !ui.commentLE->hasAcceptableInput() )
00126         error = i18nc("@info", "<interface>Comment</interface> contains invalid characters.");
00127     else
00128         ok = true;
00129 
00130     ui.okPB()->setEnabled( ok );
00131     ui.errorLB->setText( error );
00132 
00133     const QString name = q->name();
00134     const QString email = q->email();
00135     const QString comment = q->comment();
00136 
00137     QStringList parts;
00138     if ( !name.isEmpty() )
00139         parts.push_back( name );
00140     if ( !comment.isEmpty() )
00141         parts.push_back( QLatin1Char( '(' ) + comment + QLatin1Char( ')' ) );
00142     if ( !email.isEmpty() )
00143         parts.push_back( QLatin1Char( '<' ) + email + QLatin1Char( '>' ) );
00144 
00145     ui.resultLB->setText( parts.join( QLatin1String( " " ) ) );
00146 }
00147 
00148 #include "moc_adduseriddialog.cpp"

kleopatra

Skip menu "kleopatra"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
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