Debian Codegraph @

src/album/thumbnail/imgviewlistview.h

raw
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 IMGVIEWLISTVIEW_H
22 #define IMGVIEWLISTVIEW_H
23
24 #include "imgviewdelegate.h"
25 //#include "application.h"
26 #include "controller/configsetter.h"
27 #include "controller/signalmanager.h"
28 //#include "controller/wallpapersetter.h"
29 #include "dbmanager/dbmanager.h"
30 #include "widgets/printhelper.h"
31 //#include "dlmenuarrow.h"
32 #include <QListWidget>
33 #include <QListWidgetItem>
34 #include <QListView>
35 #include <QList>
36 #include <DPushButton>
37 #include <DImageButton>
38 #include <DIconButton>
39 #include <DListView>
40 #include <QWidgetAction>
41 #include <QPixmap>
42 #include <QIcon>
43 #include <DLabel>
44 #include <QFileInfo>
45 #include <QSize>
46 #include <QStandardItemModel>
47 #include <QBuffer>
48 #include <DMenu>
49 #include <QMouseEvent>
50 #include <QPointer>
51 #include <DApplicationHelper>
52 #include "albumgloabl.h"
53
54 DWIDGET_USE_NAMESPACE
55
56 class ImgViewListView : public DListView
57 {
58 Q_OBJECT
59
60 public:
61 explicit ImgViewListView(QWidget *parent = nullptr);
62 ~ImgViewListView() override;
63
64 void setAllFile(const SignalManager::ViewInfo &info, const QString &path);//设置需要展示的所有缩略图
65
66 int getSelectIndexByPath(const QString &path);
67 //将选中的项居中
68 void setSelectCenter();
69 //查看下一张
70 void openNext();
71 bool isLast();
72 //查看前一张
73 void openPre();
74 bool isFirst();
75 //移除当前选中
76 void removeCurrent();
77 protected:
78 // void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
79 public slots:
80 //有新的图片加载上来
81 void slotOneImgReady(const QString &path, QPixmap pix);
82 //列表点击事件
83 void onClicked(const QModelIndex &index);
84 private:
85 void cutPixmap(DBImgInfo &DBImgInfo);
86 //加载后50张图片
87 void loadFiftyRight();
88 //当点击的是最后一个时,向前移动动画
89 void startMoveToLeftAnimation();
90 //根据行号获取路径path
91 const QString getPathByRow(int row);
92 signals:
93 void openImg(int index, QString path);
94 public:
95 const static int ITEM_NORMAL_WIDTH = 30;//非选中状态宽度
96 const static int ITEM_NORMAL_HEIGHT = 40;//非选中状态高度
97 const static int ITEM_CURRENT_WH = 50;//当前选中状态宽高
98 public:
99 ImgViewDelegate *m_delegate = nullptr;
100 QStandardItemModel *m_model = nullptr;
101 QStringList m_allFileList;//需要展示的全部缩略图路径
102
103 QPropertyAnimation *m_moveAnimation = nullptr;//移动动画
104
105 int m_currentRow = -1;//当前展示项
106 int m_pre = -1;
107 QString m_currentPath;
108 };
109
110 #endif // THUMBNAILLISTVIEW_H