| 1 |
/* |
| 2 |
* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd. |
| 3 |
* |
| 4 |
* Author: ZhangYong <[email protected]> |
| 5 |
* |
| 6 |
* Maintainer: ZhangYong <[email protected]> |
| 7 |
* |
| 8 |
* This program is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
#ifndef ALBUMDELEGATE_H |
| 22 |
#define ALBUMDELEGATE_H |
| 23 |
|
| 24 |
#include <QObject> |
| 25 |
#include <QDateTime> |
| 26 |
#include <QStyledItemDelegate> |
| 27 |
#include <QDebug> |
| 28 |
|
| 29 |
#include "albumgloabl.h" |
| 30 |
|
| 31 |
class TDThumbnailThread; |
| 32 |
class ThumbnailDelegate : public QStyledItemDelegate |
| 33 |
{ |
| 34 |
Q_OBJECT |
| 35 |
|
| 36 |
public: |
| 37 |
enum DelegateType { |
| 38 |
NullType = 0, |
| 39 |
AllPicViewType,//所有照片 |
| 40 |
|
| 41 |
TimeLineViewType,//时间线 |
| 42 |
|
| 43 |
SearchViewType,//搜索 |
| 44 |
|
| 45 |
AlbumViewImportTimeLineViewType,//相册-最近导入 |
| 46 |
AlbumViewTrashType,//相册-已删除 |
| 47 |
AlbumViewFavoriteType,//相册-收藏 |
| 48 |
AlbumViewCustomType,//相册-自定义 |
| 49 |
AlbumViewPhoneType//相册-设备 |
| 50 |
}; |
| 51 |
|
| 52 |
explicit ThumbnailDelegate(DelegateType type, QObject *parent = nullptr); |
| 53 |
void setIsDataLocked(bool value); |
| 54 |
// void setNeedPaint(bool value); |
| 55 |
|
| 56 |
void setItemSize(QSize size); |
| 57 |
//绘制图片和视频 |
| 58 |
void drawImgAndVideo(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; |
| 59 |
private slots: |
| 60 |
void onThemeTypeChanged(int themeType); |
| 61 |
|
| 62 |
protected: |
| 63 |
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; |
| 64 |
|
| 65 |
QSize sizeHint(const QStyleOptionViewItem &option, |
| 66 |
const QModelIndex &index) const Q_DECL_OVERRIDE; |
| 67 |
|
| 68 |
bool editorEvent(QEvent *event, |
| 69 |
QAbstractItemModel *model, |
| 70 |
const QStyleOptionViewItem &option, |
| 71 |
const QModelIndex &index) Q_DECL_OVERRIDE; |
| 72 |
|
| 73 |
signals: |
| 74 |
void sigCancelFavorite(const QModelIndex &index); |
| 75 |
// void sigPageNeedResize(const int &index) const; |
| 76 |
|
| 77 |
private: |
| 78 |
DBImgInfo itemData(const QModelIndex &index) const; |
| 79 |
|
| 80 |
public: |
| 81 |
QString m_imageTypeStr; |
| 82 |
|
| 83 |
private: |
| 84 |
QPixmap selectedPixmapLight; |
| 85 |
QPixmap selectedPixmapDark; |
| 86 |
QColor m_borderColor; |
| 87 |
QString m_defaultThumbnail; |
| 88 |
bool m_itemdata = false; |
| 89 |
DelegateType m_delegatetype = NullType; |
| 90 |
bool bneedpaint = true; |
| 91 |
QSize m_size; |
| 92 |
QPixmap m_default;//图片默认图片 |
| 93 |
QPixmap m_videoDefault;//视频默认图片 |
| 94 |
QPixmap m_damagePixmap; |
| 95 |
}; |
| 96 |
|
| 97 |
#endif // ALBUMDELEGATE_H |