コード例 #1
0
ファイル: fileutils.cpp プロジェクト: zhc921106/TexturePacker
QVector<QString> FileUtils::getAllFiles(const QString &path)
{
    QVector<QString> result;
    QDir dir(path);
    QFileInfoList fileInfoLists = dir.entryInfoList();
    QFileInfoList::const_iterator iterator = fileInfoLists.constBegin();

    for(; iterator != fileInfoLists.constEnd(); iterator++)
    {
        QString filename = iterator->fileName();

        if (!filename.startsWith("."))
        {
            if (iterator->isDir())
            {
                result += getAllFiles(iterator->absoluteFilePath());
            }
            else if (iterator->isFile())
            {
                result.push_back(iterator->absoluteFilePath());
            }
            else
            {
                //
            }
        }
    }

    return result;
}
コード例 #2
0
int QgsSVGDiagramFactoryWidget::addDirectoryToPreview( const QString& path )
{
  //go through all files of a directory
  QDir directory( path );
  if ( !directory.exists() || !directory.isReadable() )
  {
    return 1; //error
  }

  QFileInfoList fileList = directory.entryInfoList( QDir::Files );
  QFileInfoList::const_iterator fileIt = fileList.constBegin();

  QProgressDialog progress( "Adding Icons...", "Abort", 0, fileList.size() - 1, this );
  //cancel button does not seem to work properly with modal dialog
  //progress.setWindowModality(Qt::WindowModal);

  int counter = 0;
  for ( ; fileIt != fileList.constEnd(); ++fileIt )
  {

    progress.setLabelText( tr( "Creating icon for file %1" ).arg( fileIt->fileName() ) );
    progress.setValue( counter );
    QCoreApplication::processEvents();
    if ( progress.wasCanceled() )
    {
      break;
    }
    QString filePath = fileIt->absoluteFilePath();

    //test if file is svg or pixel format
    bool fileIsSvg = testSvgFile( filePath );

    //exclude files that are not svg or image
    if ( !fileIsSvg )
    {
      ++counter; continue;
    }

    QListWidgetItem * listItem = new QListWidgetItem( mPreviewListWidget );

    if ( fileIsSvg )
    {
      QIcon icon( filePath );
      listItem->setIcon( icon );
    }

    listItem->setText( "" );
    //store the absolute icon file path as user data
    listItem->setData( Qt::UserRole, fileIt->absoluteFilePath() );
    ++counter;
  }

  return 0;
}
コード例 #3
0
ファイル: QBtCompareDirsDialog.cpp プロジェクト: sclown/bsc
//*******************************************************************
// read_dir                                                  PRIVATE
//-------------------------------------------------------------------
// Rekursywne odczytywanie calej zawartosci wskazanego katalogu.
// Odczytana zawrtosc katalogu jest zapamietywania w hash-tablicy.
//*******************************************************************
void QBtCompareDirsDialog::read_dir( const QString& in_parent,
                                     const QString& in_dir,
                                     DirMap& out_data ) const
{
   static const int sflag = QDir::AllDirs
                          | QDir::Files
                          | QDir::NoDotAndDotDot
                          | QDir::Readable
                          | QDir::Writable
                          | QDir::Hidden;
                   
   const QDir dir( in_dir, "*", QDir::Unsorted, QFlags<QDir::Filter>( sflag ) );
   const QFileInfoList items = dir.entryInfoList();

   FileMap files_map = FileMap();
   QFileInfoList::const_iterator it = items.begin();
   const QFileInfoList::const_iterator end = items.end();
   while( continue_ && ( it != end ) ) {
      if( it->isDir() ) read_dir( in_parent, it->absoluteFilePath(), out_data );
      else              files_map.insert( it->fileName(), *it );
      ++it;
   }
   QString path = in_dir;
   out_data.insert( path.remove( in_parent ), files_map );
}
コード例 #4
0
ファイル: SimpleSearchEngine.cpp プロジェクト: xffox/piclex
bool SimpleSearchEngine::setDirectory(const QString &path)
{
    QDir dir(path);
    if(!dir.exists())
    {
        Log().warning("SimpleSearchEngine: set directory failed: directory doesn't"
                "exist '%s'",
                qPrintable(path));
        return false;
    }

    Log().debug("SimpleSearchEngine: set directory '%s'", qPrintable(path));

    QFileInfoList fileInfoList = dir.entryInfoList(
            QDir::Files);

    mFilenames.clear();

    QFileInfoList::const_iterator iter = fileInfoList.begin();
    for(; iter != fileInfoList.end(); ++iter)
        mFilenames.append(iter->absoluteFilePath());

    updateResults();

    return true;
}
コード例 #5
0
  //list all directories in $prefix/share/qgis/svg
  foreach( QString path, QgsApplication::svgPaths() )
  {
    QDir svgDirectory( path );
    if ( !svgDirectory.exists() || !svgDirectory.isReadable() )
    {
      continue; //error
    }

    QFileInfoList directoryList = svgDirectory.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
    QFileInfoList::const_iterator dirIt = directoryList.constBegin();
    for ( ; dirIt != directoryList.constEnd(); ++dirIt )
    {
      if ( addDirectoryToPreview( dirIt->absoluteFilePath() ) == 0 )
      {
        mSearchDirectoriesComboBox->addItem( dirIt->absoluteFilePath() );
      }
    }
  }
コード例 #6
0
void QgsComposerPictureWidget::addStandardDirectoriesToPreview()
{
  mPreviewListWidget->clear();

  //list all directories in $prefix/share/qgis/svg
  QStringList svgPaths = QgsApplication::svgPaths();
  for ( int i = 0; i < svgPaths.size(); i++ )
  {
    QDir svgDirectory( svgPaths[i] );
    if ( !svgDirectory.exists() || !svgDirectory.isReadable() )
    {
      continue;
    }

    //add directory itself
    mSearchDirectoriesComboBox->addItem( svgDirectory.absolutePath() );
    addDirectoryToPreview( svgDirectory.absolutePath() );

    //and also subdirectories
    QFileInfoList directoryList = svgDirectory.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
    QFileInfoList::const_iterator dirIt = directoryList.constBegin();
    for ( ; dirIt != directoryList.constEnd(); ++dirIt )
    {
      if ( addDirectoryToPreview( dirIt->absoluteFilePath() ) == 0 )
      {
        mSearchDirectoriesComboBox->addItem( dirIt->absoluteFilePath() );
      }
    }
  }

  //include additional user-defined directories for images
  QSettings s;
  QStringList userDirList = s.value( "/Composer/PictureWidgetDirectories" ).toStringList();
  QStringList::const_iterator userDirIt = userDirList.constBegin();
  for ( ; userDirIt != userDirList.constEnd(); ++userDirIt )
  {
    addDirectoryToPreview( *userDirIt );
    mSearchDirectoriesComboBox->addItem( *userDirIt );
  }

  mPreviewsLoaded = true;
}
コード例 #7
0
void NowReadingEngine::update()
{
    QFileInfoList okularFiles = getOkularXMLFiles();
    QFileInfoList::const_iterator it = okularFiles.constBegin();
    uint limit = MaxDataModelSize;

    for ( ; it != okularFiles.constEnd() && limit--; ++it) {
        QString okularFileName = it->absoluteFilePath();
        DataModel::iterator itDm = _dataModel.find(okularFileName);

        if ((itDm != _dataModel.end()) && /* We have an entry for this element */
            (itDm.value().accessTime >= it->lastModified())) { /* And it's up to date */
                /* No need to update */
                continue;
        }

        NowReadingEntry entry;
        if (convertOkularXMLFileToEntry(okularFileName, entry)) {
            setData(entry.path, "currentPage", entry.currentPage);
            setData(entry.path, "totalPages", entry.totalPages);
            setData(entry.path, "accessTime", entry.accessTime);
            _dataModel[okularFileName] = entry;
        }
    }

    /* Cleanup */
    if (_dataModel.size() > MaxDataModelSize) {
        // Find elements to evict
        // First - what is the modification time of the last element we want to preserve?

        QDateTime oldestElementDate;
        QList<DataModel::mapped_type> values = _dataModel.values();
        nth_element(values.begin(), values.begin()+MaxDataModelSize-1, values.end());
        oldestElementDate = (values.begin()+MaxDataModelSize-1)->accessTime;

        // Now find all elements older than the oldest allowable
        DataModel::iterator it = _dataModel.begin();

        while (it != _dataModel.end()) {
            if (it.value().accessTime <  oldestElementDate) {
                removeSource(it.value().path);
                it = _dataModel.erase(it);
            }
            else {
                ++it;
            }
        }

    }

    /* Single shot timer used as in case the update takes very long
       we can get overflow of timer events to handle */
    QTimer::singleShot(PollingInterval, this, SLOT(update()));
}
コード例 #8
0
void FindImageRunnable::run()
{
	using std::vector;
	using std::string;
	using itk::GDCMSeriesFileNames;
	if (m_forceFinish) {
		emit finish();
		return;
	}
	// Find Dicom files
	{
		// Generate a sequence of fileNames from a DICOM series
		GDCMSeriesFileNames::Pointer nameGenerator = GDCMSeriesFileNames::New();
		nameGenerator->SetUseSeriesDetails(true);
		nameGenerator->SetDirectory(m_folderPath.toStdString().c_str());
		//nameGenerator->AddSeriesRestriction("0008|0021");
		nameGenerator->GetInputFileNames();

		// basing on all seriesUIDs
		// get file names form corresponding serires UID
		try {
			const vector<string>& seriesUID = nameGenerator->GetSeriesUIDs();

			vector<string>::const_iterator seriesEnd = seriesUID.end();
			for (vector<string>::const_iterator cit = seriesUID.cbegin();
				cit != seriesUID.cend(); ++cit) {

				GDCImageIORead(nameGenerator->GetFileNames(*cit));

			}
		}
		catch (itk::ExceptionObject& e) {
			qDebug() << e.what();
		}

	}

	//Find Nifti file
	{
		QStringList filterList;
		filterList << "*.nii" << "*.nii.gz";
		QDir dir(m_folderPath);
		QFileInfoList niiFileList = dir.entryInfoList(filterList);

		// basing on wildcard to find out all NIFTI files
		for (QFileInfoList::const_iterator cit = niiFileList.cbegin();
			cit != niiFileList.cend(); ++cit)
		{
			vector<string> fileNames(1, cit->absoluteFilePath().toStdString());
			GDCImageIORead(fileNames);
		}
	}
	emit finish();
}
コード例 #9
0
ファイル: ImagePane.cpp プロジェクト: kenschweller/qtmaze
static void PopulateWithImages(QListWidget * const imagelist, const QString &path)
{
	QDir imagesDir(path);
	QStringList extensions;
	extensions << "*.jpg" << "*.png" << "*.bmp" << "*.gif";
	const QFileInfoList fileList = imagesDir.entryInfoList(extensions, QDir::Files, QDir::Name | QDir::IgnoreCase);
	for (QFileInfoList::const_iterator it = fileList.begin(); it != fileList.end(); ++it)
	{
		QListWidgetItem * const item = new QListWidgetItem(QIcon(QPixmap(it->absoluteFilePath())), it->fileName());
		imagelist->addItem(item);
	}
}
コード例 #10
0
ファイル: mainwindow.cpp プロジェクト: laybatin/ImageDomino
/*
 * FilesModelUpdate
 * extfilter_imgs_ 에 들어있는 파일들을 실제로 보여지도록 만든다.
 * 조그만 아이콘으로 만들기 위한 작업
 */
void MainWindow::FilesModelUpdate() {
    QFileInfoList::const_iterator iter;

    file_model_->clear();

    for (iter=extfilter_imgs_.begin(); iter!=extfilter_imgs_.end(); ++iter) {
        qDebug() << iter->absoluteFilePath();
        QImage img_buffer(iter->absoluteFilePath());
        QIcon icon = GetThumnail(&img_buffer);

        QStandardItem* item;
        if(!icon.isNull()) {
            item = new QStandardItem(icon,iter->fileName());
            file_model_->appendRow(item);
        }
    }


    extfilter_imgs_.clear();;

}
コード例 #11
0
ファイル: fileutils.cpp プロジェクト: zhc921106/TexturePacker
QVector<QString> FileUtils::getAllImageFiles(const QString & path)
{
    QVector<QString> result;
    QDir dir(path);
    QFileInfoList fileInfoLists = dir.entryInfoList();
    QFileInfoList::const_iterator iterator = fileInfoLists.constBegin();

    for(; iterator != fileInfoLists.constEnd(); iterator++)
    {
        QString filename = iterator->fileName();

        if (!filename.startsWith("."))
        {
            if (iterator->isDir())
            {
                result += getAllImageFiles(iterator->absoluteFilePath());
            }
            else if (iterator->isFile())
            {
                QString ext = iterator->completeSuffix();
                QString extLower = ext.toLower();
                if (extLower.endsWith("png") ||
                        extLower.endsWith("jpg") ||
                        extLower.endsWith("jpeg"))
                {
                    result.push_back(iterator->absoluteFilePath());
                }
            }
            else
            {
                //
            }
        }
    }

    return result;
}
コード例 #12
0
void NewFormWidget::loadFrom(const QString &path, bool resourceFile, const QString &uiExtension,
                       const QString &selectedItem, QTreeWidgetItem *&selectedItemFound)
{
    const QDir dir(path);

    if (!dir.exists())
        return;

    // Iterate through the directory and add the templates
    const QFileInfoList list = dir.entryInfoList(QStringList(QLatin1String("*.") + uiExtension),
                                                 QDir::Files);

    if (list.isEmpty())
        return;

    const QChar separator = resourceFile ? QChar(QLatin1Char('/'))
                                         : QDir::separator();
    QTreeWidgetItem *root = new QTreeWidgetItem(m_ui->treeWidget);
    root->setFlags(root->flags() & ~Qt::ItemIsSelectable);
    // Try to get something that is easy to read.
    QString visiblePath = path;
    int index = visiblePath.lastIndexOf(separator);
    if (index != -1) {
        // try to find a second slash, just to be a bit better.
        const int index2 = visiblePath.lastIndexOf(separator, index - 1);
        if (index2 != -1)
            index = index2;
        visiblePath = visiblePath.mid(index + 1);
        visiblePath = QDir::toNativeSeparators(visiblePath);
    }

    const QChar underscore = QLatin1Char('_');
    const QChar blank = QLatin1Char(' ');
    root->setText(0, visiblePath.replace(underscore, blank));
    root->setToolTip(0, path);

    const QFileInfoList::const_iterator lcend = list.constEnd();
    for (QFileInfoList::const_iterator it = list.constBegin(); it != lcend; ++it) {
        if (!it->isFile())
            continue;

        QTreeWidgetItem *item = new QTreeWidgetItem(root);
        const QString text = it->baseName().replace(underscore, blank);
        if (selectedItemFound == 0 && text == selectedItem)
            selectedItemFound = item;
        item->setText(0, text);
        item->setData(0, TemplateNameRole, it->absoluteFilePath());
    }
}
コード例 #13
0
ファイル: iconview.cpp プロジェクト: DaveDaCoda/mythtv
void IconView::LoadThumbnail(ThumbItem *item)
{
    if (!item)
        return;

    bool canLoadGallery = m_isGallery;

    QString imagePath;
    if (canLoadGallery)
    {
        if (item->IsDir())
        {
            // try to find a highlight
            QDir subdir(item->GetPath(), "*.highlight.*",
                        QDir::Name, QDir::Files);

            if (subdir.count() > 0)
            {
                // check if the image format is understood
                QFileInfoList::const_iterator it = subdir.entryInfoList().begin();
                if (it != subdir.entryInfoList().end())
                {
                    imagePath = it->absoluteFilePath();
                }
            }
        }
        else
        {
            QString fn = item->GetName();
            int firstDot = fn.indexOf('.');
            if (firstDot > 0)
            {
                fn.insert(firstDot, ".thumb");
                imagePath = QString("%1/%2").arg(m_currDir).arg(fn);
            }
        }

        canLoadGallery = !(QFile(imagePath).exists());
    }

    if (!canLoadGallery)
        imagePath = QString("%1%2.jpg")
                            .arg(ThumbGenerator::getThumbcacheDir(m_currDir))
                            .arg(item->GetName());

    item->SetImageFilename(imagePath);
}
コード例 #14
0
int FmDriveDetailsContent::getDataSizeByAbsolutePath( const QString &driveName,
        const FmDriveDetailsDataGroup &dataGroup,
            QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped )
{
    quint64 totalSize = 0;
    QStringList typeFilter = dataGroup.pathList();
    
    for( QStringList::const_iterator it = typeFilter.begin(); 
           it!= typeFilter.end(); ++it ) {
        if ( *isStopped ){
            return FmErrCancel;
        }        
        QString driver(FmUtils::removePathSplash(FmUtils::getDriveNameFromPath(driveName)));
        QFileInfo fileInfo(QString(driver + (*it)));
        if (fileInfo.exists()) {
            if (fileInfo.isFile()) {
                totalSize += fileInfo.size();    
            } else if (fileInfo.isDir()) {
                QList<QDir> dirs;
                dirs.append(QDir(fileInfo.absolutePath()));
                // traverse the whole path
                while (!dirs.isEmpty()) {
                    QDir::Filters filter = QDir::NoDotAndDotDot | QDir::AllEntries;
                    QFileInfoList infoList = dirs.first().entryInfoList( filter );
                    for ( QFileInfoList::const_iterator it = infoList.begin(); it != infoList.end(); ++it ) {
                        if ( *isStopped ){
                            return FmErrCancel;
                        }                        
                        if ( it->isFile() ) {
                            totalSize += it->size();  
                        }
                        else if ( it->isDir() ) {
                            dirs.append( QDir( it->absoluteFilePath() ) );
                        } 
                    }
                    dirs.removeFirst();
                }
            }
            
        }
    }
 
    detailsSizeList.append( new FmDriveDetailsSize( dataGroup.dataType(), totalSize ) );
    return FmErrNone;
}
コード例 #15
0
KipiImageCollectionShared::KipiImageCollectionShared(const QUrl& albumPath)
    : ImageCollectionShared(),
      m_albumPath(albumPath),
      m_images()
{
    // go through the album and add its images:
    const QString albumPathString = m_albumPath.toLocalFile();

    // add only the files, because recursion through directories should be
    // handled in KipiInterface::add[Selected]Album
    // TODO: restrict the search to images!
    const QFileInfoList files     = QDir(albumPathString).entryInfoList(QDir::Files);

    for (QFileInfoList::const_iterator it = files.constBegin(); it!=files.constEnd(); ++it)
    {
            m_images.append(QUrl::fromLocalFile(it->absoluteFilePath()));
    }
}
コード例 #16
0
QMap<QString, QString> QgsComposerManager::defaultTemplates() const
{
  QMap<QString, QString> templateMap;

  //search for default templates in $pkgDataPath/composer_templates
  QDir defaultTemplateDir( QgsApplication::pkgDataPath() + "/composer_templates" );
  if ( !defaultTemplateDir.exists() )
  {
    return templateMap;
  }

  QFileInfoList fileInfoList = defaultTemplateDir.entryInfoList( QDir::Files );
  QFileInfoList::const_iterator infoIt = fileInfoList.constBegin();
  for ( ; infoIt != fileInfoList.constEnd(); ++infoIt )
  {
    templateMap.insert( infoIt->baseName(), infoIt->absoluteFilePath() );
  }
  return templateMap;
}
コード例 #17
0
QMap<QString, QString> QgsComposerManager::defaultTemplates( bool fromUser ) const
{
  QMap<QString, QString> templateMap;

  //search for default templates in $pkgDataPath/composer_templates
  // user templates in $qgisSettingsDirPath/composer_templates
  QDir defaultTemplateDir( fromUser ? mUserTemplatesDir : mDefaultTemplatesDir );
  if ( !defaultTemplateDir.exists() )
  {
    return templateMap;
  }

  QFileInfoList fileInfoList = defaultTemplateDir.entryInfoList( QDir::Files );
  QFileInfoList::const_iterator infoIt = fileInfoList.constBegin();
  for ( ; infoIt != fileInfoList.constEnd(); ++infoIt )
  {
    templateMap.insert( infoIt->baseName(), infoIt->absoluteFilePath() );
  }
  return templateMap;
}
コード例 #18
0
int QgsComposerPictureWidget::addDirectoryToPreview( const QString& path )
{
  //go through all files of a directory
  QDir directory( path );
  if ( !directory.exists() || !directory.isReadable() )
  {
    return 1; //error
  }

  QFileInfoList fileList = directory.entryInfoList( QDir::Files );
  QFileInfoList::const_iterator fileIt = fileList.constBegin();

  QProgressDialog progress( "Adding Icons...", "Abort", 0, fileList.size() - 1, this );
  //cancel button does not seem to work properly with modal dialog
  //progress.setWindowModality(Qt::WindowModal);

  int counter = 0;
  for ( ; fileIt != fileList.constEnd(); ++fileIt )
  {

    progress.setLabelText( tr( "Creating icon for file %1" ).arg( fileIt->fileName() ) );
    progress.setValue( counter );
    QCoreApplication::processEvents();
    if ( progress.wasCanceled() )
    {
      break;
    }
    QString filePath = fileIt->absoluteFilePath();

    //test if file is svg or pixel format
    bool fileIsPixel = false;
    bool fileIsSvg = testSvgFile( filePath );
    if ( !fileIsSvg )
    {
      fileIsPixel = testImageFile( filePath );
    }

    //exclude files that are not svg or image
    if ( !fileIsSvg && !fileIsPixel )
    {
      ++counter; continue;
    }

    QListWidgetItem * listItem = new QListWidgetItem( mPreviewListWidget );
    listItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );

    if ( fileIsSvg )
    {
      QIcon icon( filePath );
      listItem->setIcon( icon );
    }
    else //for pixel formats: create icon from scaled pixmap
    {
      QPixmap iconPixmap( filePath );
      if ( iconPixmap.isNull() )
      {
        ++counter; continue; //unknown file format or other problem
      }
      //set pixmap hardcoded to 30/30, same as icon size for mPreviewListWidget
      QPixmap scaledPixmap( iconPixmap.scaled( QSize( 30, 30 ), Qt::KeepAspectRatio ) );
      QIcon icon( scaledPixmap );
      listItem->setIcon( icon );
    }

    listItem->setText( "" );
    //store the absolute icon file path as user data
    listItem->setData( Qt::UserRole, fileIt->absoluteFilePath() );
    ++counter;
  }

  return 0;
}
コード例 #19
0
int FmDriveDetailsContent::getDataSizeByTraversePath( const QString &driveName,
            QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped )
{
    qint64 imageSize( 0 );
    qint64 soundSize( 0 );
    qint64 midpJavaSize( 0 );
    qint64 nativeAppsSize( 0 );
    qint64 videoSize( 0 );
    qint64 documentsSize( 0 );
   
    FmFileTypeRecognizer fileTypeRecognizer;
    
    QList<QDir> dirs;
    dirs.append( QDir( driveName ) );
    
    // traverse the whole drive
    while (!dirs.isEmpty()) {
        QDir::Filters filter = QDir::NoDotAndDotDot | QDir::AllEntries;
        // do not summarize system and hidden files, these size will go into others category
        // if( isSysHiddenIncluded ) {
        // filter = filter | QDir::Hidden | QDir::System;
        // }

        QFileInfoList infoList = dirs.first().entryInfoList( filter );
        for ( QFileInfoList::const_iterator it = infoList.begin(); it != infoList.end(); ++it ) {
            if ( *isStopped ){
                return FmErrCancel;
            }
            
            if ( it->isFile() ) {
            FmFileTypeRecognizer::FileType fileType = 
                    fileTypeRecognizer.getType( it->absoluteFilePath() );
            switch ( fileType )
                {
                case FmFileTypeRecognizer::FileTypeImage:
                    imageSize += it->size();
                    break;
                case FmFileTypeRecognizer::FileTypeTone:
                    soundSize += it->size();
                    break;
                case FmFileTypeRecognizer::FileTypeJava:
                    midpJavaSize += it->size();
                    break;
                case FmFileTypeRecognizer::FileTypeSisx:
                    nativeAppsSize += it->size();
                    break;
                case FmFileTypeRecognizer::FileTypeVideo:
                    videoSize += it->size();
                    break;
                case FmFileTypeRecognizer::FileTypeText:
                    documentsSize += it->size();
                    break;
                default:
                    // do not need handle other type 
                    break;
                }
            }
            else if ( it->isDir() ) {
                dirs.append( QDir( it->absoluteFilePath() ) );
            } 
        }
        dirs.removeFirst();
    }
       
    // store result to detailsSizeList.
    detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeImages, imageSize ) ) ;
    detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeSoundFiles, soundSize ) );
    detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeMidpJava, midpJavaSize ) );
    detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeNativeApps, nativeAppsSize ) );
    detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeVideos, videoSize ) );
    detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeDocuments, documentsSize ) );
    return FmErrNone;
}
コード例 #20
0
  openstudio::path WeatherFileFinder::find(const JobParams &t_params,
      const boost::optional<std::string> &t_filelocationname,
      const boost::optional<std::string> &t_weatherfilename)
  {
    openstudio::path epwdir;

    try {
      if (t_params.has("epwfile"))
      {
        openstudio::path epwfile = toPath(t_params.get("epwfile").children.at(0).value);

        if (!epwfile.empty() && boost::filesystem::exists(epwfile))
        {
          LOG(Info, "Valid epwfile found, returning: " << openstudio::toString(epwfile));

          return epwfile;
        }
      } else {
        LOG(Info, "No epwfile found in params, moving on for other methods of finding weather file");
      }
    } catch (const std::exception &) {
      // No epw dir set in params
      LOG(Info, "Error with epwfile found in params, moving on for other methods of finding weather file");
    }

    try {
      if (t_params.has("epwdir"))
      {
        epwdir = toPath(t_params.get("epwdir").children.at(0).value);
      }
    } catch (const std::exception &) {
      // No epw dir set in params
      LOG(Info, "No EPWDir known finding weather file will be much harder");
    }

    if (epwdir.empty() || !boost::filesystem::exists(epwdir) || !boost::filesystem::is_directory(epwdir))
    {
      LOG(Info, "The configured EPWDir either does not exist or is not a directory: " << toString(epwdir));
    }


    if (t_weatherfilename)
    {
      openstudio::path p = toPath(*t_weatherfilename);

      if (!boost::filesystem::exists(p))
      {
        p = epwdir / toPath(*t_weatherfilename);

        if (!boost::filesystem::exists(p))
        {
          LOG(Info, "Weather file discovered from comment header cannot be found at: " << toString(p));
        } else {
          return p;
        }
        LOG(Info, "Weather file discovered from comment header cannot be found at: " << *t_weatherfilename);
      } else {
        return p;
      }

    }

    if (t_filelocationname)
    {
      LOG(Info, "attempting to find weather file from location name: " << *t_filelocationname);

      // We did not have an epw set, so let's try to find one
      try {
        QDir dir(openstudio::toQString(epwdir), "*.epw");
        QFileInfoList files = dir.entryInfoList();

        std::set<std::string> desiredname = getNameComponents(*t_filelocationname);

        openstudio::path bestmatch;
        size_t matchsize = 0;

        for (QFileInfoList::const_iterator itr = files.begin();
            itr != files.end();
            ++itr)
        {
          std::set<std::string> foundname = getNameComponents(openstudio::toString(itr->fileName()));

          std::vector<std::string> matches;
          std::set_intersection(desiredname.begin(), desiredname.end(), foundname.begin(), foundname.end(),
              std::back_inserter(matches));

          if (matches.size() > matchsize)
          {
            matchsize = matches.size();
            bestmatch = openstudio::toPath(itr->absoluteFilePath());
          }
        }

        if (matchsize > 2)
        {
          LOG(Info, "Adding best match epw from the list found: " << toString(bestmatch));
          return bestmatch;
        } else {
          LOG(Info, "No best match epw file found, continuing with no epw set");
        }

      } catch (const std::exception &) {
        LOG(Info, "No EPw file set and no epwdir provided. We are continuing, but EnergyPlus will likely fail");
      }
    } else {
      LOG(Info, "No EPw file set and no location information parsed from IDF. We are continuing, but EnergyPlus will likely fail");
    }  

    LOG(Info, "No weather file found");

    return openstudio::path();
  }
