File indexing completed on 2024-05-19 05:05:30
0001 /*************************************************************************** 0002 * SPDX-License-Identifier: GPL-2.0-or-later 0003 * * 0004 * SPDX-FileCopyrightText: 2004-2017 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_GUI_ITALICTEXTITEMMODEL_H 0021 #define KBIBTEX_GUI_ITALICTEXTITEMMODEL_H 0022 0023 #include <QAbstractItemModel> 0024 0025 #include "kbibtexgui_export.h" 0026 0027 /** 0028 * The ItalicTextItemModel allows to maintain a list of value pairs: 0029 * The first element of the pair will be the shown text (should be 0030 * i18n'ized), the second value is supposed to be a string to identify 0031 * the shown text. If this identifier is empty or null, the first pair 0032 * element will be drawn in italic text. 0033 * 0034 * @author Thomas Fischer 0035 */ 0036 class KBIBTEXGUI_EXPORT ItalicTextItemModel : public QAbstractItemModel 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 enum ItalicTextItemModelRole { 0042 /// Role to retrieve identifier for a row 0043 IdentifierRole = Qt::UserRole + 9672 0044 }; 0045 0046 explicit ItalicTextItemModel(QObject *parent = nullptr); 0047 ~ItalicTextItemModel() override; 0048 0049 /** 0050 * Add a new entry (pair of shown text and identifier) to this model. 0051 * @param shownText i18n'ized text to be shown to the user 0052 * @param identifier internal identifier (if empty, shownText will be set in italics) 0053 */ 0054 void addItem(const QString &shownText, const QString &identifier); 0055 0056 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0057 QModelIndex index(int row, int column, const QModelIndex &) const override; 0058 QModelIndex parent(const QModelIndex &) const override; 0059 int rowCount(const QModelIndex &) const override; 0060 int columnCount(const QModelIndex &) const override; 0061 0062 private: 0063 class Private; 0064 Private *const d; 0065 }; 0066 0067 #endif // KBIBTEX_GUI_ITALICTEXTITEMMODEL_H