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


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

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


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

示例1: setupNodeChildren

void WWidgetNode::setupNodeChildren()
{
	QFileInfo info(m_strPath);
	if (!info.isDir()) { qDebug() << "[ERROR] Not a directory in WWidgetNode::setupNodeChildren"; }

	QDir          dir(info.absoluteFilePath());
	QFileInfo     newinfo;
	QFileInfoList list;
	WWidgetNode * child;
	int           count = 0;
	// loop all entries in dir
	for (int i = 0; i < dir.entryInfoList().count(); i++)
	{
		// get entry of this dir
		newinfo = dir.entryInfoList().at(i);
		// continue if entry is not a dir
		if (!newinfo.fileName().compare(".") || !newinfo.fileName().compare("..")) { continue; }
		// depending on this dir type choose what to do with the cuirrent entry
		switch (m_intNodeType)
		{
		case ROOT:
			if (newinfo.isDir())
			{
				// create category child
                QString strTemp = newinfo.absoluteFilePath();
                child = new WWidgetNode(CATEGORY, strTemp, count, this);
				childWWidgetNodes.append(child);
				count++;
			}
			break;
		case CATEGORY:
			if (newinfo.isDir())
			{
				list = QDir(newinfo.absoluteFilePath()).entryInfoList();
				for (int j = 0; j < list.count(); j++)
				{
					// check if selected child dir contains a project file
					if (list.at(j).filePath().contains(".wtw"))
					{
						// create widget child
                        QString strTemp = newinfo.absoluteFilePath();
                        child = new WWidgetNode(WIDGET, strTemp, count, this);
						// discirminate some widgets (do not add to WWidgetNode tree but yes to QObject tree)
						QString strName = child->getName();
						if (strName.compare("WTabItem"  ) != 0 &&
							strName.compare("WMenuItem" ) != 0 &&
							strName.compare("WPopupItem") != 0)
						{
							// append to list of widgets
							childWWidgetNodes.append(child);
							count++;
						}
					}
				}
			}
			break;
		case WIDGET:
			if (newinfo.isFile() && newinfo.fileName().contains(".wtw"))
			{

				m_strName = newinfo.baseName(); // must be class name
				QFile file(newinfo.absoluteFilePath());
				if (!file.open(QFile::ReadOnly)) { qDebug() << "[ERROR] Opening file in WWidgetNode::setupNodeChildren : " << newinfo.absoluteFilePath(); }
				m_byteConfig = file.readAll();
			}
			else if (newinfo.isDir() && QDir(newinfo.absoluteFilePath()).dirName().compare("icon", Qt::CaseInsensitive) == 0)
			{
				list = QDir(newinfo.absoluteFilePath()).entryInfoList();
				for (int j = 0; j < list.count(); j++)
				{
					// check if selected child is icon file
					if (list.at(j).baseName().compare(dir.dirName()) == 0)
					{
						// get icon
						m_icon = QIcon(list.at(j).absoluteFilePath());
					}
				}
			}
			break;
		default:
			break;
		}

	}

	if (m_intNodeType == WIDGET)
	{
	    Icons::GetCache().insert(m_strName, m_icon);
	}

	// set name for category
	if (m_intNodeType == CATEGORY && count > 0)
	{
		m_strName = dir.dirName();
	}

	// just in case
	updateRowNumbers();
}
开发者ID:jamal-fuma,项目名称:WtDesigner,代码行数:99,代码来源:mywidgetmodel.cpp

示例2: copyDirAndFiles

bool CopyDir::copyDirAndFiles(QString srcDir, QString dstDir, QStringList *nameExcludeFilter, QStringList *nameIncludeFilter, QStringList *srcFileList, QStringList *dstFileList)
{
   if(mExitNow)
     return false;

   mutex.lock();
   if(mPause)
   {
      pauseThreads.wait(&mutex);
   }
   mutex.unlock();

   bool isFirst = false;

   if(srcFileList == NULL)
   {
      isFirst = true;
      srcFileList = new QStringList;
      dstFileList = new QStringList;
   }

   QDir rootPath(QDir::toNativeSeparators(srcDir));
   QDir destPath(QDir::toNativeSeparators(dstDir));

   rootPath.setFilter(QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files);
   QFileInfoList entryList = rootPath.entryInfoList();

   QRegExp rx;
   rx.setPatternSyntax(QRegExp::Wildcard);
   bool moveOn;
   QString dirName;

   for(int i=0; i<entryList.size(); i++)
   {
      if(mExitNow)
      {
	      return false;
      }

	   QFileInfo entry = entryList.at(i);

	   // we do exclude list checking, a lot easier to exclude a couple file types than list all of the included ones
      moveOn = false;
      for(int j=0; j<nameExcludeFilter->size(); j++)
      {
	      rx.setPattern(nameExcludeFilter->at(j));
		   QString name = entry.absoluteFilePath();
	      if(rx.exactMatch(name))
	      {
			   moveOn = true;

			   // now let's check to make sure this specific file isn't on the include list, that overrides exluded types
			   for(int k=0; k<nameIncludeFilter->size(); k++)
			   {
			      // compare the file to the include file adding the root directory (the include filter should be relative files)
			      QString filePath = QDir::toNativeSeparators(entry.filePath());
			      QString include = QDir::toNativeSeparators(mRootDir + "/" + nameIncludeFilter->at(k));
               if(include.compare(filePath) == 0)
   			   {
                     moveOn = false;
		      		  break;
			      }
   			}

			   break;
	      }
	   }

	   // if we have been matched against the exclude list then lets skip
      if(moveOn)
         continue;

      // now we copy it over
      if(entry.isDir())
      {
         dirName = entry.fileName();
         bool pathCreated = false;
         QString targetSubPath(QDir::separator() + dirName);

         if(QDir(destPath.path() + targetSubPath).exists())
         {
            pathCreated = true;
         }
         else
         {
            pathCreated = destPath.mkdir(dirName);
         }

         if(pathCreated)
         {
            copyDirAndFiles(srcDir + QDir::separator() + dirName, destPath.path() + QDir::separator() + dirName, nameExcludeFilter, nameIncludeFilter, srcFileList, dstFileList);
         }
      }
      else if(entry.isFile())
      {
         srcFileList->push_back(entry.absoluteFilePath());
         dstFileList->push_back(dstDir + QDir::separator() + entry.fileName());
      }

   }
//.........这里部分代码省略.........
开发者ID:Areloch,项目名称:Torque3D-ProjectManager,代码行数:101,代码来源:copyDir.cpp

示例3: listFolder

void ScanFileOrFolder::listFolder(QFileInfo source,QFileInfo destination)
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1 (%2), destination: %3 (%4)").arg(source.absoluteFilePath()).arg(source.isSymLink()).arg(destination.absoluteFilePath()).arg(destination.isSymLink()));
    if(stopIt)
        return;
    destination=resolvDestination(destination);
    if(stopIt)
        return;
    if(fileErrorAction==FileError_Skip)
        return;
    //if is same
    if(source.absoluteFilePath()==destination.absoluteFilePath())
    {
        emit folderAlreadyExists(source,destination,true);
        waitOneAction.acquire();
        QString destinationSuffixPath;
        switch(folderExistsAction)
        {
            case FolderExists_Merge:
            break;
            case FolderExists_Skip:
                return;
            break;
            case FolderExists_Rename:
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination before rename: "+destination.absoluteFilePath());
                if(newName.isEmpty())
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"pattern: "+folder_isolation.pattern());
                    //resolv the new name
                    destinationSuffixPath=destination.baseName();
                    int num=1;
                    do
                    {
                        if(num==1)
                        {
                            if(firstRenamingRule.isEmpty())
                                destinationSuffixPath=tr("%1 - copy").arg(destination.baseName());
                            else
                            {
                                destinationSuffixPath=firstRenamingRule;
                                destinationSuffixPath.replace(QStringLiteral("%name%"),destination.baseName());
                            }
                        }
                        else
                        {
                            if(otherRenamingRule.isEmpty())
                                destinationSuffixPath=tr("%1 - copy (%2)").arg(destination.baseName()).arg(num);
                            else
                            {
                                destinationSuffixPath=otherRenamingRule;
                                destinationSuffixPath.replace(QStringLiteral("%name%"),destination.baseName());
                                destinationSuffixPath.replace(QStringLiteral("%number%"),QString::number(num));
                            }
                        }
                        num++;
                        if(destination.completeSuffix().isEmpty())
                            destination.setFile(destination.absolutePath()+text_slash+destinationSuffixPath);
                        else
                            destination.setFile(destination.absolutePath()+text_slash+destinationSuffixPath+text_dot+destination.completeSuffix());
                    }
                    while(destination.exists());
                }
                else
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"use new name: "+newName);
                    destinationSuffixPath = newName;
                }
                destination.setFile(destination.absolutePath()+text_slash+destinationSuffixPath);
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination after rename: "+destination.absoluteFilePath());
            break;
            default:
                return;
            break;
        }
    }
    //check if destination exists
    if(checkDestinationExists)
    {
        if(destination.exists())
        {
            emit folderAlreadyExists(source,destination,false);
            waitOneAction.acquire();
            QString destinationSuffixPath;
            switch(folderExistsAction)
            {
                case FolderExists_Merge:
                break;
                case FolderExists_Skip:
                    return;
                break;
                case FolderExists_Rename:
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination before rename: "+destination.absoluteFilePath());
                    if(newName.isEmpty())
                    {
                        //resolv the new name
                        QFileInfo destinationInfo;
                        int num=1;
                        do
                        {
                            if(num==1)
//.........这里部分代码省略.........
开发者ID:amitamitamitamit,项目名称:Ultracopier,代码行数:101,代码来源:ScanFileOrFolder.cpp

示例4: cmdGetIcon_Click

void IconSettings::cmdGetIcon_Click(){
    QString fileName, searchPath=this->prefix_path;

    if ((!txtWorkDir->text().isEmpty()) and (QDir(txtWorkDir->text()).exists())){
        searchPath = txtWorkDir->text();
    } else {
        if (QDir(this->prefix_path).exists()){
           searchPath=this->prefix_path;
        } else {
           searchPath=QDir::homePath();
        }
    }

    QFileDialog dialog(this);
      dialog.setFilter(QDir::Dirs | QDir::Files | QDir::Hidden);
      dialog.setFileMode(QFileDialog::ExistingFile);
      dialog.setWindowTitle(tr("Open image file"));

#if QT_VERSION >= 0x040500
      if (CoreLib->getSetting("advanced", "useNativeFileDialog", false, 1)==0){
          dialog.setOptions(QFileDialog::DontUseNativeDialog);
      }
#endif

      if ((!iconPath.isEmpty()) and (QFile(iconPath).exists())){
          QStringList list = iconPath.split("/");
          searchPath = iconPath.left(iconPath.length() - list.last().length());
      }
      dialog.setDirectory(searchPath);

        #ifndef WITH_ICOUTILS
        dialog.setNameFilter(tr("Image files (*.png *.jpg *.gif *.bmp *.xpm)"));
        #else
        dialog.setNameFilter(tr("Image and Win32 binary files (*.png *.jpg *.gif *.bmp *.xpm *.exe *.dll);;Image files (*.png *.jpg *.gif *.bmp *.xpm);;Win32 Executable (*.exe);;Win32 Shared libraies (*.dll);;Win32 Executable and Shared libraies (*.exe *.dll)"));
        #endif
      //dialog.setSidebarUrls(add_prefix_urls);

     if (dialog.exec())
        fileName = dialog.selectedFiles().first();

    if(!fileName.isEmpty()){
        if ((fileName.toLower().right(3)!="exe") && (fileName.toLower().right(3)!="dll")){
            cmdGetIcon->setIcon (QIcon(fileName));
        } else {

            QStringList args;
            args << "-x";
            args << "-t" << "14";

            QString tmpDir="";
            QStringList list1 = fileName.split("/");

            tmpDir.append(QDir::homePath());
            tmpDir.append("/.config/");
            tmpDir.append(APP_SHORT_NAME);
            tmpDir.append("/tmp/");
            tmpDir.append(list1.last());

            QDir tmp(tmpDir);
            tmp.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
            QFileInfoList list = tmp.entryInfoList();

            if (tmp.exists(tmpDir)){
                for (int i = 0; i < list.size(); ++i) {
                    QFileInfo fileInfo = list.at(i);
                    if (!tmp.remove(fileInfo.filePath()))
                        qDebug()<<"[EE] - Can't delete files at: "<<fileInfo.filePath();
                }
            } else {
                if (!tmp.mkdir(tmpDir)){
                    qDebug()<<"[EE] - Can't create temp directory at: "<<tmpDir;
                }
            }

            args << "-o" << tmpDir;
            args << fileName;

            Process exportProcess(args, CoreLib->getSetting("icotool", "wrestool").toString(), QDir::homePath(), tr("Exporting icon from binary file.<br>This can take a while..."), tr("Exporting icon"), FALSE);

            if (exportProcess.exec()==QDialog::Accepted){
            //icotool -x -o ./regedit.png --width=32 --height=32 ./regedit.exe_14_100_0.ico
                args.clear();
                args << "-x";

                QDir ico_dir(tmpDir);
                // Updating file index
                list = ico_dir.entryInfoList();

                //Creating file list for converting
                for (int i = 0; i < list.size(); ++i) {
                    QFileInfo fileInfo = list.at(i);
                    qDebug() << fileInfo.fileName();
                    if (fileInfo.fileName().right(3)=="ico")
                        args << fileInfo.filePath();
                }

                args << "-o" << QString("%1/").arg(tmpDir);

                //Converting ico files to png

//.........这里部分代码省略.........
开发者ID:ercolinux,项目名称:q4wine,代码行数:101,代码来源:iconsettings.cpp

示例5: run

void PathProcess::run()
{
   emit Log("jejee");

    m_CurrentValue = 0;
    emit ThreadProcessBar(m_CurrentValue);

    mConvertProcess = new QProcess(this);
    connect(mConvertProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readyReadStandardOutput()));
    connect(mConvertProcess, SIGNAL(finished(int)), this, SLOT(ConvertFinished()));

    QDir dir(this->path);
    if (!dir.exists())
    {
        return;
    }
    QStringList filters;
    filters << QString("*.ts") << QString("*.TS");
    dir.setFilter(QDir::Files); //设置类型过滤器,只为文件格式
    dir.setNameFilters(filters);  //设置文件名称过滤器,只为filters格式(后缀为.jpeg等图片格式)

    QFileInfoList list = dir.entryInfoList();

    int file_count = list.count();
    if (file_count <= 0)
    {
        return;
    }
    m_CurrentFile= file_count;

    emit Log("The path has ts file number:" + QString::number(file_count));

    for (int i = 0; i < file_count; i++)
    {
        QFileInfo fileInfo = list.at(i);


        QString mkdir_path = fileInfo.path() + "/" + fileInfo.baseName();
        qDebug() << "mkdir_path" + mkdir_path;

        //mkdir same name dir
        QDir *dir_mkdir = new QDir;
        bool exist = dir_mkdir->exists(mkdir_path);
        if (exist)
        {
        }
        else
        {
            bool ok = dir_mkdir->mkdir(mkdir_path);
            if (ok)
            {
                //textEdit->append(mkdir_path + " path create ok");
            }
        }
        delete dir_mkdir;

        QString m3u8_name = fileInfo.path() + "/" + fileInfo.baseName()+"/" + fileInfo.baseName() +".m3u8";
        QString list_name = fileInfo.path() + "/" + fileInfo.baseName()+"/" + fileInfo.baseName() +"%03d.ts";

        QStringList args;

        args <<"-i"<<fileInfo.absoluteFilePath();
        args <<"-c"<<"copy";
        args <<"-map"<<"0";
        args <<"-f"<<"segment";
        args <<"-segment_list"<< m3u8_name;
        args <<"-segment_time"<<"10";
        args <<list_name;

        qDebug() << args << endl;

        mConvertProcess->setProcessChannelMode(QProcess::MergedChannels);

        QString program = QApplication::applicationDirPath() + "/ffmpeg/ffmpeg";
        //QString program = "D:/ffmpeg/qtffmpeg/ffmpeghls/ffmpegtosegment/github/ffmpeg-segment/bin/ffmpeg";
        mConvertProcess->start(program, args);


        while (false == mConvertProcess->waitForFinished())
        {
        }

    }
     emit Log("Convert Surcessfully\N");
    m_CurrentValue=100 ;
    emit ThreadProcessBar(m_CurrentValue);
}
开发者ID:clzhan,项目名称:ffmpeg-segment,代码行数:87,代码来源:pathprocess.cpp

示例6: dir

///
/// Loads only usable plugins
///
std::vector<LadspaFXInfo*> Effects::getPluginList()
{
	if ( m_pluginList.size() != 0 ) {
		return m_pluginList;
	}

	foreach ( const QString& sPluginDir, Filesystem::ladspa_paths() ) {
		INFOLOG( "*** [getPluginList] reading directory: " + sPluginDir );

		QDir dir( sPluginDir );
		if ( !dir.exists() ) {
			INFOLOG( "Directory " + sPluginDir + " not found" );
			continue;
		}

		QFileInfoList list = dir.entryInfoList();
		for ( int i = 0; i < list.size(); ++i ) {
			QString sPluginName = list.at( i ).fileName();

			if ( ( sPluginName == "." ) || ( sPluginName == ".." ) ) {
				continue;
			}

			// if the file ends with .so or .dll is a plugin, else...
#ifdef WIN32
			int pos = sPluginName.indexOf( ".dll" );
#else
#ifdef Q_OS_MACX
			int pos = sPluginName.indexOf( ".dylib" );
#else
			int pos = sPluginName.indexOf( ".so" );
#endif
#endif
			if ( pos == -1 ) {
				continue;
			}
			//warningLog( "[getPluginList] Loading: " + sPluginName  );

			QString sAbsPath = QString( "%1/%2" ).arg( sPluginDir ).arg( sPluginName );

			QLibrary lib( sAbsPath );
			LADSPA_Descriptor_Function desc_func = ( LADSPA_Descriptor_Function )lib.resolve( "ladspa_descriptor" );
			if ( desc_func == NULL ) {
				ERRORLOG( "Error loading the library. (" + sAbsPath + ")" );
				continue;
			}
			const LADSPA_Descriptor * d;
			if ( desc_func ) {
				for ( unsigned i = 0; ( d = desc_func ( i ) ) != NULL; i++ ) {
					LadspaFXInfo* pFX = new LadspaFXInfo( QString::fromLocal8Bit(d->Name) );
					pFX->m_sFilename = sAbsPath;
					pFX->m_sLabel = QString::fromLocal8Bit(d->Label);
					pFX->m_sID = QString::number(d->UniqueID);
					pFX->m_sMaker = QString::fromLocal8Bit(d->Maker);
					pFX->m_sCopyright = QString::fromLocal8Bit(d->Copyright);

					//INFOLOG( "Loading: " + pFX->m_sLabel );

					for ( unsigned j = 0; j < d->PortCount; j++ ) {
						LADSPA_PortDescriptor pd = d->PortDescriptors[j];
						if ( LADSPA_IS_PORT_INPUT( pd ) && LADSPA_IS_PORT_CONTROL( pd ) ) {
							pFX->m_nICPorts++;
						} else if ( LADSPA_IS_PORT_INPUT( pd ) && LADSPA_IS_PORT_AUDIO( pd ) ) {
							pFX->m_nIAPorts++;
						} else if ( LADSPA_IS_PORT_OUTPUT( pd ) && LADSPA_IS_PORT_CONTROL( pd ) ) {
							pFX->m_nOCPorts++;
						} else if ( LADSPA_IS_PORT_OUTPUT( pd ) && LADSPA_IS_PORT_AUDIO( pd ) ) {
							pFX->m_nOAPorts++;
						} else {
//							string sPortName = d->PortNames[ j ];
							QString sPortName;
							ERRORLOG( QString( "%1::%2 unknown port type" ).arg( pFX->m_sLabel ).arg( sPortName ) );
						}
					}
					if ( ( pFX->m_nIAPorts == 2 ) && ( pFX->m_nOAPorts == 2 ) ) {	// Stereo plugin
						m_pluginList.push_back( pFX );
					} else if ( ( pFX->m_nIAPorts == 1 ) && ( pFX->m_nOAPorts == 1 ) ) {	// Mono plugin
						m_pluginList.push_back( pFX );
					} else {	// not supported plugin
						//WARNINGLOG( "Plugin not supported: " + sPluginName  );
						delete pFX;
					}
				}
			} else {
				ERRORLOG( "Error loading: " + sPluginName  );
			}
		}
	}
开发者ID:elpescado,项目名称:hydrogen,代码行数:91,代码来源:effects.cpp

示例7: qdir

/**
 * @brief Apply output parsers, return the next expected model output file name(s).
 * @param step          Step number to search the files for.
 * @param test_only     If true, only tests if the expected output file exists.
 * @return              Vector containing the output file name(s).
 */
std::vector<std::string> BinaryHandler::_get_data_filenames( int step,
                                                             bool test_only )
{
    std::vector<std::string> output_files;
    QString run_id = QString::number( _toothLife->getID() );
    QString run_path = systemTempPath + "/" + run_id + "/";
    QDir qdir(run_path);

    std::string ext = "";
    if (_output_style == "PLY" || _output_style == "") {
        ext = ".ply";
    }
    else if (_output_style == "Matrix") {
        ext = ".txt";
    }
    else if (_output_style == "Humppa") {
        ext = ".off";
    }
    else {
        return output_files;
    }

    //
    // TODO: Imnplement control of output file names.
    //

    // Note: allowing for some room in the input file name:
    int iter = step*stepSize;
    QString target = QString::number(iter) + "*" + run_id + "*"
                     + QString(ext.c_str());
    QStringList filter;
    filter << target;
    QFileInfoList files = qdir.entryInfoList( filter, QDir::Files );

    if (files.size() == 0) {
        return output_files;
    }

    if (test_only) {
        for (auto file : files) {
            output_files.push_back( file.fileName().toStdString() );
        }
        return output_files;
    }

/*
    std::cout << std::endl;
    std::cout << "** Running parsers in " << run_path.toStdString() << std::endl;
    std::cout << "** Parser target " << target.toStdString() << std::endl;
    std::cout << "** Number of files to be parsed: " << files.size() << std::endl;
*/

    // Apply parsers
    for (int i=0; i<files.size(); i++) {
        QString file = files.at(i).fileName();

        for (auto& parser : _output_parsers) {
            QString path_style = "..\bin\\";
            #if defined(__linux__) || defined(__APPLE__)
            path_style = "../bin/";
            #endif
            QString parser_out = "parser_tmp_" + run_id + ".txt";
            QString cmd = path_style + parser + " " + file + " "
                          + parser_out;

            QProcess process;
            process.start(cmd);
            if(!process.waitForFinished( PARSER_TIMEOUT )) {
                // TODO: Add checks for other errors, e.g., does the parser exist.
               qDebug() << "Error: Parser" << parser << "failed to finish in"
                        << PARSER_TIMEOUT << "msecs on file" << file <<". SKipping.";
               continue;
            }

            // Replace the input file with the parser output if applicable.
            if (QFile::exists(parser_out)) {
                QFile::remove(file);
                QFile::copy(parser_out, file);
                QFile::remove(parser_out);
            }
        }
    }

    // Assuming a fixed output file name for now.
    std::string outfile = std::to_string(iter) + "_" + run_id.toStdString() + ext;
    output_files.push_back( outfile );

    return output_files;
}
开发者ID:tjhakkin,项目名称:MorphoMaker,代码行数:95,代码来源:binaryhandler.cpp

示例8: initialize

bool WPSRun::initialize()
{
    if(work_folder == "")
    {
        qDebug()<<"work_folder == """;
        return false;
    }

    ClearDir(work_folder);

    if(!p_namelist_tool->writeasciiWrf(work_folder))
    {
        qDebug()<<"Ошибка при создании namelist.wps";
        return false;
    }
    if(!p_namelist_tool->writeasciiWps(work_folder))
    {
        qDebug()<<"Ошибка при создании namelist.input";
        return false;
    }
    if(!p_namelist_tool->writeasciiOBSPROC(work_folder))
    {
        qDebug()<<"Ошибка при создании namelist.obsproc";
        return false;
    }
    if(!p_namelist_tool->writeasciiARWPost(work_folder))
    {
        qDebug()<<"Ошибка при создании namelist.ARWPost";
        return false;
    }
    ///////// WPS
    QFile::link(wps_root+"geogrid/src/geogrid.exe", work_folder+"geogrid.exe");
    QFile::link(wps_root+"geogrid/GEOGRID.TBL.ARW", work_folder+"GEOGRID.TBL");
    QFile::link(wps_root+"metgrid/src/metgrid.exe", work_folder+"metgrid.exe");
    QFile::link(wps_root+"metgrid/METGRID.TBL.ARW", work_folder+"METGRID.TBL");
    QFile::link(wps_root+"ungrib/src/ungrib.exe", work_folder+"ungrib.exe");
    QFile::link(wps_root+"ungrib/Variable_Tables/Vtable.GFS", work_folder+"Vtable");
    //////////END WPS
    ///////// WRF
    QDir dir(wrf_root+"run");
    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    QFileInfoList list = dir.entryInfoList();
    for (int i = 0; i < list.size(); ++i) {
        QFileInfo fileInfo = list.at(i);
        QFile::link(fileInfo.filePath(),work_folder+fileInfo.fileName());
    }
    QFile::link(wrf_root+"main/ndown.exe", work_folder+"ndown.exe");
    QFile::link(wrf_root+"main/nup.exe", work_folder+"nup.exe");
    QFile::link(wrf_root+"main/real.exe", work_folder+"real.exe");
    QFile::link(wrf_root+"main/tc.exe", work_folder+"tc.exe");
    QFile::link(wrf_root+"main/wrf.exe", work_folder+"wrf.exe");
    //////////END WRF
    QFile::link(wrf_root+"/MaxTools/mpd.hosts", work_folder+"mpd.hosts");

    QFile::link(wrf_root+"/MaxTools/myhosts", work_folder+"myhosts");

    // Link NCL files to draw images
    QFile::link(wrf_root+"/MaxTools/NCLrun.sh", work_folder+"NCLrun.sh");
    QFile::link(wrf_root+"/MaxTools/NCLscript.ncl", work_folder+"NCLscript.ncl");

    QFile::link(arwpost_root+"src/ARWpost.exe", work_folder+"ARWpost.exe");

    GribLink(grib_files,work_folder);

    //////////WRFDA
    QFile::link(wrfda_root+"/var/da/da_wrfvar.exe", work_folder+"da_wrfvar.exe"); //Ассимиляция
    QFile::link(wrfda_root+"/var/run/be.dat.cv3", work_folder+"be.dat"); //link background error statistics as be.dat


    QFile::link(wrfda_root+"/var/da/da_update_bc.exe", work_folder+"da_update_bc.exe"); //Обновление граничных условий
    QFile::link(wrf_root+"/MaxTools/parame.in", work_folder+"parame.in"); // namelist для da_update_bc.exe

    QFile::link(wrfda_root+"/var/obsproc/src/obsproc.exe", work_folder+"obsproc.exe"); //Препроцессинг метеоинформации в LITTLE_R
    QFile::link(wrfda_root+"/var/obsproc/obserr.txt", work_folder+"obserr.txt"); //Препроцессинг метеоинформации в LITTLE_R
    QString filename = work_folder + "ob.little_r";
    Little_r_fm12* little_r_fm12 = new Little_r_fm12(this); /**< указатель на Класс для записи в Little_r приземных наблюдений*/
    little_r_fm12->OpenFile(filename); //Открываем файл для записи

    QDateTime date = p_namelist_tool->GetDateTimeStart();

    for(int index=26001;index<26008;index++)
    {
        little_r_fm12->writeRZD_DB_data(index,date); //Пишем станцию
    }
    little_r_fm12->CloseFile(); // Закрываем файл

    //////////END WRFDA
    return true;
}
开发者ID:maxselym,项目名称:Magistral,代码行数:89,代码来源:wpsrun.cpp

示例9: getMaskToConfig

QString OptionsWindow::getMaskToConfig(int step) {
	QString mask;
	QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat); // создание нового объекта
	QDir dir;
	QFileInfoList list;
	QString temp_qstring = "default.conf";
	QString path;

	switch(step) {
	case 0:

		dir.cd("/root");
		if(!dir.cd(".WiFiHostapdAP")) {
		dir.mkdir(QString("%1").arg(".WiFiHostapdAP"));
		dir.cd(".WiFiHostapdAP"); }

		if(!dir.cd("./Mask/")) {
			dir.mkdir(QString("%1").arg("Mask"));
			dir.cd("./Mask/"); }

		if(!dir.cd("./hostapd/")) {
			dir.mkdir(QString("%1").arg("hostapd"));
			dir.cd("./hostapd/"); }

		dir.setFilter(QDir::Files);
		list = dir.entryInfoList();

		if(list.size()==0) {

			QFile new_Default_Mask("/root/.WiFiHostapdAP/Mask/hostapd/default.conf");
			new_Default_Mask.open(QIODevice::Append | QIODevice::Text);
			QTextStream out(&new_Default_Mask);
			out << "#Name:Default\n";
			out << "#Type:Hostapd\n";
			out << "interface=[INTERFACE]\n";
			out << "driver=[DRIVER]\n";
			out << "ssid=[SSID]\n";
			out << "country_code=[COUNTRY_CODE]\n";
			out << "[TYPE_AP]\n";
			out << "channel=[CHANNEL]\n";
			out << "macaddr_acl=0\n";
			out << "[HIDEAP]\n";
			out << "[PROTECT]";
			new_Default_Mask.close();

			list.clear();
			dir.setFilter(QDir::Files);
			list = dir.entryInfoList();
		}
		path = "/root/.WiFiHostapdAP/Mask/hostapd/";

		for (int i = 0; i < list.size(); ++i) {
			QFileInfo fileInfo = list.at(i);
			if(fileInfo.fileName() == GlobalSettings->value("AP/ConfigMask", "default.conf").toString())
				temp_qstring = GlobalSettings->value("AP/ConfigMask", "default.conf").toString();
		}
		path += temp_qstring;

		break;
	case 1:

		dir.cd("/root");
		if(!dir.cd(".WiFiHostapdAP")) {
		dir.mkdir(QString("%1").arg(".WiFiHostapdAP"));
		dir.cd(".WiFiHostapdAP"); }

		if(!dir.cd("./Mask/")) {
			dir.mkdir(QString("%1").arg("Mask"));
			dir.cd("./Mask/"); }

		if(!dir.cd("./dnsmasq/")) {
			dir.mkdir(QString("%1").arg("dnsmasq"));
			dir.cd("./dnsmasq/"); }

		dir.setFilter(QDir::Files);
		list = dir.entryInfoList();

		if(list.size()==0) {
			// If the pattern is not present, create the default template
			QFile new_Default_Mask("/root/.WiFiHostapdAP/Mask/dnsmasq/default.conf");
			new_Default_Mask.open(QIODevice::Append | QIODevice::Text);
			QTextStream out(&new_Default_Mask);
			out << "#Name:Default\n";
			out << "#Type:DNSMASQ\n";
			out << "interface=[INTERFACE]\n";
			out << "dhcp-range=[RANGE_1],[RANGE_2],[IP_TIME];\n";
			out<< "[OpenDNS]";

			new_Default_Mask.close();

			list.clear();
			dir.setFilter(QDir::Files);
			list = dir.entryInfoList();
		}

		path = "/root/.WiFiHostapdAP/Mask/dnsmasq/";
		for (int i = 0; i < list.size(); ++i) {
			QFileInfo fileInfo = list.at(i);
			if(fileInfo.fileName() == GlobalSettings->value("AP/ConfigMask1", "default.conf").toString())
				temp_qstring = GlobalSettings->value("AP/ConfigMask1", "default.conf").toString();
//.........这里部分代码省略.........
开发者ID:coolshou,项目名称:wifisoftap,代码行数:101,代码来源:optionswindow.cpp

示例10: loadOnScreen

void CBkImages::loadOnScreen(QWidget *parent, double, double, double)
/////////////////////////////////////////////////////////////////////
{
  QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/data/dssfits/", "*.fits");
  dir.setFilter(QDir::Files);
  QFileInfoList list = dir.entryInfoList();

  // TODO: pridat dialog pro rescale obrazku

  QProgressDialog dlg(tr("Please wait..."), tr("Cancel"), 0, list.count() - 1, parent);
  dlg.setWindowModality(Qt::WindowModal);
  dlg.setMinimumDuration(0);
  dlg.show();

  for (int i = 0; i < list.count(); i++)
  {
    bool memOk;
    bool found = false;
    dlg.setValue(i);
    QApplication::processEvents();

    QFileInfo fi = list.at(i);

    if (dlg.wasCanceled())
    {
      pcMainWnd->updateDSS();
      return;
    }

    for (int i = 0; i < m_tImgList.count(); i++)
    {
      if (!m_tImgList[i].filePath.compare(fi.filePath(), Qt::CaseInsensitive))
      {
        found = true;
        break;
      }
    }

    if (found)
      continue;

    CFits *f = new CFits;
    if (!f->load(fi.filePath(), memOk, false))
    {
      delete f;
    }
    else
    {
      if (pcMapView->isRaDecOnScreen(f->m_ra, f->m_dec))
      {
        bkImgItem_t i;
        delete f;
        bool memOk;

        CFits *f = new CFits;
        if (f->load(fi.filePath(), memOk))
        {
          i.bShow = true;
          i.filePath = fi.filePath();
          //qDebug("%s", qPrintable(i.filePath));
          i.byteSize = (int)fi.size();
          i.ptr = (void *)f;
          i.fileName = fi.fileName();
          i.type = BKT_DSSFITS;
          i.rd.Ra = f->m_ra;
          i.rd.Dec = f->m_dec;
          i.size = anSep(f->m_cor[0].Ra, f->m_cor[0].Dec, f->m_cor[2].Ra, f->m_cor[2].Dec);
          i.param.brightness = 0;
          i.param.contrast = 100;
          i.param.gamma = 150;
          i.param.invert = false;
          i.param.autoAdjust = false;
          i.param.dlgSize = 0;
          i.param.useMatrix = false;
          memset(i.param.matrix, 0, sizeof(i.param.matrix));
          i.param.matrix[1][1] = 1;

          m_totalSize += i.byteSize;

          m_tImgList.append(i);
          //pcMainWnd->updateDSS();
        }
      }
      else
      {
        delete f;
      }
    }
  }

  pcMainWnd->updateDSS();
}
开发者ID:GPUWorks,项目名称:skytechx,代码行数:92,代码来源:cbkimages.cpp

示例11: extractEdgeImage

void MainWindow_M::extractEdgeImage()
{
	QString path = QFileDialog::getExistingDirectory(this, tr("Open Directory"),".\\database", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
	if(path == "")
		return;
	QDir dir(path);
	if(!dir.exists())
		return;

	QString eifilename = path.section('\\',-1);
	eifilename = path + "\\" + eifilename + ".xml";

	// convert the fileName from QString to char*
	char file[256];
	int len = 0;
	for(;len < eifilename.length(); len++)
	{
		file[len] = (eifilename.at(len)).toAscii();
	}
	file[len] = '\0';

	// store this edge image
	FileStorage fs(file,FileStorage::WRITE);
	if(!fs.isOpened())
	{
		return;
	}

	CSAImageProcess imageProcess;
	QImage srcImage;
	QString fileName;
	dir.setFilter(QDir::Files | QDir::NoSymLinks);

	QFileInfoList list = dir.entryInfoList();
	int i = 0;
	while(i < list.size())
	{
		QFileInfo fileInfo = list.at(i++);
		fileName = fileInfo.fileName();
		if(fileName.section('.',-1) != "png" && fileName.section('.',-1) != "PNG")
			continue;
		fileName = fileInfo.path() + "/"+fileName;

		// convert the fileName from QString to char*
		char file[256];
		int len = 0;
		for(;len < fileName.length(); len++)
		{
			file[len] = (fileName.at(len)).toAscii();
		}
		file[len] = '\0';

		// read the image
		Mat mat = imread(file,CV_LOAD_IMAGE_COLOR);

		Mat edgelength,edgeorientation,m,m_n,edgeresponse;
		imageProcess.edgeextraction(mat,edgelength,edgeorientation,m,m_n,edgeresponse);

		// save this edge image
		char name[256];
		sprintf(name,"edgeimage_%d",i);
		fs<<name<<edgelength;
	}
	fs.release();
}
开发者ID:lvpei,项目名称:v9,代码行数:65,代码来源:mainwindow_m.cpp

示例12: UpdateList

//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tFilepathSelector::UpdateList()
{
    m_FilePathList.clear();
    m_FriendlyFilepathList.clear();
    m_DisplayList.clear();
    m_pListWidget->clear();

    // First add the NONE option,  No need to translate (appears in settings.ini)
    m_FilePathList << "None";
    m_FriendlyFilepathList << "None";
    m_DisplayList << "None";

    int currentRow = 0; // setCurrentRow to the currentFile
    // Add files from all locations
    for (int i = 0; i < m_PathAndDirNameList.size(); ++i)
    {
        tPathAndDirname pathAndDirname = m_PathAndDirNameList.at(i);

        QDir directory(pathAndDirname.Path(), "", m_SortFlags, m_Filters);
        directory.setNameFilters(m_NameFilters);
        QFileInfoList fileInfoList = directory.entryInfoList();

        for (int j = 0; j < fileInfoList.size(); ++j)
        {
            QFileInfo fileInfo = fileInfoList.at(j);

            // Add the real filepath string to our list
            m_FilePathList.append(fileInfo.filePath());

            // Add the user displayed filepath e.g. "Sonar.sl2 (factory)"
            const QString dirname = pathAndDirname.DirName();
            QString friendlyFilepath;
            if (dirname.isEmpty())
            {
                friendlyFilepath = fileInfo.fileName();
                m_FriendlyFilepathList.append(friendlyFilepath);
            }
            else
            {
                friendlyFilepath = QString("%1 (%2)").arg(fileInfo.fileName()).arg(dirname);
                m_FriendlyFilepathList.append(friendlyFilepath);

                // compare currentFile to path and set currentRow if there is an exact match
                if (friendlyFilepath.compare(m_CurrentFile) == 0)
                {
                    currentRow = j + 1;
                }
            }

            if (m_ShowFileSize)
            {
                QString item = QString("%1 (%2)").arg(friendlyFilepath).arg(FormatSize(fileInfo.size()));
                m_DisplayList << item;
            }
            else
            {
                m_DisplayList << friendlyFilepath;
            }
        }
    }

    m_pListWidget->addItems(m_DisplayList);

    if (m_CurrentFile.isEmpty())
    {
        m_pListWidget->setCurrentRow(0);
    }
    else
    {
        m_pListWidget->setCurrentRow(currentRow);
    }
}
开发者ID:dulton,项目名称:53_hero,代码行数:75,代码来源:tFilepathSelector.cpp

示例13: get_dir_files

void get_dir_files (QStringList *input_files, QStringList *input_dirs)
{
  for (NV_INT32 i = 0 ; i < input_dirs->size () ; i++)
    {
      QStringList nameFilter;
      QString type = input_dirs->at (i).section (':', 0, 0);

      if (type == "GSF")
        {
          nameFilter << "*.d\?\?" << "*.gsf";
        }
      else if (type == "WLF")
        {
          nameFilter << "*.wlf" << "*.wtf" << "*.whf";
        }
      else if (type == "HAWKEYE")
        {
          nameFilter << "*.bin";
        }
      else if (type == "HOF")
        {
          nameFilter << "*.hof";
        }
      else if (type == "TOF")
        {
          nameFilter << "*.tof";
        }
      else if (type == "UNISIPS")
        {
          nameFilter << "*.u";
        }
      else if (type == "YXZ")
        { 
          nameFilter << "*.yxz" << "*.txt";
        }
      else if (type == "HYPACK")
        {
          nameFilter << "*.raw";
        }
      else if (type == "IVS XYZ")
        {
          nameFilter << "*.xyz";
        }
      else if (type == "LLZ")
        {
          nameFilter << "*.llz";
        }
      else if (type == "CZMIL")
        {
          nameFilter << "*.cxy";
        }
      else if (type == "DTED")
        {
          nameFilter << "*.dt1" << "*.dt2";
        }
      else if (type == "CHRTR")
        {
          nameFilter << "*.fin" << "*.ch2";
        }
      else if (type == "BAG")
        {
          nameFilter << "*.bag";
        }
      else
        {
          NV_CHAR atype[128];
          strcpy (atype, type.toAscii ());
          fprintf (stderr, "\n\nUnknown data type %s on [DIR] = field, ignoring!\n\n", atype);
          continue;
        }

      
      QString file = input_dirs->at (i).section (':', 1, 1).trimmed ();
      QDir dirs;
      dirs.cd (file);

      dirs.setFilter (QDir::Dirs | QDir::Readable);


      //  Get all matching files in this directory.

      QDir files;
      files.setFilter (QDir::Files | QDir::Readable);
      files.setNameFilters (nameFilter);


      if (files.cd (file))
        {
          QFileInfoList flist = files.entryInfoList ();
          for (NV_INT32 i = 0 ; i < flist.size () ; i++)
            {
              //  Don't load HOF timing lines.

              QString tst = flist.at (i).absoluteFilePath ();

              if (!nameFilter.contains ("*.hof") || tst.mid (tst.length () - 13, 4) != "_TA_")
                {
                  input_files->append (tst);
                }
            }
//.........这里部分代码省略.........
开发者ID:dmagiccys,项目名称:pfmabe,代码行数:101,代码来源:readParameterFile.cpp

示例14: deleteThisDirectoryAndEverythingBelow

bool PathHelper::deleteThisDirectoryAndEverythingBelow(QString topDirPath)
{
    DLog("-- deleteThisDirectoryAndEverythingBelow: ") << 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 + symlinks to anything except directories
        QFileInfoList files = topDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden | QDir::System | QDir::Drives/* | QDir::NoSymLinks*/);
        for(int i = 0; i < files.count(); i++)
        {
            QString currFileInPath = files.at(i).fileName();
            QString currFileFullPath = topDir.filePath(currFileInPath);
            QFileInfo currFileInfo(currFileFullPath);
            if( !currFileInfo.isSymLink() && !currFileInfo.isFile() ) {
                WLog("Not a symlink and not a file! Cannot remove it!") << currFileFullPath;
                return false;
            }

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

        // Now recursively delete any child directories
        QFileInfoList dirs = topDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden);
        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
                DLog(QString("The dir is a symlink file [%1]. Simply remove it.").arg(currDirAbsolutePath));
                if(!QDir().remove(currDirAbsolutePath))
                {
                        WLog("Failed to remove the symlink file: " << currDirAbsolutePath);
                        return false;
                }
            }
            else if( !PathHelper::deleteThisDirectoryAndEverythingBelow( currDirAbsolutePath ) ) {
                WLog("Failed to delete subdir: ") << currDirAbsolutePath;
                return false;
            }
        }
    }

    //Finally, remove empty top directory
    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,代码行数:61,代码来源:pathhelper.cpp

示例15: disconnect

void CCCITT4Client::UpdateFileList()
{
    QListWidgetItem *pListItem;
    QDir *pDir;
    QFileInfoList list;
    int i, j;
    bool bFileExists, bItemExists;

    /* Disconnect the list event while changing the contents */
    disconnect(ui->listWidgetFiles, SIGNAL(itemSelectionChanged()), this, SLOT(OnFilesListSelectionChanged()));

    /* Obtain a list of all the tif files in the selected directory */
    pDir = new QDir(ui->lineEditPath->text());
    list = pDir->entryInfoList(QStringList("*.tif"), QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks, QDir::Time);

    /* Remove list elements of which the corresponding file does not exist anymore */
    for(i = 0; i < ui->listWidgetFiles->count(); i++)
    {
        pListItem = ui->listWidgetFiles->item(i);

        /* Verify if the file exists */
        bFileExists = false;
        if(pListItem != NULL)
        {
            for(j = 0; (j < list.size()) && (bFileExists == false); j++)
            {
                if(list.at(j).fileName().compare(pListItem->text()) == 0)
                {
                    bFileExists = true;
                }
            }
        }

        /* Delete the list element if the file doesn't exists */
        if(bFileExists == false)
        {
            ui->listWidgetFiles->removeItemWidget(pListItem);
            delete pListItem;
            pListItem = NULL;
            i = 0;
        }
    }

    /* Iterate over all the files and add them to the list if they are not contained yet */
    for(i = 0; i < list.size(); ++i)
    {
        bItemExists = false;
        for(j = 0; j < ui->listWidgetFiles->count(); j++)
        {
            if(list.at(i).fileName().compare(ui->listWidgetFiles->item(j)->text()) == 0)
            {
                bItemExists = true;
            }
        }

        if(bItemExists == false)
        {
            pListItem = new QListWidgetItem(QIcon(list.at(i).absoluteFilePath()), list.at(i).fileName());

            ui->listWidgetFiles->addItem(pListItem);
        }
    }

    /* Alternate the backgroundcolor of the list elements */
    for(i = 0; i < ui->listWidgetFiles->count(); i++)
    {
        if(i & 0x1)
        {
            ui->listWidgetFiles->item(i)->setBackgroundColor(QColor::fromHsv(0,0,240));
        }
        else
        {
            ui->listWidgetFiles->item(i)->setBackgroundColor(QColor::fromHsv(0,0,255));
        }
    }

    delete pDir;

    /* reconnnect the list event */
    connect(ui->listWidgetFiles, SIGNAL(itemSelectionChanged()), this, SLOT(OnFilesListSelectionChanged()));
}
开发者ID:freecores,项目名称:bw_tiff_compression,代码行数:81,代码来源:CCITT4Client.cpp


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