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


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

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


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

示例1: add_default_policy

//---------------------------------------------------------------------------
void MainWindow::add_default_policy()
{
    QDir policies_dir(":/policies");

    policies_dir.setFilter(QDir::Files);
    QFileInfoList list = policies_dir.entryInfoList();
    for (int i = 0; i < list.count(); ++i)
    {
        QFile file(list[i].absoluteFilePath());

        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
            continue;
        QByteArray schematron = file.readAll();
        const std::string& file_str = list[i].absoluteFilePath().toStdString();
        C.policies.import_schema_from_memory(file_str, schematron.constData(), schematron.length());
    }

    QString path = get_local_folder();
    path += "/policies";
    policies_dir = QDir(path);

    policies_dir.setFilter(QDir::Files);
    list = policies_dir.entryInfoList();
    for (int i = 0; i < list.count(); ++i)
    {
        QFile file(list[i].absoluteFilePath());

        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
            continue;
        QByteArray data = file.readAll();
        C.policies.import_schema_from_memory(list[i].absoluteFilePath().toStdString(),
                                             data.constData(), data.length());
    }
}
开发者ID:GuillaumeRoques,项目名称:MediaConch_SourceCode,代码行数:35,代码来源:mainwindow.cpp

示例2: deleteDir

void FileUtils::deleteDir(const QString& fileDir)
{
	QDir dir(QDir::currentPath());
	if (!dir.exists(fileDir)) return;
	QDir fdir(fileDir);
	QFileInfoList fileList = fdir.entryInfoList();
	if (fileList.count() > 2)
	{
		for (int i = 0; i < fileList.count(); ++i)
		{
			const QFileInfo file = fileList.at(i);
			if (file.fileName() == "." || file.fileName() == "..")
			{
				continue;
			}
			if (file.isDir())
			{
				deleteDir(fileDir + "/" + file.fileName());
			}
			else
			{
				QString filePath = file.absoluteFilePath();
				QFile::remove(filePath);
			}
		}
	}		
	dir.rmdir(fileDir);
}
开发者ID:HeavenDoor,项目名称:Stock,代码行数:28,代码来源:fileutils.cpp

示例3: deleteThisDirectoryAndEverythingBelow

bool PathManager::deleteThisDirectoryAndEverythingBelow(QString topDirPath)
{
    {
        QDir topDir(topDirPath);

        if (!topDir.exists()) {
            WLog(QString("The given topDir does not exists: %1").arg(topDirPath));
            return true;
        }

        //First delete any files in the current directory
        QFileInfoList files = topDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden | QDir::System/* | QDir::NoSymLinks*/);
        for(int i = 0; i < files.count(); i++)
        {
            QString currFileInPath = files.at(i).fileName();
            /*QString currFileAbsolutePath = files.at(i).absoluteFilePath();
        if(QFileInfo(currFileAbsolutePath).isSymLink()) {
            // it's a symlink simply remove it
            PATH_MANAGER_INTERNAL_LOG_TO_DATABASE(QString("The dir is a symlink file [%1]. Simply remove it.").arg(currDirAbsolutePath));
            QDir().remove(currDirAbsolutePath);
        }
        else */

            if( !topDir.remove(currFileInPath) ) {
                WLogS << " ! The specified file cannot be removed: " << currFileInPath;
                WLog(QString("The specified file cannot be removed: %1").arg(files.at(i).absoluteFilePath()));
                return false;
            }
        }

        //Now recursively delete any child directories
        QFileInfoList dirs = topDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs);
        for(int i = 0; i < dirs.count(); i++)
        {
            QString currDirAbsolutePath = dirs.at(i).absoluteFilePath();
            if(QFileInfo(currDirAbsolutePath).isSymLink()) {
                // it's a symlink to a dir, simply remove this symlink file
                WLog(QString("The dir is a symlink file [%1]. Simply remove it.").arg(currDirAbsolutePath));
                QDir().remove(currDirAbsolutePath);
            }
            else if( !PathManager::deleteThisDirectoryAndEverythingBelow( currDirAbsolutePath ) ) {
                return false;
            }
        }
    }

    //Finally, remove empty top directory

