stardict.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*****************************************************************************
  2. * stardict.h - QStarDict, a StarDict clone written using Qt *
  3. * Copyright (C) 2008 Alexander Rodin *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License along *
  16. * with this program; if not, write to the Free Software Foundation, Inc., *
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
  18. *****************************************************************************/
  19. #ifndef STARDICT_H
  20. #define STARDICT_H
  21. #include "lib.h"
  22. #include "../dictplugin.h"
  23. #include <string>
  24. #include <QVector>
  25. #include <QHash>
  26. class StarDict: public QObject, public QStarDict::DictPlugin
  27. {
  28. Q_OBJECT
  29. #if QT_VERSION >= 0x050000
  30. Q_PLUGIN_METADATA(IID "org.qstardict.DictPlugin/1.0" FILE "stardict.json")
  31. #endif
  32. Q_INTERFACES(QStarDict::DictPlugin)
  33. public:
  34. StarDict(QObject *parent = 0);
  35. ~StarDict();
  36. QString name() const
  37. { return "stardict"; }
  38. QString version() const
  39. { return "0.1"; }
  40. QString description() const
  41. { return "The StarDict plugin"; }
  42. QStringList authors() const
  43. { return QStringList()
  44. << "Hu Zheng <huzheng_001@163.com>"
  45. << "Opera Wang <wangvisual@sohu.com>"
  46. << "Alexander Rodin <rodin.alexander@gmail.com>"; }
  47. Features features() const
  48. { return Features(SearchSimilar | SettingsDialog); }
  49. QStringList availableDicts() const;
  50. QStringList loadedDicts() const
  51. { return m_loadedDicts.keys(); }
  52. void setLoadedDicts(const QStringList &loadedDicts);
  53. DictInfo dictInfo(const QString &dict);
  54. bool isTranslatable(const QString &dict, const QString &word);
  55. Translation translate(const QString &dict, const QString &word);
  56. virtual QStringList findSimilarWords(const QString &dict, const QString &word);
  57. int execSettingsDialog(QWidget *parent);
  58. friend class SettingsDialog;
  59. private:
  60. QString parseData(const char *data, int dictIndex = -1,
  61. bool htmlSpaces = false, bool reformatLists = false, bool expandAbbreviations = false);
  62. Libs *m_sdLibs;
  63. QStringList m_dictDirs;
  64. QHash<QString, int> m_loadedDicts;
  65. bool m_reformatLists;
  66. bool m_expandAbbreviations;
  67. };
  68. #endif // STARDICT_H
  69. // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent