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


C++ QDir::setFilter方法代码示例

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


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

示例1: listFiles

QStringList filestuff::listFiles(QString directory, QString filter, QString sort, bool reversed)
{
    QStringList results;
    bool empty;
    QDir dir = directory;
    if(filter == "files"){
        dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    } else if(filter == "folders"){
        dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
    } else if(filter == "both"){
        dir.setFilter(QDir::Dirs | QDir::Files |
                      QDir::NoDotAndDotDot | QDir::NoSymLinks);

    }
    if(reversed){
        dir.setSorting(QDir::Reversed);
    }
    QFileInfoList list = dir.entryInfoList();
    for (int i = 0; i < list.size(); ++i){
       QFileInfo fileInfo = list.at(i);
       results.append(fileInfo.fileName());
       empty = false;
    }
    if(empty == true){
        results.append("Nothing Here!");
    }
    return results;
}
开发者ID:Astrognome,项目名称:MCMx,代码行数:28,代码来源:filestuff.cpp

示例2: parse

void ParseDirectoryThread::parse(QDir dir)
{
    //Ensure recursion limit hasn't been reached
    //if (recursionLimit >= RECURSION_LIMIT)
    //    return;
    
    //Stop parsing if variable is changed
    if (pStopParsing)
        return;

    //Get only files for now
    dir.setFilter(QDir::Files | QDir::NoSymLinks);

    QFileInfo fi(dir.path());
    if (fi.isFile())
    {
        //If user shared a single file, add directly to list
        FileListStruct f;
        f.rootDir = pRootDir;
        f.fileName = dir.path();
        pFileList->append(f);
        return;
    }

    QFileInfoList list = dir.entryInfoList();
    for (int i = 0; i < list.size(); i++)
    {
        //Add every file in the current directory
        FileListStruct f;
        f.rootDir = pRootDir;
        f.fileName = list.at(i).filePath();
        pFileList->append(f);
        //pFileList->append(list.at(i).absoluteFilePath());
    }

    //Get only directories
    dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);

    list = dir.entryInfoList();
    for (int k = 0; k < list.size(); k++)
    {
        //Iterate through all subdirectories and recursively call this function
        QDir nextDir(list.at(k).filePath());
        if (nextDir.isReadable())
        {
            recursionLimit++;
            parse(nextDir);
        }
    }
}
开发者ID:BackupGGCode,项目名称:arpmanetdc,代码行数:50,代码来源:parsedirectorythread.cpp

示例3: searchDirectoryRecursive

// searches a given path recursive and return found pathes to picture files (JPEG)
void ExifScout::searchDirectoryRecursive(QString directoryPath){
    std::cerr << "Folder: " << (std::string)directoryPath.toAscii() << "\n";

    // search specifications
    QDir currentDir = QDir(directoryPath);
    currentDir.setSorting( QDir::Name);
    currentDir.setFilter( QDir::Files | QDir::Dirs );
    QStringList files = currentDir.entryList(QStringList("*.jpg"));
    QStringList dirs = currentDir.entryList(QDir::Dirs, QDir::Name);

    for(int i=0;i<files.size();i++) {
        files[i] = directoryPath+"/"+files[i];
    }
    foundFiles.append(files);

    for(int i=0;i<dirs.size();i++) {
        if (dirs[i] != "." and dirs[i] != "..")
            searchDirectoryRecursive(directoryPath+"/"+dirs[i]);
    }

    // write found files to console
    std::cerr << foundFiles.size() << " Files found. \n";
       /* for(int i = 0; i < foundFiles.size(); i++){
            std::cerr << foundFiles.at(i).toStdString() << "\n";
        }*/
}
开发者ID:hypergnash,项目名称:Exif-Scout,代码行数:27,代码来源:exif-scout_window.cpp

示例4: ListFilesInDirectoryTest

QMultiMap<QString,FileAttributes> ListFilesInDirectoryTest(QDir dir, bool Hash)
{
    extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
    qt_ntfs_permission_lookup++; // turn checking on
    QMultiMap<QString, FileAttributes> fileAttHashTable; //making hash table to store file attributes
    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    dir.setSorting(QDir::Name);
    QFileInfoList list = dir.entryInfoList();
    for (int i = 0; i < list.size(); ++i)
    {
       QFileInfo fileInfo = list.at(i);
       if (fileInfo.isFile())
       {
           FileAttributes tempFileAttributes;
           QDateTime date = fileInfo.lastModified();
           QString lastModified = date.toString();

            tempFileAttributes.absoluteFilePath = fileInfo.absoluteFilePath();
            tempFileAttributes.fileName = fileInfo.fileName();
            tempFileAttributes.filePath= fileInfo.path();
            if (Hash) tempFileAttributes.md5Hash = GetFileMd5hash(fileInfo.absoluteFilePath());
            tempFileAttributes.lastModified  = fileInfo.lastModified();
            tempFileAttributes.lastRead = fileInfo.lastRead();
            tempFileAttributes.created = fileInfo.created();
            tempFileAttributes.isHidden =  fileInfo.isHidden();
            tempFileAttributes.size = fileInfo.size();
            tempFileAttributes.owner = fileInfo.owner();
            fileAttHashTable.insert(fileInfo.absoluteFilePath(),tempFileAttributes);
       }

    }
return fileAttHashTable;
}
开发者ID:szkrawcz,项目名称:aInf,代码行数:33,代码来源:dirgrinder.cpp

示例5: treeFingerprint

QString CollectionScanner::treeFingerprint(QDir directory, QString hash) {
    // qDebug() << "Hashing" << directory.absolutePath();
    directory.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Readable);
    QFileInfoList list = directory.entryInfoList();
    for (int i = 0; i < list.size(); ++i) {
        QFileInfo fileInfo = list.at(i);
        if (fileInfo.isDir()) {
            // this is a directory, recurse
            QString subDirPath = fileInfo.absoluteFilePath();
#ifdef APP_MAC
            if (directoryBlacklist.contains(subDirPath)) {
                // qDebug() << "Skipping directory" << subDirPath;
                continue;
            }
#endif
            hash += DataUtils::md5(treeFingerprint(QDir(subDirPath), hash));
        } else {
            // this is a file, add to hash
            const uint lastModified = fileInfo.lastModified().toTime_t();
            hash += QString::number(lastModified);
            hash += fileInfo.absoluteFilePath();
        }
    }
    // qDebug() << hash;
    return hash;
}
开发者ID:PhillipMwaniki,项目名称:musique,代码行数:26,代码来源:collectionscanner.cpp

示例6: findStyle

