File indexing completed on 2024-05-19 05:05:47
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_PROCESSING_IDSUGGESTIONS_H 0021 #define KBIBTEX_PROCESSING_IDSUGGESTIONS_H 0022 0023 #include <Entry> 0024 0025 #ifdef HAVE_KF 0026 #include "kbibtexprocessing_export.h" 0027 #endif // HAVE_KF 0028 0029 /** 0030 * @author Thomas Fischer <fischer@unix-ag.uni-kl.de> 0031 */ 0032 class KBIBTEXPROCESSING_EXPORT IdSuggestions 0033 { 0034 public: 0035 enum class CaseChange {None, ToUpper, ToLower, ToCamelCase}; 0036 0037 struct IdSuggestionTokenInfo { 0038 int len; 0039 int startWord, endWord; 0040 bool lastWord; 0041 CaseChange caseChange; 0042 QString inBetween; 0043 }; 0044 0045 static QString formatId(const Entry &entry, const QString &formatStr); 0046 static QString defaultFormatId(const Entry &entry); 0047 static bool hasDefaultFormat(); 0048 0049 /** 0050 * Apply the default formatting string to the entry. 0051 * If no default formatting string is set, the entry 0052 * will stay untouched and the function return false. 0053 * If the formatting string is set, the entry's id 0054 * will be changed accordingly and the function returns true. 0055 * 0056 * @param entry entry where the id has to be set 0057 * @return true if the id was set, false otherwise 0058 */ 0059 static bool applyDefaultFormatId(Entry &entry); 0060 0061 static QStringList formatIdList(const Entry &entry); 0062 0063 static QStringList formatStrToHuman(const QString &formatStr); 0064 0065 static QString formatAuthorRange(int minValue, int maxValue, bool lastAuthor); 0066 0067 static struct IdSuggestionTokenInfo evalToken(const QString &token); 0068 0069 private: 0070 class IdSuggestionsPrivate; 0071 }; 0072 0073 #endif // KBIBTEX_PROCESSING_IDSUGGESTIONS_H