Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Delete image not work after rename. #113

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions libimageviewer/viewpanel/contents/bottomtoolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,12 @@ void LibBottomToolbar::checkAdaptScreenBtn()

void LibBottomToolbar::deleteImage()
{
if (m_imgListWidget->getImgCount() == 0)
return;
//移除正在展示照片
if (m_imgListWidget) {
QString path = m_imgListWidget->getCurrentPath();
if (m_imgListWidget->getImgCount() == 0)
return;

QString path = getCurrentItemInfo().path;

QFile file(path);
if (!file.exists()) {
Expand Down Expand Up @@ -373,7 +374,7 @@ void LibBottomToolbar::onTrashBtnClicked()
//更换删除顺序,相册需要现在显示删除,再删除本体
QString path;
if (m_imgListWidget) {
path = m_imgListWidget->getCurrentPath();
path = getCurrentItemInfo().path;
}
if (path.isEmpty() && m_currentpath.isEmpty()) {
path = m_currentpath;
Expand Down
9 changes: 8 additions & 1 deletion libimageviewer/viewpanel/contents/imgviewlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,17 @@ void LibImgViewListView::slotOneImgReady(QString path, imageViewerSpace::ItemInf
if (data.path == path) {
pix.imgWidth = data.imgWidth;
pix.imgHeight = data.imgHeight;
// cutPixmap(pix);

// 更新文件信息
QVariant meta;
meta.setValue(pix);
m_model->setData(index, meta, Qt::DisplayRole);

// 判断当前的文件路径是否变更(重命名时),若变更则更新
if (path == m_currentPath && pix.path != m_currentPath) {
m_currentPath = pix.path;
}

this->update(index);
this->viewport()->update();
break;
Expand Down