void QQuickControlSettings::findStyle(QQmlEngine *engine, const QString &styleName)
{
    QString path = styleImportPath(engine, styleName);
    QDir dir;
    dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
    dir.setPath(path);
    dir.cd(styleName);

    StyleData styleData;

    foreach (const QString &fileName, dir.entryList()) {
        // This assumes that there is only one library in the style directory,
        // which should be a safe assumption. If at some point it's determined
        // not to be safe, we'll have to resolve the init and path functions
        // here, to be sure that it is the correct library.
        if (QLibrary::isLibrary(fileName)) {
            styleData.m_stylePluginPath = dir.absoluteFilePath(fileName);
            break;
        }
    }

    // If there's no plugin for the style, then the style's files are
    // contained in this directory (which contains a qmldir file instead).
    styleData.m_styleDirPath = dir.absolutePath();

    m_styleMap[styleName] = styleData;
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:27,代码来源:qquickcontrolsettings.cpp

示例7: pairwiseHistogramDirectory

/*
 * Construct the PGH for the images in a folder
 * @parameter 1: folderPath - the images folder
 * @parameter 2: angleAcc -the angle accuracy
 * @parameter 3: columns - the distance accuracy
 */
void GeometricHistogram::pairwiseHistogramDirectory(string folderPath,
		LocalHistogram::AccuracyPGH angleAcc, int distanceAcc) {
	QDir qdir;
	QString fPath(folderPath.c_str());
	qdir.setPath(fPath);
	qdir.setFilter(QDir::Files);
	QStringList filterNames;
	filterNames << "*.JPG";
	qdir.setNameFilters(QStringList("*.JPG"));
	QFileInfoList files = qdir.entryInfoList();
	for (int i = 0; i < files.size(); i++) {
		QFileInfo file = files.at(i);
		QString _name = file.absoluteFilePath();
		int index2 = _name.lastIndexOf("/");
		QString savePath = "test/pghmatrix/"
				+ _name.mid(index2 + 1, _name.length() - index2 - 5).replace(
						" ", "") + "_L"
				+ QString::number(LocalHistogram::heightOfAngleAxis(angleAcc))
				+ "_C" + QString::number(distanceAcc) + ".PGH";
		qDebug() << savePath;
		Image sceneImage(_name.toStdString());
		vector<Line> lines = sceneImage.lineSegment();
		vector<LocalHistogram> listLocalPGH;
		ShapeHistogram sceneHist = sceneImage.getShapeHistogram();
		listLocalPGH = sceneHist.constructPGH(lines);
		vector<vector<int> > matrix = sceneHist.constructMatPGH(listLocalPGH,angleAcc,
				distanceAcc);
		sceneHist.writeMatrix(matrix, savePath.toStdString());
	}
}
开发者ID:linhlevandlu,项目名称:MorphoSpecies_V2,代码行数:36,代码来源:GeometricHistogram.cpp

示例8: dir

err_info *Ocromni::init (void)
   {
   void *lib = dlopen ("libxocr.so", RTLD_LAZY);

   // try some other locations, so the user doesn't need LD_LIBRARY_PATH
   if (!lib)
      {
      // first try to find the directory
      QStringList dirlist = QString ("/usr/local/lib/,/usr/lib").split (',');
      QString fname;

      for (int i = 0; i < dirlist.size (); i++)
         {
         QDir dir (dirlist [i]);

         dir.setFilter (QDir::Dirs);
         const QString filter = "nuance-omnipage-csdk*";
         dir.setNameFilter (filter);

//          qDebug () << dir.path () << dir.count ();
         QStringList list = dir.entryList ();
         foreach (QString path, list)
            {
            fname = dir.path () + "/" + path + "/libxocr.so";
            QFile file (fname);

            if (file.exists (fname))
               break;
            fname.clear ();
            }
//          qDebug () << list.size ();
         }
开发者ID:arunjalota,项目名称:paperman,代码行数:32,代码来源:ocromni.cpp

示例9: if

Updater::Updater(const UpdateInformation &information, QObject *parent) : QObject(parent),
	m_transfer(NULL),
	m_transfersCount(0),
	m_transfersSuccessful(true)
{
	const QString path = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + QLatin1String("/OtterBrowser/");
	QDir directory = QDir(path);

	if (!directory.exists())
	{
		QDir().mkdir(path);
	}
	else if (directory.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).count() > 0)
	{
		directory.setNameFilters(QStringList() << QLatin1String("*.*"));
		directory.setFilter(QDir::Files);

		for (int i = 0; i < directory.entryList().count(); ++i)
		{
			directory.remove(directory.entryList().at(i));
		}
	}

	clearUpdate();

	downloadFile(information.scriptUrl, path);

	m_transfer = downloadFile(information.fileUrl, path);
	m_transfer->setUpdateInterval(500);

	connect(m_transfer, SIGNAL(progressChanged(qint64,qint64)), this, SLOT(updateProgress(qint64,qint64)));
}
开发者ID:chunyisong,项目名称:otter-browser,代码行数:32,代码来源:Updater.cpp

示例10: if

void K3ChessSettings::enumLocales(QDir dir)
{
   dir.setFilter(QDir::Files | QDir::Dirs);
   QFileInfoList items = dir.entryInfoList();
   foreach(QFileInfo fi, items)
   {
      if(fi.isDir())
      {
         if(!fi.fileName().startsWith("."))
            enumLocales(fi.filePath());
      }
      else if(fi.fileName().endsWith(".ini"))
      {
         QSettings ini(fi.filePath(), QSettings::IniFormat);
         ini.setIniCodec(QTextCodec::codecForName("UTF-8"));
         QString name = ini.value("Info/LocaleName", QString()).toString();
         if(!name.isEmpty())
         {
            locales_.insert(std::make_pair(name, fi.filePath()));
         }
      }
   }
   //
   QString lname = settings_.value("Locale",
                                    cDefaultLocaleName).toString();
   //
   if((!locales_.empty() && locales_.find(lname)==locales_.end()) ||
       (locales_.empty() && lname!=cDefaultLocaleName))
   {
      settings_.setValue("Locale", cDefaultLocaleName);
   }
}
开发者ID:joaoamaral,项目名称:k3chess,代码行数:32,代码来源:Settings.cpp

示例11: processImageFiles

void processImageFiles()
{
	QString workingImageDirPath = QString(workingAssetsDir) + "Textures\\";
	QDir workingImageDir (workingImageDirPath);
	if(workingImageDir.exists())
	{
		QStringList imageFileFilters;
		imageFileFilters << "*.png";

		workingImageDir.setFilter(QDir::Files | QDir::NoSymLinks);
		workingImageDir.setNameFilters(imageFileFilters);
		QFileInfoList workingImageFiles = workingImageDir.entryInfoList();

		for(int i = 0; i < workingImageFiles.size(); i++)
		{
			QFileInfo unprocessedImageFile = workingImageFiles.at(i);
			QFileInfo outImage(QString(outAssetsDir) + "Textures\\" + unprocessedImageFile.fileName());

			bool needsCopy = (!outImage.exists() || (outImage.lastModified() < unprocessedImageFile.lastModified()));
			if(needsCopy)
			{
				QDir::root().mkpath(outImage.absolutePath());
				QImage workingImage = QImage(QDir::toNativeSeparators(unprocessedImageFile.absoluteFilePath()));
				workingImage = QGLWidget::convertToGLFormat(workingImage);
				bool saved = workingImage.save(outImage.absoluteFilePath(), "PNG");
			}
		}
	}
	else
	{
		qDebug("No working Image folder.");
	}
}
开发者ID:tmgarcia,项目名称:CPPGameEngine,代码行数:33,代码来源:Main.cpp

示例12: processShaderFiles

void processShaderFiles()
{
	QString workingShaderDirPath = QString(workingAssetsDir) + "Shaders\\";
	QDir workingShaderDir (workingShaderDirPath);
	
	if(workingShaderDir.exists())
	{
		QStringList shaderFileFilters;
		shaderFileFilters << "*.glsl";

		workingShaderDir.setFilter(QDir::Files | QDir::NoSymLinks);
		workingShaderDir.setNameFilters(shaderFileFilters);
		QFileInfoList workingShaderFiles = workingShaderDir.entryInfoList();

		for(int i = 0; i < workingShaderFiles.size(); i++)
		{
			QFileInfo workingShader = workingShaderFiles.at(i);
			QFileInfo outShader(QString(outAssetsDir) + "Shaders\\" + workingShader.fileName());
			bool needsCopy = (!outShader.exists() || (outShader.lastModified() < workingShader.lastModified()));
			if(needsCopy)
			{
				QString copyCommand("echo f|xcopy /y \"" +  QDir::toNativeSeparators(workingShader.absoluteFilePath()) + "\" \"" + QDir::toNativeSeparators(outShader.absoluteFilePath()) + "\"");
				int result = system(copyCommand.toUtf8().constData());
			}
		}
	}
	else
	{
		qDebug("No working Shader folder.");
	}
}
开发者ID:tmgarcia,项目名称:CPPGameEngine,代码行数:31,代码来源:Main.cpp

示例13: getAllFilesToBeProcessed

/**
* Walks through the whole directory tree and returns a list of every file found.
* @param fileOrDirectory - File or directory to search
* @return a list containing all files found
**/
QStringList medAbstractDatabaseImporter::getAllFilesToBeProcessed ( QString fileOrDirectory )
{
    //Trick to use QString with accent
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

    QString file = fileOrDirectory;
    QDir dir ( file );
    dir.setFilter ( QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot );

    QStringList fileList;
    if ( dir.exists() )
    {
        QDirIterator directory_walker ( file, QDir::Files, QDirIterator::Subdirectories );
        while ( directory_walker.hasNext() )
        {
            fileList << directory_walker.next();
        }
    }
    else
        fileList << file;

    fileList.sort();

    return fileList;
}
开发者ID:mjuhoor,项目名称:medInria-public,代码行数:30,代码来源:medAbstractDatabaseImporter.cpp

示例14: userDirectory

QDir QLCFile::userDirectory(QString path, QString fallBackPath, QStringList extensions)
{
    Q_UNUSED(fallBackPath)
    QDir dir;

#if defined(Q_WS_X11) || defined(Q_OS_LINUX)
    // If the current user is root, return the system fixture dir.
    // Otherwise return a path under user's home dir.
    if (geteuid() == 0 && QLCFile::isRaspberry() == false)
        dir = QDir(fallBackPath);
    else
        dir.setPath(QString("%1/%2").arg(getenv("HOME")).arg(path));
#elif defined(__APPLE__) || defined (Q_OS_MAC)
    /* User's input profile directory on OSX */
    dir.setPath(QString("%1/%2").arg(getenv("HOME")).arg(path));
#else
    /* User's input profile directory on Windows */
    LPTSTR home = (LPTSTR) malloc(256 * sizeof(TCHAR));
    GetEnvironmentVariable(TEXT("UserProfile"), home, 256);
    dir.setPath(QString("%1/%2")
                    .arg(QString::fromUtf16(reinterpret_cast<ushort*> (home)))
                    .arg(path));
    free(home);
#endif

    // Ensure the directory exists
    if (dir.exists() == false)
        dir.mkpath(".");

    dir.setFilter(QDir::Files);
    dir.setNameFilters(extensions);

    return dir;
}
开发者ID:ChrisLaurie,项目名称:qlcplus,代码行数:34,代码来源:qlcfile.cpp

示例15: logExt

void
SendLogsDialog::send()
{
    SendLogsRequest* request = new SendLogsRequest( ui.moreInfoTextEdit->toPlainText() );

    connect( request, SIGNAL( success() ), SLOT( onSuccess() ) );
    connect( request, SIGNAL( error() ), SLOT( onError() ) );

    QDir logDir = CoreDir::logs();
    QStringList logExt( "*.log" );
        
    // find logs
    logDir.setFilter( QDir::Files | QDir::Readable );
    logDir.setNameFilters( logExt );
    QList<QFileInfo> logFiles = logDir.entryInfoList();
    
    foreach( QFileInfo log, logFiles )
        request->addLog( log.completeBaseName(), log.absoluteFilePath() );

    request->addLogData( "clientinfo", clientInformationString() );
    request->addLogData( "sysinfo", systemInformationString() );
    
    request->send();
    
    ui.buttonBox->setEnabled( false );
    ui.moreInfoTextEdit->setEnabled( false );
    ui.spinner->show();
    ui.spinner->movie()->start();
}
开发者ID:RJ,项目名称:lastfm-desktop,代码行数:29,代码来源:SendLogsDialog.cpp


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