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-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_GUI_GUIHELPER_H 0021 #define KBIBTEX_GUI_GUIHELPER_H 0022 0023 #include <QAbstractItemModel> 0024 #include <QPoint> 0025 #include <QSize> 0026 0027 #include "kbibtexgui_export.h" 0028 0029 class QPainter; 0030 0031 /** 0032 * @author Thomas Fischer 0033 */ 0034 class KBIBTEXGUI_EXPORT GUIHelper 0035 { 0036 public: 0037 /** 0038 * Given a model containing strings in the first column attached 0039 * to the root node, search all those strings for equivalence to 0040 * a given string. The test for equivalence is case-insensitive 0041 * and the role how this string is retrieved from the model can 0042 * be chosen. 0043 * If the string was found, the row number (0 to rowCount()-1) is 0044 * returned. If the string was not found or any other error 0045 * condition occurred, a negative value is returned. 0046 * 0047 * @param model model containing strings to test for case-insensitive equivalence 0048 * @param value value to search for in the model 0049 * @param role role used to retrieve string data from the model 0050 * @return row of value's occurrence or a negative value if not found or any other error 0051 */ 0052 static int selectValue(QAbstractItemModel *model, const QString &value, int role = Qt::DisplayRole); 0053 static int selectValue(QAbstractItemModel *model, const int value, int role = Qt::DisplayRole); 0054 }; 0055 0056 #endif // KBIBTEX_GUI_GUIHELPER_H