chatgui: клик по медиа с отсутствующим файлом — сброс пометки и перекачка

This commit is contained in:
evgeny committed 2026-09-22 21:59:59 +03:00
1 parent d237dfec7c
commit 7198154106
2 files changed
+15 -8

No files matched your search

+11 -8
View File
@@ -92,7 +92,7 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
m_videoOpenCb(fp);
return true;
}
return false;
/* файл пропал (вычистка кеша/удаление) — перекачиваем ниже */
}
if (dlState == 1) return false; /* скачивается */
@@ -119,7 +119,7 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
m_imageOpenCb(fp);
return true;
}
return false;
/* файл пропал (вычистка кеша/удаление) — перекачиваем ниже */
}
if (dlState == 1) return false; /* скачивается */
@@ -142,11 +142,13 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
if (dlState == 2) { /* downloaded: open file */
QString fp = index.data(MsgVoiceFileRole).toString();
if (!fp.isEmpty() && QFile::exists(fp))
if (!fp.isEmpty() && QFile::exists(fp)) {
QDesktopServices::openUrl(QUrl::fromLocalFile(fp));
return true;
return true;
}
/* файл пропал (вычистка кеша/удаление) — перекачиваем ниже */
}
if (dlState != 0) return false; /* downloading — no action */
if (dlState == 1) return false; /* downloading — no action */
if (chId.isEmpty() || msgId <= 0) return false;
struct attachment_dl_req* req = (struct attachment_dl_req*)
@@ -178,8 +180,9 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
(int)onPlayBtn, (int)onWaveform, qPrintable(filePath), QFile::exists(filePath),
dlState, (long long)msgId);
/* not downloaded: start download (play will start on completion) */
if (filePath.isEmpty() && dlState != 1) {
/* not downloaded (or file evicted): start download (play will start on completion) */
bool fileMissing = filePath.isEmpty() || !QFile::exists(filePath);
if (fileMissing && dlState != 1) {
if (chId.isEmpty() || msgId <= 0) return false;
struct attachment_dl_req* req = (struct attachment_dl_req*)
u_malloc(sizeof(struct attachment_dl_req));
@@ -193,7 +196,7 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
return true;
}
if (filePath.isEmpty()) return false;
if (fileMissing) return false;
GUI_DEBUG("editorEvent voice click: filePath=%s exists=%d wave=%d",
qPrintable(filePath), QFile::exists(filePath), (int)onWaveform);
if (filePath.isEmpty()) return false;