"Fossies" - the Fresh Open Source Software Archive

Member "kydpdict-0.9.5/src/ydpdictionary.h" (20 Jan 2006, 3512 Bytes) of package /linux/privat/old/kydpdict-0.9.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ydpdictionary.h" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2  *                                                                         *
    3  *   This program is free software; you can redistribute it and/or modify  *
    4  *   it under the terms of the GNU General Public License as published by  *
    5  *   the Free Software Foundation; either version 2 of the License, or     *
    6  *   (at your option) any later version.                                   *
    7  *                                                                         *
    8  ***************************************************************************/
    9 
   10 #ifndef YDPDICTIONARY_H
   11 #define YDPDICTIONARY_H
   12 
   13 #include <qobject.h>
   14 
   15 class QListBox;
   16 class QString;
   17 
   18 class kydpConfig;
   19 class ydpConverter;
   20 
   21 // shortcuts
   22 #define color1 cnf->kFontKolor1
   23 #define color2 cnf->kFontKolor2
   24 #define color3 cnf->kFontKolor3
   25 #define color4 cnf->kFontKolor4
   26 
   27 // capabilities bits
   28 #define hasEnglish2Polish   0x00000001
   29 #define hasPolish2English   0x00000002
   30 #define hasGerman2Polish    0x00000004
   31 #define hasPolish2German    0x00000008
   32 
   33 class ydpDictionary : public QObject {
   34     Q_OBJECT
   35 public:
   36     ydpDictionary(kydpConfig *config, QListBox *listBox, ydpConverter *converter);
   37     virtual ~ydpDictionary();
   38 
   39     virtual int OpenDictionary(void);
   40     virtual int CheckDictionary(void);
   41     virtual void CloseDictionary(void);
   42     // return capabilities bits
   43     int GetDictionaryInfo(void);
   44 
   45     QString GetDefinition(int index);
   46     int Play (int index, kydpConfig *config);
   47     // return number of all/grammar/category tips
   48     virtual int GetTipNumber(int type);
   49     // return abbreviated part of tip
   50     virtual QString GetInputTip(int index);
   51     // return description part of tip
   52     virtual QString GetOutputTip(int index);
   53     // create a page with tips and their meanings
   54     // assumed: abbr. with lowercase - grammar, UPPERCASE - category
   55     virtual QString GetInfoPage(void);
   56     void ListScrollUp(int offset);
   57     void ListScrollDown(int offset);
   58     // find best match
   59     virtual int FindWord(QString word);
   60 
   61     int topitem;
   62     int wordCount;          /* number of words */
   63 
   64 private:
   65     // read a definition, convert from local encoding, store in curDefinition
   66     virtual int ReadDefinition (int index);
   67     // convert definition into qt-html enriched text
   68     virtual QString rtf2html (QString definition);
   69     // return filename of audio sample
   70     virtual QString SampleName(QString path, int index);
   71     // update internal dictionary files names w/ respect to language and direction
   72     virtual void UpdateFName(void);
   73     // return a tip from tips table according to index, always override this if tips present
   74     virtual QString GetTip(int index);
   75 
   76     // GUI element holding index
   77     QListBox    *dictList;
   78 
   79 protected:
   80     unsigned short fix16(unsigned short x);
   81     unsigned int fix32(unsigned int x);
   82     QString stripDelimiters(QString word);
   83 
   84     // configuration holder
   85     kydpConfig *cnf;
   86     // text converter
   87     ydpConverter *cvt;
   88 
   89     struct dictionaryCache {
   90         int wordCount;
   91         char **words;
   92     } dictCache[4];
   93 
   94     char** words;           /* actual words */
   95     QString curDefinition;      /* contains current definition (RTF)*/
   96 
   97 public slots:
   98     void ListRefresh (int index);
   99     void ListScroll1Up();
  100     void ListScroll1Down();
  101     void ListScrollPageUp();
  102     void ListScrollPageDown();
  103 
  104 signals:
  105     void dictionaryChanged(const int wordnum = -1, char **words = NULL, ydpConverter *converter = NULL);
  106 };
  107 
  108 class KeyEater : public QObject {
  109     public:
  110     KeyEater(ydpDictionary* parent);
  111     ~KeyEater();
  112     protected:
  113     bool eventFilter( QObject *o, QEvent *e );
  114     private:
  115     ydpDictionary *myDict;
  116 };
  117 
  118 #endif