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


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

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


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

示例1: pushDirectory

/*!
    \internal
*/
void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo)
{
    QString path = fileInfo.filePath();

#ifdef Q_OS_WIN
    if (fileInfo.isSymLink())
        path = fileInfo.canonicalFilePath();
#endif

    if (iteratorFlags & QDirIterator::FollowSymlinks)
        visitedLinks << fileInfo.canonicalFilePath();

    if (engine) {
        engine->setFileName(path);
        QAbstractFileEngineIterator *it = engine->beginEntryList(filters, nameFilters);
        if (it) {
            it->setPath(path);
            fileEngineIterators << it;
        } else {
            // No iterator; no entry list.
        }
    } else {
#ifndef QT_NO_FILESYSTEMITERATOR
        QFileSystemIterator *it = new QFileSystemIterator(fileInfo.d_ptr->fileEntry,
            filters, nameFilters, iteratorFlags);
        nativeIterators << it;
#endif
    }
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:32,代码来源:qdiriterator.cpp

示例2: qDebug

void ThothWindow::on_pushButton_4_clicked()
{
    //Select build model

    QModelIndex indx = ui->treeViewBuild->currentIndex();
    QFileInfo info = m_buildModel->fileInfo(indx);
    if(info.isFile())
    {
        if(info.suffix() == QString("obj"))
        {
            qDebug("Create model with path: %s", qPrintable(info.absoluteFilePath()));
            if(info.absoluteFilePath().contains(QString("wall"),Qt::CaseInsensitive))
            {
                CScenary::getInstance()->setActiveModel(info.canonicalFilePath().toStdString());
                CScenary::getInstance()->setActiveType(WALL);
            }
            if(info.absoluteFilePath().contains(QString("stair"), Qt::CaseInsensitive))
            {
                CScenary::getInstance()->setActiveModel(info.canonicalFilePath().toStdString());
                CScenary::getInstance()->setActiveType(STAIR);
            }
            RenderManager::GetInstance()->GetRenderMode(EDITOR_2D)->setEditMode(INSERTING);
        }
    }
    ui->contextGL->setFocus();
}
开发者ID:Blackcatn13,项目名称:houseDesigner,代码行数:26,代码来源:thothwindow.cpp

示例3: parseDirectories

void SubComponentManager::parseDirectories()
{
    if (!m_filePath.isEmpty()) {
        const QString file = m_filePath.toLocalFile();
        QFileInfo dirInfo = QFileInfo(QFileInfo(file).path());
        if (dirInfo.exists() && dirInfo.isDir())
            parseDirectory(dirInfo.canonicalFilePath());

        foreach (const QString &subDir, QDir(QFileInfo(file).path()).entryList(QDir::Dirs | QDir::NoDot | QDir::NoDotDot)) {
            parseDirectory(dirInfo.canonicalFilePath() + "/" + subDir, true, subDir.toUtf8());
        }
    }

    foreach (const Import &import, m_imports) {
        if (import.isFileImport()) {
            QFileInfo dirInfo = QFileInfo(m_filePath.resolved(import.file()).toLocalFile());
            if (dirInfo.exists() && dirInfo.isDir())
                parseDirectory(dirInfo.canonicalFilePath(), true, dirInfo.baseName().toUtf8());
        } else {
            QString url = import.url();
            url.replace(QLatin1Char('.'), QLatin1Char('/'));
            QFileInfo dirInfo = QFileInfo(url);
            foreach (const QString &path, importPaths()) {
                QString fullUrl  = path + QLatin1Char('/') + url;
                dirInfo = QFileInfo(fullUrl);
                if (dirInfo.exists() && dirInfo.isDir()) {
                    //### todo full qualified names QString nameSpace = import.uri();
                    parseDirectory(dirInfo.canonicalFilePath(), false);
                }
            }
        }
    }
开发者ID:Gardenya,项目名称:qtcreator,代码行数:32,代码来源:subcomponentmanager.cpp

示例4: getMimeType

QString Configuration::getMimeType(const QFileInfo& info) {
    QString result("application/octet-stream");
    magic_t magicMimePredictor;
    magicMimePredictor = magic_open(MAGIC_MIME_TYPE); // Open predictor
    if (!magicMimePredictor) {
        qDebug() << "libmagic: Unable to initialize magic library";
    }
    else
    {
        if (magic_load(magicMimePredictor, 0)) { // if not 0 - error
            qDebug() << "libmagic: Can't load magic database - " +
                        QString(magic_error(magicMimePredictor));
            magic_close(magicMimePredictor); // Close predictor
        }
        else
        {
            char *file = info.canonicalFilePath().toAscii().data();
            const char *mime;
            mime = magic_file(magicMimePredictor, file); // getting mime-type
            result = QString(mime);
            magic_close(magicMimePredictor); // Close predictor
        }
    }
    qDebug() << "libmagic: result mime type - " + result + "for file: " +
                info.canonicalFilePath();
    return result;
}
开发者ID:mtao,项目名称:MultiscreenManga,代码行数:27,代码来源:configuration.cpp

示例5: advance

/*!
    \internal
*/
void QDirIteratorPrivate::advance()
{
    // Store the current entry
    if (!fileEngineIterators.isEmpty())
        currentFilePath = fileEngineIterators.top()->currentFilePath();

    // Advance to the next entry
    if (followNextDir) {
        // Start by navigating into the current directory.
        followNextDir = false;

        QAbstractFileEngineIterator *it = fileEngineIterators.top();

        QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
        if (currentFileInfo.isSymLink())
            subDir = currentFileInfo.canonicalFilePath();
#endif
        pushSubDirectory(subDir, it->nameFilters(), it->filters());
    }

    while (!fileEngineIterators.isEmpty()) {
        QAbstractFileEngineIterator *it = fileEngineIterators.top();

        // Find the next valid iterator that matches the filters.
        bool foundDirectory = false;
        while (it->hasNext()) {
            it->next();
            if (matchesFilters(it)) {
                currentFileInfo = nextFileInfo;
                nextFileInfo = it->currentFileInfo();
                // Signal that we want to follow this entry.
                followNextDir = shouldFollowDirectory(nextFileInfo);
                //We found a matching entry.
                return;

            } else if (iteratorFlags & QDirIterator::Subdirectories) {
                QFileInfo fileInfo = it->currentFileInfo();

                if (!shouldFollowDirectory(fileInfo))
                    continue;
                QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
                if (fileInfo.isSymLink())
                    subDir = fileInfo.canonicalFilePath();
#endif
                pushSubDirectory(subDir, it->nameFilters(), it->filters());
                
                foundDirectory = true;
                break;
            }
        }
        if (!foundDirectory)
            delete fileEngineIterators.pop();
    }
    currentFileInfo = nextFileInfo;
    done = true;
}
开发者ID:Fale,项目名称:qtmoko,代码行数:61,代码来源:qdiriterator.cpp

示例6: getHaikuIcon

QIcon QFileIconProviderPrivate::getHaikuIcon(const QFileInfo &fi) const
{
    QIcon retIcon;
    
	BNode node(fi.canonicalFilePath().toUtf8().constData());
	if (node.InitCheck() == B_OK) {
		BNodeInfo nodeinfo(&node);
		
		BBitmap *hIcon = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32);
		nodeinfo.GetTrackerIcon(hIcon, B_MINI_ICON);
		if(hIcon) {
			QPixmap p = QPixmap::fromHaikuBitmap(hIcon);
			retIcon.addPixmap(p);
			delete hIcon;
		}

		BBitmap *hIconBig = new BBitmap(BRect(0, 0, 31, 31), B_RGBA32);
		nodeinfo.GetTrackerIcon(hIcon, B_LARGE_ICON);
		if(hIconBig) {
			QPixmap p = QPixmap::fromHaikuBitmap(hIconBig);
			retIcon.addPixmap(p);
			delete hIconBig;
		}		
	}	
    return retIcon;
}
开发者ID:diversys,项目名称:qt4,代码行数:26,代码来源:qfileiconprovider.cpp

示例7: canonicalFilePath

/*!
    \overload
*/
bool QFileInfo::operator==(const QFileInfo &fileinfo) const
{
    Q_D(const QFileInfo);
    // ### Qt 5: understand long and short file names on Windows
    // ### (GetFullPathName()).
    if (fileinfo.d_ptr == d_ptr)
        return true;
    if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
        return false;
    if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
        return false;
    if (fileinfo.size() == size()) { //if the size isn't the same...
        QString file1 = canonicalFilePath(),
                file2 = fileinfo.canonicalFilePath();
        if (file1.length() == file2.length()) {
            if (!fileinfo.d_ptr->fileEngine->caseSensitive()) {
                for (int i = 0; i < file1.length(); i++) {
                    if (file1.at(i).toLower() != file2.at(i).toLower())
                        return false;
                }
                return true;
            }
            return (file1 == file2);
        }
    }
    return false;
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:30,代码来源:qfileinfo.cpp

示例8: execute

void VideoInput::execute()
{
    QFileInfo path = mIn;
    if(mCurrentFile != path)
    {
        if(mCapture.isOpened()){
            mCapture.release();
        }
        if(!mCapture.open(path.canonicalFilePath().toStdString())){
            throw std::runtime_error("Could not open video stream 1");
        }
        if(!mCapture.isOpened()){
            throw std::runtime_error("Could not open video stream 2");
        }

        mCurrentFile = path;
        int framePos = qRound(mCapture.get(CV_CAP_PROP_FRAME_COUNT) * (double)mStart);
        mCapture.set(CV_CAP_PROP_POS_FRAMES, framePos);

    }
    double elapsedFrames = mCapture.get(CV_CAP_PROP_POS_FRAMES) / mCapture.get(CV_CAP_PROP_FRAME_COUNT);
    if(!mCapture.grab() || elapsedFrames > (double) mEnd){
        // Check if *.avi has finished
        if((bool)mRepeat){
            // Reset frame pos to start pos
            int framePos = qRound(mCapture.get(CV_CAP_PROP_FRAME_COUNT) * (double)mStart);
            mCapture.set(CV_CAP_PROP_POS_FRAMES, framePos);
            if(!mCapture.grab()){
                return;
            }
        } else {
            return;
        }
    }
    double realFps = mCapture.get(CV_CAP_PROP_FPS);
    double factor = mSpeed;
    if(factor == 0){
        factor = 0.001;
    }
    double duration = 1000.0 / (realFps * factor);
    double elapsed = mTimer.elapsed();
    if(elapsed < duration && duration > 0){
        msleep(duration-elapsed);
    }

    // Restart timer
    mTimer.restart();

    // Send image
    cv::Mat img;
    if(!mCapture.retrieve(img)){
        return;
    }

    mFpsOut.send(realFps);
    mPositionOut.send(mCapture.get(CV_CAP_PROP_POS_FRAMES) / mCapture.get(CV_CAP_PROP_FRAME_COUNT));
    mElapsedOut.send(mCapture.get(CV_CAP_PROP_POS_MSEC)/1000.0);

    mOut.send(img.clone());
}
开发者ID:OFFIS-Automation,项目名称:Framework,代码行数:60,代码来源:VideoInput.cpp

示例9: checkAndPushDirectory

/*!
    \internal
 */
void QDirIteratorPrivate::checkAndPushDirectory(const QFileInfo &fileInfo)
{
    // If we're doing flat iteration, we're done.
    if (!(iteratorFlags & QDirIterator::Subdirectories))
        return;

    // Never follow non-directory entries
    if (!fileInfo.isDir())
        return;

    // Follow symlinks only when asked
    if (!(iteratorFlags & QDirIterator::FollowSymlinks) && fileInfo.isSymLink())
        return;

    // Never follow . and ..
    QString fileName = fileInfo.fileName();
    if (QLatin1String(".") == fileName || QLatin1String("..") == fileName)
        return;

    // No hidden directories unless requested
    if (!(filters & QDir::AllDirs) && !(filters & QDir::Hidden) && fileInfo.isHidden())
        return;

    // Stop link loops
    if (!visitedLinks.isEmpty() &&
        visitedLinks.contains(fileInfo.canonicalFilePath()))
        return;

    pushDirectory(fileInfo);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:33,代码来源:qdiriterator.cpp

示例10: dir

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Populate port list
    QVector<QString> ports;

#if (defined (Q_OS_MAC) || defined (Q_OS_LINUX))

    // Add USB serial port adapters
    // TODO Strangely usb serial port adapters are not enumerated, even when connected
    QString devdir = "/dev";
    QDir dir(devdir);
    dir.setFilter(QDir::System);

    QFileInfoList list = dir.entryInfoList();
    for (int i = list.size() - 1; i >= 0; i--) {
        QFileInfo fileInfo = list.at(i);
        if ((fileInfo.fileName().contains(QString("ttyUSB")) || fileInfo.fileName().contains(QString("ttyS")) || fileInfo.fileName().contains(QString("tty.")) || fileInfo.fileName().contains(QString("ttyACM")))
            && !fileInfo.fileName().contains(QString("tty.B")))
        {
            ports.append(fileInfo.canonicalFilePath());
        }
    }
#endif

    foreach (QString port, ports)
    {
        ui->comboBox->addItem(port);
    }
开发者ID:zhao0079,项目名称:FMU_DFU,代码行数:32,代码来源:mainwindow.cpp

示例11: getDirSize

/* private slots */
qint64 ShredThread::getDirSize(QString &dir)
{
    uint _size = 0;
    QDir::Filters flags =
            QDir::AllEntries |
            QDir::NoDotAndDotDot |
            QDir::Hidden |
            QDir::System |
            QDir::AllDirs;
    QDir d;
    d.setPath(dir);
    QList<QFileInfo> entry = d.entryInfoList(flags);
    if ( !entry.isEmpty() ) {
        QList<QFileInfo>::const_iterator i;
        for ( i=entry.constBegin(); i<entry.constEnd(); i++ ) {
            QFileInfo item = *i;
            if ( !item.exists() ) continue;
            QString path = item.canonicalFilePath();
            if ( path==d.absoluteFilePath(dir)
                 || item.isSymLink() )
                continue;
            if ( item.isDir() ) {
                _size += getDirSize(path);
            } else {
                _size += item.size();
            };
        };
    };
    return _size;
}
开发者ID:F1ash,项目名称:se-sandbox-runner,代码行数:31,代码来源:shred_thread.cpp

示例12: f

void
M3uLoader::getTags( const QFileInfo& info )
{
    QByteArray fileName = QFile::encodeName( info.canonicalFilePath() );
    const char *encodedName = fileName.constData();

    TagLib::FileRef f( encodedName );
    TagLib::Tag *tag = f.tag();

    QString artist = TStringToQString( tag->artist() ).trimmed();
    QString album  = TStringToQString( tag->album() ).trimmed();
    QString track  = TStringToQString( tag->title() ).trimmed();

    if ( artist.isEmpty() || track.isEmpty() )
    {
        qDebug() << "Error parsing" << info.fileName();
        return;
    }
    else
    {
        qDebug() << Q_FUNC_INFO << artist << track << album;
        Tomahawk::query_ptr q = Tomahawk::Query::get( artist, track, album, uuid(), !m_createNewPlaylist );
        if ( !q.isNull() )
            m_tracks << q;
    }
}
开发者ID:demelziraptor,项目名称:tomahawk,代码行数:26,代码来源:M3uLoader.cpp

示例13: canonicalFilePath

/*!
    \overload
*/
bool QFileInfo::operator==(const QFileInfo &fileinfo) const
{
    Q_D(const QFileInfo);
    // ### Qt 5: understand long and short file names on Windows
    // ### (GetFullPathName()).
    if (fileinfo.d_ptr == d_ptr)
        return true;
    if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
        return false;

    // Assume files are the same if path is the same
    if (d->fileEntry.filePath() == fileinfo.d_ptr->fileEntry.filePath())
        return true;

    Qt::CaseSensitivity sensitive;
    if (d->fileEngine == 0 || fileinfo.d_ptr->fileEngine == 0) {
        if (d->fileEngine != fileinfo.d_ptr->fileEngine) // one is native, the other is a custom file-engine
            return false;

        sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
    } else {
        if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
            return false;
        sensitive = d->fileEngine->caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
    }

    if (fileinfo.size() != size()) //if the size isn't the same...
        return false;

   // Fallback to expensive canonical path computation
   return canonicalFilePath().compare(fileinfo.canonicalFilePath(), sensitive) == 0;
}
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:35,代码来源:qfileinfo.cpp

示例14: shouldFollowDirectory

/*!
    \internal
 */
bool QDirIteratorPrivate::shouldFollowDirectory(const QFileInfo &fileInfo)
{
    // If we're doing flat iteration, we're done.
    if (!(iteratorFlags & QDirIterator::Subdirectories))
        return false;
    
    // Never follow non-directory entries
    if (!fileInfo.isDir())
        return false;


    // Never follow . and ..
    if (fileInfo.fileName() == QLatin1String(".") || fileInfo.fileName() == QLatin1String(".."))
        return false;

      
    // Check symlinks
    if (fileInfo.isSymLink() && !(iteratorFlags & QDirIterator::FollowSymlinks)) {
        // Follow symlinks only if FollowSymlinks was passed
        return false;
    }

    // Stop link loops
    if (visitedLinks.contains(fileInfo.canonicalFilePath()))
        return false;
    
    return true;
}
开发者ID:Fale,项目名称:qtmoko,代码行数:31,代码来源:qdiriterator.cpp

示例15: main

int main(int argc, char **argv) {
	QApplication app(argc, argv);
	QApplication::setApplicationName("ViewDown");
	QApplication::setApplicationVersion("1.0");
	app.setWindowIcon(QIcon("qrc:///viewdown.ico"));

	QCommandLineParser parser;
	parser.setApplicationDescription("Markdown viewer, reloading on changes.");
	parser.addPositionalArgument("file", "markdown file to view and reload on change.");
	parser.addPositionalArgument("watch", "files or directories to watch as trigger for reload.", "[watch...]");
	const QCommandLineOption styleOption("s", "css file to use as stylesheet.", "css");
	parser.addOption(styleOption);
	parser.addHelpOption();
	parser.addVersionOption();

	parser.process(app);

	QUrl styleUrl;
	if (parser.isSet(styleOption)) {
		const QString path = parser.value(styleOption);
		QFileInfo info = QFileInfo(path);
		if (info.exists())
		        styleUrl = QUrl::fromLocalFile(info.canonicalFilePath());
		else
			qWarning("No such file: %s", qPrintable(path));
	}
	if (styleUrl.isEmpty())
		styleUrl = QUrl("qrc:///github.css");

	MainWindow *browser = new MainWindow(parser.positionalArguments(), styleUrl);
	browser->show();
	return app.exec();
}
开发者ID:Cornu,项目名称:viewdown,代码行数:33,代码来源:main.cpp


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