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

knode

  • sources
  • kde-4.14
  • kdepim
  • knode
kncomposereditor.cpp
Go to the documentation of this file.
1 
22 #include "kncomposereditor.h"
23 #include "knglobals.h"
24 #include "utilities.h"
25 #include <KPIMTextEdit/EMailQuoteHighlighter>
26 #include <KConfigGroup>
27 #include <QApplication>
28 #include <messagecomposer/utils/util.h>
29 
30 KNComposerEditor::KNComposerEditor( QWidget *parent)
31  :KMeditor(parent)
32 {
33  setSpellCheckingConfigFileName( KNGlobals::self()->config()->name() );
34 }
35 
36 KNComposerEditor::~KNComposerEditor()
37 {
38 }
39 
40 void KNComposerEditor::changeHighlighterColors(KPIMTextEdit::EMailQuoteHighlighter * highlighter )
41 {
42  KConfigGroup config( knGlobals.config(), "VISUAL_APPEARANCE" );
43  QColor defaultColor1( 0x00, 0x80, 0x00 ); // defaults from kmreaderwin.cpp
44  QColor defaultColor2( 0x00, 0x70, 0x00 );
45  QColor defaultColor3( 0x00, 0x60, 0x00 );
46  QColor defaultForeground( qApp->palette().color( QPalette::Text ) );
47  QColor col1 = config.readEntry( "ForegroundColor", defaultForeground );
48  QColor col2 = config.readEntry( "quote3Color", defaultColor3 );
49  QColor col3 = config.readEntry( "quote2Color", defaultColor2 );
50  QColor col4 = config.readEntry( "quote1Color", defaultColor1 );
51 
52  highlighter->setQuoteColor(col1, col2, col3, col4);
53 }
54 
55 void KNComposerEditor::slotRot13()
56 {
57  QTextCursor cursor = textCursor();
58  if ( cursor.hasSelection() )
59  insertPlainText( MessageComposer::Util::rot13( cursor.selectedText() ) );
60  //FIXME: breaks HTML formatting
61 }
62 
63 
64 void KNComposerEditor::slotRemoveBox()
65 {
66  //Laurent: fix me
67 #if 0
68  if (hasMarkedText()) {
69  QString s = QString::fromLatin1("\n") + markedText() + QString::fromLatin1("\n");
70  s.replace(QRegExp("\n,----[^\n]*\n"),"\n");
71  s.replace(QRegExp("\n| "),"\n");
72  s.replace(QRegExp("\n`----[^\n]*\n"),"\n");
73  s.remove(0,1);
74  s.truncate(s.length()-1);
75  insert(s);
76  } else {
77  int l = currentLine();
78  int c = currentColumn();
79 
80  QString s = textLine(l); // test if we are in a box
81  if (!((s.left(2) == "| ")||(s.left(5)==",----")||(s.left(5)=="`----")))
82  return;
83 
84  setAutoUpdate(false);
85 
86  // find & remove box begin
87  int x = l;
88  while ((x>=0)&&(textLine(x).left(5)!=",----"))
89  x--;
90  if ((x>=0)&&(textLine(x).left(5)==",----")) {
91  removeLine(x);
92  l--;
93  for (int i=x;i<=l;++i) { // remove quotation
94  s = textLine(i);
95  if (s.left(2) == "| ") {
96  s.remove(0,2);
97  insertLine(s,i);
98  removeLine(i+1);
99  }
100  }
101  }
102 
103  // find & remove box end
104  x = l;
105  while ((x<numLines())&&(textLine(x).left(5)!="`----"))
106  x++;
107  if ((x<numLines())&&(textLine(x).left(5)=="`----")) {
108  removeLine(x);
109  for (int i=l+1;i<x;++i) { // remove quotation
110  s = textLine(i);
111  if (s.left(2) == "| ") {
112  s.remove(0,2);
113  insertLine(s,i);
114  removeLine(i+1);
115  }
116  }
117  }
118 
119  setCursorPosition(l,c-2);
120 
121  setAutoUpdate(true);
122  repaint();
123  }
124 #endif
125 }
126 
127 void KNComposerEditor::slotAddBox()
128 {
129  MessageComposer::Util::addTextBox(this);
130 }
kncomposereditor.h
QWidget
QString::truncate
void truncate(int position)
QTextCursor
utilities.h
QTextCursor::selectedText
QString selectedText() const
KNGlobals::self
static KNGlobals * self()
Return the KNGlobals instance.
Definition: knglobals.cpp:72
QString::remove
QString & remove(int position, int n)
QRegExp
QTextCursor::hasSelection
bool hasSelection() const
KNComposerEditor::KNComposerEditor
KNComposerEditor(QWidget *parent=0)
Constructs a KNComposerEditor object.
Definition: kncomposereditor.cpp:30
QString
QColor
KNComposerEditor::slotRot13
void slotRot13()
Warning: This function switches back to plain text mode.
Definition: kncomposereditor.cpp:55
knglobals.h
QString::replace
QString & replace(int position, int n, QChar after)
KNComposerEditor::~KNComposerEditor
virtual ~KNComposerEditor()
Definition: kncomposereditor.cpp:36
QString::length
int length() const
QString::left
QString left(int n) const
QString::fromLatin1
QString fromLatin1(const char *str, int size)
KMeditor
knGlobals
#define knGlobals
Keep compatibility with the old way.
Definition: knglobals.h:28
KNComposerEditor::changeHighlighterColors
virtual void changeHighlighterColors(KPIMTextEdit::EMailQuoteHighlighter *highlighter)
Definition: kncomposereditor.cpp:40
KNComposerEditor::slotAddBox
void slotAddBox()
Definition: kncomposereditor.cpp:127
KNComposerEditor::slotRemoveBox
void slotRemoveBox()
Definition: kncomposereditor.cpp:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knode

Skip menu "knode"
  • Main Page
  • Namespace List
  • 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
  • pimprint

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