4
Copyright (c) 2003 by Roberto Pariset <victorheremita@fastwebnet.it>
5
Copyright (c) 2003 by Martijn Klingens <klingens@kde.org>
7
Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
9
*************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
*************************************************************************
19
#include "autoreplaceconfig.h"
24
#include <kconfiggroup.h>
27
AutoReplaceConfig::AutoReplaceConfig()
32
// reload configuration reading it from kopeterc
33
void AutoReplaceConfig::load()
35
KConfigGroup config(KGlobal::config(), "AutoReplace Plugin");
37
QStringList wordsList = config.readEntry( "WordsToReplace", QStringList() );
38
if( wordsList.isEmpty() )
40
// basic list, key/value
41
// a list based on i18n should be provided, i.e. for italian
42
// "qsa,qualcosa,qno,qualcuno" remember UTF-8 accents
43
wordsList = defaultAutoReplaceList();
46
// we may be reloading after removing an entry from the list
49
for ( QStringList::ConstIterator it = wordsList.constBegin(); it != wordsList.constEnd(); ++it )
53
if( it == wordsList.constEnd() )
59
m_autoreplaceIncoming = config.readEntry( "AutoReplaceIncoming" , false );
60
m_autoreplaceOutgoing = config.readEntry( "AutoReplaceOutgoing" , true );
61
m_addDot = config.readEntry( "DotEndSentence" , false );
62
m_upper = config.readEntry( "CapitalizeBeginningSentence" , false );
65
QStringList AutoReplaceConfig::defaultAutoReplaceList()
67
return i18nc( "list_of_words_to_replace",
68
"ur,your,r,are,u,you,theres,there is,arent,are not,dont,do not" ).split( ',', QString::SkipEmptyParts );
71
void AutoReplaceConfig::loadDefaultAutoReplaceList()
73
const QStringList wordsList = defaultAutoReplaceList();
76
for ( QStringList::ConstIterator it = wordsList.constBegin(); it != wordsList.constEnd(); ++it )
85
bool AutoReplaceConfig::autoReplaceIncoming() const
87
return m_autoreplaceIncoming;
90
bool AutoReplaceConfig::autoReplaceOutgoing() const
92
return m_autoreplaceOutgoing;
95
bool AutoReplaceConfig::dotEndSentence() const
100
bool AutoReplaceConfig::capitalizeBeginningSentence() const
105
void AutoReplaceConfig::setAutoReplaceIncoming(bool enabled)
107
m_autoreplaceIncoming = enabled;
110
void AutoReplaceConfig::setAutoReplaceOutgoing(bool enabled)
112
m_autoreplaceOutgoing = enabled;
115
void AutoReplaceConfig::setDotEndSentence(bool enabled)
120
void AutoReplaceConfig::setCapitalizeBeginningSentence(bool enabled)
126
void AutoReplaceConfig::setMap( const WordsToReplace &w )
131
AutoReplaceConfig::WordsToReplace AutoReplaceConfig::map() const
136
void AutoReplaceConfig::save()
138
KConfigGroup config(KGlobal::config(), "AutoReplace Plugin" );
140
QStringList newWords;
141
WordsToReplace::ConstIterator it;
142
for ( it = m_map.constBegin(); it != m_map.constEnd(); ++it )
144
newWords.append( it.key() );
145
newWords.append( it.value() );
148
config.writeEntry( "WordsToReplace", newWords );
150
config.writeEntry( "AutoReplaceIncoming" , m_autoreplaceIncoming );
151
config.writeEntry( "AutoReplaceOutgoing" , m_autoreplaceOutgoing );
152
config.writeEntry( "DotEndSentence" , m_addDot );
153
config.writeEntry( "CapitalizeBeginningSentence" , m_upper );
158
// vim: set noet ts=4 sts=4 sw=4: