当前位置: 首页>>代码示例>>C++>>正文


C++ QFileInfoList::isEmpty方法代码示例

本文整理汇总了C++中QFileInfoList::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfoList::isEmpty方法的具体用法?C++ QFileInfoList::isEmpty怎么用?C++ QFileInfoList::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QFileInfoList的用法示例。


在下文中一共展示了QFileInfoList::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadDir

void ThumbGenerator::loadDir(QImage& image, const QFileInfo& fi)
{
    QDir dir(fi.absoluteFilePath());
    dir.setFilter(QDir::Files);

    QFileInfoList list = dir.entryInfoList();
    QFileInfoList::const_iterator it = list.begin();
    const QFileInfo *f;

    bool found = false;
    while (it != list.end())
    {
        f = &(*it);
        QImageReader testread(f->absoluteFilePath());
        testread.setAutoDetectImageFormat(false);
        if (testread.canRead())
        {
            found = true;
            break;
        }
        ++it;
    }

    if (found)
    {
        loadFile(image, *f);
        return;
    }
    else
    {
        // if we didn't find the image yet
        // go into subdirs and keep looking
        dir.setFilter(QDir::Dirs);
        QFileInfoList dirlist = dir.entryInfoList();
        if (dirlist.isEmpty())
            return;

        QFileInfoList::const_iterator it = dirlist.begin();
        const QFileInfo *f;

        while (it != dirlist.end() && image.isNull() )
        {

            f = &(*it);
            ++it;

            if (f->fileName() == "." || f->fileName() == "..")
                continue;

            loadDir(image, *f);
        }
    }
}
开发者ID:Openivo,项目名称:mythtv,代码行数:53,代码来源:thumbgenerator.cpp

示例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;
}
开发者ID:netrunner-debian-attic,项目名称:kaboom,代码行数:51,代码来源:recursivedirjob.cpp

示例3: getPrefixIcon

QIcon MainMenu::getPrefixIcon(const QString &prefixHash) const
{
    QString iconPath = FS::prefix(prefixHash).absoluteFilePath(".icon");
    if (!QFile::exists(iconPath))
    {
        QFileInfoList iList = FS::icons(prefixHash).entryInfoList(QDir::Files);
        if (!iList.isEmpty())
        {
            QFile::copy(iList.first().absoluteFilePath(), iconPath);
            return QIcon(iconPath);
        }
        return style()->standardIcon(QStyle::SP_DirIcon);
    }
    return QIcon(iconPath);
}
开发者ID:Iaroslav464,项目名称:WineWizard,代码行数:15,代码来源:mainmenu.cpp

示例4: 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();
}
开发者ID:JustFFunny,项目名称:WorkSpace,代码行数:48,代码来源:main.cpp

示例5: defaultProjectFile

/**
 * @brief QgsServer::defaultProjectFile
 * @return the default project file
 */
QFileInfo QgsServer::defaultProjectFile()
{
  QDir currentDir;
  fprintf( FCGI_stderr, "current directory: %s\n", currentDir.absolutePath().toUtf8().constData() );
  QStringList nameFilterList;
  nameFilterList << QStringLiteral( "*.qgs" );
  QFileInfoList projectFiles = currentDir.entryInfoList( nameFilterList, QDir::Files, QDir::Name );
  for ( int x = 0; x < projectFiles.size(); x++ )
  {
    QgsMessageLog::logMessage( projectFiles.at( x ).absoluteFilePath(), QStringLiteral( "Server" ), QgsMessageLog::INFO );
  }
  if ( projectFiles.isEmpty() )
  {
    return QFileInfo();
  }
  return projectFiles.at( 0 );
}
开发者ID:ndavid,项目名称:QGIS,代码行数:21,代码来源:qgsserver.cpp

示例6: fi

//! [4]
QXmlNodeModelIndex
FileTree::nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &nodeIndex) const
{
    const QFileInfo fi(toFileInfo(nodeIndex));
    const Type type = Type(nodeIndex.additionalData());

    if (type != File && type != Directory) {
        Q_ASSERT_X(axis == Parent, Q_FUNC_INFO, "An attribute only has a parent!");
        return toNodeIndex(fi, Directory);
    }

    switch (axis) {
    case Parent:
        return toNodeIndex(QFileInfo(fi.path()), Directory);

    case FirstChild:
    {
        if (type == File) // A file has no children.
            return QXmlNodeModelIndex();
        else {
            Q_ASSERT(type == Directory);
            Q_ASSERT_X(fi.isDir(), Q_FUNC_INFO, "It isn't really a directory!");
            const QDir dir(fi.absoluteFilePath());
            Q_ASSERT(dir.exists());

            const QFileInfoList children(dir.entryInfoList(QStringList(),
                                         m_filterAllowAll,
                                         m_sortFlags));
            if (children.isEmpty())
                return QXmlNodeModelIndex();
            const QFileInfo firstChild(children.first());
            return toNodeIndex(firstChild);
        }
    }

    case PreviousSibling:
        return nextSibling(nodeIndex, fi, -1);

    case NextSibling:
        return nextSibling(nodeIndex, fi, 1);
    }

    Q_ASSERT_X(false, Q_FUNC_INFO, "Don't ever get here!");
    return QXmlNodeModelIndex();
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:46,代码来源:filetree.cpp

示例7: scanDirectory

void ImportMusicDialog::scanDirectory(QString &directory, vector<TrackInfo*> *tracks)
{
    QDir d(directory);

    if (!d.exists())
        return;

    const QFileInfoList list = d.entryInfoList();
    if (list.isEmpty())
        return;

    QFileInfoList::const_iterator it = list.begin();
    const QFileInfo *fi;

    while (it != list.end())
    {
        fi = &(*it);
        ++it;
        if (fi->fileName() == "." || fi->fileName() == "..")
            continue;
        QString filename = fi->absoluteFilePath();
        if (fi->isDir())
            scanDirectory(filename, tracks);
        else
        {
            Decoder *decoder = Decoder::create(filename, NULL, NULL, true);
            if (decoder)
            {
                Metadata *metadata = decoder->getMetadata();
                if (metadata)
                {
                    TrackInfo * track = new TrackInfo;
                    track->metadata = metadata;
                    track->isNewTune = Ripper::isNewTune(metadata->Artist(),
                            metadata->Album(), metadata->Title());
                    track->metadataHasChanged = false;
                    tracks->push_back(track);
                    m_sourceFiles.append(filename);
                }

                delete decoder;
            }
        }
    }
}
开发者ID:txase,项目名称:mythtv,代码行数:45,代码来源:importmusic.cpp

示例8: RenamePak

/**********
*返回值:0成功
*1原包名不存在
*2创建包出错
*3目的包名已经存在
*4替换包名过程出错
***********/
int PathManager::RenamePak(QString &path, QString &oldPakName, QString &newPakName)
{
	QString oldName = oldPakName;
	QString newName = newPakName;
	oldName.replace(".", "/");
	newName.replace(".", "/");

	QString srcDir = path + "/" + oldName;
	QString destDir = path + "/" + newName;
	QDir dirSrc(srcDir);
	QDir dirDest(destDir);
	if (!dirSrc.exists()){
		return 1;
	}

	dirSrc.setFilter(QDir::NoDotAndDotDot | QDir::Files);
	QFileInfoList allFiles = dirSrc.entryInfoList();
	if (allFiles.isEmpty()){
		return 1;
	}

	if (!dirDest.exists() && !dirDest.mkpath(destDir)){
		return 2;
	}
	dirDest.setFilter(QDir::NoDotAndDotDot | QDir::Files);
	if (!dirDest.entryInfoList().isEmpty()){
		return 3;
	}

	for (QFileInfoList::iterator ite = allFiles.begin(); ite != allFiles.end(); ite++){
		QString tmpName = ite->absoluteFilePath();
		tmpName = tmpName.mid(tmpName.lastIndexOf("/") + 1);
		if (!dirDest.exists()){
			if (dirDest.mkpath(destDir)){
				return 4;
			}
		}
		if (!CopyFile(ite->absoluteFilePath(), destDir + "/" + tmpName, true) || !QFile::remove(ite->absoluteFilePath())){
			return 4;
		}
	}

	RemoveEmptyDirFromDeepest(srcDir);
	return 0;
}
开发者ID:cnandroidlib,项目名称:AutopackingAndroid,代码行数:52,代码来源:PathManager.cpp

示例9: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    moded = false;

    home.setPath(QDir::homePath().append(QDir::separator()).append(".qnotes"));
    if (!home.exists()) {
        home.setPath(QDir::homePath());
        home.mkdir(".qnotes");
        home.cd(".qnotes");
    }
    home.setFilter(QDir::Files | QDir::NoSymLinks);
    home.setSorting(QDir::Time);
    QFileInfoList list = home.entryInfoList();

    if (list.isEmpty()) {
        ui->listWidget->addItem(tr("Vítejte"));
        ui->listWidget->setCurrentRow(0);
        cur_note = tr("Vítejte");
        ui->plainTextEdit->setPlainText(tr("Tuto poznámku můžete klidně smazat."));
        save();
    } else {
        for (int i = 0; i < list.size(); ++i) {
            QFileInfo fileInfo = list.at(i);

            ui->listWidget->addItem(fileInfo.fileName());
        }
        ui->listWidget->setCurrentRow(0);
        cur_note = ui->listWidget->item(0)->text();
        load();
    }

    connect(ui->actionUlozit, SIGNAL(triggered()), this, SLOT(save()));
    connect(ui->actionVypnout, SIGNAL(triggered()), this, SLOT(squit()));
    connect(ui->actionPridat, SIGNAL(triggered()), this, SLOT(add()));
    connect(ui->actionSmazat, SIGNAL(triggered()), this, SLOT(rm()));
    connect(ui->actionPrejmenovat, SIGNAL(triggered()), this, SLOT(ren()));
    connect(ui->plainTextEdit, SIGNAL(textChanged()), this, SLOT(mod()));
    connect(ui->actionO, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->listWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(change(QListWidgetItem*)));
    connect(ui->actionO_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
开发者ID:qwertzdenek,项目名称:QNote,代码行数:44,代码来源:mainwindow.cpp

示例10: findD3dCompiler

QString findD3dCompiler(Platform platform, const QString &qtBinDir, unsigned wordSize)
{
    const QString prefix = QStringLiteral("D3Dcompiler_");
    const QString suffix = QLatin1String(windowsSharedLibrarySuffix);
    // Get the DLL from Kit 8.0 onwards
    const QString kitDir = QString::fromLocal8Bit(qgetenv("WindowsSdkDir"));
    if (!kitDir.isEmpty()) {
        QString redistDirPath = QDir::cleanPath(kitDir) + QStringLiteral("/Redist/D3D/");
        if (platform & ArmBased) {
            redistDirPath += QStringLiteral("arm");
        } else {
            redistDirPath += wordSize == 32 ? QStringLiteral("x86") : QStringLiteral("x64");
        }
        QDir redistDir(redistDirPath);
        if (redistDir.exists()) {
            const QFileInfoList files = redistDir.entryInfoList(QStringList(prefix + QLatin1Char('*') + suffix), QDir::Files);
            if (!files.isEmpty())
                return files.front().absoluteFilePath();
        }
    }
    QStringList candidateVersions;
    for (int i = 47 ; i >= 40 ; --i)
        candidateVersions.append(prefix + QString::number(i) + suffix);
    // Check the bin directory of the Qt SDK (in case it is shadowed by the
    // Windows system directory in PATH).
    foreach (const QString &candidate, candidateVersions) {
        const QFileInfo fi(qtBinDir + QLatin1Char('/') + candidate);
        if (fi.isFile())
            return fi.absoluteFilePath();
    }
    // Find the latest D3D compiler DLL in path (Windows 8.1 has d3dcompiler_47).
    if (platform & IntelBased) {
        QString errorMessage;
        unsigned detectedWordSize;
        foreach (const QString &candidate, candidateVersions) {
            const QString dll = findInPath(candidate);
            if (!dll.isEmpty()
                && readPeExecutable(dll, &errorMessage, 0, &detectedWordSize, 0)
                && detectedWordSize == wordSize) {
                return dll;
            }
        }
    }
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:43,代码来源:utils.cpp

示例11: read_dcmrawdatapath

void CycleRead::read_dcmrawdatapath(QString dcmrawpath)
{
  QFileInfo file;
  QDir dcmrawdir;

  dcmrawdir.setPath(dcmrawpath);


  QFileInfoList fList = dcmrawdir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files , QDir::Name);

  if (!fList.isEmpty())
//    QMessageBox::warning(this, tr("Warning"), "No Files in Directory!\n"+file.absoluteFilePath(),
//                               QMessageBox::Ok);

  {
    for(int i=0;i < fList.size(); ++i)
    {
      file = fList.at(i);

      if(("dcm" == file.completeSuffix()) && (!_all_filenames.contains(file.filePath())))
      {
        _all_filenames.push_back(file.filePath());

        if(_fileblocks.isEmpty())
        { //if its the fist file - and no fileblocks exist - create first
          FileBlock fileblock;
          fileblock.set_file(file);
          _fileblocks.push_back(fileblock);
        }
        else
        {
          if(!_fileblocks.last().set_file(file))
          { //if actual file is not for actual block
            FileBlock fileblock;
            fileblock.set_file(file);
            _fileblocks.push_back(fileblock);  //create new block at the back
          }
        }
      }
    }
  }
}
开发者ID:IMTtugraz,项目名称:AGILE,代码行数:42,代码来源:cycleread.cpp

示例12: finished

void Q3LocalFs::operationListChildren( Q3NetworkOperation *op )
{
#ifdef QLOCALFS_DEBUG
    qDebug( "Q3LocalFs: operationListChildren" );
#endif
    op->setState( StInProgress );

    dir = QDir( url()->path() );
    dir.setNameFilter( url()->nameFilter() );
    dir.setMatchAllDirs( true );
    if ( !dir.isReadable() ) {
	QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
	op->setState( StFailed );
	op->setProtocolDetail( msg );
	op->setErrorCode( (int)ErrListChildren );
	emit finished( op );
	return;
    }

    QFileInfoList filist = dir.entryInfoList(QDir::All | QDir::Hidden | QDir::System);
    if ( filist.isEmpty() ) {
	QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
	op->setState( StFailed );
	op->setProtocolDetail( msg );
	op->setErrorCode( (int)ErrListChildren );
	emit finished( op );
	return;
    }

    emit start( op );

    Q3ValueList<QUrlInfo> infos;
    for (int i = 0; i < filist.size(); ++i) {
        QFileInfo fi = filist.at(i);
	infos << QUrlInfo( fi.fileName(), convertPermissions(&fi), fi.owner(), fi.group(),
			   fi.size(), fi.lastModified(), fi.lastRead(), fi.isDir(), fi.isFile(),
			   fi.isSymLink(), fi.isWritable(), fi.isReadable(), fi.isExecutable() );
    }
    emit newChildren( infos, op );
    op->setState( StDone );
    emit finished( op );
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:42,代码来源:q3localfs.cpp

示例13: dir

void NewWizardPage4::buildTemplatesList()
      {

      QDir dir(mscoreGlobalShare + "/templates");
      QFileInfoList fil = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Readable | QDir::Dirs | QDir::Files, QDir::Name);
      if(fil.isEmpty()){
          fil.append(QFileInfo(QFile(":data/Empty_Score.mscz")));
          }

      QDir myTemplatesDir(preferences.getString(PREF_APP_PATHS_MYTEMPLATES));
      fil.append(myTemplatesDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Readable | QDir::Dirs | QDir::Files, QDir::Name));

      // append templates directories from extensions
      QStringList extensionsDir = Extension::getDirectoriesByType(Extension::templatesDir);
      for (QString extDir : extensionsDir) {
            QDir extTemplateDir(extDir);
            fil.append(extTemplateDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Readable | QDir::Dirs | QDir::Files, QDir::Name));
            }
      templateFileBrowser->setScores(fil);
      }
开发者ID:salewski,项目名称:MuseScore,代码行数:20,代码来源:newwizard.cpp

示例14: loadDir

void ThumbGenerator::loadDir(QImage& image, const QFileInfo& fi)
{
    QDir dir(fi.absoluteFilePath());
    dir.setFilter(QDir::Files);

    QFileInfoList list = dir.entryInfoList();

    for (QFileInfoList::const_iterator it = list.begin();
         it != list.end() && !m_cancel; ++it)
    {
        const QFileInfo *f = &(*it);
        QImageReader testread(f->absoluteFilePath());
        if (testread.canRead())
        {
            loadFile(image, *f);
            return;
        }
    }

    // If we are supposed to cancel, don't recurse into subdirs, just quit
    if (m_cancel)
        return;

    // if we didn't find the image yet
    // go into subdirs and keep looking
    dir.setFilter(QDir::Dirs);
    QFileInfoList dirlist = dir.entryInfoList();
    if (dirlist.isEmpty())
        return;

    for (QFileInfoList::const_iterator it = dirlist.begin();
         it != dirlist.end() && image.isNull() && !m_cancel; ++it)
    {
        const QFileInfo *f = &(*it);

        if (f->fileName() == "." || f->fileName() == "..")
            continue;

        loadDir(image, *f);
    }
}
开发者ID:Olti,项目名称:mythtv,代码行数:41,代码来源:thumbgenerator.cpp

示例15: checkSystem

void SysStatus::checkSystem(bool checkjails){
  complete = QFile::exists("/tmp/.rebootRequired");
  if(!complete){ 
    //Get all the possible flag files and only take the most recent (latest flag - they overwrite each other)
    QStringList upinfo = pcbsd::Utils::runShellCommand("syscache needsreboot isupdating");
    if(upinfo.length() < 2 || upinfo.join("").contains("[ERROR]") ){
      //Fallback method in case syscache is not working for some reason
      QDir procdir(UPDATE_PROC_DIR);
      QFileInfoList files = procdir.entryInfoList(QStringList() << UPDATE_PROC_FLAG_FILE_FILTER, QDir::Files, QDir::Time);
      QStringList tmp; for(int i=0; i<files.length(); i++){ tmp << files[i].absoluteFilePath(); }
      QString flag;
      if(!files.isEmpty()){ flag = pcbsd::Utils::readTextFile(files.first().absoluteFilePath()).simplified().toLower(); }
      //qDebug() << "No syscache running - use flags:" << tmp << flag;
      complete = (UPDATE_PROC_FINISHED == flag );
      updating = (UPDATE_PROC_WORKING == flag );
    }else{
      //Use the syscache info
      complete = (upinfo[0]=="true");
      updating = (upinfo[1]=="true");
    }
    if(!updating && !complete){
      //Run syscache to probe for updates that are available
      QString cmd = "syscache hasmajorupdates hassecurityupdates haspcbsdupdates \"pkg #system hasupdates\" \"jail list\"";
      QStringList info = pcbsd::Utils::runShellCommand(cmd);
      if(info.length() < 5){ return; } //no info from syscache
      sys = (info[0] == "true");
      sec = (info[1] == "true") || (info[2] == "true"); //combine security updates with pcbsd patches for notifications
      pkg = (info[3] == "true");
      //Now look for jail updates
      if(checkjails && !info[4].simplified().isEmpty() ){
	QStringList jls = info[4].split(", ");
	cmd = "syscache";
	for(int i=0; i<jls.length(); i++){
	  cmd.append(" \"pkg "+jls[i]+" hasupdates\"");
	}
	QStringList jinfo = pcbsd::Utils::runShellCommand(cmd);
	jail = jinfo.contains("true");
      }
    }
  }
}
开发者ID:cthunter01,项目名称:pcbsd,代码行数:41,代码来源:SysStatus.cpp


注:本文中的QFileInfoList::isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。