~ubuntu-branches/ubuntu/raring/kdepimlibs/raring-proposed

« back to all changes in this revision

Viewing changes to kpimtextedit/textedit.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Thomas
  • Date: 2012-05-24 21:48:49 UTC
  • mto: This revision was merged to the branch mainline in revision 120.
  • Revision ID: package-import@ubuntu.com-20120524214849-jg6g61f1r51u3mgo
Tags: upstream-4.8.80a
ImportĀ upstreamĀ versionĀ 4.8.80a

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "textedit.h"
23
23
 
24
24
#include "emailquotehighlighter.h"
 
25
#include "emoticontexteditaction.h"
25
26
 
26
27
#include <kmime/kmime_codecs.h>
27
28
 
55
56
      : actionAddImage( 0 ),
56
57
        actionDeleteLine( 0 ),
57
58
        q( parent ),
58
 
        imageSupportEnabled( false )
 
59
        imageSupportEnabled( false ),
 
60
        emoticonSupportEnabled( false )
59
61
    {
60
62
    }
61
63
 
93
95
 
94
96
    void _k_slotDeleteLine();
95
97
 
 
98
    void _k_slotAddEmoticon(const QString&);
96
99
    /// The action that triggers _k_slotAddImage()
97
100
    KAction *actionAddImage;
98
101
 
99
102
    /// The action that triggers _k_slotDeleteLine()
100
103
    KAction *actionDeleteLine;
101
104
 
 
105
    EmoticonTextEditAction *actionAddEmoticon;
102
106
    /// The parent class
103
107
    TextEdit *q;
104
108
 
105
109
    /// Whether or not adding or pasting images is supported
106
110
    bool imageSupportEnabled;
107
111
 
 
112
    bool emoticonSupportEnabled;
108
113
    /**
109
114
     * The names of embedded images.
110
115
     * Used to easily obtain the names of the images.
379
384
    actionCollection->addAction( QLatin1String( "add_image" ), d->actionAddImage );
380
385
    connect( d->actionAddImage, SIGNAL(triggered(bool)), SLOT(_k_slotAddImage()) );
381
386
  }
 
387
  if ( d->emoticonSupportEnabled ) {
 
388
    d->actionAddEmoticon = new EmoticonTextEditAction( this );
 
389
    actionCollection->addAction( QLatin1String( "add_emoticon" ), d->actionAddEmoticon );
 
390
    connect( d->actionAddEmoticon, SIGNAL(emoticonActivated(QString)), SLOT(_k_slotAddEmoticon(QString)) );
 
391
  }
382
392
 
383
393
  d->actionDeleteLine = new KAction( i18n( "Delete Line" ), this );
384
394
  d->actionDeleteLine->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_K ) );
415
425
        QTextImageFormat imageFormat = fragment.charFormat().toImageFormat();
416
426
        if ( imageFormat.isValid() && imageFormat.name() == matchName ) {
417
427
          int pos = fragment.position();
418
 
          if ( !cursorPositionsToSkip.contains( pos ) ) {
 
428
          if ( !cursorPositionsToSkip.contains( pos )  ) {
419
429
            QTextCursor cursor( document() );
420
430
            cursor.setPosition( pos );
421
431
            cursor.setPosition( pos + 1, QTextCursor::KeepAnchor );
533
543
  return retList;
534
544
}
535
545
 
 
546
void TextEditPrivate::_k_slotAddEmoticon( const QString& text)
 
547
{
 
548
  QTextCursor cursor = q->textCursor();
 
549
  cursor.insertText( text );
 
550
}
 
551
 
536
552
void TextEditPrivate::_k_slotAddImage()
537
553
{
538
554
  QPointer<KFileDialog> fdlg = new KFileDialog( QString(), QString(), q );
562
578
  return d->imageSupportEnabled;
563
579
}
564
580
 
 
581
void KPIMTextEdit::TextEdit::enableEmoticonActions()
 
582
{
 
583
  d->emoticonSupportEnabled = true;
 
584
}
 
585
 
 
586
bool KPIMTextEdit::TextEdit::isEnableEmoticonActions() const
 
587
{
 
588
  return d->emoticonSupportEnabled;
 
589
}
 
590
 
 
591
 
565
592
QByteArray KPIMTextEdit::TextEdit::imageNamesToContentIds(
566
593
  const QByteArray &htmlBody, const KPIMTextEdit::ImageList &imageList )
567
594
{