digiKam
itemcategorizedview.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 : 2009-04-22
7  * Description : Qt model-view for items
8  *
9  * Copyright (C) 2009-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2017 by Simon Frei <freisim93 at gmail dot com>
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_ITEM_CATEGORIZED_VIEW_H
26 #define DIGIKAM_ITEM_CATEGORIZED_VIEW_H
27 
28 // Local includes
29 
30 #include "iteminfo.h"
31 #include "itemviewcategorized.h"
32 #include "thumbnailsize.h"
33 #include "iccsettingscontainer.h"
34 
35 namespace Digikam
36 {
37 
38 class Album;
39 class ItemAlbumModel;
40 class ItemAlbumFilterModel;
41 class ItemModel;
42 class ItemFilterModel;
43 class ImageSortFilterModel;
44 class ItemDelegate;
45 class ItemDelegateOverlay;
46 class ItemThumbnailModel;
47 
49 {
50  Q_OBJECT
51 
52 public:
53 
54  explicit ItemCategorizedView(QWidget* const parent = nullptr);
55  ~ItemCategorizedView() override;
56 
58 
59  ItemModel* imageModel() const;
61 
62  QItemSelectionModel* getSelectionModel() const;
63 
66 
69 
73 
74  ItemDelegate* delegate() const;
75 
76  Album* currentAlbum() const;
77  ItemInfo currentInfo() const;
78  QUrl currentUrl() const;
79 
80  ItemInfoList allItemInfos() const;
81  QList<QUrl> allUrls() const;
84 
87  void toIndex(const QUrl& url);
88 
95  ItemInfo nextInOrder(const ItemInfo& startingPoint, int nth);
96 
98  {
99  return nextInOrder(info, -1);
100  }
101 
103  {
104  return nextInOrder(info, 1);
105  }
106 
107  QModelIndex indexForInfo(const ItemInfo& info) const;
108 
110 
111  virtual void setThumbnailSize(const ThumbnailSize& size);
112 
117  Album* albumAt(const QPoint& pos) const;
118 
121  void addOverlay(ItemDelegateOverlay* overlay, ItemDelegate* delegate = nullptr);
122 
123  void removeOverlay(ItemDelegateOverlay* overlay);
124 
125  void addSelectionOverlay(ItemDelegate* delegate = nullptr);
126 
127 public Q_SLOTS:
128 
129  void openAlbum(const QList<Album*>& album);
130 
131  void setThumbnailSize(int size);
132 
135  void setCurrentWhenAvailable(qlonglong imageId);
136 
139  void setCurrentUrlWhenAvailable(const QUrl& url);
140 
143  void setCurrentUrl(const QUrl& url);
144 
147  void setCurrentInfo(const ItemInfo& info);
148 
151  void setSelectedUrls(const QList<QUrl>& urlList);
152 
155  void setSelectedItemInfos(const QList<ItemInfo>& infos);
156 
159  void hintAt(const ItemInfo& info);
160 
161 Q_SIGNALS:
162 
163  void currentChanged(const ItemInfo& info);
164 
167  void selected(const QList<ItemInfo>& newSelectedInfos);
168 
171  void deselected(const QList<ItemInfo>& nowDeselectedInfos);
172 
174  void imageActivated(const ItemInfo& info);
175 
177  void modelChanged();
178 
179 protected Q_SLOTS:
180 
181  void slotItemInfosAdded();
182  void slotCurrentUrlTimer();
183 
184 protected:
185 
187  void installDefaultModels();
188 
189  // reimplemented from parent class
190 
191  QSortFilterProxyModel* filterModel() const override;
193  QModelIndex nextIndexHint(const QModelIndex& indexToAnchor,
194  const QItemSelectionRange& removed) const override;
195 
197  void indexActivated(const QModelIndex& index, Qt::KeyboardModifiers modifiers) override;
198  void currentChanged(const QModelIndex& index, const QModelIndex& previous) override;
199  void selectionChanged(const QItemSelection&, const QItemSelection&) override;
200  void updateGeometries() override;
201 
203  virtual void activated(const ItemInfo& info, Qt::KeyboardModifiers modifiers);
204  virtual void showContextMenuOnInfo(QContextMenuEvent* event, const ItemInfo& info);
205  void showContextMenuOnIndex(QContextMenuEvent* event, const QModelIndex& index) override;
206 
207  ItemInfo imageInfo(const QModelIndex& index) const;
208  ItemInfoList imageInfos(const QList<QModelIndex>& indexes) const;
209 
210 private Q_SLOTS:
211 
212  void slotIccSettingsChanged(const ICCSettingsContainer&, const ICCSettingsContainer&);
213  void slotFileChanged(const QString& filePath);
214  void slotDelayedEnter();
215 
216 private:
217 
218  void scrollToStoredItem();
219 
220 private:
221 
222  class Private;
223  Private* const d;
224 };
225 
226 } // namespace Digikam
227 
228 #endif // DIGIKAM_ITEM_CATEGORIZED_VIEW_H
Definition: abstractitemdragdrophandler.h:42
Abstract base class for all album types.
Definition: album.h:67
Definition: iccsettingscontainer.h:44
Definition: itemfiltermodel.h:63
Definition: itemalbumfiltermodel.h:40
Definition: itemalbummodel.h:47
Definition: itemcategorizedview.h:49
void updateGeometries() override
Definition: itemcategorizedview.cpp:601
Album * albumAt(const QPoint &pos) const
Definition: itemcategorizedview.cpp:699
void deselected(const QList< ItemInfo > &nowDeselectedInfos)
Emitted when items are deselected. There may be other selected infos left. This signal is not emitted...
void setItemDelegate(ItemDelegate *delegate)
Definition: itemcategorizedview.cpp:244
QModelIndex indexForInfo(const ItemInfo &info) const
Definition: itemcategorizedview.cpp:359
void modelChanged()
Emitted when a new model is set.
virtual void showContextMenuOnInfo(QContextMenuEvent *event, const ItemInfo &info)
Definition: itemcategorizedview.cpp:726
void slotCurrentUrlTimer()
Definition: itemcategorizedview.cpp:650
ItemThumbnailModel * imageThumbnailModel() const
Returns 0 if the ItemModel is not an ItemThumbnailModel.
Definition: itemcategorizedview.cpp:219
Album * currentAlbum() const
Definition: itemcategorizedview.cpp:286
void setSelectedItemInfos(const QList< ItemInfo > &infos)
Definition: itemcategorizedview.cpp:542
ImageSortFilterModel * imageSortFilterModel() const
Definition: itemcategorizedview.cpp:209
virtual void activated(const ItemInfo &info, Qt::KeyboardModifiers modifiers)
Reimplement these in a subclass.
Definition: itemcategorizedview.cpp:716
void installDefaultModels()
install default ItemAlbumModel and filter model, ready for use
Definition: itemcategorizedview.cpp:141
void hintAt(const ItemInfo &info)
Definition: itemcategorizedview.cpp:555
void openAlbum(const QList< Album * > &album)
Definition: itemcategorizedview.cpp:419
ItemInfo nextInOrder(const ItemInfo &startingPoint, int nth)
Definition: itemcategorizedview.cpp:364
void showContextMenuOnIndex(QContextMenuEvent *event, const QModelIndex &index) override
Reimplement these in a subclass.
Definition: itemcategorizedview.cpp:721
QItemSelectionModel * getSelectionModel() const
Definition: itemcategorizedview.cpp:731
void setModels(ItemModel *model, ImageSortFilterModel *filterModel)
Definition: itemcategorizedview.cpp:159
ItemInfo imageInfo(const QModelIndex &index) const
Definition: itemcategorizedview.cpp:310
void setSelectedUrls(const QList< QUrl > &urlList)
Definition: itemcategorizedview.cpp:517
ItemFilterModel * imageFilterModel() const
Returns any ItemFilterMode in chain. May not be sourceModel()
Definition: itemcategorizedview.cpp:214
ItemInfoList selectedItemInfosCurrentFirst() const
Definition: itemcategorizedview.cpp:335
ItemAlbumFilterModel * imageAlbumFilterModel() const
Definition: itemcategorizedview.cpp:229
ItemInfo nextInfo(const ItemInfo &info)
Definition: itemcategorizedview.h:102
void addOverlay(ItemDelegateOverlay *overlay, ItemDelegate *delegate=nullptr)
Add and remove an overlay. It will as well be removed automatically when destroyed....
Definition: itemcategorizedview.cpp:573
ItemInfo previousInfo(const ItemInfo &info)
Definition: itemcategorizedview.h:97
void setCurrentUrlWhenAvailable(const QUrl &url)
Definition: itemcategorizedview.cpp:466
ItemModel * imageModel() const
Definition: itemcategorizedview.cpp:204
void removeOverlay(ItemDelegateOverlay *overlay)
Definition: itemcategorizedview.cpp:589
void addSelectionOverlay(ItemDelegate *delegate=nullptr)
Definition: itemcategorizedview.cpp:619
void setCurrentWhenAvailable(qlonglong imageId)
Definition: itemcategorizedview.cpp:461
virtual void setThumbnailSize(const ThumbnailSize &size)
Definition: itemcategorizedview.cpp:452
void setCurrentInfo(const ItemInfo &info)
Definition: itemcategorizedview.cpp:510
QModelIndex nextIndexHint(const QModelIndex &indexToAnchor, const QItemSelectionRange &removed) const override
Definition: itemcategorizedview.cpp:376
ItemInfoList imageInfos(const QList< QModelIndex > &indexes) const
Definition: itemcategorizedview.cpp:315
ItemInfoList allItemInfos() const
Definition: itemcategorizedview.cpp:320
void setCurrentUrl(const QUrl &url)
Definition: itemcategorizedview.cpp:489
void selected(const QList< ItemInfo > &newSelectedInfos)
Emitted when new items are selected. The parameter includes only the newly selected infos,...
QList< QUrl > allUrls() const
Definition: itemcategorizedview.cpp:325
~ItemCategorizedView() override
Definition: itemcategorizedview.cpp:135
void currentChanged(const ItemInfo &info)
void imageActivated(const ItemInfo &info)
Emitted when the given image is activated. Info is never null.
void indexActivated(const QModelIndex &index, Qt::KeyboardModifiers modifiers) override
Definition: itemcategorizedview.cpp:666
ItemDelegate * delegate() const
Definition: itemcategorizedview.cpp:239
ItemInfo currentInfo() const
Definition: itemcategorizedview.cpp:300
ItemInfoList selectedItemInfos() const
Definition: itemcategorizedview.cpp:330
void slotItemInfosAdded()
Definition: itemcategorizedview.cpp:638
ItemAlbumModel * imageAlbumModel() const
Returns 0 if the ItemModel is not an ItemAlbumModel.
Definition: itemcategorizedview.cpp:224
QSortFilterProxyModel * filterModel() const override
Definition: itemcategorizedview.cpp:234
ItemCategorizedView(QWidget *const parent=nullptr)
Definition: itemcategorizedview.cpp:115
ThumbnailSize thumbnailSize() const
Definition: itemcategorizedview.cpp:429
AbstractItemDragDropHandler * dragDropHandler() const override
Definition: itemcategorizedview.cpp:736
void toIndex(const QUrl &url)
Definition: itemcategorizedview.cpp:354
QUrl currentUrl() const
Definition: itemcategorizedview.cpp:305
Definition: itemdelegateoverlay.h:41
Definition: itemdelegate.h:44
Definition: itemfiltermodel.h:125
Definition: iteminfolist.h:47
Definition: iteminfo.h:78
Definition: itemmodel.h:53
Definition: itemthumbnailmodel.h:41
Definition: itemviewcategorized.h:44
Definition: thumbnailsize.h:42
@ Album
Definition: coredbfields.h:58
Definition: datefolderview.cpp:43