//    if( !topDir.rmdir(topDir.path()) ) {
    if( !QDir().rmdir(topDirPath) ) {
        WLog(QString("The specified directory cannot be removed: %1. Maybe it's still not empty.").arg(topDirPath));
        return false;
    }

    return true;
}
开发者ID:Bitfall,项目名称:AppWhirr-SamplesAndPrototypes,代码行数:56,代码来源:pathmanager.cpp

示例4: DelSDPicFile

void XMLMoveThread::DelSDPicFile()
{
    //qDebug()<<tr("删除图片开始");
    QDir dir;
    if(!dir.exists("/SDHC"))
    {
        LogMsg("lane", tr("未检测到SD卡,不执行SD卡文件清理操作"));
        //qDebug()<<tr("未检测到SD卡,不执行SD卡文件清理操作");
        return;
    }
    QString dirName = "/SDHC/PicFile";
    if(!dir.exists(dirName))
    {
        LogMsg("lane", tr("SD中不存在图片备份,不执行SD卡文件清理操作"));
        //qDebug()<<tr("SD中不存在图片备份,不执行SD卡文件清理操作");
        return;
    }
    QDate curDate = QDateTime::currentDateTime().addDays(-getLaneInfo()->getPicSaveDay()).date();
    QString tmpFileName = curDate.toString("MMdd");
    dir.setPath(dirName);
    QFileInfoList dirList = dir.entryInfoList(QDir::Dirs,QDir::Time);
    QFileInfo dirInfo;
    int count = dirList.count();
    for(int i = count - 1;i > 0;i--)
    {
        //qDebug()<<tr("SD卡图片文件夹数量:%1").arg(count);
        //保留一个文件夹
        //        if(count <= 3)
        //        {
        //            qDebug()<<tr("保留一个文件夹");
        //            return;
        //        }
        dirInfo = dirList.at(i);
        if(!dirInfo.fileName().startsWith(".") && dirInfo.created().date() <= curDate)
            //if(dirInfo.fileName() == tmpFileName)
        {
            tmpFileName = dirInfo.fileName();
            //qDebug()<<tr("确定要删除文件目录:%1").arg(tmpFileName);
            dir.setPath(dirName + "/" + tmpFileName);
            QFileInfoList fileList = dir.entryInfoList(QDir::Files,QDir::Time);
            for(int i = 0;i < fileList.count();i++)
            {
                if(!dir.exists("/SDHC"))
                {
                    LogMsg("lane", tr("文件清理过程中检测不到SD卡"));
                    //qDebug()<<tr("文件清理过程中检测不到SD卡");
                    return;
                }
                QFile::remove(fileList.at(i).filePath());
            }
            dir.rmdir(dirInfo.filePath());
            //count --;
        }
    }
}
开发者ID:eilin1208,项目名称:QT_Test,代码行数:55,代码来源:xmlmovethread.cpp

示例5: DrivesListPretty

QStringList WinApi::DrivesListPretty() {
  QFileInfoList list = QDir::drives();
  QStringList result;
#if (QT_VERSION >= 0x40700)
  result.reserve(list.count());
#endif
  for (int i = 0; i < list.count(); i++) {
    result.append(WinApi::VolumeNamePretty(list.at(i).filePath().left(2)));
  }
  return result;
}
开发者ID:divyang4481,项目名称:photivo,代码行数:11,代码来源:ptWinApi.cpp

示例6: QObject

LangManager::LangManager(QObject *parent) :
    QObject(parent)
{
    //: Fill this with your language (ex: English, Deutch, Français, etc)
    tr("__LANG__");
    //: Fill this with the country your language is for (United-States, France, etc.)
    tr("__COUNTRY__");

    QStringList searchDirs;
#ifdef Q_OS_MAC
    searchDirs << qApp->applicationDirPath() + "/../Resources/lang"
               << qApp->applicationDirPath() + "/../../../../resources";
#else
    searchDirs << qApp->applicationDirPath() + "/lang"
               << qApp->applicationDirPath() + "/../resources";
#endif

    QDir searchDir;
    searchDir.setFilter(QDir::Files);
    searchDir.setNameFilters(QStringList() << "*.qm");

    QFileInfoList files;
    for(QString dir : searchDirs) {
        searchDir.setPath(dir);
        files = searchDir.entryInfoList();
        if(files.count()) {
            LOG_INFO(QString("%1 translations found in the directory %2")
                     .arg(files.count())
                     .arg(searchDir.absolutePath()));
            break;
        }
    }

    // Insert default translation. By doing this here, we ensure the LanguageEvent will
    // correctly be posted when switching from any language to default.
    _langMap.insert(TYM_DEFAULT_LANGUAGE, "English (United States)");
    _translatorMap.insert(TYM_DEFAULT_LANGUAGE, new QTranslator(this));

    for(QFileInfo f : files) {
        QString key = f.baseName();

        QTranslator* transl = new QTranslator(this);
        transl->load(f.fileName(), f.absolutePath());
        _translatorMap.insert(key, transl);

        QString langName = transl->translate("LangManager", "__LANG__")
                + " (" + transl->translate("LangManager", "__COUNTRY__") + ")";
        if(langName == " ()") {
            langName = key;
        }
        _langMap.insert(key, langName);
    }
}
开发者ID:alorence,项目名称:tym,代码行数:53,代码来源:langmanager.cpp

示例7: GribLink

void WPSRun::GribLink(QString sDir,QString output_root)
{
    int i1 =0;
    int i2 =0;
    int i3 =0;
    QDir dir(sDir);
    dir.setSorting(QDir::Type|QDir::Reversed);
    QFileInfoList list = dir.entryInfoList();
    QDateTime* dt = new QDateTime();
    QDateTime StartDT = p_namelist_tool->GetDateTimeStart();
    QDateTime EndDT = p_namelist_tool->GetDateTimeEnd();
    QStringList dateList;

    int n;
    if(list.count()>100) //Если файлов очччень много, то берем последние 100
    {
        n = 100;
    } else
    {
        n = list.count();
    }
    for (int iList=0;iList<n;iList++)
    {

        QFileInfo info = list[iList];
        if(info.isFile())
        {
            QString sFilePath = info.filePath();
            p_namelist_tool->GetDateTimeFromGrib2(sFilePath,dt);
            if(*dt<StartDT || *dt>EndDT||dateList.contains(dt->toString("hhmmddMMyyyy")))
                continue;
            dateList<<dt->toString("hhmmddMMyyyy");

            QFile::link(sFilePath, output_root+"GRIBFILE."+Alphabet[i3]+Alphabet[i2]+Alphabet[i1]);
            i1++;
            if(i1>25)
            {
                i1 =0;
                i2++;
                if(i2>25)
                {
                    i2 =0;
                    i3++;
                    if(i3>25)
                    {
                        break;
                    }
                }
            }
        }
    }
}
开发者ID:maxselym,项目名称:Magistral,代码行数:52,代码来源:wpsrun.cpp

示例8: createScreensaver

/*!
    Creates and returns a screensaver on the given token.
    \param token Identifies the screensaver to be created.
    \return The created state.
 */
