digiKam
dtrashitemmodel.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 : 2015-08-09
7  * Description : DTrash item info model
8  *
9  * Copyright (C) 2015 by Mohamed_Anwer <m_dot_anwer at gmx 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_DTRASH_ITEM_MODEL_H
25 #define DIGIKAM_DTRASH_ITEM_MODEL_H
26 
27 // Qt includes
28 
29 #include <QAbstractTableModel>
30 
31 // Local includes
32 
33 #include "dtrashiteminfo.h"
34 #include "thumbnailloadthread.h"
35 
36 namespace Digikam
37 {
38 
39 class DTrashItemModel : public QAbstractTableModel
40 {
41  Q_OBJECT
42 
43 public:
44 
46  {
51  };
52 
53 public:
54 
55  explicit DTrashItemModel(QObject* const parent = nullptr);
56  ~DTrashItemModel() override;
57 
64  bool pixmapForItem(const QString& path, QPixmap& pix) const;
65 
69  void clearCurrentData();
70 
75  void loadItemsForCollection(const QString& colPath);
76 
80  DTrashItemInfo itemForIndex(const QModelIndex& index);
81 
86 
90  QModelIndex indexForItem(const DTrashItemInfo& itemInfo) const;
91 
96 
100  bool isEmpty();
101 
106  void changeThumbSize(int size);
107 
109 public:
110 
111  int rowCount(const QModelIndex&) const override;
112  int columnCount(const QModelIndex&) const override;
113 
114  QVariant data(const QModelIndex& index, int role) const override;
115  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
116 
117  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
118 
119 public Q_SLOTS:
120 
125  void append(const DTrashItemInfo& itemInfo);
126 
132  void removeItems(const QModelIndexList& indexes);
133 
137  void refreshLayout();
138 
144  void refreshThumbnails(const LoadingDescription& desc, const QPixmap& pix);
145 
146 Q_SIGNALS:
147 
148  void dataChange();
149 
150 private:
151 
152  class Private;
153  Private* const d;
154 };
155 
156 } // namespace Digikam
157 
158 #endif // DIGIKAM_DTRASH_ITEM_MODEL_H
Definition: dtrashiteminfo.h:36
Definition: dtrashitemmodel.h:40
QModelIndex indexForItem(const DTrashItemInfo &itemInfo) const
returns the index for the DTrashItemInfo in model
Definition: dtrashitemmodel.cpp:412
void removeItems(const QModelIndexList &indexes)
removes list of items for given indexes from model data and informs the view
Definition: dtrashitemmodel.cpp:299
bool isEmpty()
Definition: dtrashitemmodel.cpp:429
QVariant data(const QModelIndex &index, int role) const override
Definition: dtrashitemmodel.cpp:106
DTrashItemInfo itemForIndex(const QModelIndex &index)
returns DTrashItemInfo for specific index in model
Definition: dtrashitemmodel.cpp:385
void loadItemsForCollection(const QString &colPath)
Runs a thread to list all items from a collection trash.
Definition: dtrashitemmodel.cpp:374
void refreshLayout()
refreshes the view layout
Definition: dtrashitemmodel.cpp:332
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: dtrashitemmodel.cpp:247
DTrashItemModel(QObject *const parent=nullptr)
Definition: dtrashitemmodel.cpp:78
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
Definition: dtrashitemmodel.cpp:195
void changeThumbSize(int size)
Changes the thumbnail size.
Definition: dtrashitemmodel.cpp:434
void refreshThumbnails(const LoadingDescription &desc, const QPixmap &pix)
refreshes the thumbnails
Definition: dtrashitemmodel.cpp:342
int columnCount(const QModelIndex &) const override
Definition: dtrashitemmodel.cpp:101
DTrashColumn
Definition: dtrashitemmodel.h:46
@ DTrashTimeStamp
Definition: dtrashitemmodel.h:49
@ DTrashRelPath
Definition: dtrashitemmodel.h:48
@ DTrashThumb
Definition: dtrashitemmodel.h:47
@ DTrashNumCol
Definition: dtrashitemmodel.h:50
~DTrashItemModel() override
Definition: dtrashitemmodel.cpp:90
void append(const DTrashItemInfo &itemInfo)
appends item to model data and informs the view
Definition: dtrashitemmodel.cpp:283
int rowCount(const QModelIndex &) const override
QAbstractItemModel interface.
Definition: dtrashitemmodel.cpp:96
DTrashItemInfoList allItems()
returns a list of all items in model
Definition: dtrashitemmodel.cpp:424
bool pixmapForItem(const QString &path, QPixmap &pix) const
loads a thumbnail for item in trash for showing
Definition: dtrashitemmodel.cpp:236
DTrashItemInfoList itemsForIndexes(const QList< QModelIndex > &indexes)
returns DTrashItemInfoList for given indexes in model
Definition: dtrashitemmodel.cpp:395
void clearCurrentData()
Clears all data from model and informs the view.
Definition: dtrashitemmodel.cpp:364
Definition: loadingdescription.h:45
@ Orientation
Definition: coredbfields.h:86
Definition: datefolderview.cpp:43