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


C++ QFileInfo::isDir方法代码示例

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


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

示例1: KIcon

void ObjectsPage::Private::addFile( const QFileInfo& info )
{
    QListWidgetItem* const item = new QListWidgetItem;
    if ( info.isDir() )
        item->setIcon( KIcon( "folder" ) );
    item->setText( info.fileName() );
    item->setData( AbsoluteFilePathRole, info.absoluteFilePath() ); 
    fileListWidget->addItem( item );
}
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:9,代码来源:objectspage.cpp

示例2: xdgIconThemePaths

// Helper to return the icon theme paths from XDG.
QStringList QGenericUnixTheme::xdgIconThemePaths()
{
    QStringList paths;
    // Add home directory first in search path
    const QFileInfo homeIconDir(QDir::homePath() + QStringLiteral("/.icons"));
    if (homeIconDir.isDir())
        paths.prepend(homeIconDir.absoluteFilePath());

    QString xdgDirString = QFile::decodeName(qgetenv("XDG_DATA_DIRS"));
    if (xdgDirString.isEmpty())
        xdgDirString = QLatin1String("/usr/local/share/:/usr/share/");
    foreach (const QString &xdgDir, xdgDirString.split(QLatin1Char(':'))) {
        const QFileInfo xdgIconsDir(xdgDir + QStringLiteral("/icons"));
        if (xdgIconsDir.isDir())
            paths.append(xdgIconsDir.absoluteFilePath());
    }
    return paths;
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:19,代码来源:qgenericunixthemes.cpp

示例3: type

QString IconFilter::type(const QFileInfo &info) const
{
    if (info.isDir())
        return QString("folder-blue");
    if (info.suffix().isEmpty())
        return QString("text-plain");
    // TODO: using a global mime dict
    return QString("text-markdown");
}
开发者ID:Icyhs,项目名称:marketo,代码行数:9,代码来源:iconfilter.cpp

示例4: on_selectButton_clicked

void SessionFolderDialog::on_selectButton_clicked() {

	QString path = this->setting.value("sessionFolder", "C:/").toString();
	QFileInfo sessionFolder = QFileDialog::getExistingDirectory(this, ("Save in"), path, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
	if(sessionFolder.isDir()) {
		this->setting.setValue("sessionFolder", sessionFolder.filePath());
		ui->filePath->setText(sessionFolder.filePath());
	}
}
开发者ID:YunhaiZhou,项目名称:VaRSoft,代码行数:9,代码来源:SessionFolderDialog.cpp

示例5: populateFileBrowser

 void FluidLauncher::populateFileBrowser(QStringList config) {
//qWarning("populateFileBrowser\n");

     Config = config;

     QString path = Config.at(0);
     QString filter = Config.at(1);
     dir.cd(path);
     //     QMessageBox::information(mainwindow,"new path",dir.absolutePath(),QMessageBox::Ok);
     dir.setFilter(QDir::Files | QDir::NoSymLinks | QDir::AllDirs | QDir::NoDot);
     dir.setSorting(QDir::DirsFirst | QDir::Name | QDir::IgnoreCase);

     QFileInfoList list = dir.entryInfoList(QStringList() << filter);

     pictureFlowWidget->setSlideCount(list.count());

     for (int i = 0; i < list.size(); ++i) {
         QFileInfo fileInfo = list.at(i);
         QImage *img = new QImage();

         if (fileInfo.isFile()) {
             img = new QImage(ExtractImage(fileInfo));
         }
         else if (fileInfo.isDir()) {
             img->load(":/core/folder.png");
         }

         QStringList sl;
         if (fileInfo.isDir()) sl.append("Dir");
         if (fileInfo.isFile()) sl.append("File");

         Launcher* newDemo = new Launcher(
                     list.at(i).fileName(),
                     list.at(i).fileName(),
                     list.at(i).fileName(),
                     "",
                     sl);
         demoList.append(newDemo);
         pictureFlowWidget->setSlide(i, *img);
         pictureFlowWidget->setSlideCaption(i, list.at(i).fileName());
         delete img;
     }
     pictureFlowWidget->setCurrentSlide(list.count()/2);
 }
开发者ID:TheProjecter,项目名称:pockemul,代码行数:44,代码来源:fluidlauncher.cpp

示例6: fileInfo

ZLFileInfo QtZLFSManager::fileInfo(const std::string &path) const
{
    const QFileInfo info = QString::fromStdString(path);

    ZLFileInfo result;
    result.Exists = info.exists();
    result.IsDirectory = info.isDir();
    result.Size = info.size();
    return result;
}
开发者ID:euroelessar,项目名称:cutereader,代码行数:10,代码来源:qtzlfsmanager.cpp

示例7: icon

QIcon OpenFileDlg::icon ( const QFileInfo& info ) const
{
    if ( info.isFile() )
        return iconFile;
    else
    if ( info.isDir() )
        return iconFolder;
    else
        return QFileIconProvider::icon( info );
}
开发者ID:timofonic,项目名称:cr3,代码行数:10,代码来源:openfiledlg.cpp

示例8: SyncFilesFromDir

/** \fn     ImageScanThread::SyncFilesFromDir(QString &, int)
 *  \brief  Loads all available files from the path on the
 *          backend and syncs depending if they are a directory or file
 *  \param  path The current directory with the files that shall be scanned syncronized
 *  \param  parentId The id of the parent directory which is required for possible subdirectories
 *  \param  baseDirectory The current root storage group path, this will be stripped before insertion into the database
 *  \return void
 */
void ImageScanThread::SyncFilesFromDir(QString &path, int parentId,
                                       const QString &baseDirectory)
{
    if (!m_continue)
    {
        LOG(VB_FILE, LOG_DEBUG,
            QString("Syncing from SG dir %1 interrupted").arg(path));
        return;
    }

    LOG(VB_FILE, LOG_DEBUG,
        QString("Syncing from SG dir %1").arg(path));

    QDir dir(path);
    if (!dir.exists())
        return;

    // Only get files and dirs, no special and hidden stuff
    dir.setFilter(QDir::Dirs | QDir::Files |
                  QDir::NoDotAndDotDot | QDir::NoSymLinks);
    QFileInfoList list = dir.entryInfoList();
    if (list.isEmpty())
        return;

    for (QFileInfoList::iterator it = list.begin(); it != list.end(); ++it)
    {
        if (!m_continue)
        {
            LOG(VB_FILE, LOG_DEBUG,
                QString("Syncing from SG dir %1 interrupted").arg(path));
            return;
        }

        QFileInfo fileInfo = *it;
        if (fileInfo.isDir())
        {
            // Get the id. This will be new parent id
            // when we traverse down the current directory.
            int id = SyncDirectory(fileInfo, parentId, baseDirectory);

            // Get new files within this directory
            QString fileName = fileInfo.absoluteFilePath();
            SyncFilesFromDir(fileName, id, baseDirectory);
        }
        else
        {
            SyncFile(fileInfo, parentId, baseDirectory);
        }

        // Increase the current progress count in case a
        // progressbar is used to show the sync progress
        if (m_progressTotalCount > m_progressCount)
            ++m_progressCount;
    }
}
开发者ID:ReArtu,项目名称:mythtv,代码行数:63,代码来源:imagescanthread.cpp

示例9: icon

QIcon FileIconProviderImplementation::icon(const QFileInfo &fileInfo) const
{
    if (debug)
        qDebug() << "FileIconProvider::icon" << fileInfo.absoluteFilePath();
    // Check for cached overlay icons by file suffix.
    if (!m_cache.isEmpty() && !fileInfo.isDir()) {
        const QString suffix = fileInfo.suffix();
        if (!suffix.isEmpty()) {
            for (int i = 0, n = m_cache.size(); i != n; ++i)
                if (m_cache.at(i).first == suffix)
                    return m_cache[i].second;
        }
    }
    // Get icon from OS.
    if (HostOsInfo::isWindowsHost() || HostOsInfo::isMacHost())
        return QFileIconProvider::icon(fileInfo);

    // File icons are unknown on linux systems.
    return fileInfo.isDir() ? QFileIconProvider::icon(fileInfo) : m_unknownFileIcon;
}
开发者ID:ProDataLab,项目名称:qt-creator,代码行数:20,代码来源:fileiconprovider.cpp

示例10: lessThan

    virtual bool lessThan( const QModelIndex & left, const QModelIndex & right ) const
    {
        FolderListModel *model = static_cast<FolderListModel*>(this->sourceModel());
        if (model->isRootIndex(left) && model->isRootIndex(right)) {
            return false;
        }
        QFileInfo l = model->fileInfo(left);
        QFileInfo r = model->fileInfo(right);
        if (l.isDir() && r.isFile()) {
            return true;
        } else if (l.isFile() && r.isDir()) {
            return false;
        }
#ifdef Q_OS_WIN
        if (l.filePath().length() <= 3 || r.filePath().length() <= 3) {
            return l.filePath().at(0) < r.filePath().at(0);
        }
#endif
        return (l.fileName().compare(r.fileName(),Qt::CaseInsensitive) < 0);
    }
开发者ID:xiangchenpublicgithub,项目名称:liteide,代码行数:20,代码来源:folderlistview.cpp

示例11: findChildren

void DocLnkSet::findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth)
{
    depth++;
    if ( depth > 10 )
  return;

    QDir dir( dr );

    /* Opie got a different approach
     * I guess it's geek vs. consumer
     * in this case to be discussed
     */
    if ( dir.exists( ".Qtopia-ignore" ) )
  return;

    const QFileInfoList *list = dir.entryInfoList();
    if ( list ) {
  QFileInfo* fi;
  for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) {
      QString bn = fi->fileName();
      if ( bn[0] != '.' ) {
    if ( fi->isDir()  ) {
        if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" )
      findChildren(fi->filePath(), mimeFilters, reference, depth);
    } else {
        if ( fi->extension(FALSE) == "desktop" ) {
      DocLnk* dl = new DocLnk( fi->filePath() );
      QFileInfo fi2(dl->file());
      bool match = FALSE;
      if ( !fi2.exists() ) {
          dir.remove( dl->file() );
      }
      if ( mimeFilters.count() == 0 ) {
          add( dl );
          match = TRUE;
      } else {
          for( QValueList<QRegExp>::ConstIterator it = mimeFilters.begin(); it != mimeFilters.end(); ++ it ) {
        if ( (*it).match(dl->type()) >= 0 ) {
            add(dl);
            match = TRUE;
        }
          }
      }
      if ( !match )
          delete dl;
        } else {
      if ( !reference.find(fi->fileName()) )
          reference.insert(fi->filePath(), (void*)2);
        }
    }
      }
  }
    }
}
开发者ID:opieproject,项目名称:opie,代码行数:54,代码来源:applnk.cpp

