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


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

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


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

示例1: HandleFile

			void PackageProcessor::HandleFile (int packageId,
					const QUrl& url, PackageProcessor::Mode mode)
			{
				QString path = Core::Instance ()
						.GetExtResourceManager ()->GetResourcePath (url);

				QProcess *unarch = new QProcess (this);
				connect (unarch,
						SIGNAL (finished (int, QProcess::ExitStatus)),
						this,
						SLOT (handlePackageUnarchFinished (int, QProcess::ExitStatus)));
				connect (unarch,
						SIGNAL (error (QProcess::ProcessError)),
						this,
						SLOT (handleUnarchError (QProcess::ProcessError)));

				QString dirname = Util::GetTemporaryName ("lackman_stagingarea");
				QStringList args;
#ifdef Q_WS_WIN
				args << "x";
#else
				args << "xzf";
#endif
				args << path;
#ifdef Q_WS_WIN
				args << "-o";
#else
				args << "-C";
#endif
				args << dirname;
				unarch->setProperty ("PackageID", packageId);
				unarch->setProperty ("StagingDirectory", dirname);
				unarch->setProperty ("Path", path);
				unarch->setProperty ("Mode", mode);

				QFileInfo sdInfo (dirname);
				QDir stagingParentDir (sdInfo.path ());
				if (!stagingParentDir.exists (sdInfo.fileName ()) &&
						!stagingParentDir.mkdir (sdInfo.fileName ()))
				{
					qWarning () << Q_FUNC_INFO
							<< "unable to create staging directory"
							<< sdInfo.fileName ()
							<< "in"
							<< sdInfo.path ();

					QString errorString = tr ("Unable to create staging directory %1.")
							.arg (sdInfo.fileName ());
					emit packageInstallError (packageId, errorString);

					return;
				}

#ifdef Q_WS_WIN
				QString command = "7za";
#else
				QString command = "tar";
#endif
				unarch->start (command, args);
			}
开发者ID:Mezomish,项目名称:leechcraft,代码行数:60,代码来源:packageprocessor.cpp

示例2: copyDirectory

bool JasonQt_File::copyDirectory(const QFileInfo &sourceDirectory, const QFileInfo &targetDirectory, const bool &cover)
{
    try
    {
        if(!sourceDirectory.isDir())
        {
            throw false;
        }

        if(sourceDirectory.filePath()[sourceDirectory.filePath().size() - 1] != '/')
        {
            throw false;
        }

        if(targetDirectory.filePath()[targetDirectory.filePath().size() - 1] != '/')
        {
            throw false;
        }

        JasonQt_File::foreachFileFromDirectory(sourceDirectory, [&](const QFileInfo &info)
        {
            const auto &&path = info.path().mid(sourceDirectory.path().size());
            if(!JasonQt_File::copyFile(info, targetDirectory.path() + "/" + ((path.isEmpty()) ? ("") : (path + "/")) + info.fileName(), cover))
            {
                throw false;
            }
        }, true);
    }
    catch(const bool &error)
    {
        return error;
    }

    return true;
}
开发者ID:188080501,项目名称:CellularAutomaton,代码行数:35,代码来源:JasonQt_File.cpp

示例3: hash

void
SoundSettings::suggestedTargetFilePath (
        const QString &filePath,
        QString       &baseDir,
        QString       &fileName,
        QString       &xmlFileName)
{
    QString            subDir;
    QFileInfo          fileInfo (filePath);
    QCryptographicHash hash(QCryptographicHash::Sha1);

    hash.addData (fileInfo.path().toUtf8());
    subDir = QString(hash.result().toHex());
    subDir.truncate (32);

    baseDir = userSaveDir() +
        QDir::separator() +
        subDir;

    fileName = fileInfo.baseName() + "." + fileInfo.completeSuffix();
    xmlFileName = fileInfo.baseName() + ".xml";

    SYS_DEBUG ("*** baseName()       = %s", SYS_STR(fileInfo.baseName()));
    SYS_DEBUG ("*** path()           = %s", SYS_STR(fileInfo.path()));
    SYS_DEBUG ("*** completeSuffix() = %s", SYS_STR(fileInfo.completeSuffix()));
}
开发者ID:deztructor,项目名称:meegotouch-controlpanelapplets,代码行数:26,代码来源:soundsettingsutils.cpp

示例4: executeFile

void FileBrowser::executeFile()
{
    LiteApi::ILiteBuild *build = LiteApi::getLiteBuild(m_liteApp);
    if (build) {
        QFileInfo info = m_folderView->contextFileInfo();
        QString cmd = FileUtil::lookPathInDir(info.fileName(),info.path());
        if (!cmd.isEmpty()) {
            build->executeCommand(cmd,QString(),info.path(),true,true,false);
        }
    }
}
开发者ID:arnold8,项目名称:liteide,代码行数:11,代码来源:filebrowser.cpp

示例5: applyConfigured

bool Themes::applyConfigured() {
	boost::optional<ThemeInfo::StyleInfo> style = Themes::getConfiguredStyle(g.s);
	if (!style) {
		return false;
	}
	
	const QFileInfo qssFile(style->getPlatformQss());
	
	qWarning() << "Theme:" << style->themeName;
	qWarning() << "Style:" << style->name;
	qWarning() << "--> qss:" << qssFile.absoluteFilePath();
	
	QFile file(qssFile.absoluteFilePath());
	if (!file.open(QFile::ReadOnly)) {
		qWarning() << "Failed to open theme stylesheet:" << file.errorString();
		return false;
	}
	
	QStringList skinPaths;
	skinPaths << qssFile.path();
	skinPaths << QLatin1String(":/themes/Mumble"); // Some skins might want to fall-back on our built-in resources

	QString themeQss = QString::fromUtf8(file.readAll());
	setTheme(themeQss, skinPaths);
	return true;
}
开发者ID:MumbleTransifexBot,项目名称:mumble,代码行数:26,代码来源:Themes.cpp

示例6:

FsItem::FsItem(QFileInfo & info)
{
   fullname = info.absoluteFilePath();
   path = info.path();
   shortname = info.fileName();
   isfile = info.isFile();
}
开发者ID:rumca-js,项目名称:Qpython,代码行数:7,代码来源:qdirreader.cpp

示例7: copyFile

bool JasonQt_File::copyFile(const QFileInfo &sourcePath, const QFileInfo &targetPath, const bool &cover)
{
    if(sourcePath.filePath()[sourcePath.filePath().size() - 1] == '/')
    {
        return false;
    }

    if(targetPath.filePath()[targetPath.filePath().size() - 1] == '/')
    {
        return false;
    }

    if(!targetPath.dir().isReadable())
    {
        if(!QDir().mkpath(targetPath.path()))
        {
            return false;
        }
    }

    if(targetPath.isFile() && !cover)
    {
        return true;
    }

    return QFile::copy(sourcePath.filePath(), targetPath.filePath());
}
开发者ID:188080501,项目名称:CellularAutomaton,代码行数:27,代码来源:JasonQt_File.cpp

示例8: writeFile

bool JasonQt_File::writeFile(const QFileInfo &targetFilePath, const QByteArray &data, const bool &cover)
{
    if(!targetFilePath.dir().isReadable())
    {
        if(!QDir().mkpath(targetFilePath.path()))
        {
            return false;
        }
    }

    if(targetFilePath.isFile() && !cover)
    {
        return true;
    }

    QFile file(targetFilePath.filePath());
    if(!file.open(QIODevice::WriteOnly))
    {
        return false;
    }

    file.write(data);
    file.waitForBytesWritten(10000);

    return true;
}
开发者ID:188080501,项目名称:CellularAutomaton,代码行数:26,代码来源:JasonQt_File.cpp

示例9: tf

PrinterAPI::PrinterAPI() : QObject(COLLECTOR)
{
	qDebug() << "PrinterAPI loaded";
	setObjectName("printer");
	printer = QString("File");
	cmd = QString("");
	color = true;
	useICC = false;
	mph = false;
	mpv = false;
	ucr = true;
	copies = true;



	QString tf(ScCore->primaryMainWindow()->doc->pdfOptions().fileName);
	if (tf.isEmpty())
	{
		QFileInfo fi = QFileInfo(ScCore->primaryMainWindow()->doc->DocName);
		tf = fi.path()+"/"+fi.baseName()+".pdf";
	}
	file = tf;


	int num = 0;
	if (ScCore->primaryMainWindow()->HaveDoc)
		num = ScCore->primaryMainWindow()->doc->Pages->count();

	for (int i = 0; i<num; i++)
	{
		pages.append(i+1);
	}
	
	separation = "No";
}
开发者ID:Fahad-Alsaidi,项目名称:scribus,代码行数:35,代码来源:api_printer.cpp

示例10: ListFilesInDirectoryTest

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

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

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

示例11: saveSubtitles

void TabDivePhotos::saveSubtitles()
{
	QVector<QString> selectedPhotos;
	if (!ui->photosView->selectionModel()->hasSelection())
		return;
	QModelIndexList indexes = ui->photosView->selectionModel()->selectedRows();
	if (indexes.count() == 0)
		indexes = ui->photosView->selectionModel()->selectedIndexes();
	selectedPhotos.reserve(indexes.count());
	for (const auto &photo: indexes) {
		if (photo.isValid()) {
			QString fileUrl = photo.data(Qt::DisplayPropertyRole).toString();
			if (!fileUrl.isEmpty()) {
				QFileInfo fi = QFileInfo(fileUrl);
				QFile subtitlefile;
				subtitlefile.setFileName(QString(fi.path()) + "/" + fi.completeBaseName() + ".ass");
				int offset = photo.data(Qt::UserRole + 1).toInt();
				int duration = photo.data(Qt::UserRole + 2).toInt();
				// Only videos have non-zero duration
				if (!duration)
					continue;
				struct membuffer b = { 0 };
				save_subtitles_buffer(&b, &displayed_dive, offset, duration);
				char *data = detach_buffer(&b);
				subtitlefile.open(QIODevice::WriteOnly);
				subtitlefile.write(data, strlen(data));
				subtitlefile.close();
				free(data);
			}

		}
	}
}
开发者ID:dirkhh,项目名称:subsurface,代码行数:33,代码来源:TabDivePhotos.cpp

示例12: loadBackup

void RepoEditor::loadBackup()
{
    RepoConf conf;
    QFileInfo fi;
    QString file;

    if (!ui->backupFile->text().isEmpty())
    {
      fi.setFile(ui->backupFile->text());
      file = QFileDialog::getOpenFileName( this, "Open file", fi.path() );
    }
    else
      file = QFileDialog::getOpenFileName( this );

    if( file.isEmpty() )
        return;

    conf.loadConf( file );

    if( !conf.count() ) {
        QMessageBox mb(QMessageBox::Critical,
                       tr( "Can't load backup file" ),
                       tr( "Selected file is not valid" ),
                       QMessageBox::Ok,
                       this);
        mb.exec();
    } else {
        repoConf->loadConf( file );
        ui->backupFile->setText( repoConf->getConfPath() + ".bak" );
    }
}
开发者ID:aarnt,项目名称:octopi,代码行数:31,代码来源:repoeditor.cpp

示例13: toNativeSeparators

// +-----------------------------------------------------------
QString ft::Utils::shortenPath(const QString &sPath, int iMaxLen)
{
	// If the string is not long enough, simply return it
	if(sPath.length() <= iMaxLen)
		return QDir::toNativeSeparators(sPath);

	QFileInfo oFile = QFileInfo(sPath);
	QString sPathOnly = oFile.path();
	QString sFileName = QDir::separator() + oFile.fileName();
	QString sDriveLetter = ""; // In case it is running on a Windows OS

    // Firstly, split the path (only) into parts (for the drive letter and/or each subfolder)
    QRegExp oRegex("([\\\\\\/][\\w -\\.]*)");
    QStringList lsParts;
	QMultiMap<int, int> mpSortedParts;
    QString sPart;

    bool bFirst = true;
    int iPos = 0;
    while((iPos = oRegex.indexIn(sPathOnly, iPos)) != -1)
    {
        if(bFirst)
        {
            sDriveLetter = sPathOnly.left(iPos);
            bFirst = false;
        }
        sPart = oRegex.cap(1);
        lsParts.push_back(sPart);
		mpSortedParts.insert(sPart.length(), lsParts.count() - 1);
        iPos += oRegex.matchedLength();
    }

	// Then, iteratively remove the larger parts while the path is bigger than
	// the maximum number of characters desired
	QString sNewPath;
	do
	{
		sNewPath = "";

		// Rebuild the path replacing the so far larger part for "..."
		QMapIterator<int, int> oSorted(mpSortedParts);
		oSorted.toBack();
		if(oSorted.hasPrevious())
		{
			int iLength = oSorted.peekPrevious().key();
			int iIndex = oSorted.peekPrevious().value();
			mpSortedParts.remove(iLength, iIndex);

			lsParts.replace(iIndex, QDir::separator() + QString("..."));
		
			for(QStringList::iterator it = lsParts.begin(); it != lsParts.end(); ++it)
				sNewPath += *it;
		}
	} while(sNewPath.length() > 0 && QString(sDriveLetter + sNewPath + sFileName).length() > iMaxLen);

	if(sNewPath.length() == 0)
		sNewPath = QDir::separator() + QString("...");

	return QDir::toNativeSeparators(sDriveLetter + sNewPath + sFileName);
}
开发者ID:flair2005,项目名称:Facial-Landmarks-Annotation-Tool,代码行数:61,代码来源:utils.cpp

示例14: on_treeView_activated

void OpenFileDialog::on_treeView_activated(const QModelIndex &index)
{
    if (mDirModel->isDir(index))
    {
        auto mSelectedDir = mDirModel->filePath(index);
        if (mSelectedDir.endsWith(".."))
        {
            // remove "/.."
            mSelectedDir = mSelectedDir.left(mSelectedDir.length()-3);
            QFileInfo info = (mSelectedDir);
            // get parent directory
            mSelectedDir = info.path();
        }

        setDirectory(mSelectedDir);
        mDirModel->setRootPath(getDirectory());
        mDirModel->setFilter(QDir::NoDot | QDir::AllEntries);
        ui->treeView->setRootIndex(mDirModel->index(getDirectory()));
    }
    else
    {
        mSelectedFile = mDirModel->filePath(index);
        this->accept();
    }
}
开发者ID:killbug2004,项目名称:xiew,代码行数:25,代码来源:OpenFileDialog.cpp

示例15: getCurrentCacheSize

void FileStorageWatcherThread::getCurrentCacheSize()
{
    mDebug() << "FileStorageWatcher: Creating cache size";
    quint64 dataSize = 0;
    QString basePath = m_dataDirectory + "/maps";
    QDirIterator it( basePath,
                     QDir::Files | QDir::Writable,
                     QDirIterator::Subdirectories );
    
    int basePathDepth = basePath.split("/").size();
    while( it.hasNext() && !m_willQuit ) {
        it.next();
        QFileInfo file = it.fileInfo();
        // We try to be very careful and just delete images
        // FIXME, when vectortiling I suppose also vector tiles will have
        // to be deleted
        QString suffix = file.suffix().toLower();
        QStringList path = file.path().split("/");

        // planet/theme/tilelevel should be deeper than 4
        if ( ( path.size() > basePathDepth + 3 ) &&
             ( path[basePathDepth + 2].toInt() >= maxBaseTileLevel ) &&
               ( ( suffix == "jpg"
                || suffix == "png"
                || suffix == "gif"
                || suffix == "svg" ) ) ) {
            dataSize += file.size();
            m_filesCache.insert(file.lastModified(), file.absoluteFilePath());
        }
    }
    m_currentCacheSize = dataSize;
}
开发者ID:calincru,项目名称:marble,代码行数:32,代码来源:FileStorageWatcher.cpp


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