-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirscan.cpp
More file actions
49 lines (44 loc) · 1.33 KB
/
dirscan.cpp
File metadata and controls
49 lines (44 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "dirscan.h"
int DirScan::k = 0;
DirScan::DirScan(QObject *parent) : QObject(parent)
{
}
void DirScan::AsncScan(const QString strPath)
{
QtConcurrent::run(this, &DirScan::Scan, strPath);
}
void DirScan::Scan(const QString strPath)
{
//! 第一次肯定是显示磁盘驱动器
if(k == 0 && !QString::compare(strPath , QString(tr("我的电脑"))))
{
QFileInfoList drivers = QDir::drives();
foreach (QFileInfo driverInfo, drivers)
{
if (driverInfo.isReadable())
{
qDebug("-----sendBack:%s\n" , driverInfo.filePath().toLatin1().data());
emit ItemScaned(strPath , driverInfo , k);
}
}
k++ ;
//! 其它就是盘符下面的内容
}
else
{
QDir dir(strPath);
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot);
qDebug() << "+++++++++++++++++" << strPath;
if(dir.exists())
{
k ++ ;
QFileInfoList fileList = dir.entryInfoList();
foreach (QFileInfo fileInfo, fileList)
{
qDebug() << "Scan==============" << fileInfo.filePath();
emit ItemScaned(strPath, fileInfo , k);
}
}
}
return ;
}