digiKam
searchresultmodel.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-01
7  * Description : A widget to search for places.
8  *
9  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2010-2011 by Michael G. Hansen <mike at mghansen dot de>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_SEARCH_RESULT_MODEL_H
26 #define DIGIKAM_SEARCH_RESULT_MODEL_H
27 
28 // Qt includes
29 
30 #include <QAbstractItemModel>
31 #include <QItemSelectionModel>
32 
33 // local includes
34 
35 #include "searchbackend.h"
36 
37 class QItemSelection;
38 
40 {
41 
42 class SearchResultItem;
43 
44 class SearchResultModel : public QAbstractItemModel
45 {
46  Q_OBJECT
47 
48 public:
49 
51  {
52  public:
53 
55  };
56 
57 public:
58 
59  explicit SearchResultModel(QObject* const parent = nullptr);
60  ~SearchResultModel() override;
61 
62  void addResults(const SearchBackend::SearchResult::List& results);
63  SearchResultItem resultItem(const QModelIndex& index) const;
64  bool getMarkerIcon(const QModelIndex& index,
65  QPoint* const offset,
66  QSize* const size,
67  QPixmap* const pixmap,
68  QUrl* const url) const;
69  void setSelectionModel(QItemSelectionModel* const selectionModel);
70  void clearResults();
71  void removeRowsByIndexes(const QModelIndexList& rowsList);
72  void removeRowsBySelection(const QItemSelection& selection);
73 
74  // QAbstractItemModel:
75  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
76  bool setData(const QModelIndex& index,
77  const QVariant& value,
78  int role) override;
79  QVariant data(const QModelIndex& index,
80  int role = Qt::DisplayRole) const override;
81  QModelIndex index(int row,
82  int column,
83  const QModelIndex& parent = QModelIndex()) const override;
84  QModelIndex parent(const QModelIndex& index) const override;
85  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
86  bool setHeaderData(int section,
87  Qt::Orientation orientation,
88  const QVariant& value, int role) override;
89  QVariant headerData(int section,
90  Qt::Orientation orientation,
91  int role) const override;
92  Qt::ItemFlags flags(const QModelIndex& index) const override;
93 
94 private:
95 
96  class Private;
97  Private* const d;
98 };
99 
100 } // namespace DigikamGenericGeolocationEditPlugin
101 
102 #endif // DIGIKAM_SEARCH_RESULT_MODEL_H
SearchBackend::SearchResult result
Definition: searchresultmodel.h:54
void setSelectionModel(QItemSelectionModel *const selectionModel)
Definition: searchresultmodel.cpp:297
SearchResultModel(QObject *const parent=nullptr)
Definition: searchresultmodel.cpp:72
bool getMarkerIcon(const QModelIndex &index, QPoint *const offset, QSize *const size, QPixmap *const pixmap, QUrl *const url) const
Definition: searchresultmodel.cpp:252
~SearchResultModel() override
Definition: searchresultmodel.cpp:78
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: searchresultmodel.cpp:182
void clearResults()
Definition: searchresultmodel.cpp:302
QModelIndex parent(const QModelIndex &index) const override
Definition: searchresultmodel.cpp:153
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: searchresultmodel.cpp:194
void removeRowsByIndexes(const QModelIndexList &rowsList)
Definition: searchresultmodel.cpp:309
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: searchresultmodel.cpp:162
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: searchresultmodel.cpp:136
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: searchresultmodel.cpp:83
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: searchresultmodel.cpp:99
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) override
Definition: searchresultmodel.cpp:172
void removeRowsBySelection(const QItemSelection &selection)
Definition: searchresultmodel.cpp:344
SearchResultItem resultItem(const QModelIndex &index) const
Definition: searchresultmodel.cpp:242
void addResults(const SearchBackend::SearchResult::List &results)
Definition: searchresultmodel.cpp:199
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Definition: searchresultmodel.cpp:90
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: geolocationedit.cpp:97
@ Orientation
Definition: coredbfields.h:86