Skip to content

Commit

Permalink
fix: 相册挂载外设时,启动时间优化
Browse files Browse the repository at this point in the history
  将扫描设备路径流程放置到点击设备时执行,节省相册启动时间

Log: 相册挂载外设时,启动时间优化
Bug: https://pms.uniontech.com/bug-view-185733.html
  • Loading branch information
starhcq committed Aug 18, 2023
1 parent f304b17 commit e96a4d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions src/src/albumControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,9 +913,6 @@ void AlbumControl::onVfsMountChangedAdd(QExplicitlySharedDataPointer<DGioMount>

//路径存在
if (bFind) {
//挂载路径,加载文件信息
sltLoadMountFileList(strPath);

emit sigMountsChange();
//发送新增
emit sigAddDevice(mount->getRootFile()->path());
Expand Down Expand Up @@ -960,6 +957,8 @@ void AlbumControl::onBlockDeviceAdded(const QString &blks)

void AlbumControl::sltLoadMountFileList(const QString &path)
{
QTime time;
time.start();
QString strPath = path;
if (!m_PhonePicFileMap.contains(strPath)) {
//获取所选文件类型过滤器
Expand Down Expand Up @@ -987,6 +986,8 @@ void AlbumControl::sltLoadMountFileList(const QString &path)
} else {
//已加载过的设备,直接发送缓存的路径
}

qDebug() << __FUNCTION__ << QString(" load device path:%1 cost [%2]ms").arg(path).arg(time.elapsed());
}

const QList<QExplicitlySharedDataPointer<DGioMount> > AlbumControl::getVfsMountList()
Expand Down Expand Up @@ -2295,12 +2296,19 @@ QString AlbumControl::getDeviceName(const QString &devicePath)
return m_durlAndNameMap.value(devicePath);
}

QStringList AlbumControl::getDevicePicPaths(const QString &path)
QStringList AlbumControl::getDevicePicPaths(const QString &strPath)
{
// 若设备路径未被扫描,先扫描出所有图片/视频文件,设备容量越大,文件越大,扫描耗时越长
if (m_PhonePicFileMap.find(strPath) == m_PhonePicFileMap.end()) {
sltLoadMountFileList(strPath);
}

QStringList pathsList;
QStringList list = m_PhonePicFileMap.value(path);
for (QString path : list) {
pathsList << "file://" + path;
if (m_PhonePicFileMap.find(strPath) != m_PhonePicFileMap.end()) {
QStringList list = m_PhonePicFileMap.value(strPath);
for (QString path : list) {
pathsList << "file://" + path;
}
}
return pathsList;
}
Expand Down
2 changes: 1 addition & 1 deletion src/src/albumControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class AlbumControl : public QObject
Q_INVOKABLE QString getDeviceName(const QString &devicePath);

//获取设备的图片
Q_INVOKABLE QStringList getDevicePicPaths(const QString &path);
Q_INVOKABLE QStringList getDevicePicPaths(const QString &strPath);

//获得device路径
Q_INVOKABLE QVariantMap getDeviceAlbumInfos(const QString &devicePath, const int &filterType = 0);
Expand Down

0 comments on commit e96a4d2

Please sign in to comment.