本文整理汇总了C++中QFileInfoList::takeFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfoList::takeFirst方法的具体用法?C++ QFileInfoList::takeFirst怎么用?C++ QFileInfoList::takeFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileInfoList
的用法示例。
在下文中一共展示了QFileInfoList::takeFirst方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find_file
void SaveSetting::find_file()
{
QDir dir(filename);
//qDebug()<<"***********findfilepathname="<<filename;
QStringList currentDirs = dir.entryList(QDir::Dirs, QDir::Name);
QStringList filters;
filters <<"*.xml";
foreach (QString sContentDir, currentDirs)
{
int addCount = 0;//璁板綍宸茬粡妫�绱㈠埌鐨勬枃浠朵釜鏁?
if(isNOExit)
{
QDir findDir(filename+QString(QDir::separator())+ sContentDir);//鏂囦欢鐨勭粷瀵硅矾寰?
findDir.setNameFilters(filters);
findDir.setSorting(QDir::DirsFirst|QDir::Name);
QFileInfoList fl = findDir.entryInfoList( QDir::Files );
while(!fl.isEmpty())
{
if(isNOExit)
{
if(addCount >= 1000)
{
isNOExit = true;
//emit findDiskPathFinished();
}
QString tmp = fl.takeFirst().absoluteFilePath();
//qDebug()<<"find -------------------------------------------- "<<tmp<<addCount;
findDiskPathName(tmp, addCount);
addCount++;
}
}
}
}
示例2: calculateDirSize
quint64 RecursiveDirJobHelper::calculateDirSize(const QString & dir)
{
QDir currentDir(dir);
if ( !currentDir.exists() ) {
emit errorOccured(Error(Error::NoSuchFileOrDirectory, dir));
return 0;
}
QFileInfoList currentList = currentDir.entryInfoList(dirFilters);
QFileInfo currentItem;
QStack<QFileInfoList> stack;
quint64 totalSize = 0;
int refreshCounter = 0;
if ( m_reportProgress ) {
//show busy waiting indicator
emit setMaximum(0);
emit setValue(0);
}
while(1){
if ( !currentList.isEmpty() ){
currentItem = currentList.takeFirst();
totalSize += stat_size(currentItem.absoluteFilePath());
if ( currentItem.isDir() && !currentItem.isSymLink() ) {
if ( !currentDir.cd(currentItem.fileName()) ) {
emit errorOccured(Error(Error::AccessDenied, currentItem.absoluteFilePath()));
} else {
stack.push(currentList);
currentList = currentDir.entryInfoList(dirFilters);
}
}
if ( m_reportProgress && (++refreshCounter % 100 == 0) )
emit setLabelText( tr("Calculating the size of \"%1\"... %2")
.arg(dir).arg(DirOperations::bytesToString(totalSize)) );
} else { // list is empty
if ( !stack.isEmpty() ){
currentList = stack.pop();
currentDir.cdUp();
} else
break;
}
}
totalSize += stat_size(dir);
qDebug() << "calculateDirSize" << dir << totalSize;
return totalSize;
}
示例3: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// QDir * _dir=new QDir();
// // _dir->mkdir("tmp//audio");
// _dir->mkpath("tmp/audio");
/**/
QDir directory(this->getPath());
qDebug()<<"getIOSFilePath,m :"<<this->getPath();
QFileInfoList fileInfoList;
if (this->hiddenFiles)
{
fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
}
else
{
fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
}
QFileInfo fileInfo;
File file;
QList<File> *fileList = new QList<File>;
QFileIconProvider *provider = new QFileIconProvider;
while (!fileInfoList.isEmpty())
{
if (this->procesEvents)
qApp->processEvents();
fileInfo = fileInfoList.takeFirst();
file.fileIcon = provider->icon(fileInfo);
file.fileName = fileInfo.fileName();
qDebug()<<"IOSFileName:"<<file.fileName;
file.fileSize = QString::number(fileInfo.size());
file.fileDate = fileInfo.lastModified().toString("MMM dd yyyy");
file.filePath = fileInfo.absoluteFilePath();
file.filePermissions = "";
file.fileOwner = fileInfo.owner();
if (fileInfo.isDir())
file.fileType = "dir";
else
file.fileType = "file";
fileList->append(file);
}
delete provider;
return fileList;
return a.exec();
}
示例4: directory
QList<File> *Computer::getFileList()
{
QDir directory(this->getPath());
QFileInfoList fileInfoList;
if (this->hiddenFiles)
{
fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
}
else
{
fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
}
QFileInfo fileInfo;
File file;
QList<File> *fileList = new QList<File>;
QFileIconProvider *provider = new QFileIconProvider;
while (!fileInfoList.isEmpty())
{
if (this->procesEvents)
qApp->processEvents();
fileInfo = fileInfoList.takeFirst();
file.fileIcon = provider->icon(fileInfo);
file.fileName = fileInfo.fileName();
file.fileSize = QString::number(fileInfo.size());
file.fileDate = fileInfo.lastModified().toString("MMM dd yyyy");
file.filePath = fileInfo.absoluteFilePath();
file.filePermissions = "";
file.fileOwner = fileInfo.owner();
if (fileInfo.isDir())
file.fileType = "dir";
else
file.fileType = "file";
fileList->append(file);
}
delete provider;
return fileList;
}
示例5: inicializa
/**
\param idasiento
**/
void BcAsientoInteligenteView::inicializa ( int idasiento )
{
BL_FUNC_DEBUG
numasiento = idasiento;
inicializaVariables();
QDir dir ( g_confpr->value( CONF_DIR_AINTELIGENTES ) );
dir.setFilter ( QDir::Files );
dir.setNameFilters ( QStringList ( "*.xml" ) );
dir.setSorting ( QDir::Size | QDir::Reversed );
QFileInfoList list = dir.entryInfoList();
if ( list.size() > 0 ) {
/// Cargamos el combo con los ficheros de asientos inteligentes disponibles
QStringList listaOrdenada;
while ( !list.isEmpty() ) {
QFileInfo fileInfo = list.takeFirst();
listaOrdenada.append ( fileInfo.fileName().replace ( ".xml", "" ) ); /// cogemos los nombres de los ficheros sin la extension
listasientos.append ( fileInfo.filePath() ); /// y la ruta completa
}
listaOrdenada.sort(); /// se ordena la lista alfabeticamente
listasientos.sort(); /// y la de la ruta, que se ordenara igual
while ( !listaOrdenada.isEmpty() )
mui_comboainteligentes->addItem ( listaOrdenada.takeFirst() ); /// y se carga en el combo
/// Calculamos el número de dígitos que tiene una cuenta.
mainCompany() ->begin();
QString query1 = "SELECT * FROM configuracion WHERE nombre = 'CodCuenta'";
BlDbRecordSet *cursoraux1 = mainCompany() ->loadQuery ( query1, "codcuenta" );
numDigitos = cursoraux1->value( 2 ).length();
mainCompany() ->commit();
delete cursoraux1;
on_mui_comboainteligentes_activated ( 0 );
}
}
示例6: recursiveRmDir
void RecursiveDirJobHelper::recursiveRmDir(const QString & dir)
{
QDir currentDir(dir);
if ( !currentDir.exists() ) {
qWarning() << "recursiveRmDir: trying to remove non-existent directory" << dir;
if (m_reportProgress) {
//no files to be removed, so set the progressbar to 100%
emit setMaximum(1);
emit setValue(1);
}
return; // directory gone, no work to do
}
QFileInfoList currentList = currentDir.entryInfoList(dirFilters);
QFileInfo currentItem;
QStack<QFileInfoList> stack;
quint64 bytesRemoved = 0;
if (m_reportProgress) {
quint64 dirSize = calculateDirSize(dir);
emit setLabelText(tr("Removing directory \"%1\"...").arg(dir));
if (dirSize > 0) {
emit setMaximum(dirSize);
//start with the size of the directory to be removed.
//we do this before starting removing files, because on some filesystems
//(like reiserfs) the directory size is variable and will be smaller
//when all files have been removed
bytesRemoved += stat_size(dir);
emit setValue(bytesRemoved);
} else {
//no files to be removed, so set the progressbar to 100%
emit setMaximum(1);
emit setValue(1);
}
}
while(1)
{
if ( !currentList.isEmpty() ){
currentItem = currentList.takeFirst();
if ( m_reportProgress ) {
bytesRemoved += stat_size(currentItem.absoluteFilePath());
emit setValue(bytesRemoved);
}
if ( currentItem.isDir() && !currentItem.isSymLink() )
{
if ( !currentDir.cd(currentItem.fileName()) ) {
emit errorOccured(Error(Error::AccessDenied, currentItem.absoluteFilePath()));
} else {
stack.push(currentList);
currentList = currentDir.entryInfoList(dirFilters);
}
}
else
{
if ( !currentDir.remove(currentItem.fileName()) )
emit errorOccured(Error(Error::RmFail, currentItem.absoluteFilePath()));
}
}
else // list is empty
{
bool quit = false;
if ( !stack.isEmpty() )
currentList = stack.pop();
else
quit = true;
//if quit == true, we remove the original dir itself, now that it is empty for sure...
QString tmpname = currentDir.dirName();
currentDir.cdUp();
if ( !currentDir.rmdir(tmpname) )
emit errorOccured(Error(Error::RmFail, currentDir.absoluteFilePath(tmpname)));
if ( quit )
break;
}
}
}
示例7: recursiveCpDir
void RecursiveDirJobHelper::recursiveCpDir(const QString & sourcePath, const QString & destPath,
RecursiveDirJob::CopyOptions options)
{
QDir source(sourcePath);
if ( !source.exists() ) {
emit errorOccured(Error(Error::NoSuchFileOrDirectory, sourcePath));
return;
}
QDir dest(destPath);
if ( dest.exists() ) {
if ( options & RecursiveDirJob::RemoveDestination ) {
//in case the destination is a symlink to another directory, we remove first
//the symlink target (returned by dest.canonicalPath()) and then the symlink itself.
recursiveRmDir(dest.canonicalPath());
if ( QFileInfo(destPath).isSymLink() ) {
QFile::remove(destPath);
}
} else if ( !(options & RecursiveDirJob::OverWrite) ) {
emit errorOccured(Error(Error::FileOrDirectoryExists, destPath));
return;
}
}
if ( dest.mkdir(dest.absolutePath()) ) {
QFile::setPermissions(destPath, QFile::permissions(sourcePath));
}
QFileInfoList currentList = source.entryInfoList(dirFilters);
QFileInfo currentItem;
QStack<QFileInfoList> stack;
QString currentName;
quint64 bytesCopied = 0;
if ( m_reportProgress ) {
quint64 dirSize = calculateDirSize(sourcePath);
emit setLabelText(tr("Copying files from \"%1\" to \"%2\"...").arg(sourcePath).arg(destPath));
if (dirSize > 0) {
emit setMaximum(dirSize);
//the directory special file is already (almost) copied in dest.mkdir() above
bytesCopied += stat_size(sourcePath);
emit setValue(bytesCopied);
} else {
//no files to be copied, so set the progressbar to 100%
emit setMaximum(1);
emit setValue(1);
}
}
while(1)
{
if ( !currentList.isEmpty() )
{
currentItem = currentList.takeFirst();
currentName = currentItem.fileName();
if ( currentItem.isSymLink() )
{
if ( options & RecursiveDirJob::OverWrite ) {
if ( !QFile::remove(dest.absoluteFilePath(currentName)) )
emit errorOccured(Error(Error::RmFail, dest.absoluteFilePath(currentName)));
}
if ( !QFile::link( DirOperations::relativeSymLinkTarget(source.absoluteFilePath(currentName)),
dest.absoluteFilePath(currentName) ) )
emit errorOccured(Error(Error::CopyFail, source.absoluteFilePath(currentName)));
}
else if ( currentItem.isDir() )
{
bool ok = false;
QFile::Permissions sourcePermissions = QFile::permissions(source.absoluteFilePath(currentName));
if ( !(ok = source.cd(currentName)) ) {
emit errorOccured(Error(Error::AccessDenied, source.absoluteFilePath(currentName)));
}
if ( ok && !dest.cd(currentName) ) {
//if the target dir doesn't exist, create it and try again.
if ( !dest.mkdir(currentName) ) {
emit errorOccured(Error(Error::MkdirFail, dest.absoluteFilePath(currentName)));
}
//preserve permissions of the directory
QFile::setPermissions(dest.absoluteFilePath(currentName), sourcePermissions);
if ( !dest.cd(currentName) ) {
//quite impossible to happen
emit errorOccured(Error(Error::AccessDenied, dest.absoluteFilePath(currentName)));
ok = false;
source.cdUp(); //revert the state of source, as we are not going to copy this dir.
}
}
if (ok) {
stack.push(currentList);
currentList = source.entryInfoList(dirFilters);
}
}
else if ( currentItem.isFile() )
{
if ( options & RecursiveDirJob::OverWrite ) {
if ( !QFile::remove(dest.absoluteFilePath(currentName)) )
//.........这里部分代码省略.........
示例8: UpdateResourceLists
void ObjectWorkspace::UpdateResourceLists()
{
// If the context path in the registry is not valid, this will not be entered
if (dtDAL::Project::GetInstance().IsContextValid())
{
assert(!mContextPath.empty());
QDir directory(mContextPath.c_str());
if (directory.cd(QString(mContextPath.c_str()) + "/shaders"))
{
QStringList nameFilters;
nameFilters << "*.xml";
QFileInfoList fileList = directory.entryInfoList(nameFilters, QDir::Files);
// Try to load all definitions
while (!fileList.empty())
{
QFileInfo fileInfo = fileList.takeFirst();
mShaderDefinitionName = QString("%1/shaders/%2").arg(QString(mContextPath.c_str()), fileInfo.fileName());
emit LoadShaderDefinition(mShaderDefinitionName);
}
directory.cdUp();
}
// Now load all the additional shader files in the shader lists.
for (int shaderIndex = 0; shaderIndex < mAdditionalShaderFiles.size(); shaderIndex++)
{
emit LoadShaderDefinition(mAdditionalShaderFiles.at(shaderIndex).c_str());
}
// Populate the map list.
QStringList mapList;
std::set<std::string> mapNames = dtDAL::Project::GetInstance().GetMapNames();
for (std::set<std::string>::iterator map = mapNames.begin(); map != mapNames.end(); map++)
{
mapList << map->c_str();
}
for (int mapIndex = 0; mapIndex < mapList.size(); mapIndex++)
{
mResourceDock->OnNewMap(mapList.at(mapIndex).toStdString());
}
// Populate the object list.
QString staticMeshDir = QString(mContextPath.c_str()) + "/staticmeshes";
if (directory.cd(staticMeshDir))
{
QStringList nameFilters;
nameFilters << "*.ive" << "*.osg";
QFileInfoList fileList = directory.entryInfoList(nameFilters, QDir::Files);
while (!fileList.empty())
{
QFileInfo fileInfo = fileList.takeFirst();
mResourceDock->OnNewGeometry(staticMeshDir.toStdString(), fileInfo.fileName().toStdString());
}
}
}
}