french -> French
[kdepim.git] / knode / kncomposereditor.cpp
blobc4bce6abf7b240013ff3ba8c640ceafa795c37cb
1 /**
2 * kncomposereditor.cpp
4 * Copyright (C) 2008 Laurent Montel <montel@kde.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA
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>
30 KNComposerEditor::KNComposerEditor( QWidget *parent)
31 :KMeditor(parent)
33 setSpellCheckingConfigFileName( KNGlobals::self()->config()->name() );
36 KNComposerEditor::~KNComposerEditor()
40 void KNComposerEditor::changeHighlighterColors(KPIMTextEdit::EMailQuoteHighlighter * highlighter )
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 );
52 highlighter->setQuoteColor(col1, col2, col3, col4);
55 void KNComposerEditor::slotRot13()
57 QTextCursor cursor = textCursor();
58 if ( cursor.hasSelection() )
59 insertPlainText( MessageComposer::Util::rot13( cursor.selectedText() ) );
60 //FIXME: breaks HTML formatting
64 void KNComposerEditor::slotRemoveBox()
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();
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;
84 setAutoUpdate(false);
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);
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);
119 setCursorPosition(l,c-2);
121 setAutoUpdate(true);
122 repaint();
124 #endif
127 void KNComposerEditor::slotAddBox()
129 MessageComposer::Util::addTextBox(this);