File indexing completed on 2024-05-19 05:05:18
0001 /*************************************************************************** 0002 * SPDX-License-Identifier: GPL-2.0-or-later 0003 * * 0004 * SPDX-FileCopyrightText: 2004-2019 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_BIBTEXFIELDS_H 0021 #define KBIBTEX_CONFIG_BIBTEXFIELDS_H 0022 0023 #include <QString> 0024 #include <QVector> 0025 0026 #include <KBibTeX> 0027 0028 #ifdef HAVE_KF 0029 #include "kbibtexconfig_export.h" 0030 #endif // HAVE_KF 0031 0032 typedef struct { 0033 /** 0034 * Name of this field in 'upper camel case', e.g. 'BookTitle', but not 0035 * 'booktitle', 'BOOKTITLE', or 'BoOkTiTlE'. 0036 */ 0037 QString upperCamelCase; 0038 /** 0039 * The 'alternative' field name is used to create 'meta fields', such as 0040 * 'author' or 'editor' combined. It shall not be used to define aliases 0041 * such as 'pdf' to be an alias for 'file'. 0042 */ 0043 QString upperCamelCaseAlt; 0044 /** 0045 * List of aliases for a field. Empty for most fields. Alias for BibLaTeX 0046 * must be explictly mentioned in BibLaTeX's official documentation, see 0047 * section 'Field Aliases'. 0048 * Field aliases shall not be used as alternative field names. 0049 */ 0050 QStringList upperCamelCaseAliases; 0051 /** 0052 * Localized (translated) name of this field. 0053 */ 0054 QString label; 0055 KBibTeX::TypeFlag preferredTypeFlag; 0056 KBibTeX::TypeFlags typeFlags; 0057 QMap<QString, int> visualIndex; 0058 QMap<QString, int> width; 0059 int defaultWidth; 0060 QMap<QString, bool> visible; 0061 bool defaultVisible; 0062 bool typeIndependent; 0063 } FieldDescription; 0064 0065 bool operator==(const FieldDescription &a, const FieldDescription &b); 0066 uint qHash(const FieldDescription &a); 0067 0068 /** 0069 @author Thomas Fischer 0070 */ 0071 class KBIBTEXCONFIG_EXPORT BibTeXFields : public QVector<FieldDescription> 0072 { 0073 public: 0074 ~BibTeXFields(); 0075 0076 /** 0077 * Only one instance of this class has to be used 0078 * @return the class's singleton 0079 */ 0080 static BibTeXFields &instance(); 0081 0082 #ifdef HAVE_KF 0083 void save(); 0084 void resetToDefaults(const QString &treeViewName); 0085 #endif // HAVE_KF 0086 0087 /** 0088 * Change the casing of a given field name to one of the predefine formats. 0089 */ 0090 QString format(const QString &name, KBibTeX::Casing casing) const; 0091 0092 static KBibTeX::TypeFlag typeFlagFromString(const QString &typeFlagString); 0093 static KBibTeX::TypeFlags typeFlagsFromString(const QString &typeFlagsString); 0094 static QString typeFlagToString(KBibTeX::TypeFlag typeFlag); 0095 static QString typeFlagsToString(KBibTeX::TypeFlags typeFlags); 0096 0097 const FieldDescription find(const QString &name) const; 0098 0099 private: 0100 Q_DISABLE_COPY(BibTeXFields) 0101 0102 explicit BibTeXFields(const QString &style, const QVector<FieldDescription> &other); 0103 0104 class BibTeXFieldsPrivate; 0105 BibTeXFieldsPrivate *d; 0106 }; 0107 0108 #endif // KBIBTEX_CONFIG_BIBTEXFIELDS_H