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

mailcommon

  • sources
  • kde-4.12
  • kdepim
  • mailcommon
  • snippets
snippetvariabledialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net,
3  Author: Tobias Koenig <tokoe@kdab.com>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #include "snippetvariabledialog_p.h"
22 
23 #include <KLocale>
24 #include <KTextEdit>
25 
26 #include <QCheckBox>
27 #include <QLabel>
28 #include <QVBoxLayout>
29 
30 using namespace MailCommon;
31 
32 SnippetVariableDialog::SnippetVariableDialog( const QString &variableName,
33  QMap<QString, QString> *variables,
34  QWidget *parent )
35  : KDialog( parent ), mVariableName( variableName ), mVariables( variables )
36 {
37  setWindowTitle( i18n( "Enter Values for Variables" ) );
38  setButtons( Ok | Cancel );
39 
40  QVBoxLayout *layout = new QVBoxLayout( mainWidget() );
41 
42  QLabel *label = new QLabel;
43  label->setText( i18n( "Enter the replacement values for '%1':", variableName ) );
44  layout->addWidget( label );
45 
46  mVariableValueText = new KTextEdit;
47  mVariableValueText->setAcceptRichText(false);
48  layout->addWidget( mVariableValueText );
49 
50  mSaveVariable = new QCheckBox;
51  mSaveVariable->setChecked( false );
52  mSaveVariable->setText( i18n( "Make value &default" ) );
53  mSaveVariable->setToolTip(
54  i18nc( "@info:tooltip",
55  "Enable this to save the value entered to the right "
56  "as the default value for this variable" ) );
57  mSaveVariable->setWhatsThis(
58  i18nc( "@info:whatsthis",
59  "If you enable this option, the value entered to the right will be saved. "
60  "If you use the same variable later, even in another snippet, the value entered "
61  "to the right will be the default value for that variable." ) );
62  layout->addWidget( mSaveVariable );
63 
64  if ( mVariables->contains( variableName ) ) {
65  mSaveVariable->setChecked( true );
66  mVariableValueText->setText( mVariables->value( variableName ) );
67  }
68 
69  mVariableValueText->setFocus();
70 }
71 
72 QString SnippetVariableDialog::variableValue() const
73 {
74  return mVariableValueText->toPlainText();
75 }
76 
77 bool SnippetVariableDialog::saveVariableIsChecked() const
78 {
79  return mSaveVariable->isChecked();
80 }
81 
82 void SnippetVariableDialog::slotButtonClicked( int button )
83 {
84  if ( button == KDialog::Ok ) {
85  if ( mSaveVariable->isChecked() ) {
86  mVariables->insert( mVariableName, mVariableValueText->toPlainText() );
87  } else {
88  mVariables->remove( mVariableName );
89  }
90 
91  accept();
92  return;
93  }
94 
95  KDialog::slotButtonClicked( button );
96 }
97 
98 #include "snippetvariabledialog_p.moc"
QWidget
KDialog
MailCommon::SnippetVariableDialog::saveVariableIsChecked
bool saveVariableIsChecked() const
Definition: snippetvariabledialog.cpp:77
snippetvariabledialog_p.h
MailCommon::SnippetVariableDialog::slotButtonClicked
virtual void slotButtonClicked(int button)
Definition: snippetvariabledialog.cpp:82
MailCommon::SnippetVariableDialog::variableValue
QString variableValue() const
Definition: snippetvariabledialog.cpp:72
MailCommon::SnippetVariableDialog::SnippetVariableDialog
SnippetVariableDialog(const QString &variableName, QMap< QString, QString > *variables, QWidget *parent=0)
Definition: snippetvariabledialog.cpp:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

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