Simplify image provider and remove useless bottleneck steps.
Add pagination on details call logs.
This commit is contained in:
parent
3589029ec5
commit
9454aa3781
2 changed files with 33 additions and 26 deletions
|
|
@ -42,43 +42,47 @@ using namespace std;
|
||||||
const QString ImageProvider::ProviderId = "internal";
|
const QString ImageProvider::ProviderId = "internal";
|
||||||
|
|
||||||
ImageAsyncImageResponse::ImageAsyncImageResponse(const QString &id, const QSize &requestedSize) {
|
ImageAsyncImageResponse::ImageAsyncImageResponse(const QString &id, const QSize &requestedSize) {
|
||||||
|
|
||||||
QString path = ":/data/image/";
|
QString path = ":/data/image/";
|
||||||
QStringList filters;
|
// Snippet for external images (useful for Chats). Do not use it for internal because of performance issue.
|
||||||
filters << "*.svg";
|
// QStringList filters;
|
||||||
filters << "*.png";
|
// filters << "*.svg";
|
||||||
QDir imageDir(path);
|
// filters << "*.png";
|
||||||
if (!imageDir.exists()) {
|
// filters << id;// Use it if we don't need wildcards.
|
||||||
lDebug() << QStringLiteral("[ImageProvider] Dir doesn't exist: `%1`.").arg(path);
|
// QDir imageDir(path);
|
||||||
emit imageGrabbed(QImage(":/data/image/warning-circle.svg"));
|
// if (!imageDir.exists()) {
|
||||||
return;
|
// lDebug() << QStringLiteral("[ImageProvider] Dir doesn't exist: `%1`.").arg(path);
|
||||||
}
|
// imageGrabbed(QImage(":/data/image/warning-circle.svg"));
|
||||||
QFileInfoList files = QDir(path).entryInfoList(filters, QDir::Files, QDir::Name);
|
// return;
|
||||||
QFileInfo fileInfo;
|
// }
|
||||||
for (QFileInfo file : files) {
|
// elapsedTimes.push_back(benchmark.restart());
|
||||||
if (file.fileName() == id) {
|
|
||||||
fileInfo = file;
|
|
||||||
mPath = file.absoluteFilePath();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// QFileInfoList files = QDir(path).entryInfoList(filters, QDir::Files, QDir::Name);
|
||||||
|
// QFileInfo fileInfo;
|
||||||
|
// for (QFileInfo file : files) {
|
||||||
|
// if (file.fileName() == id) {
|
||||||
|
// fileInfo = file;
|
||||||
|
// mPath = file.absoluteFilePath();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// elapsedTimes.push_back(benchmark.restart());
|
||||||
|
mPath = path + id;
|
||||||
QFile file(mPath);
|
QFile file(mPath);
|
||||||
|
QFileInfo fileInfo(file);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
lDebug() << QStringLiteral("[ImageProvider] File doesn't exist: `%1`.").arg(path + id);
|
lDebug() << QStringLiteral("[ImageProvider] File doesn't exist: `%1`.").arg(path + id);
|
||||||
emit imageGrabbed(QImage(":/data/image/warning-circle.svg"));
|
imageGrabbed(QImage(":/data/image/warning-circle.svg"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Q_UNLIKELY(!file.open(QIODevice::ReadOnly))) {
|
if (Q_UNLIKELY(!file.open(QIODevice::ReadOnly))) {
|
||||||
qWarning() << QStringLiteral("[ImageProvider] Unable to open file: `%1`.").arg(path);
|
qWarning() << QStringLiteral("[ImageProvider] Unable to open file: `%1`.").arg(path);
|
||||||
emit imageGrabbed(QImage(":/data/image/warning-circle.svg"));
|
imageGrabbed(QImage(":/data/image/warning-circle.svg"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage image;
|
QImage image;
|
||||||
|
|
||||||
if (fileInfo.suffix() == "svg") {
|
if (fileInfo.suffix() == "svg") {
|
||||||
QSvgRenderer renderer(mPath);
|
QSvgRenderer renderer(mPath);
|
||||||
if (Q_UNLIKELY(!renderer.isValid())) {
|
if (Q_UNLIKELY(!renderer.isValid())) {
|
||||||
|
|
@ -102,9 +106,8 @@ ImageAsyncImageResponse::ImageAsyncImageResponse(const QString &id, const QSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else image = QImage(mPath);
|
} else image = QImage(mPath);
|
||||||
|
if (!image.isNull()) imageGrabbed(image);
|
||||||
if (!image.isNull()) emit imageGrabbed(image);
|
else imageGrabbed(QImage(":/data/image/warning-circle.svg"));
|
||||||
else emit imageGrabbed(QImage(":/data/image/warning-circle.svg"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageAsyncImageResponse::imageGrabbed(QImage image) {
|
void ImageAsyncImageResponse::imageGrabbed(QImage image) {
|
||||||
|
|
|
||||||
|
|
@ -748,9 +748,13 @@ AbstractMainPage {
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
model: CallHistoryProxy {
|
model: CallHistoryProxy {
|
||||||
|
id: detailsHistoryProxy
|
||||||
filterText: mainItem.selectedRowHistoryGui ? mainItem.selectedRowHistoryGui.core.remoteAddress : ""
|
filterText: mainItem.selectedRowHistoryGui ? mainItem.selectedRowHistoryGui.core.remoteAddress : ""
|
||||||
|
onFilterTextChanged: maxDisplayItems = initialDisplayItems
|
||||||
|
initialDisplayItems: detailListView.height / (56 * DefaultStyle.dp) + 5
|
||||||
|
displayItemsStep: initialDisplayItems / 2
|
||||||
}
|
}
|
||||||
|
onAtYEndChanged: if(atYEnd) detailsHistoryProxy.displayMore()
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
width:detailListView.width
|
width:detailListView.width
|
||||||
height: 56 * DefaultStyle.dp
|
height: 56 * DefaultStyle.dp
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue