QString file1Path
= "C:\\TestQFSM\\file1";
QString file2Path
= "C:\\TestQFSM\\file2";
QString file3Path
= "C:\\TestQFSM\\file3";
bool madeDirectory = cDrive.mkdir(dirPath);
qDebug() << "Made directory? " << madeDirectory << " expecting true";
file1Stream << "Some text";
file1.flush();
file1.close();
bool file1Exists
= QFile(file1Path
).
exists();
qDebug() << "File1Exists? " << file1Exists << " expecting true";
file2Stream << "Some text";
file2.flush();
file2.close();
bool file2Exists
= QFile(file2Path
).
exists();
qDebug() << "File2Exists? " << file2Exists << " expecting true";
bool file3Exists
= QFile(file3Path
).
exists();
qDebug() << "File3Exists? " << file3Exists << " expecting false";
QFileSystemModel* fileSystemModel = new QFileSystemModel(this);
fileSystemModel->setRootPath("");
bool file1Valid = fileSystemModel->index(file1Path).isValid();
qDebug() << "File1 Valid? " << file1Valid << " expecting true";
bool file2Valid = fileSystemModel->index(file2Path).isValid();
qDebug() << "File2 Valid? " << file2Valid << " expecting true";
bool file3Valid = fileSystemModel->index(file3Path).isValid();
qDebug() << "File3 Valid? " << file3Valid << " expecting false";
bool file1Removed = fileSystemModel->remove(fileSystemModel->index(file1Path));
qDebug() << "File1 Removed? " << file1Removed << " expecting true";
bool file2Removed = fileSystemModel->remove(fileSystemModel->index(file2Path));
qDebug() << "File2 Removed? " << file2Removed << " expecting true";
bool file3Removed = fileSystemModel->remove(fileSystemModel->index(file3Path));
qDebug() << "File3 Removed? " << file3Removed << " expecting false";
file1Exists
= QFile(file1Path
).
exists();
qDebug() << "File1Exists after removal? " << file1Exists << " expecting false";
file2Exists
= QFile(file2Path
).
exists();
qDebug() << "File2Exists after removal? " << file2Exists << " expecting false";
file3Exists
= QFile(file3Path
).
exists();
qDebug() << "File3Exists after removal? " << file3Exists << " expecting false";
file1Valid = fileSystemModel->index(file1Path).isValid();
qDebug() << "File1 Valid after removal? " << file1Valid << " expecting false";
file2Valid = fileSystemModel->index(file2Path).isValid();
qDebug() << "File2 Valid after removal? " << file2Valid << " expecting false";
file3Valid = fileSystemModel->index(file3Path).isValid();
qDebug() << "File3 Valid after removal? " << file3Valid << " expecting false";
Bookmarks