Skip to content

Commit 4c2b5fc

Browse files
committed
fix: image viewer contain videos
Image viewer not need show videos. Log: image viewer remove videos. Bug: https://pms.uniontech.com/bug-view-295427.html
1 parent 92f72a2 commit 4c2b5fc

File tree

5 files changed

+41
-9
lines changed

5 files changed

+41
-9
lines changed

src/qml/Control/ListView/ThumbnailListViewTools.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ function executeViewImageCutSwitch() {
88
var indexes = thumbnailModel.selectedIndexes
99
if (indexes.length > 0) {
1010
var url = thumbnailModel.data(indexes[0], "url").toString()
11-
var allUrls = thumbnailModel.allUrls()
12-
menuItemStates.executeViewImageCutSwitch(url, allUrls)
11+
var allPicUrls = thumbnailModel.allPictureUrls()
12+
menuItemStates.executeViewImageCutSwitch(url, allPicUrls)
1313
}
1414
}
1515
}
@@ -20,12 +20,13 @@ function executeViewImage(x, y, w, h) {
2020
var indexes = thumbnailModel.selectedIndexes
2121
if (indexes.length > 0) {
2222
var url = thumbnailModel.data(indexes[0], "url").toString()
23-
var allUrls = thumbnailModel.allUrls()
2423
if (FileControl.isVideo(url)) {
24+
var allUrls = thumbnailModel.allUrls()
2525
menuItemStates.executeViewImageCutSwitch(url, allUrls)
2626
} else {
27+
var allPicUrls = thumbnailModel.allPictureUrls()
2728
GStatus.enteringImageViewer = true
28-
menuItemStates.executeViewImageCutSwitch(url, allUrls)
29+
menuItemStates.executeViewImageCutSwitch(url, allPicUrls)
2930
GStatus.sigMoveCenter(x, y, w, h)
3031
GStatus.sigShowToolBar()
3132
}
@@ -47,7 +48,7 @@ function executeDelete() {
4748
// 执行全屏预览
4849
function executeFullScreen() {
4950
if (window.visibility !== Window.FullScreen && selectedUrls.length > 0) {
50-
var allUrls = thumbnailModel.allUrls()
51+
var allUrls = thumbnailModel.allPictureUrls()
5152
var indexes = thumbnailModel.selectedIndexes
5253
if (indexes.length > 0) {
5354
menuItemStates.executeFullScreen(allUrls[indexes[0]], allUrls)
@@ -63,7 +64,7 @@ function executePrint() {
6364
// 执行幻灯片放映
6465
function excuteSlideShow() {
6566
if (selectedUrls.length > 0) {
66-
var allUrls = thumbnailModel.allUrls()
67+
var allUrls = thumbnailModel.allPictureUrls()
6768
menuItemStates.excuteSlideShow(allUrls)
6869
//stackControl.startMainSliderShow(allUrls, allUrls.indexOf(selectedUrls[0]))
6970
}

src/src/thumbnailview/imagedatamodel.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ QVariant ImageDataModel::data(const QModelIndex &index, int role) const
8181
return "other";
8282
}
8383
}
84+
85+
case Roles::ItemTypeFlagRole: {
86+
return info.itemType;
87+
}
8488
}
8589

8690
return {};

src/src/thumbnailview/roles.h

+16-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,22 @@ class Roles : public QObject
1414
public:
1515
using QObject::QObject;
1616
~Roles() = default;
17-
enum RoleNames { BlankRole = Qt::UserRole + 1, DBImgInfoRole, Thumbnail, ReloadThumbnail, ItemTypeRole, SelectedRole, SourceIndex
18-
, ModelTypeRole, FileNameRole, UrlRole, FilePathRole, PathHashRole, RemainDaysRole
19-
};
17+
enum RoleNames {
18+
BlankRole = Qt::UserRole + 1,
19+
DBImgInfoRole,
20+
Thumbnail,
21+
ReloadThumbnail,
22+
ItemTypeRole,
23+
SelectedRole,
24+
SourceIndex,
25+
ModelTypeRole,
26+
FileNameRole,
27+
UrlRole,
28+
FilePathRole,
29+
PathHashRole,
30+
RemainDaysRole,
31+
ItemTypeFlagRole,
32+
};
2033
};
2134

2235
#endif

src/src/thumbnailview/thumbnailmodel.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,19 @@ QJsonArray ThumbnailModel::allUrls()
329329
return arr;
330330
}
331331

332+
QStringList ThumbnailModel::allPictureUrls()
333+
{
334+
QStringList pictureUrls;
335+
for (int row = 0; row < rowCount(); row++) {
336+
QModelIndex idx = index(row, 0);
337+
if (ItemTypePic == idx.data(Roles::ItemTypeFlagRole).toInt()) {
338+
pictureUrls.append(idx.data(Roles::UrlRole).toString());
339+
}
340+
}
341+
342+
return pictureUrls;
343+
}
344+
332345
QJsonArray ThumbnailModel::allPaths()
333346
{
334347
QJsonArray arr;

src/src/thumbnailview/thumbnailmodel.h

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class ThumbnailModel : public QSortFilterProxyModel
7070
Q_INVOKABLE int proxyIndex(const int &indexValue);
7171
Q_INVOKABLE int sourceIndex(const int &indexValue);
7272
Q_INVOKABLE QJsonArray allUrls();
73+
Q_INVOKABLE QStringList allPictureUrls();
7374
Q_INVOKABLE QJsonArray allPaths();
7475
Q_INVOKABLE QJsonArray selectedUrls();
7576
Q_INVOKABLE QJsonArray selectedPaths();

0 commit comments

Comments
 (0)