• 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
  • widgets
regexplineedit.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 
3  Copyright (c) 2004 Ingo Kloecker <kloecker@kde.org>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 
19  In addition, as a special exception, the copyright holders give
20  permission to link the code of this program with any edition of
21  the Qt library by Trolltech AS, Norway (or with modified versions
22  of Qt that use the same license as Qt), and distribute linked
23  combinations including the two. You must obey the GNU General
24  Public License in all respects for all of the code used other than
25  Qt. If you modify this file, you may extend this exception to
26  your version of the file, but you are not obligated to do so. If
27  you do not wish to do so, delete this exception statement from
28  your version.
29 */
30 
31 #include "regexplineedit.h"
32 
33 #include <KDialog>
34 #include <KLineEdit>
35 #include <KLocale>
36 #include <KRegExpEditorInterface>
37 #include <KServiceTypeTrader>
38 
39 #include <QHBoxLayout>
40 #include <QString>
41 #include <QPushButton>
42 
43 namespace MailCommon {
44 
45 RegExpLineEdit::RegExpLineEdit( QWidget *parent )
46  : QWidget( parent ),
47  mLineEdit( 0 ),
48  mRegExpEditButton( 0 ),
49  mRegExpEditDialog( 0 )
50 {
51  initWidget();
52 }
53 
54 RegExpLineEdit::RegExpLineEdit( const QString &str, QWidget *parent )
55  : QWidget( parent ),
56  mLineEdit( 0 ),
57  mRegExpEditButton( 0 ),
58  mRegExpEditDialog( 0 )
59 {
60  initWidget( str );
61 }
62 
63 void RegExpLineEdit::initWidget( const QString &str )
64 {
65  QHBoxLayout * hlay = new QHBoxLayout( this );
66  hlay->setSpacing( KDialog::spacingHint() );
67  hlay->setMargin( 0 );
68 
69  mLineEdit = new KLineEdit( str, this );
70  mLineEdit->setClearButtonShown( true );
71  mLineEdit->setTrapReturnKey(true);
72  setFocusProxy( mLineEdit );
73  hlay->addWidget( mLineEdit );
74 
75  connect( mLineEdit, SIGNAL(textChanged(QString)),
76  this, SIGNAL(textChanged(QString)) );
77  connect( mLineEdit, SIGNAL(returnPressed()),
78  this, SIGNAL(returnPressed()) );
79 
80  if ( !KServiceTypeTrader::self()->query( QLatin1String("KRegExpEditor/KRegExpEditor") ).isEmpty() ) {
81  mRegExpEditButton = new QPushButton( i18n( "Edit..." ), this );
82  mRegExpEditButton->setObjectName( QLatin1String("mRegExpEditButton") );
83  mRegExpEditButton->setSizePolicy( QSizePolicy::Minimum,
84  QSizePolicy::Fixed );
85  hlay->addWidget( mRegExpEditButton );
86 
87  connect( mRegExpEditButton, SIGNAL(clicked()),
88  this, SLOT(slotEditRegExp()) );
89  }
90 }
91 
92 void RegExpLineEdit::clear()
93 {
94  mLineEdit->clear();
95 }
96 
97 QString RegExpLineEdit::text() const
98 {
99  return mLineEdit->text();
100 }
101 
102 void RegExpLineEdit::setText( const QString & str )
103 {
104  mLineEdit->setText( str );
105 }
106 
107 void RegExpLineEdit::showEditButton( bool show )
108 {
109  if ( !mRegExpEditButton ) {
110  return;
111  }
112 
113  if ( show ) {
114  mRegExpEditButton->show();
115  } else {
116  mRegExpEditButton->hide();
117  }
118 }
119 
120 void RegExpLineEdit::slotEditRegExp()
121 {
122  if ( !mRegExpEditDialog ) {
123  mRegExpEditDialog =
124  KServiceTypeTrader::createInstanceFromQuery<KDialog>(
125  QLatin1String("KRegExpEditor/KRegExpEditor"), QString(), this );
126  }
127 
128  KRegExpEditorInterface *iface = qobject_cast<KRegExpEditorInterface *>( mRegExpEditDialog );
129 
130  if ( iface ) {
131  iface->setRegExp( mLineEdit->text() );
132  if ( mRegExpEditDialog->exec() == KDialog::Accepted ) {
133  mLineEdit->setText( iface->regExp() );
134  }
135  }
136 }
137 
138 } // namespace MailCommon
139 
140 #include "regexplineedit.moc"
MailCommon::RegExpLineEdit::returnPressed
void returnPressed()
MailCommon::RegExpLineEdit::setText
void setText(const QString &)
Definition: regexplineedit.cpp:102
QWidget
MailCommon::RegExpLineEdit::slotEditRegExp
void slotEditRegExp()
Definition: regexplineedit.cpp:120
MailCommon::RegExpLineEdit::clear
void clear()
Definition: regexplineedit.cpp:92
MailCommon::RegExpLineEdit::textChanged
void textChanged(const QString &)
MailCommon::RegExpLineEdit::RegExpLineEdit
RegExpLineEdit(const QString &str, QWidget *parent=0)
Definition: regexplineedit.cpp:54
regexplineedit.h
MailCommon::RegExpLineEdit::showEditButton
void showEditButton(bool)
Definition: regexplineedit.cpp:107
MailCommon::RegExpLineEdit::text
QString text() const
Definition: regexplineedit.cpp:97
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