digiKam
importcategorizedview.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 : 2012-07-13
7  * Description : Qt categorized item view for camera items
8  *
9  * Copyright (C) 2012 by Islam Wazery <wazery at ubuntu dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_IMPORT_CATEGORIZED_VIEW_H
25 #define DIGIKAM_IMPORT_CATEGORIZED_VIEW_H
26 
27 // Local includes
28 
29 #include "itemviewcategorized.h"
30 #include "importimagemodel.h"
31 #include "importfiltermodel.h"
32 #include "importthumbnailmodel.h"
33 #include "itemdelegateoverlay.h"
34 #include "camiteminfo.h"
35 #include "digikam_export.h"
36 
37 namespace Digikam
38 {
39 
40 class ImportDelegate;
41 class ICCSettingsContainer;
42 
43 class DIGIKAM_GUI_EXPORT ImportCategorizedView : public ItemViewCategorized
44 {
45  Q_OBJECT
46 
47 public:
48 
49  explicit ImportCategorizedView(QWidget* const parent = nullptr);
50  ~ImportCategorizedView() override;
51 
52  void setModels(ImportItemModel* model,
53  ImportSortFilterModel* filterModel);
54 
55  ImportItemModel* importItemModel() const;
56  ImportSortFilterModel* importSortFilterModel() const;
57 
58  QItemSelectionModel* getSelectionModel() const;
59 
63  ImportFilterModel* importFilterModel() const;
64 
68  ImportThumbnailModel* importThumbnailModel() const;
69 
70  ImportDelegate* delegate() const;
71 
72  CamItemInfo currentInfo() const;
73  QUrl currentUrl() const;
74 
75  QList<CamItemInfo> selectedCamItemInfos() const;
76  QList<CamItemInfo> selectedCamItemInfosCurrentFirst() const;
77  QList<QUrl> selectedUrls() const;
78 
79  QList<CamItemInfo> camItemInfos() const;
80  QList<QUrl> urls() const;
81 
85  void toIndex(const QUrl& url);
86 
93  CamItemInfo nextInOrder(const CamItemInfo& startingPoint, int nth);
94 
96  {
97  return nextInOrder(info, -1);
98  }
99 
101  {
102  return nextInOrder(info, 1);
103  }
104 
109  void addOverlay(ItemDelegateOverlay* overlay, ImportDelegate* delegate = nullptr);
110  void removeOverlay(ItemDelegateOverlay* overlay);
111 
112  void addSelectionOverlay(ImportDelegate* delegate = nullptr);
113 
114  ThumbnailSize thumbnailSize() const;
115 
116  virtual void setThumbnailSize(const ThumbnailSize& size);
117 
118 public Q_SLOTS:
119 
120  void setThumbnailSize(int size);
121 
125  void setCurrentWhenAvailable(qlonglong camItemId);
126 
130  void setCurrentUrl(const QUrl& url);
131 
135  void setCurrentInfo(const CamItemInfo& info);
136 
140  void setSelectedUrls(const QList<QUrl>& urlList);
141 
145  void setSelectedCamItemInfos(const QList<CamItemInfo>& infos);
146 
150  void hintAt(const CamItemInfo& info);
151 
152 Q_SIGNALS:
153 
154  void currentChanged(const CamItemInfo& info);
155 
160  void selected(const QList<CamItemInfo>& newSelectedInfos);
161 
166  void deselected(const QList<CamItemInfo>& nowDeselectedInfos);
167 
172 
176  void modelChanged();
177 
178 protected Q_SLOTS:
179 
180  void slotCamItemInfosAdded();
181 
182 protected:
183 
185  QSortFilterProxyModel* filterModel() const override;
186  AbstractItemDragDropHandler* dragDropHandler() const override;
187  QModelIndex nextIndexHint(const QModelIndex& indexToAnchor, const QItemSelectionRange& removed) const override;
188 
189  void setItemDelegate(ImportDelegate* delegate);
190  void indexActivated(const QModelIndex& index, Qt::KeyboardModifiers modifiers) override;
191  void currentChanged(const QModelIndex& index, const QModelIndex& previous) override;
192  void paintEvent(QPaintEvent* e) override;
193  void selectionChanged(const QItemSelection&, const QItemSelection&) override;
194  void updateGeometries() override;
195 
197  virtual void activated(const CamItemInfo& info, Qt::KeyboardModifiers modifiers);
198  virtual void showContextMenuOnInfo(QContextMenuEvent* event, const CamItemInfo& info);
199  void showContextMenuOnIndex(QContextMenuEvent* event, const QModelIndex& index) override;
200 
201 private Q_SLOTS:
202 
203  void slotFileChanged(const QString& filePath);
204  void slotDelayedEnter();
205  void slotIccSettingsChanged(const ICCSettingsContainer&, const ICCSettingsContainer&);
206 
207 private:
208 
209  void scrollToStoredItem();
210 
211 private:
212 
213  // Disable
215  ImportCategorizedView& operator=(const ImportCategorizedView&) = delete;
216 
217 private:
218 
219  class Private;
220  Private* const d;
221 };
222 
223 } // namespace Digikam
224 
225 #endif // DIGIKAM_IMPORT_CATEGORIZED_VIEW_H
Definition: abstractitemdragdrophandler.h:42
Definition: camiteminfo.h:48
Definition: iccsettingscontainer.h:44
Definition: importcategorizedview.h:44
CamItemInfo nextInfo(const CamItemInfo &info)
Definition: importcategorizedview.h:100
void deselected(const QList< CamItemInfo > &nowDeselectedInfos)
void selected(const QList< CamItemInfo > &newSelectedInfos)
CamItemInfo previousInfo(const CamItemInfo &info)
Definition: importcategorizedview.h:95
void currentChanged(const CamItemInfo &info)
void camItemInfoActivated(const CamItemInfo &info)
Definition: importdelegate.h:45
Definition: importfiltermodel.h:101
Definition: importimagemodel.h:43
Definition: importfiltermodel.h:43
Definition: importthumbnailmodel.h:40
Definition: itemdelegateoverlay.h:41
Definition: itemviewcategorized.h:44
Definition: thumbnailsize.h:42
Definition: datefolderview.cpp:43