コード例 #21
0
ファイル: LocalProcess.cpp プロジェクト: CUEBoxer/OpenStudio
  LocalProcess::FileSet LocalProcess::dirFiles(const QString &dir) const
  {
    QFileInfoList fil;

    
    QDir subdirs(dir, "mergedjob-*", QDir::Name, QDir::Dirs);
    QFileInfoList mergedjobdirs = subdirs.entryInfoList();

    for (QFileInfoList::const_iterator itr = mergedjobdirs.begin();
         itr != mergedjobdirs.end();
         ++itr)
    {

      QDir mergeddir(itr->absoluteFilePath(), "", QDir::Name, QDir::Files);
      fil.append(mergeddir.entryInfoList());
    }
  

    QDir d(dir, "", QDir::Name, QDir::Files);
    fil.append(d.entryInfoList());

    QFileInfoList filtered;

    // Filter out all files that are part of the set of input files. Everything remaining should be an outputfile
    for (QFileInfoList::const_iterator itr = fil.begin();
         itr != fil.end();
         ++itr)
    {
      bool partofinput = false;
      for (std::vector<std::pair<openstudio::path, openstudio::path> >::const_iterator itr2 = m_requiredFiles.begin();
          itr2 != m_requiredFiles.end();
          ++itr2)
      {
        QString fileName = itr->fileName();
        QString fileName2 = toQString(itr2->second.filename());
        if (fileName == fileName2)
        {
          partofinput = true;
          break;
        }
      }

      if (!partofinput)
      {
        filtered.push_back(*itr);
      }
    }

    FileSet out;

    typedef FileInfo (*filetransform)(QFileInfo);

    try{
      std::transform(filtered.begin(), filtered.end(), std::inserter(out, out.end()), 
          static_cast<filetransform>(&RunManager_Util::dirFile));
    } catch(openstudio::Exception& e) {
      LOG_AND_THROW("Exception caught " << e.what());
    }

    return out;
  }