🦄 refactor(文件同步): 调整后端接口

This commit is contained in:
huheng@kylinos.cn 2022-11-29 18:55:41 +08:00
parent f73261ad5e
commit ec718bde7c
4 changed files with 10 additions and 12 deletions

View File

@ -84,9 +84,9 @@ void FileParSer::getItemCountList(QString path, FileParSer::KeyType type, QMap<i
return;
}
void FileParSer::getFileInfoList(QString path, QMap<QString, FileInfo> &map, QString flag)
void FileParSer::getFileInfoList(QString path, QList<FileInfo> &list, QString flag)
{
map.clear();
list.clear();
QFile *file = new QFile(path);
if (!file->open(QIODevice::ReadOnly)) {
// 打开文件失败
@ -123,7 +123,7 @@ void FileParSer::getFileInfoList(QString path, QMap<QString, FileInfo> &map, QSt
fileInfo.setThumbnailPath(path.mid(0, path.lastIndexOf("/")) + "/thumbnail/" + flag
+ thumbPath.mid(thumbPath.lastIndexOf("/") + 1, thumbPath.size()));
}
map.insert(fileInfo.name(), fileInfo);
list.append(fileInfo);
}
file->close();
file->deleteLater();

View File

@ -38,7 +38,7 @@ public:
void getItemCountList(QString path, FileParSer::KeyType type, QMap<int, int> &map);
// 获取文件信息
void getFileInfoList(QString path, QMap<QString, FileInfo> &map, QString flag = "");
void getFileInfoList(QString path, QList<FileInfo> &list, QString flag = "");
// 获取缩略图列表
void getThumbList(QString path, QStringList &list);

View File

@ -81,25 +81,24 @@ void FileSyncManage::getItemCount(FileParSer::KeyType type, QMap<int, int> &map)
}
void FileSyncManage::getClassifiedFileList(FileSyncManage::FileKey key, FileSyncManage::FileType type,
QMap<QString, FileInfo> &map)
QList<FileInfo> &list)
{
map.clear();
qInfo() << "Get classification file list...";
int index = getIndex(key, type);
switch (type) {
case FileType::Picture:
m_fileParser->getFileInfoList(FILE_DOWN_PATH + m_uuid + "/" + CONFIG_FILE_LIST.value(index), map,
m_fileParser->getFileInfoList(FILE_DOWN_PATH + m_uuid + "/" + CONFIG_FILE_LIST.value(index), list,
FLAGE_LIST.value(key) + PICTURE_FLAGE);
break;
case FileType::Video:
m_fileParser->getFileInfoList(FILE_DOWN_PATH + m_uuid + "/" + CONFIG_FILE_LIST.value(index), map,
m_fileParser->getFileInfoList(FILE_DOWN_PATH + m_uuid + "/" + CONFIG_FILE_LIST.value(index), list,
FLAGE_LIST.value(key) + VIDEO_FLAGE);
break;
case FileType::Music:
m_fileParser->getFileInfoList(FILE_DOWN_PATH + m_uuid + "/" + CONFIG_FILE_LIST.value(index), map);
m_fileParser->getFileInfoList(FILE_DOWN_PATH + m_uuid + "/" + CONFIG_FILE_LIST.value(index), list);
break;
case FileType::Doc:
m_fileParser->getFileInfoList(FILE_DOWN_PATH + m_uuid + "/" + CONFIG_FILE_LIST.value(index), map);
m_fileParser->getFileInfoList(FILE_DOWN_PATH + m_uuid + "/" + CONFIG_FILE_LIST.value(index), list);
break;
}
}

View File

@ -44,8 +44,7 @@ public:
void getItemCount(FileParSer::KeyType type, QMap<int, int> &map);
// 获取分类列表
void getClassifiedFileList(FileSyncManage::FileKey key, FileSyncManage::FileType type,
QMap<QString, FileInfo> &map);
void getClassifiedFileList(FileSyncManage::FileKey key, FileSyncManage::FileType type, QList<FileInfo> &lsit);
void updateFileInfo(FileSyncManage::FileKey key, FileSyncManage::FileType type);