00001 #ifndef UTIL_H
00002 #define UTIL_H
00003
00004 #include <stdio.h>
00005 #include <qaction.h>
00006 #include <qdir.h>
00007 #include <qfont.h>
00008 #include <qfontdatabase.h>
00009 #include <qlistview.h>
00010 #include <qmap.h>
00011 #include <qstringlist.h>
00012 #include <qtextstream.h>
00013 #include <qvaluelist.h>
00014 #include <zlib.h>
00015 #include <stdlib.h>
00016 #include "Base.h"
00017 #include "PixMap.h"
00018 #include "Term.h"
00019
00020 typedef QValueList<int> IdList;
00021 typedef QMap<int,IdList> IdListMap;
00022
00023 enum Action {
00024 ACTION_REVEAL = 0,
00025 ACTION_RIGHT_ANSWER,
00026 ACTION_WRONG_ANSWER,
00027 ACTION_EDIT_QUIZ_TERM,
00028 ACTION_START_QUIZ,
00029 ACTION_MANAGE_GLOSSARIES,
00030 ACTION_IMPORT,
00031 ACTION_EXPORT,
00032 ACTION_SHOW_ALL_GLOSSARIES_AND_TERMS,
00033 ACTION_PREFERENCES,
00034 ACTION_QUIT,
00035 ACTION_ADD_FOLDER,
00036 ACTION_ADD_GLOSSARY,
00037 ACTION_REMOVE_ITEM,
00038 ACTION_ADD_TERM,
00039 ACTION_EDIT_TERM,
00040 ACTION_REMOVE_TERMS,
00041 ACTION_CHECK_ALL_TERMS,
00042 ACTION_INVERSE_CHECKED_TERMS,
00043 ACTION_MAXIMIZE,
00044 ACTION_SEARCH,
00045 ACTION_COUNT
00046 };
00047
00048 const QString actionId[] = {
00049 "reveal",
00050 "rightAnswer",
00051 "wrongAnswer",
00052 "editQuizTerm",
00053 "startQuiz",
00054 "manageGlossaries",
00055 "import",
00056 "export",
00057 "showAllGlossariesAndTerms",
00058 "preferences",
00059 "quit",
00060 "addFolder",
00061 "addGlossary",
00062 "removeItem",
00063 "addTerm",
00064 "editTerm",
00065 "removeTerms",
00066 "checkAllTerms",
00067 "inverseCheckedTerms",
00068 "maximize",
00069 "search"
00070 };
00071
00072 class Util {
00073
00074 public:
00075
00076 static const QString languageCodeList[];
00077 static const QString& getLanguageCode( const QString& language );
00078
00079 static QString escapeXml( QString xml );
00080 static bool makeDirectory( const QString& dir );
00081 static bool copy( const QString& fromFile, const QString& toFile );
00082 static bool deleteDirectory( const QString& dir );
00083 static QString term2Xml( const Term& term, QStringList* languages = NULL, uint indentLevel = 0 );
00084 static int getDefaultQuizLength();
00085 static QString getDefaultLabelsFontFamily();
00086 static int getDefaultLabelsFontSizeModifier();
00087 static QString getDefaultFontFamily();
00088 static int getDefaultFontSizeModifier();
00089
00090 static QString getDigraph( const QString& buffer );
00091 static QAction* createAction( const QString& name, const char** icon, QObject* receiver, const char* slot, int defaultKey = -1, bool toggle = false );
00092 static QString describeKey( int key );
00093
00094
00095 static QByteArray qCompress( const QByteArray& byteArray, int compressionLevel = -1 );
00096 static QByteArray qUncompress( const QByteArray& byteArray );
00097
00098 private:
00099
00100 static QMap<QString, QString>* digraphMap;
00101
00102 static void initDigraphs();
00103
00104 };
00105
00106 #endif