File indexing completed on 2025-01-19 03:53:49
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-11-25 0007 * Description : a bar used to search a string - version based on database models 0008 * 0009 * SPDX-FileCopyrightText: 2007-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_SEARCH_TEXT_BAR_DB_H 0016 #define DIGIKAM_SEARCH_TEXT_BAR_DB_H 0017 0018 // Local includes 0019 0020 #include "digikam_export.h" 0021 #include "searchtextbar.h" 0022 0023 namespace Digikam 0024 { 0025 0026 class AbstractAlbumModel; 0027 class AlbumFilterModel; 0028 0029 /** 0030 * A text input for searching entries with visual feedback. 0031 * Can be used on Database Models. 0032 * 0033 * @author Gilles Caulier 0034 */ 0035 class DIGIKAM_GUI_EXPORT SearchTextBarDb : public SearchTextBar 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 0041 explicit SearchTextBarDb(QWidget* const parent, 0042 const QString& name, 0043 const QString& msg=QString()); 0044 ~SearchTextBarDb() override; 0045 0046 /** 0047 * If the given model is != null, the model is used to populate the 0048 * completion for this text field. 0049 * 0050 * @param model to fill from or null for manual mode 0051 * @param uniqueIdRole a role for which the model will return a unique integer for each entry 0052 * @param displayRole the role to retrieve the text for completion, default is Qt::DisplayRole. 0053 */ 0054 void setModel(QAbstractItemModel* model, int uniqueIdRole, int displayRole = Qt::DisplayRole); 0055 0056 /** 0057 * Sets the album model this text bar shall use to invoke filtering on and 0058 * reading the result for highlighting from. 0059 * 0060 * @param model album model to use for filtering. <code>null</code> 0061 * means there is no model to use and external 0062 * connections need to be created with 0063 * signalSearchTextSettings and slotSearchResult 0064 */ 0065 void setModel(AbstractAlbumModel* const model); 0066 0067 /** 0068 * Sets the filter model this text bar shall use to invoke filtering on and 0069 * reading the result for highlighting from. 0070 * 0071 * @param filterModel filter model to use for filtering. <code>null</code> 0072 * means there is no model to use and external 0073 * connections need to be created with 0074 * signalSearchTextSettings and slotSearchResult 0075 */ 0076 void setFilterModel(AlbumFilterModel* const filterModel); 0077 0078 private: 0079 0080 class Private; 0081 Private* const d; 0082 }; 0083 0084 } // namespace Digikam 0085 0086 #endif // DIGIKAM_SEARCH_TEXT_BAR_DB_H