示例12: fixupPathForMac

QString fixupPathForMac(const QString& directory) {
    // On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
    // filename if the directory is valid.
    QString path = "";
    QFileInfo fileInfo = QFileInfo(directory);
    if (fileInfo.isDir()) {
        fileInfo.setFile(directory, "__HIFI_INVALID_FILE__");
        path = fileInfo.filePath();
    }
    return path;
}
开发者ID:kencooke,项目名称:hifi,代码行数:11,代码来源:WindowScriptingInterface.cpp

示例13: checkLocalPath

void Folder::checkLocalPath()
{
    const QFileInfo fi(_definition.localPath);

    if( fi.isDir() && fi.isReadable() ) {
        qDebug() << "Checked local path ok";
    } else {
        // Check directory again
        if( !FileSystem::fileExists(_definition.localPath, fi) ) {
            _syncResult.setErrorString(tr("Local folder %1 does not exist.").arg(_definition.localPath));
            _syncResult.setStatus( SyncResult::SetupError );
        } else if( !fi.isDir() ) {
            _syncResult.setErrorString(tr("%1 should be a folder but is not.").arg(_definition.localPath));
            _syncResult.setStatus( SyncResult::SetupError );
        } else if( !fi.isReadable() ) {
            _syncResult.setErrorString(tr("%1 is not readable.").arg(_definition.localPath));
            _syncResult.setStatus( SyncResult::SetupError );
        }
    }
}
开发者ID:stonerl,项目名称:client,代码行数:20,代码来源:folder.cpp

示例14: convertIndex

/** Get the folder which is the target of one's double-click. */
void FileSystemTreeView::convertIndex(const QModelIndex &index)
{
	QFileInfo fileInfo = _fileSystemModel->fileInfo(index);
	if (fileInfo.isDir()) {
		emit folderChanged(_fileSystemModel->filePath(index));
	} else {
		QStringList tracks;
		tracks << "file://" + fileInfo.absoluteFilePath();
		emit aboutToInsertToPlaylist(-1, tracks);
	}
}
开发者ID:VengefulVeggie,项目名称:Miam-Player,代码行数:12,代码来源:filesystemtreeview.cpp

示例15: setSslCertificatesPath

void Config::setSslCertificatesPath(const QString& sslCertificatesPath)
{
    QFileInfo sslPathInfo = QFileInfo(sslCertificatesPath);
    if (sslPathInfo.isDir()) {
        if (sslCertificatesPath.endsWith('/'))
            m_sslCertificatesPath = sslCertificatesPath + "*";
        else
            m_sslCertificatesPath = sslCertificatesPath + "/*";
    } else {
        m_sslCertificatesPath = sslCertificatesPath;
    }
}
开发者ID:30114,项目名称:phantomjs,代码行数:12,代码来源:config.cpp


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