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

knode

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

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