diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cb91c2..ecc71cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,61 +1,79 @@ #Name the project project(kiten) cmake_minimum_required( VERSION 2.8.12 ) #ECM setup find_package(ECM 1.7 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) find_package(Qt5 REQUIRED COMPONENTS Core Widgets) find_package(KF5 5.15 REQUIRED COMPONENTS Archive Completion Config ConfigWidgets CoreAddons Crash DocTools I18n KHtml Notifications XmlGui) include(KDEInstallDirs) include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(ECMInstallIcons) -include( CheckIncludeFiles ) +include(CheckIncludeFiles) include(ECMGenerateHeaders) include(ECMAddAppIcon) +include(ECMMarkNonGuiExecutable) +include(GenerateExportHeader) ## Make it easy for radselect and kiten to find libkiten headers -include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/lib) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib) include_directories(${CMAKE_CURRENT_BINARY_DIR}) +## Find mman.h on Windows +if(WIN32) + find_path(MMAN_INCLUDE_PATH NAMES sys/mman.h) + if(NOT MMAN_INCLUDE_PATH) + message(FATAL_ERROR "On Windows, you need to install mman-win32 headers.") + endif() + message(STATUS "Found mman-win32 include: ${MMAN_INCLUDE_PATH}") + + find_library(MMAN_LIBRARY NAMES mman) + if(NOT MMAN_LIBRARY) + message(FATAL_ERROR "On Windows, you need to install mman-win32 library.") + endif() + message(STATUS "Found mman-win32 library: ${MMAN_LIBRARY}") +endif(WIN32) + ## Generate config.h check_include_files(stdint.h HAVE_STDINT_H) check_include_files(inttypes.h HAVE_INTTYPES_H) configure_file( config-kiten.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kiten.h ) add_definitions(-DTRANSLATION_DOMAIN=\"kiten\") ## Build each subdir add_subdirectory( app ) add_subdirectory( data/font ) add_subdirectory( data/pics ) add_subdirectory( doc ) add_subdirectory( kanjibrowser ) add_subdirectory( lib ) add_subdirectory( radselect ) ## Build kitengen, a small index generator used by the kiten app set(kitengen_SRCS xjdxgen.c) add_executable(kitengen ${kitengen_SRCS}) +ecm_mark_nongui_executable(kitengen) target_link_libraries(kitengen ${QT_QTCORE_LIBRARY}) install( TARGETS kitengen ${INSTALL_TARGETS_DEFAULT_ARGS} ) install(FILES org.kde.kiten.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) ## Install our datafiles install( FILES data/edict data/kanjidic data/radkfile data/vconj data/romkana.cnv DESTINATION ${DATA_INSTALL_DIR}/kiten ) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b8a4cf0..8d4a6fe 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,58 +1,65 @@ ############# kitenlib ################# set(KITEN_LIB_VERSION "5.0.0") set(KITEN_LIB_SOVERSION "5") set(edict_SRCS DictEdict/deinflection.cpp DictEdict/dictfileedict.cpp DictEdict/entryedict.cpp DictEdict/indexededictfile.cpp DictEdict/linearedictfile.cpp DictEdict/dictfilefieldselector.cpp) set(kanjidic_SRCS DictKanjidic/dictfilekanjidic.cpp DictKanjidic/entrykanjidic.cpp) set(dictionary_SRCS ${edict_SRCS} ${kanjidic_SRCS}) set(kiten_LIB_SRCS dictionarymanager.cpp dictionarypreferencedialog.cpp dictquery.cpp entry.cpp entrylist.cpp historyptrlist.cpp kromajiedit.cpp ${dictionary_SRCS}) add_library(kiten SHARED ${kiten_LIB_SRCS}) -target_link_libraries(kiten - Qt5::Core - Qt5::Widgets - KF5::Completion - KF5::ConfigCore - KF5::ConfigGui - KF5::CoreAddons - KF5::I18n - KF5::WidgetsAddons) +generate_export_header(kiten) + +target_link_libraries(kiten + Qt5::Core + Qt5::Widgets + KF5::Completion + KF5::ConfigCore + KF5::ConfigGui + KF5::CoreAddons + KF5::I18n + KF5::WidgetsAddons) + +if(WIN32) + target_include_directories(kiten PRIVATE ${MMAN_INCLUDE_PATH}) + target_link_libraries(kiten ${MMAN_LIBRARY}) +endif() + set_target_properties(kiten PROPERTIES VERSION ${KITEN_LIB_VERSION} SOVERSION ${KITEN_LIB_SOVERSION}) install( TARGETS kiten ${INSTALL_TARGETS_DEFAULT_ARGS}) ############ install headers ############# install( FILES dictionarymanager.h dictionarypreferencedialog.h dictquery.h entry.h entrylist.h historyptrlist.h kromajiedit.h - libkitenexport.h DESTINATION ${INCLUDE_INSTALL_DIR}/libkiten COMPONENT Devel ) install(FILES DictEdict/dictfileedict.h DictEdict/entryedict.h DESTINATION ${INCLUDE_INSTALL_DIR}/libkiten/DictEdict COMPONENT Devel) install(FILES DictKanjidic/dictfilekanjidic.h DictKanjidic/entrykanjidic.h DESTINATION ${INCLUDE_INSTALL_DIR}/libkiten/DictKanjidic COMPONENT Devel) diff --git a/lib/DictEdict/dictfileedict.h b/lib/DictEdict/dictfileedict.h index f91649b..8867e19 100644 --- a/lib/DictEdict/dictfileedict.h +++ b/lib/DictEdict/dictfileedict.h @@ -1,88 +1,88 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2001 Jason Katz-Brown * * Copyright (C) 2006 Joseph Kerian * * Copyright (C) 2006 Eric Kjeldergaard * * Copyright (C) 2011 Daniel E. Moctezuma * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_DICTFILEEDICT_H #define KITEN_DICTFILEEDICT_H #include #include "dictfile.h" #include "indexededictfile.h" -#include "libkitenexport.h" +#include "kiten_export.h" #include "linearedictfile.h" #include #include class Deinflection; class DictQuery; class DictionaryPreferenceDialog; class EntryEdict; class KConfigSkeleton; class KConfigSkeletonItem; class QString; class QStringList; class KITEN_EXPORT DictFileEdict : public DictFile { friend class EntryEdict; public: DictFileEdict(); virtual ~DictFileEdict(); EntryList *doSearch( const DictQuery &query ) Q_DECL_OVERRIDE; QStringList listDictDisplayOptions( QStringList x ) const Q_DECL_OVERRIDE; bool loadDictionary( const QString &file , const QString &name ) Q_DECL_OVERRIDE; void loadSettings(); void loadSettings( KConfigSkeleton *config ) Q_DECL_OVERRIDE; DictionaryPreferenceDialog *preferencesWidget( KConfigSkeleton *config , QWidget *parent = NULL ) Q_DECL_OVERRIDE; bool validDictionaryFile( const QString &filename ) Q_DECL_OVERRIDE; bool validQuery( const DictQuery &query ) Q_DECL_OVERRIDE; static QString *deinflectionLabel; static QString *wordType; protected: virtual QMap displayOptions() const; QStringList *loadListType( KConfigSkeletonItem *item , QStringList *list , const QMap &long2short ); //This is a blatant abuse of protected methods to make the kanji subclass easy virtual Entry *makeEntry( const QString &entry ); LinearEdictFile m_edictFile; static QStringList *displayFields; private: QMap loadDisplayOptions() const; Deinflection *m_deinflection; bool m_hasDeinflection; }; #endif diff --git a/lib/DictEdict/entryedict.h b/lib/DictEdict/entryedict.h index 6bdee7a..6b631dd 100644 --- a/lib/DictEdict/entryedict.h +++ b/lib/DictEdict/entryedict.h @@ -1,113 +1,113 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2006 Joseph Kerian * * Copyright (C) 2006 Eric Kjeldergaard * * Copyright (C) 2011 Daniel E. Moctezuma #include #include #ifndef KITEN_EDICTFORMATTING #define KITEN_EDICTFORMATTING namespace EdictFormatting { extern QStringList Nouns; extern QStringList Verbs; extern QStringList Adjectives; extern QStringList Adverbs; extern QStringList IchidanVerbs; extern QStringList GodanVerbs; extern QStringList FukisokuVerbs; extern QStringList Expressions; extern QStringList Prefix; extern QStringList Suffix; extern QString Particle; extern QMultiHash PartOfSpeechCategories; extern QSet PartsOfSpeech; extern QSet MiscMarkings; extern QSet FieldOfApplication; } #endif class KITEN_EXPORT EntryEdict : public Entry { friend class DictFileEdict; public: // EntryEdict( const EntryEdict &x ) : Entry( x ) {} //No special members to copy in this one EntryEdict( const QString &dict ); EntryEdict( const QString &dict, const QString &entry ); Entry *clone() const Q_DECL_OVERRIDE; /** * Simple accessor. */ QString getTypes() const; /** * Simple accessor. */ QStringList getTypesList() const; bool isAdjective() const; bool isAdverb() const; bool isCommon() const; bool isExpression() const; bool isFukisokuVerb() const; bool isGodanVerb() const; bool isIchidanVerb() const; bool isNoun() const; bool isParticle() const; bool isPrefix() const; bool isSuffix() const; bool isVerb() const; bool matchesWordType( const DictQuery &query ) const; QString dumpEntry() const Q_DECL_OVERRIDE; QString getDictionaryType() const Q_DECL_OVERRIDE; QString HTMLWord() const Q_DECL_OVERRIDE; bool loadEntry( const QString &entryLine ) Q_DECL_OVERRIDE; QString toHTML() const Q_DECL_OVERRIDE; protected: virtual QString kanjiLinkify( const QString &inString ) const; private: /** * Types that match this entry (i.e. n, adj, adv). */ QStringList m_types; //Field of Application goes into the hash QList m_miscMarkings; }; #endif diff --git a/lib/DictKanjidic/dictfilekanjidic.h b/lib/DictKanjidic/dictfilekanjidic.h index 6448433..1cfc54a 100644 --- a/lib/DictKanjidic/dictfilekanjidic.h +++ b/lib/DictKanjidic/dictfilekanjidic.h @@ -1,73 +1,73 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2001 Jason Katz-Brown * * Copyright (C) 2006 Joseph Kerian * * Copyright (C) 2006 Eric Kjeldergaard * * Copyright (C) 2011 Daniel E. Moctezuma * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_DICTFILEKANJIDIC_H #define KITEN_DICTFILEKANJIDIC_H #include "dictfile.h" -#include "libkitenexport.h" +#include "kiten_export.h" #include class DictQuery; class Entry; class EntryList; class KConfigSkeleton; class KConfigSkeletonItem; class KITEN_EXPORT DictFileKanjidic : public DictFile { friend class EntryKanjidic; public: DictFileKanjidic(); virtual ~DictFileKanjidic(); QMap displayOptions() const; EntryList *doSearch( const DictQuery &query ) Q_DECL_OVERRIDE; QStringList dumpDictionary(); QStringList listDictDisplayOptions( QStringList list ) const Q_DECL_OVERRIDE; bool loadDictionary( const QString &file , const QString &name ) Q_DECL_OVERRIDE; QStringList *loadListType( KConfigSkeletonItem *item , QStringList *list , const QMap &long2short ); void loadSettings(); void loadSettings( KConfigSkeleton *item ) Q_DECL_OVERRIDE; bool validDictionaryFile( const QString &filename ) Q_DECL_OVERRIDE; bool validQuery( const DictQuery &query ) Q_DECL_OVERRIDE; protected: virtual inline Entry *makeEntry( const QString &entry ); static QStringList *displayFields; private: QMap loadDisplayOptions() const; QStringList m_kanjidic; bool m_validKanjidic; }; #endif diff --git a/lib/DictKanjidic/entrykanjidic.h b/lib/DictKanjidic/entrykanjidic.h index e1d0456..b6496a4 100644 --- a/lib/DictKanjidic/entrykanjidic.h +++ b/lib/DictKanjidic/entrykanjidic.h @@ -1,74 +1,74 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2001 Jason Katz-Brown * * Copyright (C) 2006 Joseph Kerian * * Copyright (C) 2006 Eric Kjeldergaard * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_ENTRYKANJIDIC_H #define KITEN_ENTRYKANJIDIC_H #include "entry.h" -#include "libkitenexport.h" +#include "kiten_export.h" #include class QString; class KITEN_EXPORT EntryKanjidic : public Entry { public: EntryKanjidic( const EntryKanjidic &dict ); explicit EntryKanjidic( const QString &dict ); EntryKanjidic( const QString &dict, const QString &entry ); Entry *clone() const Q_DECL_OVERRIDE; QString dumpEntry() const Q_DECL_OVERRIDE; QString getAsRadicalReadings() const; QStringList getAsRadicalReadingsList() const; QString getDictionaryType() const Q_DECL_OVERRIDE; QString getInNamesReadings() const; QStringList getInNamesReadingsList() const; QString getKanjiGrade() const; QString getKunyomiReadings() const; QStringList getKunyomiReadingsList() const; QString getOnyomiReadings() const; QStringList getOnyomiReadingsList() const; QString getStrokesCount() const; bool loadEntry( const QString &entryLine ) Q_DECL_OVERRIDE; QString toHTML() const Q_DECL_OVERRIDE; protected: bool extendedItemCheck( const QString &key, const QString &value ) const Q_DECL_OVERRIDE; virtual QString HTMLExtendedInfo( const QString &field ) const; QString HTMLReadings() const Q_DECL_OVERRIDE; QString HTMLWord() const Q_DECL_OVERRIDE; virtual QString makeReadingLink( const QString &inReading ) const; QStringList AsRadicalReadings; QStringList InNamesReadings; QStringList KunyomiReadings; QStringList OnyomiReadings; QStringList originalReadings; private: QString addReadings( const QStringList &list ) const; }; #endif diff --git a/lib/dictfile.h b/lib/dictfile.h index 86822aa..5b7fa7e 100644 --- a/lib/dictfile.h +++ b/lib/dictfile.h @@ -1,181 +1,181 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2006 Joseph Kerian * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_DICTFILE_H #define KITEN_DICTFILE_H -#include "libkitenexport.h" +#include "kiten_export.h" #include #include class DictQuery; class DictionaryPreferenceDialog; class Entry; class EntryList; class KConfig; class KConfigSkeleton; class QStringList; class QWidget; /** * @short Abstract base class, used internally by the library for handling different types of dictionaries * This is a virtual class that enforces the interface between the DictionaryManager * class and the DictionaryManager.handler files. IMPLEMENT in combination with an * Entry subclass (if needed) to add a new dictionary format. Also see the addDictionary * method in the DictionaryManager class. * * This documentation is mostly for those who are adding a new type of dictionary to * kiten. This class is not exported outside of the library. */ class /* NO_EXPORT */ DictFile { private: /** * You are not allowed to create a dictFile subclass without specifying the type-name */ DictFile() {} public: /** * Use this constructor for your subclasses. Dictionary subclasses MUST specify their type * at creation. */ explicit DictFile( const QString& dictionaryTypeName ) : m_dictionaryType( dictionaryTypeName ) {} /** * Destructor */ virtual ~DictFile() {} /** * This method allows the user to test if a dictionary is the proper type for this format. * This process is allowed to take some time, but nonetheless you should find checking the format * of a few hundred entries sufficient for this. * * @param filename the name of the file, suitable for using with QFile::setFileName() */ virtual bool validDictionaryFile( const QString &filename ) = 0; /** * Is this query relevant to this dictionary type? Usually this will return true, * unless the query specifies extended attributes that the dictionary does not provide. * * @param query the query to examine for relevance to this dictionary type */ virtual bool validQuery( const DictQuery &query ) = 0; /** * This actually conducts the search on the given query. This is usually most of the work * * @param query the DictQuery that specifies what results to return */ virtual EntryList *doSearch( const DictQuery &query ) = 0; /** * Load a dictionary as at system startup. * * @param file the file to open, in a format suitable for use with QFile::setFileName() * @param name the name of the file to open, used in various user-interface aspects. * It may be related to the file parameter, but perhaps not. */ virtual bool loadDictionary( const QString &file, const QString &name ) = 0; /** * Load a new dictionary. This is called with the assumption that this dictionary * has not been opened previously, in case you need to build an index or other activity. * If you do not re-implement this method, it simply calls loadDictionary(). * * @param file the file to open, in a format suitable for use with QFile::setFileName() * @param name the name of the file to open, used in various user-interface aspects. * It may be related to the file parameter, but perhaps not. */ virtual bool loadNewDictionary( const QString &file, const QString &name ) { return loadDictionary( file, name ); } /** * Return a list of the fields that can be displayed, note the following * should probably always be returned: --NewLine--, Word/Kanji, Meaning, * Reading. This function is passed a list originally containing those * four items. This function is used to enumerate possible types the user * chooses to have displayed in the preferences dialog box. * This will often be a very similar list to getSearchableAttributes(), * but due to optional forms of spelling and other situations, it may * not be exactly the same. Note: The "Dictionary" option will be * appended to your list at the end. */ virtual QStringList listDictDisplayOptions( QStringList ) const = 0 ; /** * If you want your own dialog to pick preferences for your dict, then override this. * Leaving it blank will leave your dictionary type without a preferences dialog. * * @param config the KConfigSkeleton object that is currently in use * @param parent the parent widget for your preferences dialog */ virtual DictionaryPreferenceDialog *preferencesWidget( KConfigSkeleton *config, QWidget *parent = NULL ) { Q_UNUSED( parent ); Q_UNUSED( config ); return NULL; } /** * Load information from the KConfigSkeleton that you've setup in * the above preferences widget. */ virtual void loadSettings( KConfigSkeleton* ) {} /** * Returns the name of the dictionary */ virtual QString getName() const { return m_dictionaryName; } /** * Returns the type of files this dictFile object deals with */ virtual QString getType() const { return m_dictionaryType; } /** * Returns the file that this is working with, usually used in the preferences display */ virtual QString getFile() const { return m_dictionaryFile; } /** * Fetch a list of searchable attributes and their codes */ virtual const QMap &getSearchableAttributes() const { return m_searchableAttributes; } protected: /** * Name is the 'primary key' of the list of dictionaries. You will want to * place this into your Entry objects to identify where they came from * (fairly important) */ QString m_dictionaryName; /** * This is mostly a placeholder, but your class will get asked what file * it is using, so either be sure to put something here, or override * getFile() and respond with something that will be sensical in a * dictionary selection dialog box. */ QString m_dictionaryFile; /** * This MUST BE SET IN THE CONSTRUCTOR. The dictionary class occasionally * uses this value and it's important for it to be set at anytime after the * constructor is called. It also must be unique to the dictionary type. If * relevant, specify dictionary versions here. */ QString m_dictionaryType; /** * This allows the programming user to see a list * of possible search types (probably through a drop down menu). * You may also find it useful in your dictFile implementation * to translate from extended attribute keys into the simpler one or two letter * code keys. These should take the format of: * (Kanji Grade => G), (Strokes => S), (Heisig Number => H) * for a simple example appropriate to kanji. */ QMap m_searchableAttributes; }; #endif diff --git a/lib/dictionarymanager.h b/lib/dictionarymanager.h index d5ab040..22eece3 100644 --- a/lib/dictionarymanager.h +++ b/lib/dictionarymanager.h @@ -1,161 +1,161 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2006 Joseph Kerian * * Copyright (C) 2011 Daniel E. Moctezuma * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_DICTIONARYMANAGER_H #define KITEN_DICTIONARYMANAGER_H -#include "libkitenexport.h" +#include "kiten_export.h" #include #include class DictFile; class DictQuery; class DictionaryPreferenceDialog; class EntryList; class KConfig; class KConfigSkeleton; class QString; class QStringList; class QWidget; /** * @short 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 */ class KITEN_EXPORT DictionaryManager { public: /** * Basic constructor */ DictionaryManager(); /** * Basic destructor */ virtual ~DictionaryManager(); /** * Open a specified dictionary, and load it under this manager's control * * @param file the filename, suitable for using with QFile::setFileName() * @param name the 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 * @param type the known dictionary type of this file */ bool addDictionary( const QString &file, const QString &name, const QString &type ); /** * Removes all previously loaded dictionaries (if any). */ void removeAllDictionaries(); /** * Close a dictionary by name * * @param name the name of the dictionary file, as given in addDictionary */ bool removeDictionary( const QString &name ); /** * List names of each open dictionary */ QStringList listDictionaries() const; /** * Returns type and file for an open dictionary of a given * * @param name the name of the dictionary whose information we are looking for */ QPair listDictionaryInfo( const QString &name ) const; /** * Lists all dictionaries of a given type (Convenient for preference dialogs) * * @param type the type of dictionaries to list */ QStringList listDictionariesOfType( const QString &type ) const; /** * This is the main search routine that most of kiten should use * * @param query the DictQuery object describing the search to conduct */ EntryList *doSearch( const DictQuery &query ) const; /** * A simple method for searching inside of a given set of results * * @param query the 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 * @param list the list of results to search for the above query in */ EntryList *doSearchInList( const DictQuery &query, const EntryList *list ) const; /** * Get a list of all supported dictionary types. Useful for preference code */ static QStringList listDictFileTypes(); /** * 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() * * @param config the config skeleton * @param parent the parent widget, as per the normal Qt widget system */ static QMap generatePreferenceDialogs( KConfigSkeleton *config, QWidget *parent = NULL ); /** * 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 usable in search string" */ static QMap generateExtendedFieldsList(); /** * Trigger loading preferences from a given KConfigSkeleton config object for a dictionary of type dict * * @param dict the dictionary type to load settings for * @param config the config skeleton object */ void loadDictSettings( const QString &dict, KConfigSkeleton *config ); /** * Load general settings */ void loadSettings( const KConfig &config ); private: /** * Static method, used to create the polymorphic dictFile object. Do not use externally. * If you are adding a new dictionary type, see the instructions in the code. */ static DictFile *makeDictFile( const QString &type ); class Private; Private* const d; }; #endif diff --git a/lib/dictionarypreferencedialog.h b/lib/dictionarypreferencedialog.h index 90346a9..163ca5d 100644 --- a/lib/dictionarypreferencedialog.h +++ b/lib/dictionarypreferencedialog.h @@ -1,94 +1,94 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2006 Joseph Kerian * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_DICTIONARYPREFERENCEDIALOG_H #define KITEN_DICTIONARYPREFERENCEDIALOG_H #include -#include "libkitenexport.h" +#include "kiten_export.h" /** * @short This abstract base class specifies the interface for dictionary * preference dialogs in user applications. The DictionaryManager class can be * asked for a list of these objects for the current session, and the appropriate * signal/slot connections can be made to handle dictionary preferences transparently * to the user application. * * One annoying caveat is that the user application still has to add preference elements * to it's own kcfg file, or the preference code will crash when trying to work with it. * Sadly, at the moment the only way to figure out what needs to be added to the kcfg is * to read the code, or the kiten.kcfg implementation. * * @author Joseph Kerian \ */ class KITEN_EXPORT DictionaryPreferenceDialog : public QWidget { Q_OBJECT public: /** * Basic constructor. Used by internal classes only. Implement if you are * adding your own dictionary type. * * @param parent the parent widget, as per normal Qt Widget handling * @param name the name of your widget, as understood by the preference code */ DictionaryPreferenceDialog( QWidget *parent, const QString &name ); /** * Basic destructor */ virtual ~DictionaryPreferenceDialog(); /** * Get the dictionary type name associated with this dialog */ QString name() const; public Q_SLOTS: /** * Connect the signal of your preferences dialog to this updateWidgets slot, to handle reading * preference settings cleanly. You can also call this slot directly from your own updateWidgets slot. */ virtual void updateWidgets() = 0; /** * Connect the signal of your preferences dialog to this updateWidgetsDefault slot, to handle setting * preference settings back to their default settings easily. */ virtual void updateWidgetsDefault() = 0; /** * Connect the signal of your preferences dialog to this updateSettings slot, to handle saving * user's preference information. */ virtual void updateSettings() = 0; Q_SIGNALS: /** * When the user edits something on this preference page, this signal should be emitted */ void widgetChanged(); protected: /** * A place to store the name, passed in the constructor */ QString m_name; }; #endif diff --git a/lib/dictquery.h b/lib/dictquery.h index 3fb5e6e..79b87eb 100644 --- a/lib/dictquery.h +++ b/lib/dictquery.h @@ -1,389 +1,389 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2006 Joseph Kerian * * Copyright (C) 2011 Daniel E. Moctezuma * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_DICTQUERY_H #define KITEN_DICTQUERY_H #include #include #include #include class QChar; -#include "libkitenexport.h" +#include "kiten_export.h" /** * @short A class to allow users of libkiten to properly setup a database * query. * * In general, you either pass or parse in parameters from users or automated * programs to be later sent to the dictionary manager. * * This class is one of the three critical classes (along with * dictionary and EntryList) that are needed to use libkiten. Essentially... * you feed the dictionary class a DictQuery, and dictionary will return an * EntryList that matches the query. * * @code * dictionary dictManager(); * //Load some dictionaries via dictionary class methods * EntryList *results; * DictQuery myQuery("kanji"); * results = dictManager.doSearch(myQuery); * //Print results (if any) * @endcode * * The internal implementation understands four distinct types of data: * Japanese Kanji * Japanese Kana * English Characters * Property Pairs of the form \name\:\value\ * * It is left up to the individual dictionary types to parse these values * for matching and appropriateness to each dictionary. * You can use the setDictionaries() method to narrow the range of the * dictionaries that it will apply to. * * A DictQuery object can be considered an "unordered set" of values. * When testing for equality or comparison, each property or text entry above * is seen as a unique item in a set. Order is not important for these * operations. The object will attempt to preserve the order from parsed * strings, but it does not consider this order to be important. * * In general, application level programs are expected to use the * QString based interfaces, and dictionary implementations and other * parts of libkiten are expected to use the direct accessors and mutators, * although specialized interfaces (such as kitenradselect) may use property * mutators for a limited set of properties. (in this case, radicals) * * The query string input is of the following format: * <QS> ::= <M>DictQuery::mainDelimiter<QS>|<R>DictQuery::mainDelimiter<QS>| * <O>DictQuery::mainDelimiter<QS>|NULL * <M> ::= kana<M>|kana * <R> ::= character<R>|character * <O> ::= <C>DictQuery::propertySeparator<D> * <C> ::= character<C>|character * <D> ::= character<D>|character * * @author Joseph Kerian \ */ class KITEN_EXPORT DictQuery { public: /** * This is the main delimiter that the DictQuery uses when parsing strings. * It is set to "space" at the moment. */ static const QString mainDelimiter; /** * This is the delimiter that DictQuery uses when parsing property strings * of the form strokes:4. It is set to ":" at the moment. */ static const QString propertySeperator; /** * Normal constructor. * * This will create an empty query object. */ DictQuery(); /** * Constructor with a given QString. * * @param str the QString will be parsed as described below in operator=(const QString&) */ explicit DictQuery( const QString& str ); /** * Copy constructor * * @param orig the original DictQuery to be copied */ DictQuery( const DictQuery& orig ); /** * Destructor */ ~DictQuery(); /** * @return true if the DictQuery is completely empty */ bool isEmpty() const; /** * Removes all text/entries from the DictQuery */ void clear(); /** * The assignment copy operator */ DictQuery &operator=( const DictQuery &old ); /** * The clone method */ DictQuery *clone() const; /** * This returns a QString that represents the query. This may be the same * as the original string, but some slight changes may have occurred if you * have done any manipulations on the DictQuery. */ const QString toString() const; /** * This is a conversion to a QString... useful in a surprising * number of cases. */ operator QString() const; /** * Use this to get a list of all the property keys in the query */ const QList listPropertyKeys() const; /** * Returns a given extended attribute */ const QString operator[]( const QString &key ) const; /** * Sets a given extended attribute */ QString operator[]( const QString &key ); /** * Get a specific property by key (is the same as using operator[] const) */ QString getProperty( const QString &key ) const; /** * Verify if a given DictQuery object has a search parameter of a * particular property. */ bool hasProperty( const QString &key ) const; /** * Set a particular property... this does significantly more error checking * than the operator[] version, and will return false if there was a * problem (an empty value or bad key) * * @param key the key for this entry * @param value the value to set this to, will overwrite the current contents of this location * * @returns false on failure */ bool setProperty( const QString& key, const QString& value ); /** * Remove all instances of a property. * * @returns true if the DictQuery had properties of the given type */ bool removeProperty( const QString &key ); /** * Returns and removes the property */ QString takeProperty( const QString &key ); /** * Returns a list of the dictionaries that this particular query * will target. An empty list (the default) will search all dictionaries * that the user has selected. */ QStringList getDictionaries() const; /** * Set the list of dictionaries to search. This will be read and used * by the dictionary manager. */ void setDictionaries( const QStringList &newDictionaries ); /** * Accessor for the non-japanese meaning field */ QString getMeaning() const; /** * Mutator for the Meaning field */ bool setMeaning( const QString &newMeaning ); /** * Accessor for the Pronunciation field (generally kana) */ QString getPronunciation() const; /** * Mutator for the Pronunciation field */ bool setPronunciation( const QString &newPronunciation ); /** * Accessor for the Word/Kanji field (this is usually used for anything * containing kanji). */ QString getWord() const; /** * Mutator for the Word/Kanji field. If what you are setting contains * only kana, consider using the setPronunciation instead. */ bool setWord( const QString &newWord ); /** * A simple setwise comparison of two DictQuery objects * Note that order is not important here... only each element * that is one of the DictQuery objects appears in the other. */ KITEN_EXPORT friend bool operator==( const DictQuery &a, const DictQuery &b ); /** * Convenient inverted override of operator==( DictQuery, DictQuery ) */ KITEN_EXPORT friend bool operator!=( const DictQuery &other, const DictQuery &query ); /** * Set-wise strictly less than. A better way to think of this * might be the "subset" operator */ KITEN_EXPORT friend bool operator<( const DictQuery &a, const DictQuery &b ); /** * Convenient override of operator<( DictQuery, DictQuery ) and operator== */ KITEN_EXPORT friend bool operator<=( const DictQuery &a, const DictQuery &b ); /** * This will append the properties and other elements of the added kanji * onto the elements of the current element. If regenerated as a string, * it should look something like concatenation */ DictQuery &operator+=( const DictQuery &old ); /** * A simple string parser, look above for examples and explanations */ DictQuery &operator=( const QString &old ); /** * A simple override of operator+=( const DictQuery& ) */ DictQuery &operator+=( const QString &old ); /** * Simple addition... similar to operator+= */ KITEN_EXPORT friend DictQuery operator+( const DictQuery &a, const DictQuery &b ); #ifndef QT_NO_CAST_ASCII /** * An ascii cast variant of the operator= * Only available if QT_NO_CAST_ASCII is not defined on lib compilation */ DictQuery &operator=( const char* ); #endif //Specify the type of matching /** * This enum is used to define the type of matching this query is supposed * to do. The names are fairly self-explanatory */ enum MatchType { Exact, Beginning, Ending, Anywhere }; /** * Get which match type is currently set on the DictQuery. */ MatchType getMatchType() const; /** * Set a match type. If this is not called, the default is matchExact. */ void setMatchType( MatchType newType ); /** * This enum is used to define the type of matching this query is supposed * to do. */ enum MatchWordType { Any, Verb, Noun, Adjective, Adverb, Prefix, Suffix, Expression }; /** * Get which word type is currently set on the DictQuery. */ MatchWordType getMatchWordType() const; /** * Set a word type. If this is not called, the default value is 'Any'. */ void setMatchWordType( MatchWordType newType ); enum FilterType { NoFilter, Rare, CommonUncommon }; /** * Get which filter is currently set on the DictQuery. */ FilterType getFilterType() const; /** * Set whether or not the query should output results separated in * common and uncommon sections. */ void setFilterType( FilterType newType ); /** * This enum is used as the return type for the two utility functions, * stringTypeCheck and charTypeCheck. */ enum StringTypeEnum { Kanji, Kana, Latin, Mixed, ParseError }; /** * A simple utility routine to tell us what sort of string we have * If the string contains only kanji, kana or non-kanji/kana characters, the result is strTypeKanji, * strTypeKana or strTypeLatin (perhaps a misnomer... but so far it's valid). * If the string contains both kanji and kana, the type returned is strTypeKanji * If the string contains any other combination, the return type is mixed. */ static StringTypeEnum stringTypeCheck( const QString &in ); /** * This utility does the same thing for QChar as stringTypeCheck does for QString. At the moment * the implementation is rather simple, and it assumes that anything that is not latin1 or kana is * a kanji. */ static StringTypeEnum charTypeCheck( const QChar &ch ); private: class Private; Private* const d; }; //Currently... KDE doesn't seem to want to use exceptions #ifdef LIBKITEN_USING_EXCEPTIONS class InvalidQueryException { public: InvalidQueryException( QString x ) { m_val = x; } InvalidQueryException( QString m = "Invalid Query String", QString x ) { m_val = x; m_msg = m; } QString value() { return m_val; } QString message() { return m_msg; } protected: QString m_val; QString m_msg; }; #endif #endif diff --git a/lib/entry.h b/lib/entry.h index cfb50c0..1ae650f 100644 --- a/lib/entry.h +++ b/lib/entry.h @@ -1,249 +1,249 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2001 Jason Katz-Brown * * Copyright (C) 2006 Joseph Kerian * * Copyright (C) 2006 Eric Kjeldergaard * * Copyright (C) 2011 Daniel E. Moctezuma * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_ENTRY_H #define KITEN_ENTRY_H #include #include -#include "libkitenexport.h" +#include "kiten_export.h" #include "dictquery.h" class Entry; class EntryList; class QString; /** * The Entry class is a generic base class for each particular entry in a given dictionary. * It's used as the basic class to ferry information back to the user application. * It also handles some of the display aspects. */ class KITEN_EXPORT Entry { friend class EntryListModel; private: /** * Default constructor, should not be used. Made private to serve as a warning * that you're doing something wrong if you try to call this. */ Entry(); protected: /** * Copy constructor */ Entry( const Entry& ); /** * Constructor that includes the dictionary source. This does not need to be overridden by * subclasses, but you might find it to be convenient as the superclass constructor to call * from your constructors. * @param sourceDictionary the dictionary name (not fileName) that this entry originated with */ Entry( const QString &sourceDictionary ); /** * A constructor that includes the basic information, nicely separated * @param sourceDictionary the dictionary name (not fileName) that this entry originated with * @param word the word entry of this dictionary entry (normally kanji/kana) * @param readings a list of possible pronunciations for this result (kana) * @param meanings a list of possible meanings for this word */ Entry( const QString &sourceDictionary, const QString &word, const QStringList &readings, const QStringList &meanings ); public: /** * Generic Destructor */ virtual ~Entry(); /** * A clone method, this should just implement "return new EntrySubClass(*this)" */ virtual Entry *clone() const = 0; /** * Fairly important method, this tests if this particular entry matches a query. The * EDICT and Kanjidic doSearch methods do an approximate match, load an Entry, and then * check more carefully by calling this method. This works nicely for handling searchWithinResults * cleanly. */ virtual bool matchesQuery( const DictQuery& ) const; /** * Get the dictionary name that generated this Entry. I can't think of a reason to be changing this */ const QString &getDictName() const; /** * Get the dictionary type (e.g. edict, kanjidic). */ virtual QString getDictionaryType() const = 0; /** * Get the word from this Entry. If the entry is of type kanji/kana/meaning/etc, this will * return the kanji. If it is of kana/meaning/etc, it will return kana. */ QString getWord() const; /** * Get a QString containing all of the meanings known, connected by the outputListDelimiter */ QString getMeanings() const; /** * Simple accessor */ QStringList getMeaningsList() const; /** * Simple accessor */ QString getReadings() const; /** * Simple accessor */ QStringList getReadingsList() const; /** * Simple accessor */ const QHash &getExtendedInfo() const; /** * Simple accessor * @param x the key for the extended info item to get */ QString getExtendedInfoItem( const QString &x ) const; /** * Simple accessor * @param key the key for the extended item that is being verified * @param value the value it is supposed to have * @returns true if the key has that value, false if it is different or does not exist */ virtual bool extendedItemCheck( const QString &key, const QString &value ) const; /** * An entry should be able to generate a representation of itself in (valid) HTML */ virtual QString toHTML() const; /** * KVTML format for exporting */ virtual QString toKVTML() const; /** * This will return a pure text interpretation of the Entry */ virtual QString toString() const; /** * An entry should be able to parse an in-file representation of an entry * as a QString and put it back. The latter will be useful for writing * to dictionaries on disk at some point. */ virtual bool loadEntry( const QString& ) = 0; /** * Return a QString of an entry, as if it were dumped back into it's source file */ virtual QString dumpEntry() const = 0; /** * An overrideable sorting function, similar to operator< in most contexts * The default version will sort by dictionary, then by fields * * @param that the second item we are comparing (this) with * @param dictionaryList the list of dictionaries (in order) to sort * If this list is empty, the entries will not be sorted in order * @param fieldList the list of fields to sort in, uses special codes of * Reading, Meaning, Word/Kanji for those elements, all others by their * extended attribute keys. */ virtual bool sort( const Entry &that, const QStringList &dictionaryList, const QStringList &fieldList ) const; /** * Overrideable sorting mechanism for sorting by individual fields. * The sort routine checks if the given field is equal, before calling this virtual function * So if this is called, you can assume that this->extendedItem(field) != that.extendedItem(field) * * @param that the second item we are comparing (this) with * @param field the specific extended item field that is being compared */ virtual bool sortByField( const Entry &that, const QString &field ) const; protected: /** * The Word (usually containing kanji) that matches this entry. If you override the accessors * above, this has no use. */ QString Word; /** * The Meanings that match this entry. If you override the accessors * above, this has no use. */ QStringList Meanings; /** * The Readings (usually kana) that match this entry. If you override the accessors * above, this has no use. */ QStringList Readings; /** * A hash of extended information. You may find it useful to store all sorts of details here */ QHash ExtendedInfo; /** * The dictionary that this entry originated at */ QString sourceDict; /** * The delimiter for lists... usually space */ QString outputListDelimiter; /** * This is used by the constructors to set some default values */ void init(); /** * Handy function for generating a link from a given QString */ virtual QString makeLink( const QString &entryString ) const; /** * Return and HTML version of a word */ virtual QString HTMLWord() const; /** * Return and HTML version of a reading list */ virtual QString HTMLReadings() const; /** * Return and HTML version of a meaning list */ virtual QString HTMLMeanings() const; /** * Handy Utility functions for matching to lists and identifying char types */ bool listMatch( const QStringList &list, const QStringList &test, DictQuery::MatchType type ) const; /** * Handy Utility functions for matching to lists and identifying char types */ bool isKanji( const QChar &character ) const; }; #endif diff --git a/lib/entrylist.h b/lib/entrylist.h index 4cc9ded..1d68af1 100644 --- a/lib/entrylist.h +++ b/lib/entrylist.h @@ -1,137 +1,137 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2001 Jason Katz-Brown * * Copyright (C) 2006 Joseph Kerian * * Copyright (C) 2006 Eric Kjeldergaard * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_ENTRYLIST_H #define KITEN_ENTRYLIST_H #include #include #include #include "dictquery.h" #include "entry.h" -#include "libkitenexport.h" +#include "kiten_export.h" /** * EntryList is a simple container for Entry objects, and is-a QList * A few simple overrides allow you to deal with sorting and translating. */ class KITEN_EXPORT EntryList : public QList { public: /** * A simple overridden iterator for working with the Entries */ typedef QListIterator EntryIterator; /** * Basic constructor, create an empty EntryList */ EntryList(); /** * Copy constructor */ EntryList( const EntryList &old ); /** * Basic Destructor, does not delete Entry* objects. Please remember to call * deleteAll() before deleting an EntryList. */ virtual ~EntryList(); /** * Delete all Entry objects in our list. In the future, we'll switch to a reference * counting system, and this will be deprecated. */ void deleteAll(); /** * Convert every element of the EntryList to a QString and return it */ QString toString() const; /** * Convert every element of the EntryList to a QString in HTML form and return it */ QString toHTML() const; /** * Convert a given range of the EntryList to a QString and return it * @param start the location in the list where we should start * @param length the length of the list we should generate */ QString toString( unsigned int start, unsigned int length ) const; /** * Convert a given range of the EntryList to a QString in HTML form and return it * @param start the location in the list where we should start * @param length the length of the list we should generate */ QString toHTML( unsigned int start, unsigned int length ) const; /** * Convert the entire list to KVTML for export to a flashcard app * @param start the location in the list where we should start * @param length the length of the list we should generate */ QString toKVTML( unsigned int start, unsigned int length ) const; /** * Sort the list according to the given fields in sortOrder, if dictionaryOrder * is blank, don't order the list by dictionary, otherwise items are sorted by dictionary * then by sortOrder aspects * @param sortOrder the keys to sort by, this should be a list of fields to sort by, this should * be the same as the fields that are returned from dictFile::listDictDisplayOptions(). * "--NewLine--" entries will be ignored, "Word/Kanji", "Meaning", and "Reading" entries will * be accepted. An entry which has an extended attribute is considered higher ranking (sorted to * a higher position) than an entry which does not have such an attribute. * @param dictionaryOrder the order for the Entry objects to be sorted in, dictionary-wise. This should * match the names of the dictionary objects, passed to the DictionaryManager. */ void sort( QStringList &sortOrder, QStringList &dictionaryOrder ); /** * Append another EntryList onto this one */ const EntryList& operator+=( const EntryList &other ); /** * Copy an entry list */ const EntryList& operator=( const EntryList &other ); /** * Append another EntryList onto this one */ void appendList( const EntryList *other ); /** * Get the query that generated this list, note that if you have appended EntryLists from * two different queries, the resulting DictQuery from this is undefined. */ DictQuery getQuery() const; /** * Set the query for this list. See getQuery() for a potential problem with this */ void setQuery( const DictQuery &newQuery ); int scrollValue() const; void setScrollValue( int val ); private: class Private; Private* const d; }; #endif diff --git a/lib/historyptrlist.h b/lib/historyptrlist.h index f472d23..4e37beb 100644 --- a/lib/historyptrlist.h +++ b/lib/historyptrlist.h @@ -1,95 +1,95 @@ /***************************************************************************** * This file is part of Kiten, a KDE Japanese Reference Tool * * Copyright (C) 2006 Joseph Kerian * * Copyright (C) 2006 Eric Kjeldergaard * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KITEN_HISTORYPTRLIST_H #define KITEN_HISTORYPTRLIST_H #include -#include "libkitenexport.h" +#include "kiten_export.h" class EntryList; class KITEN_EXPORT HistoryPtrList { public: /** * Construct a HistoryPtrList, this should be done early on */ HistoryPtrList(); /** * Destructor... kill all lists before going */ virtual ~HistoryPtrList(); /** * Add an item to the end of the history list and set it as * the current displayed item. */ void addItem( EntryList *newItem ); /** * Return a list of the entries. Note that this is usually * just a QStringList of all of the EntryList's DictQuery->toString() calls. */ QStringList toStringList(); /** * Return a list of the entries prior to the current one (not including * the current entry. */ QStringList toStringListPrev(); /** * Return a summary list that only includes those after the current */ QStringList toStringListNext(); /** * Add one to the current location, convenient for 'forward' buttons */ void next( int distance = 1 ); /** * Sub one from the current location, the counterpart to next() */ void prev( int distance = 1 ); /** * Return the current numerical 0-based location */ int index(); /** * Return the item at the location given by the parameter, and set it * to be the current history list item. */ /** * Return the current item */ EntryList *current(); /** * Set the current item */ void setCurrent( int i ); /** * Return the total number of items in the list */ int count(); private: class Private; Private* const d; }; #endif diff --git a/lib/libkitenexport.h b/lib/libkitenexport.h deleted file mode 100644 index 8bf784f..0000000 --- a/lib/libkitenexport.h +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - * This file is part of Kiten, a KDE Japanese Reference Tool * - * Copyright (C) 2006 Joseph Kerian * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public License * - * along with this library; see the file COPYING.LIB. If not, write to * - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301, USA. * - *****************************************************************************/ - -#ifndef KITEN_LIBKITENEXPORT_H -#define KITEN_LIBKITENEXPORT_H - -#define KDE_EXPORT __attribute__ ((visibility("default"))) -#define KDE_IMPORT __attribute__ ((visibility("default"))) - -#if defined Q_OS_WIN -# ifndef KITEN_EXPORT -# ifdef MAKE_KITEN_LIB -# define KITEN_EXPORT KDE_EXPORT -# else -# define KITEN_EXPORT KDE_IMPORT -# endif -# endif -#else /* UNIX */ -# define KITEN_EXPORT KDE_EXPORT -#endif - -#endif