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

kiten/lib

Public Member Functions | Static Public Member Functions | List of all members
DictionaryManager Class Reference

#include <dictionarymanager.h>

Public Member Functions

 DictionaryManager ()
 
virtual ~DictionaryManager ()
 
bool addDictionary (const QString &file, const QString &name, const QString &type)
 
EntryList * doSearch (const DictQuery &query) const
 
EntryList * doSearchInList (const DictQuery &query, const EntryList *list) const
 
QStringList listDictionaries () const
 
QStringList listDictionariesOfType (const QString &type) const
 
QPair< QString, QString > listDictionaryInfo (const QString &name) const
 
void loadDictSettings (const QString &dict, KConfigSkeleton *config)
 
void loadSettings (const KConfig &config)
 
void removeAllDictionaries ()
 
bool removeDictionary (const QString &name)
 

Static Public Member Functions

static QMap< QString, QString > generateExtendedFieldsList ()
 
static QMap< QString,
DictionaryPreferenceDialog * > 
generatePreferenceDialogs (KConfigSkeleton *config, QWidget *parent=NULL)
 
static QStringList listDictFileTypes ()
 

Detailed Description

The DictionaryManager class is the fundamental dictionary management class.

All interfaces with the rest of the programs using the various dictionaries will work through this "interface class" to keep the formatting and other such nasty details away from programs and sections which just want to use the dictionary without bothering with the internal formatting details. As a general rule, call this class with a DictQuery to get a list of entries as the result.

The idea is that the interfaces need to know how to load a query, pass the query to dictionary. DictionaryManager will return to them an EntryList object, each Entry knows how to display itself (via the magic of C++ polymorphism). There are some setup and preference handling methods which complicate things, but generally speaking this is the way this should work.

Author
Joseph Kerian jkeri.nosp@m.an@g.nosp@m.mail..nosp@m.com

Definition at line 58 of file dictionarymanager.h.

Constructor & Destructor Documentation

DictionaryManager::DictionaryManager ( )

Basic constructor.

The constructor.

Set autodelete on our dictionary list

Definition at line 77 of file dictionarymanager.cpp.

DictionaryManager::~DictionaryManager ( )
virtual

Basic destructor.

Delete everything in our hash.

Definition at line 85 of file dictionarymanager.cpp.

Member Function Documentation

bool DictionaryManager::addDictionary ( const QString &  file,
const QString &  name,
const QString &  type 
)

Open a specified dictionary, and load it under this manager's control.

Given a named Dict file/name/type...

Parameters
filethe filename, suitable for using with QFile::setFileName()
namethe name of the file, which may be related to file, but perhaps not, for all future dealings with this file, this name will be the key value
typethe known dictionary type of this file

create and add the object if it seems to work properly on creation.

Definition at line 104 of file dictionarymanager.cpp.

EntryList * DictionaryManager::doSearch ( const DictQuery &  query) const

This is the main search routine that most of kiten should use.

Examine the DictQuery and farm out the search to the specialized dict managers.

Parameters
querythe DictQuery object describing the search to conduct

Note that a global search limit will probably be implemented either here or in the DictFile implementations... probably both

Parameters
querythe query, see DictQuery documentation

Definition at line 138 of file dictionarymanager.cpp.

EntryList * DictionaryManager::doSearchInList ( const DictQuery &  query,
const EntryList *  list 
) const

A simple method for searching inside of a given set of results.

For this case, we let polymorphism do most of the work.

Parameters
querythe new query that will pare down our results list, there is no requirement that this query includes the query that generated the EntryList, the results are calculated only out of the second parameter
listthe list of results to search for the above query in

We assume that the user wants to pare down the results, so we let the individual entry metching methods run over the new query and accept (and copy) any of those that pass.

Definition at line 198 of file dictionarymanager.cpp.

QMap< QString, QString > DictionaryManager::generateExtendedFieldsList ( )
static

Compiles a list of all fields beyond the basic three (word/pronunciation/meaning) that all dictionary types support.

This can be used to generate a preference dialog, or provide more direct references. The return value is "full name of the field" => "abbreviation useable in search string"

Definition at line 215 of file dictionarymanager.cpp.

QMap< QString, DictionaryPreferenceDialog * > DictionaryManager::generatePreferenceDialogs ( KConfigSkeleton *  config,
QWidget *  parent = NULL 
)
static

Given a config and parent widget, return a mapping from dictionary types to preference dialogs.

If a particular dictionary type does not provide a preference dialog, it will not be included in this list, so occasionally keys(returnvalue) != listDictFileTypes()

Parameters
configthe config skeleton
parentthe parent widget, as per the normal Qt widget system

Definition at line 239 of file dictionarymanager.cpp.

QStringList DictionaryManager::listDictFileTypes ( )
static

Get a list of all supported dictionary types.

IMPORTANT: To add a dictionary type, you have to manually add the creation step here, the prev method, and #include your header file above.

Useful for preference code

If you have fully implemented the interface in DictionaryManager.h, It should simply work.

Definition at line 277 of file dictionarymanager.cpp.

QStringList DictionaryManager::listDictionaries ( ) const

List names of each open dictionary.

Return a list of the dictionaries by their name (our key) Note that this dictionary name does not necessarily have to have anything to do with the actual dictionary name...

Definition at line 261 of file dictionarymanager.cpp.

QStringList DictionaryManager::listDictionariesOfType ( const QString &  type) const

Lists all dictionaries of a given type (Convenient for preference dialogs)

Return a list of the names of each dictionary of a given type.

Parameters
typethe type of dictionaries to list
typethe type of the dictionary we want a list of

Definition at line 309 of file dictionarymanager.cpp.

QPair< QString, QString > DictionaryManager::listDictionaryInfo ( const QString &  name) const

Returns type and file for an open dictionary of a given.

Return the dictionary type and file used by a named dictionary.

Parameters
namethe name of the dictionary whose information we are looking for

returns a pair of empty QStrings if you specify an invalid name

Parameters
namethe name of the dictionary, as given in the addDictionary method

Definition at line 294 of file dictionarymanager.cpp.

void DictionaryManager::loadDictSettings ( const QString &  dict,
KConfigSkeleton *  config 
)

Trigger loading preferences from a given KConfigSkeleton config object for a dictionary of type dict.

Load preference settings for a particular dictionary.

Parameters
dictthe dictionary type to load settings for
configthe config skeleton object

Definition at line 329 of file dictionarymanager.cpp.

void DictionaryManager::loadSettings ( const KConfig &  config)

Load general settings.

Definition at line 339 of file dictionarymanager.cpp.

void DictionaryManager::removeAllDictionaries ( )

Removes all previously loaded dictionaries (if any).

Definition at line 365 of file dictionarymanager.cpp.

bool DictionaryManager::removeDictionary ( const QString &  name)

Close a dictionary by name.

Remove a dictionary from the list, and delete the dictionary object (it should close files, deallocate memory, etc).

Parameters
namethe name of the dictionary file, as given in addDictionary
namethe name of the dictionary, as given in the addDictionary method

Definition at line 376 of file dictionarymanager.cpp.


The documentation for this class was generated from the following files:
  • dictionarymanager.h
  • dictionarymanager.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:16:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kiten/lib

Skip menu "kiten/lib"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

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