Screensaver* ScreensaverFactoryPrivate::createScreensaver(const ScreensaverToken &token)
{
    QStringList pluginPaths;

    // check plugin dirs from root of different drives
    QFileInfoList drives = QDir::drives();
    for(int i=0; i < drives.count(); i++) {
        QFileInfo drive = drives.at(i);
        QString driveLetter = drive.absolutePath();
        QString path = driveLetter + mPluginDirectory;
        if (QDir(path).exists()) {
            pluginPaths << path;
        }
    }

    // check plugin dir relative to current dir
    if (QDir(mPluginDirectory).exists() && 
        !pluginPaths.contains(QDir(mPluginDirectory).absolutePath())) {
        pluginPaths << mPluginDirectory;
    }

    IScreensaverProvider *provider(0);
    QPluginLoader *loader = new QPluginLoader();
    QObject *plugin(0);

    for(int i=0; i < pluginPaths.count(); i++) {
        QString path = pluginPaths.at(i);
        QString fileName = QDir(path).absoluteFilePath(token.mLibrary);

        loader->setFileName(fileName);
        plugin = loader->instance();
        provider = qobject_cast<IScreensaverProvider*>(plugin);
        if (provider) {
            break;
        }
    }

    Screensaver *screensaver(0);

    if (provider) {
        screensaver = provider->createScreensaver(token);
        if (!screensaver) {
            qWarning() << "Screensaver creation failed.";
            qWarning() << token.mLibrary << "cannot provide" << token.mUri;
            loader->unload();
            delete loader;
        } else {
            // unload plugin once screensaver gets deleted
            ScreensaverPluginUnloader *unloader = new ScreensaverPluginUnloader(loader);
            unloader->connect(screensaver, SIGNAL(destroyed()), SLOT(deleteLater()));
        }
    } else {
        qDebug() << "Screensaver creation failed.";
        qWarning() << token.mLibrary << "- provider not found";
        loader->unload();
        delete loader;
    }

    return screensaver;
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:65,代码来源:screensaverfactory.cpp

示例9: dir

LADSPAPresetManager::LADSPAPresetManager()
{
    m_iPresetCount = 0;

    LADSPALoader * loader = new LADSPALoader();

    QDir dir(WWidget::getPath(QString("../../ladspa_presets"))); // TODO
    QFileInfoList files = dir.entryInfoList();
    m_Presets.resize(files.count());
    for (QFileInfoList::iterator fileIter = files.begin(); fileIter != files.end(); fileIter++)
    {
        qDebug() << "LADSPA: file " << (*fileIter).filePath();
        if ((*fileIter).isDir())
        {
            continue;
        }

        QFile file((* fileIter).filePath());

        QDomDocument document("Preset");
        file.open(QIODevice::ReadOnly);
        document.setContent(&file);
        file.close();

        LADSPAPreset * preset = new LADSPAPreset(document.documentElement(), loader);
        m_Presets [m_iPresetCount] = preset;
        m_iPresetCount++;
    }
}
开发者ID:Shunty,项目名称:mixxx,代码行数:29,代码来源:ladspapresetmanager.cpp

示例10: addDir

void LocalSong::addDir()
{
    locDir= QFileDialog::getExistingDirectory(this,tr("扫描本地目录"),musicPaths.isEmpty() ? QDir::homePath() : musicPaths.first(),QFileDialog::ShowDirsOnly
                                              | QFileDialog::DontResolveSymlinks);
    QDir dir(locDir);
    if(false==dir.exists())
    {
        return;
    }
    dir.setFilter(QDir::Files | QDir::NoSymLinks);
    QFileInfoList list = dir.entryInfoList();

    int file_count = list.count();
    if(file_count <= 0)
    {
        return;
    }
    for(int i=0; i<file_count;++i)
    {
        QFileInfo file_info = list.at(i);
        QString suffix = file_info.suffix();
        if(QString::compare(suffix, QString("mp3"), Qt::CaseInsensitive) == 0)
        {
            QString absolute_file_path = file_info.absoluteFilePath();
            addSongList(absolute_file_path);
            setInfo(absolute_file_path);
        }
    }
    qDebug()<<"已添加整个目录"<<locDir;
    unsigned long dirLength=songlist.length();
    qDebug()<<"歌曲总数为"<<dirLength;
    emit dirCount(dirLength);
}
开发者ID:yuenar,项目名称:QtMusicPlayer,代码行数:33,代码来源:LocalSong.cpp

示例11: createCurrentAlbum

void Controller::createCurrentAlbum(QString _dir, QString _currentImage)
{
   _dir.remove(0,8);
   QDir dir;
   QStringList currentList;
   QStringList filters;
   dir.setPath(_dir);
   dir.setSorting(QDir::Name);
   filters << "*.png" << "*.jpg" << "*.bmp";
   QFileInfoList list = dir.entryInfoList(filters,QDir::Files|QDir::NoDotAndDotDot);
   for(int i = 0; i < list.count(); ++i)
   {
        QFileInfo fileInfo = list.at(i);
        currentList << "file:///" + fileInfo.absoluteFilePath();
   }
   if(m_listAlbums.find("current") != m_listAlbums.end())
   {
        m_listAlbums.remove("current");
   }

   m_listAlbums.insert("current",new Album(currentList,_currentImage));
   m_listAlbums.find("current").value()->setName("current");
   m_pCurrentCtrl->setAlbum(m_listAlbums.find("current").value());
   m_pCurrentCtrl->start(QThread::IdlePriority);
   m_pCurrentAlbum = m_listAlbums.find("current").value();
}
开发者ID:KyryloBR,项目名称:PictureSubmarine,代码行数:26,代码来源:controller.cpp

示例12: documentTransition

void UniboardSankoreTransition::documentTransition()
{
    if (QFileInfo(mUniboardSourceDirectory).exists() || QFileInfo(mOldSankoreDirectory).exists()){
        QString uniboardDocumentDirectory = mUniboardSourceDirectory + "/document";

        QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(uniboardDocumentDirectory);
        fileInfoList << UBFileSystemUtils::allElementsInDirectory(mOldSankoreDirectory + "/document");

        QString backupDirectoryPath = UBFileSystemUtils::normalizeFilePath(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));

        if (fileInfoList.count() != 0){
            mTransitionDlg = new UBUpdateDlg(NULL, fileInfoList.count(), backupDirectoryPath);
            connect(mTransitionDlg, SIGNAL(updateFiles()), this, SLOT(startDocumentTransition()));
            connect(this, SIGNAL(transitionFinished(bool)), mTransitionDlg, SLOT(onFilesUpdated(bool)));
            mTransitionDlg->show();
        }
开发者ID:KubaO,项目名称:Sankore-3.1,代码行数:16,代码来源:UniboardSankoreTransition.cpp

示例13: RecurseDirectory

void RecurseDirectory(const QString dir, bool recursion)
{
    QDir dirEnt(dir);
    QFileInfoList list = dirEnt.entryInfoList();
    for(int i = 0; i < list.count(); i++)
    {
        QFileInfo info = list[i];

        QString filePath = info.filePath();
        QString fileExt = info.suffix().toLower();
        QString name = dir + QDir::separator();
        if(recursion && info.isDir())
        {
            // recursive
            if(info.fileName() != ".." && info.fileName() != ".")
            {
                RecurseDirectory(filePath, recursion);
            }
        }
        else
            if(imageExtensions.contains(fileExt))
            {
                if(!QFile::exists(name + info.completeBaseName() + QString(".atlas")))
                {
                    packerData *data = new packerData;
                    data->path = info.absoluteFilePath();
                    data->file = filePath.replace(topImageDir, "");
                    //                qDebug() << "Packing " << data->path << "...";
                    mainPacker->addItem(data->path, data);
                }
            }
    }
}
开发者ID:GumbertGumbert,项目名称:Cheetah-Texture-Packer,代码行数:33,代码来源:main.cpp

示例14: init

void LPhotoData::init() {
  if (imageTimer->isActive()) {
    imageTimer->stop();
  }

  images.clear();

  QDir imgdir(m_dirpath);
  imgdir.setFilter(QDir::Files | QDir::NoSymLinks);

  QFileInfoList infolist = imgdir.entryInfoList();

  for (int i = 0; i < infolist.count(); i++) {
    QImage test_img(infolist.at(i).filePath());
    if (!test_img.isNull()) {
      images << infolist.at(i).filePath();
    }
  }
  slideCount = images.count();

  if (slideCount > 0) {
    if (!imageTimer->isActive()) {
      imageTimer->start(3000);
    }
  }
}
开发者ID:shaheeqa,项目名称:plexydesk,代码行数:26,代码来源:localphotos.cpp

示例15: RecurseDirectory

bool RecurseDirectory(HZIP hz, QString sDir, QString prevDir = "") 
{
       QDir dir(sDir);
       QFileInfoList list = dir.entryInfoList();
       for (int iList=0;iList<list.count();iList++)
       {
           QFileInfo info = list[iList];

           QString sFilePath = info.filePath();
           if (info.isDir())
           {
               // recursive
               if (info.fileName()!=".." && info.fileName()!=".")
               {
                    ZRESULT zr;
                   return RecurseDirectory(hz, sFilePath);
               }
           }
           else
           {
               // Do something with the file here
               
               if(ZipAdd(hz, (/*sDir.right(sDir.size() - sDir.lastIndexOf("/") -1) + "/" + */info.fileName()).toLatin1().data(), info.absoluteFilePath().toLatin1().data()) != ZR_OK)
                   return false;
           }
       }

       return true;
};
开发者ID:LiTianjue,项目名称:openvpn-client,代码行数:29,代码来源:czip.cpp


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