File indexing completed on 2024-05-19 05:05:17
0001 /*************************************************************************** 0002 * SPDX-License-Identifier: GPL-2.0-or-later 0003 * * 0004 * SPDX-FileCopyrightText: 2004-2020 Thomas Fischer <fischer@unix-ag.uni-kl.de> 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, * 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0014 * GNU General Public License for more details. * 0015 * * 0016 * You should have received a copy of the GNU General Public License * 0017 * along with this program; if not, see <https://www.gnu.org/licenses/>. * 0018 ***************************************************************************/ 0019 0020 #ifndef KBIBTEX_CONFIG_BIBTEXENTRIES_H 0021 #define KBIBTEX_CONFIG_BIBTEXENTRIES_H 0022 0023 #include <QStringList> 0024 #include <QVector> 0025 0026 #include <KBibTeX> 0027 0028 #include "preferences.h" 0029 0030 #ifdef HAVE_KF 0031 #include "kbibtexconfig_export.h" 0032 #endif // HAVE_KF 0033 0034 typedef struct { 0035 QString upperCamelCase; 0036 QString upperCamelCaseAlt; 0037 QString label; 0038 QStringList requiredItems; 0039 QStringList optionalItems; 0040 } EntryDescription; 0041 0042 bool operator==(const EntryDescription &a, const EntryDescription &b); 0043 uint qHash(const EntryDescription &a); 0044 0045 /** 0046 @author Thomas Fischer 0047 */ 0048 class KBIBTEXCONFIG_EXPORT BibTeXEntries : public QVector<EntryDescription> 0049 { 0050 public: 0051 virtual ~BibTeXEntries(); 0052 0053 /** 0054 * Only one instance of this class has to be used 0055 * @return the class's singleton 0056 */ 0057 static const BibTeXEntries &instance(); 0058 0059 /** 0060 * Change the casing of a given entry name to one of the predefine formats. 0061 * 0062 */ 0063 /** 0064 * Change the casing of a given entry name to one of the predefine formats. 0065 * @param name entry name to format 0066 * @param casing can be any of the predefined formats such as lower camel case or upper case 0067 * @return returns the formatted entry name if possible or the "name" parameter's value as fall-back 0068 */ 0069 QString format(const QString &name, KBibTeX::Casing casing = Preferences::instance().bibTeXKeywordCasing()) const; 0070 0071 /** 0072 * Returns the given entry name's i18n'ized, human-readable label, 0073 * for example "Journal Article" for entry name "article". 0074 * @param name entry name to look up the label for 0075 * @return the label for the entry if available, else an empty string 0076 */ 0077 QString label(const QString &name) const; 0078 0079 private: 0080 Q_DISABLE_COPY(BibTeXEntries) 0081 0082 explicit BibTeXEntries(const QVector<EntryDescription> &other); 0083 0084 class BibTeXEntriesPrivate; 0085 BibTeXEntriesPrivate *d; 0086 }; 0087 0088 #endif // KBIBTEX_CONFIG_BIBTEXENTRIES_H