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

kpimidentities

  • sources
  • kde-4.14
  • kdepimlibs
  • kpimidentities
signature.cpp
1 /*
2  Copyright (c) 2002-2004 Marc Mutz <mutz@kde.org>
3  Copyright (c) 2007 Tom Albers <tomalbers@kde.nl>
4  Copyright (c) 2009 Thomas McGuire <mcguire@kde.org>
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 "signature.h"
23 
24 #include <kdebug.h>
25 #include <klocalizedstring.h>
26 #include <kmessagebox.h>
27 #include <kconfiggroup.h>
28 #include <kurl.h>
29 #include <kprocess.h>
30 #include <KRichTextEdit>
31 #include <kpimutils/kfileio.h>
32 
33 #include <QFileInfo>
34 #include <QSharedPointer>
35 #include <QImage>
36 
37 #include <assert.h>
38 #include <QtCore/QDir>
39 #include <kpimtextedit/textedit.h>
40 
41 using namespace KPIMIdentities;
42 
43 class SignaturePrivate
44 {
45  public:
46  SignaturePrivate()
47  :enabled( false )
48  {
49  }
50  struct EmbeddedImage
51  {
52  QImage image;
53  QString name;
54  };
55  typedef QSharedPointer<EmbeddedImage> EmbeddedImagePtr;
56 
59  QList<EmbeddedImagePtr> embeddedImages;
60 
62  QString saveLocation;
63  bool enabled;
64 };
65 
66 QDataStream &operator<< ( QDataStream &stream, const SignaturePrivate::EmbeddedImagePtr &img )
67 {
68  return stream << img->image << img->name;
69 }
70 
71 QDataStream &operator>> ( QDataStream &stream, SignaturePrivate::EmbeddedImagePtr &img )
72 {
73  return stream >> img->image >> img->name;
74 }
75 
76 // TODO: KDE5: BIC: Add a real d-pointer.
77 // This QHash is just a workaround around BIC issues, for more info see
78 // http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++
79 typedef QHash<const Signature*,SignaturePrivate*> SigPrivateHash;
80 Q_GLOBAL_STATIC( SigPrivateHash, d_func )
81 
82 static SignaturePrivate* d( const Signature *sig )
83 {
84  SignaturePrivate *ret = d_func()->value( sig, 0 );
85  if ( !ret ) {
86  ret = new SignaturePrivate;
87  d_func()->insert( sig, ret );
88  }
89  return ret;
90 }
91 
92 static void delete_d( const Signature* sig )
93 {
94  SignaturePrivate *ret = d_func()->value( sig, 0 );
95  delete ret;
96  d_func()->remove( sig );
97 }
98 
99 Signature::Signature()
100  : mType( Disabled ),
101  mInlinedHtml( false )
102 {}
103 
104 Signature::Signature( const QString &text )
105  : mText( text ),
106  mType( Inlined ),
107  mInlinedHtml( false )
108 {}
109 
110 Signature::Signature( const QString &url, bool isExecutable )
111  : mUrl( url ),
112  mType( isExecutable ? FromCommand : FromFile ),
113  mInlinedHtml( false )
114 {}
115 
116 void Signature::assignFrom ( const KPIMIdentities::Signature &that )
117 {
118  mUrl = that.mUrl;
119  mInlinedHtml = that.mInlinedHtml;
120  mText = that.mText;
121  mType = that.mType;
122  d( this )->enabled = d( &that )->enabled;
123  d( this )->saveLocation = d( &that )->saveLocation;
124  d( this )->embeddedImages = d( &that )->embeddedImages;
125 }
126 
127 Signature::Signature ( const Signature &that )
128 {
129  assignFrom( that );
130 }
131 
132 Signature& Signature::operator= ( const KPIMIdentities::Signature & that )
133 {
134  if ( this == &that ) {
135  return *this;
136  }
137 
138  assignFrom( that );
139  return *this;
140 }
141 
142 Signature::~Signature()
143 {
144  delete_d( this );
145 }
146 
147 QString Signature::rawText( bool *ok ) const
148 {
149  switch ( mType ) {
150  case Disabled:
151  if ( ok ) {
152  *ok = true;
153  }
154  return QString();
155  case Inlined:
156  if ( ok ) {
157  *ok = true;
158  }
159  return mText;
160  case FromFile:
161  return textFromFile( ok );
162  case FromCommand:
163  return textFromCommand( ok );
164  };
165  kFatal( 5325 ) << "Signature::type() returned unknown value!";
166  return QString(); // make compiler happy
167 }
168 
169 QString Signature::textFromCommand( bool *ok ) const
170 {
171  assert( mType == FromCommand );
172 
173  // handle pathological cases:
174  if ( mUrl.isEmpty() ) {
175  if ( ok ) {
176  *ok = true;
177  }
178  return QString();
179  }
180 
181  // create a shell process:
182  KProcess proc;
183  proc.setOutputChannelMode( KProcess::SeparateChannels );
184  proc.setShellCommand( mUrl );
185  int rc = proc.execute();
186 
187  // handle errors, if any:
188  if ( rc != 0 ) {
189  if ( ok ) {
190  *ok = false;
191  }
192  QString wmsg = i18n( "<qt>Failed to execute signature script<p><b>%1</b>:</p>"
193  "<p>%2</p></qt>", mUrl, QLatin1String( proc.readAllStandardError() ) );
194  KMessageBox::error( 0, wmsg );
195  return QString();
196  }
197 
198  // no errors:
199  if ( ok ) {
200  *ok = true;
201  }
202 
203  // get output:
204  QByteArray output = proc.readAllStandardOutput();
205 
206  // TODO: hmm, should we allow other encodings, too?
207  return QString::fromLocal8Bit( output.data(), output.size() );
208 }
209 
210 QString Signature::textFromFile( bool *ok ) const
211 {
212  assert( mType == FromFile );
213 
214  // TODO: Use KIO::NetAccess to download non-local files!
215  if ( !KUrl( mUrl ).isLocalFile() &&
216  !( QFileInfo( mUrl ).isRelative() &&
217  QFileInfo( mUrl ).exists() ) ) {
218  kDebug( 5325 ) << "Signature::textFromFile:"
219  << "non-local URLs are unsupported";
220  if ( ok ) {
221  *ok = false;
222  }
223  return QString();
224  }
225 
226  if ( ok ) {
227  *ok = true;
228  }
229 
230  // TODO: hmm, should we allow other encodings, too?
231  const QByteArray ba = KPIMUtils::kFileToByteArray( mUrl, false );
232  return QString::fromLocal8Bit( ba.data(), ba.size() );
233 }
234 
235 QString Signature::withSeparator( bool *ok ) const
236 {
237  QString signature = rawText( ok );
238  if ( ok && ( *ok ) == false ) {
239  return QString();
240  }
241 
242  if ( signature.isEmpty() ) {
243  return signature; // don't add a separator in this case
244  }
245 
246  const bool htmlSig = ( isInlinedHtml() && mType == Inlined );
247  QString newline = htmlSig ? QLatin1String("<br>") : QLatin1String("\n");
248  if ( htmlSig && signature.startsWith( QLatin1String( "<p" ) ) ) {
249  newline.clear();
250  }
251 
252  if ( signature.startsWith( QString::fromLatin1( "-- " ) + newline ) ||
253  ( signature.indexOf( newline + QString::fromLatin1( "-- " ) + newline ) != -1 ) ) {
254  // already have signature separator at start of sig or inside sig:
255  return signature;
256  } else {
257  // need to prepend one:
258  return QString::fromLatin1( "-- " ) + newline + signature;
259  }
260 }
261 
262 void Signature::setUrl( const QString &url, bool isExecutable )
263 {
264  mUrl = url;
265  mType = isExecutable ? FromCommand : FromFile;
266 }
267 
268 void Signature::setInlinedHtml( bool isHtml )
269 {
270  mInlinedHtml = isHtml;
271 }
272 
273 bool Signature::isInlinedHtml() const
274 {
275  return mInlinedHtml;
276 }
277 
278 // config keys and values:
279 static const char sigTypeKey[] = "Signature Type";
280 static const char sigTypeInlineValue[] = "inline";
281 static const char sigTypeFileValue[] = "file";
282 static const char sigTypeCommandValue[] = "command";
283 static const char sigTypeDisabledValue[] = "disabled";
284 static const char sigTextKey[] = "Inline Signature";
285 static const char sigFileKey[] = "Signature File";
286 static const char sigCommandKey[] = "Signature Command";
287 static const char sigTypeInlinedHtmlKey[] = "Inlined Html";
288 static const char sigImageLocation[] = "Image Location";
289 static const char sigEnabled[] ="Signature Enabled";
290 
291 // Returns the names of all images in the HTML code
292 static QStringList findImageNames( const QString &htmlCode )
293 {
294  QStringList ret;
295 
296  // To complicated for us, so cheat and let a text edit do the hard work
297  KPIMTextEdit::TextEdit edit;
298  edit.setHtml( htmlCode );
299  foreach ( const KPIMTextEdit::ImageWithNamePtr &image, edit.imagesWithName() ) {
300  ret << image->name;
301  }
302  return ret;
303 }
304 
305 void Signature::cleanupImages() const
306 {
307  // Remove any images from the internal structure that are no longer there
308  if ( isInlinedHtml() ) {
309  foreach ( const SignaturePrivate::EmbeddedImagePtr &imageInList, d( this )->embeddedImages ) {
310  bool found = false;
311  foreach ( const QString &imageInHtml, findImageNames( mText ) ) {
312  if ( imageInHtml == imageInList->name ) {
313  found = true;
314  break;
315  }
316  }
317  if ( !found ) {
318  d( this )->embeddedImages.removeAll( imageInList );
319  }
320  }
321  }
322 
323  // Delete all the old image files
324  if ( !d( this )->saveLocation.isEmpty() ) {
325  QDir dir( d( this )->saveLocation );
326  foreach ( const QString &fileName, dir.entryList( QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks ) ) {
327  if ( fileName.toLower().endsWith( QLatin1String( ".png" ) ) ) {
328  kDebug() << "Deleting old image" << dir.path() + fileName;
329  dir.remove( fileName );
330  }
331  }
332  }
333 }
334 
335 void Signature::saveImages() const
336 {
337  if ( isInlinedHtml() && !d( this )->saveLocation.isEmpty() ) {
338  foreach ( const SignaturePrivate::EmbeddedImagePtr &image, d( this )->embeddedImages ) {
339  QString location = d( this )->saveLocation + QLatin1Char('/') + image->name;
340  if ( !image->image.save( location, "PNG" ) ) {
341  kWarning() << "Failed to save image" << location;
342  }
343  }
344  }
345 }
346 
347 void Signature::readConfig( const KConfigGroup &config )
348 {
349  QString sigType = config.readEntry( sigTypeKey );
350  if ( sigType == QLatin1String(sigTypeInlineValue) ) {
351  mType = Inlined;
352  mInlinedHtml = config.readEntry( sigTypeInlinedHtmlKey, false );
353  } else if ( sigType == QLatin1String(sigTypeFileValue) ) {
354  mType = FromFile;
355  mUrl = config.readPathEntry( sigFileKey, QString() );
356  } else if ( sigType == QLatin1String(sigTypeCommandValue) ) {
357  mType = FromCommand;
358  mUrl = config.readPathEntry( sigCommandKey, QString() );
359  } else if ( sigType == QLatin1String(sigTypeDisabledValue) ) {
360  d( this )->enabled = false;
361  }
362  if ( mType != Disabled ) {
363  d( this )->enabled = config.readEntry( sigEnabled, true );
364  }
365 
366  mText = config.readEntry( sigTextKey );
367  d( this )->saveLocation = config.readEntry( sigImageLocation );
368 
369  if ( isInlinedHtml() && !d( this )->saveLocation.isEmpty() ) {
370  QDir dir( d( this )->saveLocation );
371  foreach ( const QString &fileName, dir.entryList( QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks ) ) {
372  if ( fileName.toLower().endsWith( QLatin1String( ".png" ) ) ) {
373  QImage image;
374  if ( image.load( dir.path() + QLatin1Char('/') + fileName ) ) {
375  addImage( image, fileName );
376  }
377  else {
378  kWarning() << "Unable to load image" << dir.path() + QLatin1Char('/') + fileName;
379  }
380  }
381  }
382  }
383 }
384 
385 void Signature::writeConfig( KConfigGroup &config ) const
386 {
387  switch ( mType ) {
388  case Inlined:
389  config.writeEntry( sigTypeKey, sigTypeInlineValue );
390  config.writeEntry( sigTypeInlinedHtmlKey, mInlinedHtml );
391  break;
392  case FromFile:
393  config.writeEntry( sigTypeKey, sigTypeFileValue );
394  config.writePathEntry( sigFileKey, mUrl );
395  break;
396  case FromCommand:
397  config.writeEntry( sigTypeKey, sigTypeCommandValue );
398  config.writePathEntry( sigCommandKey, mUrl );
399  break;
400  default:
401  break;
402  }
403  config.writeEntry( sigTextKey, mText );
404  config.writeEntry( sigImageLocation, d( this )->saveLocation );
405  config.writeEntry( sigEnabled, d( this )->enabled );
406 
407  cleanupImages();
408  saveImages();
409 }
410 
411 static bool isCursorAtEndOfLine( const QTextCursor &cursor )
412 {
413  QTextCursor testCursor = cursor;
414  testCursor.movePosition( QTextCursor::EndOfLine, QTextCursor::KeepAnchor );
415  return !testCursor.hasSelection();
416 }
417 
418 static void insertSignatureHelper( const QString &signature,
419  KRichTextEdit *textEdit,
420  Signature::Placement placement,
421  bool isHtml,
422  bool addNewlines )
423 {
424  if ( !signature.isEmpty() ) {
425 
426  // Save the modified state of the document, as inserting a signature
427  // shouldn't change this. Restore it at the end of this function.
428  bool isModified = textEdit->document()->isModified();
429 
430  // Move to the desired position, where the signature should be inserted
431  QTextCursor cursor = textEdit->textCursor();
432  QTextCursor oldCursor = cursor;
433  cursor.beginEditBlock();
434 
435  if ( placement == Signature::End ) {
436  cursor.movePosition( QTextCursor::End );
437  } else if ( placement == Signature::Start ) {
438  cursor.movePosition( QTextCursor::Start );
439  } else if ( placement == Signature::AtCursor ) {
440  cursor.movePosition( QTextCursor::StartOfLine );
441  }
442  textEdit->setTextCursor( cursor );
443 
444 
445  QString lineSep;
446  if ( addNewlines ) {
447  if ( isHtml ) {
448  lineSep = QLatin1String( "<br>" );
449  } else {
450  lineSep = QLatin1Char( '\n' );
451  }
452  }
453 
454  // Insert the signature and newlines depending on where it was inserted.
455  int newCursorPos = -1;
456  QString headSep;
457  QString tailSep;
458  if ( placement == Signature::End ) {
459  // There is one special case when re-setting the old cursor: The cursor
460  // was at the end. In this case, QTextEdit has no way to know
461  // if the signature was added before or after the cursor, and just
462  // decides that it was added before (and the cursor moves to the end,
463  // but it should not when appending a signature). See bug 167961
464  if ( oldCursor.position() == textEdit->toPlainText().length() ) {
465  newCursorPos = oldCursor.position();
466  }
467  headSep = lineSep;
468  } else if ( placement == Signature::Start ) {
469  // When prepending signatures, add a couple of new lines before
470  // the signature, and move the cursor to the beginning of the QTextEdit.
471  // People tends to insert new text there.
472  newCursorPos = 0;
473  headSep = lineSep + lineSep;
474  if ( !isCursorAtEndOfLine( cursor ) ) {
475  tailSep = lineSep;
476  }
477  } else if ( placement == Signature::AtCursor ) {
478  if ( !isCursorAtEndOfLine( cursor ) ) {
479  tailSep = lineSep;
480  }
481  }
482 
483  const QString full_signature = headSep + signature + tailSep;
484  if ( isHtml ) {
485  textEdit->insertHtml( full_signature );
486  } else {
487  textEdit->insertPlainText( full_signature );
488  }
489 
490  cursor.endEditBlock();
491 
492  if ( newCursorPos != -1 ) {
493  oldCursor.setPosition( newCursorPos );
494  }
495 
496  textEdit->setTextCursor( oldCursor );
497  textEdit->ensureCursorVisible();
498 
499  textEdit->document()->setModified( isModified );
500 
501  if ( isHtml ) {
502  textEdit->enableRichTextMode();
503  }
504  }
505 }
506 
507 void Signature::insertIntoTextEdit( KRichTextEdit *textEdit,
508  Placement placement, bool addSeparator )
509 {
510  if ( !isEnabledSignature() ) {
511  return;
512  }
513  QString signature;
514  if ( addSeparator ) {
515  signature = withSeparator();
516  } else {
517  signature = rawText();
518  }
519  insertSignatureHelper( signature, textEdit, placement,
520  ( isInlinedHtml() &&
521  type() == KPIMIdentities::Signature::Inlined ),
522  true );
523 }
524 
525 void Signature::insertIntoTextEdit( Placement placement, AddedText addedText,
526  KPIMTextEdit::TextEdit *textEdit ) const
527 {
528  insertSignatureText( placement, addedText, textEdit, false );
529 }
530 
531 void Signature::insertIntoTextEdit( Placement placement, AddedText addedText,
532  KPIMTextEdit::TextEdit *textEdit, bool forceDisplay ) const
533 {
534  insertSignatureText( placement, addedText, textEdit, forceDisplay );
535 }
536 
537 void Signature::insertSignatureText(Placement placement, AddedText addedText, KPIMTextEdit::TextEdit *textEdit, bool forceDisplay) const
538 {
539  if ( !forceDisplay ) {
540  if ( !isEnabledSignature() ) {
541  return;
542  }
543  }
544  QString signature;
545  if ( addedText & AddSeparator ) {
546  signature = withSeparator();
547  } else {
548  signature = rawText();
549  }
550  insertSignatureHelper( signature, textEdit, placement,
551  ( isInlinedHtml() &&
552  type() == KPIMIdentities::Signature::Inlined ),
553  ( addedText & AddNewLines ) );
554 
555  // We added the text of the signature above, now it is time to add the images as well.
556  if ( isInlinedHtml() ) {
557  foreach ( const SignaturePrivate::EmbeddedImagePtr &image, d( this )->embeddedImages ) {
558  textEdit->loadImage( image->image, image->name, image->name );
559  }
560  }
561 }
562 
563 
564 void Signature::insertPlainSignatureIntoTextEdit( const QString &signature, KRichTextEdit *textEdit,
565  Signature::Placement placement, bool isHtml )
566 {
567  insertSignatureHelper( signature, textEdit, placement, isHtml, true );
568 }
569 
570 // --------------------- Operators -------------------//
571 
572 QDataStream &KPIMIdentities::operator<<
573 ( QDataStream &stream, const KPIMIdentities::Signature &sig )
574 {
575  return stream << static_cast<quint8>( sig.mType ) << sig.mUrl << sig.mText
576  << d( &sig )->saveLocation << d( &sig )->embeddedImages << d( &sig )->enabled;
577 }
578 
579 QDataStream &KPIMIdentities::operator>>
580 ( QDataStream &stream, KPIMIdentities::Signature &sig )
581 {
582  quint8 s;
583  stream >> s >> sig.mUrl >> sig.mText >> d( &sig )->saveLocation >> d( &sig )->embeddedImages >>d( &sig )->enabled;
584  sig.mType = static_cast<Signature::Type>( s );
585  return stream;
586 }
587 
588 bool Signature::operator== ( const Signature &other ) const
589 {
590  if ( mType != other.mType ) {
591  return false;
592  }
593 
594  if ( d( this )->enabled != d( &other )->enabled ) {
595  return false;
596  }
597 
598  if ( mType == Inlined && mInlinedHtml ) {
599  if ( d( this )->saveLocation != d( &other )->saveLocation ) {
600  return false;
601  }
602  if ( d( this )->embeddedImages != d( &other )->embeddedImages ) {
603  return false;
604  }
605  }
606 
607  switch ( mType ) {
608  case Inlined:
609  return mText == other.mText;
610  case FromFile:
611  case FromCommand:
612  return mUrl == other.mUrl;
613  default:
614  case Disabled:
615  return true;
616  }
617 }
618 
619 QString Signature::toPlainText() const
620 {
621  QString sigText = rawText();
622  if ( !sigText.isEmpty() && isInlinedHtml() && type() == Inlined ) {
623  // Use a QTextDocument as a helper, it does all the work for us and
624  // strips all HTML tags.
625  QTextDocument helper;
626  QTextCursor helperCursor( &helper );
627  helperCursor.insertHtml( sigText );
628  sigText = helper.toPlainText();
629  }
630  return sigText;
631 }
632 
633 void Signature::addImage ( const QImage& imageData, const QString& imageName )
634 {
635  Q_ASSERT( !( d( this )->saveLocation.isEmpty() ) );
636  SignaturePrivate::EmbeddedImagePtr image( new SignaturePrivate::EmbeddedImage() );
637  image->image = imageData;
638  image->name = imageName;
639  d( this )->embeddedImages.append( image );
640 }
641 
642 void Signature::setImageLocation ( const QString& path )
643 {
644  d( this )->saveLocation = path;
645 }
646 
647 // --------------- Getters -----------------------//
648 
649 QString Signature::text() const
650 {
651  return mText;
652 }
653 
654 QString Signature::url() const
655 {
656  return mUrl;
657 }
658 
659 Signature::Type Signature::type() const
660 {
661  return mType;
662 }
663 
664 // --------------- Setters -----------------------//
665 
666 void Signature::setText( const QString &text )
667 {
668  mText = text;
669  mType = Inlined;
670 }
671 
672 void Signature::setType( Type type )
673 {
674  mType = type;
675 }
676 
677 
678 void Signature::setEnabledSignature(bool enabled)
679 {
680  d( this )->enabled = enabled;
681 }
682 
683 bool Signature::isEnabledSignature() const
684 {
685  return d( this )->enabled;
686 }
QTextCursor::position
int position() const
KPIMIdentities::Signature::AtCursor
The signature is placed at the current cursor position.
Definition: signature.h:112
QString::indexOf
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
KPIMIdentities::Signature::~Signature
~Signature()
Destructor.
Definition: signature.cpp:142
QImage::load
bool load(QIODevice *device, const char *format)
QTextCursor
KPIMIdentities::Signature::AddNewLines
Add a newline character in front or after the signature, depending on the placement.
Definition: signature.h:227
QTextCursor::insertHtml
void insertHtml(const QString &html)
QByteArray
KPIMIdentities::Signature::Start
The signature is placed at the start of the textedit.
Definition: signature.h:110
KPIMIdentities::Signature::insertIntoTextEdit
void KPIMIDENTITIES_DEPRECATED insertIntoTextEdit(KRichTextEdit *textEdit, Placement placement=End, bool addSeparator=true)
Definition: signature.cpp:507
QDataStream
KPIMIdentities::Signature::setText
void setText(const QString &text)
Set the signature text and mark this signature as being of "inline text" type.
Definition: signature.cpp:666
KPIMIdentities::Signature::Signature
Signature()
Constructor for disabled signature.
Definition: signature.cpp:99
QString::remove
QString & remove(int position, int n)
KPIMIdentities::Signature::setImageLocation
void setImageLocation(const QString &path)
Sets the location where the copies of the signature images will be stored.
Definition: signature.cpp:642
KPIMIdentities::Signature::rawText
QString rawText(bool *ok=0) const
Definition: signature.cpp:147
QTextCursor::movePosition
bool movePosition(MoveOperation operation, MoveMode mode, int n)
QString::clear
void clear()
QFlags
QTextCursor::hasSelection
bool hasSelection() const
QString::fromLocal8Bit
QString fromLocal8Bit(const char *str, int size)
KPIMIdentities::Signature::setEnabledSignature
void setEnabledSignature(bool enabled)
setEnabledSignature
Definition: signature.cpp:678
KPIMIdentities::Signature::isInlinedHtml
bool isInlinedHtml() const
Definition: signature.cpp:273
QSharedPointer
QHash
KPIMIdentities::Signature::setInlinedHtml
void setInlinedHtml(bool isHtml)
Sets the inlined signature to text or html.
Definition: signature.cpp:268
KPIMIdentities::Signature::operator=
Signature & operator=(const Signature &that)
Assignment operator.
Definition: signature.cpp:132
QTextCursor::endEditBlock
void endEditBlock()
KPIMIdentities::Signature
Abstraction of a signature (aka "footer").
Definition: signature.h:89
QString::isEmpty
bool isEmpty() const
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QString::endsWith
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
QString
QList
QStringList
QFileInfo
QString::toLower
QString toLower() const
QHash::value
const T value(const Key &key) const
QLatin1Char
QTextCursor::beginEditBlock
void beginEditBlock()
KPIMIdentities::Signature::End
The signature is placed at the end of the textedit.
Definition: signature.h:111
QImage
KPIMIdentities::Signature::insertPlainSignatureIntoTextEdit
static void KPIMIDENTITIES_DEPRECATED insertPlainSignatureIntoTextEdit(const QString &signature, KRichTextEdit *textEdit, Placement placement=End, bool isHtml=false)
Inserts this given signature into the given text edit.
Definition: signature.cpp:564
QDir
KPIMIdentities::Signature::AddSeparator
The separator '– ' will be added in front of the signature.
Definition: signature.h:225
KPIMIdentities::Signature::Type
Type
Type of signature (ie.
Definition: signature.h:98
QTextDocument::toPlainText
QString toPlainText() const
QLatin1String
QTextDocument
KPIMIdentities::Signature::toPlainText
QString toPlainText() const
Returns the text of the signature.
Definition: signature.cpp:619
KPIMIdentities::Signature::withSeparator
QString withSeparator(bool *ok=0) const
Definition: signature.cpp:235
QByteArray::data
char * data()
QString::fromLatin1
QString fromLatin1(const char *str, int size)
KPIMIdentities::Signature::operator==
bool operator==(const Signature &other) const
Used for comparison.
Definition: signature.cpp:588
KPIMIdentities::Signature::setUrl
void setUrl(const QString &url, bool isExecutable=false)
Set the signature URL and mark this signature as being of "from file" resp.
Definition: signature.cpp:262
KPIMIdentities::Signature::type
Type type() const
Definition: signature.cpp:659
QByteArray::size
int size() const
KPIMIdentities::Signature::addImage
void addImage(const QImage &image, const QString &imageName)
Adds the given image to the signature.
Definition: signature.cpp:633
KPIMIdentities::Signature::Placement
Placement
Describes the placement of the signature text when it is to be inserted into a text edit...
Definition: signature.h:109
QTextCursor::setPosition
void setPosition(int pos, MoveMode m)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:46 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kpimidentities

Skip menu "kpimidentities"
  • 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