digiKam
modelcompleter.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2010-06-13
7  * Description : A QCompleter for AbstractAlbumModels
8  *
9  * Copyright (C) 2007-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2009-2010 by Johannes Wienke <languitar at semipol dot de>
11  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_MODEL_COMPLETER_H
27 #define DIGIKAM_MODEL_COMPLETER_H
28 
29 // QT includes
30 
31 #include <QAbstractItemModel>
32 #include <QStringList>
33 #include <QCompleter>
34 
35 // Local includes
36 
37 #include "digikam_export.h"
38 
39 namespace Digikam
40 {
41 
42 class DIGIKAM_EXPORT ModelCompleter : public QCompleter
43 {
44  Q_OBJECT
45 
46 public:
47 
48  explicit ModelCompleter(QObject* const parent = nullptr);
49  ~ModelCompleter() override;
50 
59  void setItemModel(QAbstractItemModel* const model, int uniqueIdRole, int displayRole = Qt::DisplayRole);
60  QAbstractItemModel* itemModel() const;
61 
62  void addItem(const QString& item);
63  void setList(const QStringList& list);
64  QStringList items() const;
65 
66 Q_SIGNALS:
67 
68  void signalHighlighted(int albumId);
70 
71 private Q_SLOTS:
72 
73  void slotDelayedModelTimer();
74  void slotHighlighted(const QModelIndex& index);
75  void slotRowsInserted(const QModelIndex& parent, int start, int end);
76  void slotRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
77  void slotDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
78  void slotModelReset();
79 
80 private:
81 
82  void sync(QAbstractItemModel* const model);
83  void sync(QAbstractItemModel* const model, const QModelIndex& index);
84 
85 private:
86 
87  class Private;
88  Private* const d;
89 };
90 
91 } // namespace Digikam
92 
93 #endif // DIGIKAM_MODEL_COMPLETER_H
Definition: modelcompleter.h:43
void signalHighlighted(int albumId)
Definition: datefolderview.cpp:43