downloaded files now stored with squawk:// prefix, that way I can move downloads folder without messing up the database

This commit is contained in:
Blue 2022-02-19 00:27:09 +03:00
parent 243edff8bd
commit d8b5ccb2da
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
14 changed files with 75 additions and 44 deletions

View file

@ -314,7 +314,7 @@ QSize MessageDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel
case Models::none:
break;
case Models::uploading:
messageSize.rheight() += Preview::calculateAttachSize(data.attach.localPath, messageRect).height() + textMargin;
messageSize.rheight() += Preview::calculateAttachSize(Shared::resolvePath(data.attach.localPath), messageRect).height() + textMargin;
[[fallthrough]];
case Models::downloading:
messageSize.rheight() += barHeight + textMargin;
@ -326,7 +326,7 @@ QSize MessageDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel
break;
case Models::ready:
case Models::local: {
QSize aSize = Preview::calculateAttachSize(data.attach.localPath, messageRect);
QSize aSize = Preview::calculateAttachSize(Shared::resolvePath(data.attach.localPath), messageRect);
messageSize.rheight() += aSize.height() + textMargin;
messageSize.setWidth(std::max(messageSize.width(), aSize.width()));
}
@ -338,7 +338,7 @@ QSize MessageDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel
}
break;
case Models::errorUpload: {
QSize aSize = Preview::calculateAttachSize(data.attach.localPath, messageRect);
QSize aSize = Preview::calculateAttachSize(Shared::resolvePath(data.attach.localPath), messageRect);
QSize commentSize = dateMetrics.boundingRect(messageRect, Qt::TextWordWrap, data.attach.error).size();
messageSize.rheight() += aSize.height() + commentSize.height() + textMargin * 2;
messageSize.setWidth(std::max(messageSize.width(), std::max(commentSize.width(), aSize.width())));
@ -455,12 +455,13 @@ int MessageDelegate::paintPreview(const Models::FeedItem& data, QPainter* painte
std::map<QString, Preview*>::iterator itr = previews->find(data.id);
QSize size = option.rect.size();
QString path = Shared::resolvePath(data.attach.localPath);
if (itr != previews->end()) {
preview = itr->second;
preview->actualize(data.attach.localPath, size, option.rect.topLeft());
preview->actualize(path, size, option.rect.topLeft());
} else {
QWidget* vp = static_cast<QWidget*>(painter->device());
preview = new Preview(data.attach.localPath, size, option.rect.topLeft(), vp);
preview = new Preview(path, size, option.rect.topLeft(), vp);
previews->insert(std::make_pair(data.id, preview));
}

View file

@ -33,6 +33,7 @@
#include "shared/icons.h"
#include "shared/global.h"
#include "shared/utils.h"
#include "shared/pathcheck.h"
#include "preview.h"