defaultdictionary.cpp

00001 
00021 #include "defaultdictionary.h"
00022 
00023 #include "broker.h"
00024 
00025 using namespace KSpell2;
00026 
00027 
00028 class DefaultDictionary::Private
00029 {
00030 public:
00031     Dictionary *dict;
00032     Broker     *broker; //not a Ptr because Broker holds DefaultDictionary
00033                         //we need it only to switch the dics
00034 };
00035 
00036 DefaultDictionary::DefaultDictionary( const QString& lang, Broker *broker )
00037     : QObject( broker ), Dictionary( lang, true )
00038 {
00039     d = new Private;
00040     d->dict = broker->dictionary();
00041     d->broker = broker;
00042     connect( broker, SIGNAL(configurationChanged()),
00043              SLOT(defaultConfigurationChanged()) );
00044 }
00045 
00046 DefaultDictionary::~DefaultDictionary()
00047 {
00048     delete d; d = 0;
00049 }
00050 
00051 bool DefaultDictionary::isValid() const
00052 {
00053     //if d->dict exists then we're valid
00054     return d->dict;
00055 }
00056 
00057 bool DefaultDictionary::check( const QString& word )
00058 {
00059     if ( d->dict )
00060         return d->dict->check( word );
00061     else
00062         return true;
00063 }
00064 
00065 QStringList DefaultDictionary::suggest( const QString& word )
00066 {
00067     if ( d->dict )
00068         return d->dict->suggest( word );
00069     else
00070         return QStringList();
00071 
00072 }
00073 
00074 bool DefaultDictionary::checkAndSuggest( const QString& word,
00075                                          QStringList& suggestions )
00076 {
00077     if ( d->dict )
00078         return d->dict->checkAndSuggest( word, suggestions );
00079     else
00080         return true;
00081 }
00082 
00083 bool DefaultDictionary::storeReplacement( const QString& bad,
00084                                           const QString& good )
00085 {
00086     if ( d->dict )
00087         return d->dict->storeReplacement( bad, good );
00088     else
00089         return false;
00090 }
00091 
00092 bool DefaultDictionary::addToPersonal( const QString& word )
00093 {
00094     if ( d->dict )
00095         return d->dict->addToPersonal( word );
00096     else
00097         return false;
00098 }
00099 
00100 bool DefaultDictionary::addToSession( const QString& word )
00101 {
00102     if ( d->dict )
00103         return d->dict->addToSession( word );
00104     else
00105         return false;
00106 }
00107 
00108 void DefaultDictionary::defaultConfigurationChanged()
00109 {
00110     delete d->dict;
00111     d->dict = d->broker->dictionary();
00112     if ( d->dict )
00113         m_language = d->dict->language();
00114     else
00115         m_language = QString::null;
00116 }
00117 
00118 #include "defaultdictionary.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys