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


C++ QDir::filePath方法代码示例

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


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

示例1: accept

void NewDocumentWizard::accept()
// ----------------------------------------------------------------------------
//   Copy template into user's document folder
// ----------------------------------------------------------------------------
{
    QString docName = field("docName").toString();
    QString docLocation = field("docLocation").toString();
    QString dstPath = docLocation + "/" + docName;

    QDir dst(dstPath);
    if (dst.exists())
    {
        QString dstPathNative = QDir::toNativeSeparators(dstPath);
        int r = QMessageBox::warning(this, tr("Folder exists"),
                    tr("Document folder:\n%1\nalready exists. "
                       "Do you want to use it anyway (current content "
                       "will be deleted)?\n"
                       "Click No to choose another location.")
                       .arg(dstPathNative),
                       QMessageBox::Yes | QMessageBox::No);
        if (r != QMessageBox::Yes)
            return;
    }

    Template t = templates.at(field("templateIdx").toInt());

    bool ok = t.copyTo(dst);
    if (!ok)
    {
        QMessageBox::warning(this, tr("Error"),
                             tr("Failed to copy document template."));
        return;
    }

    docPath = dstPath;
    if (t.mainFile != "")
    {
        QString oldName = t.mainFile.replace(QRegExp("\\.ddd$"), "");
        QString newName = docName;
        if (oldName != newName)
        {
            // Rename template main file to doc name.
            // We need to remove the destination file if it is there
            QDir dstDir = QDir(dstPath);
            Rename(dstDir, oldName, newName, ".ddd");
            Rename(dstDir, oldName, newName, ".ddd.sig");
            Rename(dstDir, oldName, newName, ".json");
            docPath = dstDir.filePath(newName + ".ddd");
        }
    }

#if !defined(CFG_NOGIT)
    // Create project to avoid prompt when document is first opened
    RepositoryFactory::repository(dstPath, RepositoryFactory::Create);
#endif
    QDialog::accept();
}
开发者ID:c3d,项目名称:tao-3D,代码行数:57,代码来源:new_document_wizard.cpp

示例2: QObject

AdBlockManager::AdBlockManager(QObject *parent): QObject(parent), _enabled(false)
{
    QDir datadir = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));

    if(!datadir.exists(AdBlockManager::ADBLOCK_FOLDER))
        datadir.mkdir(AdBlockManager::ADBLOCK_FOLDER);

    datadir.cd(AdBlockManager::ADBLOCK_FOLDER);
    this->_rulesfile = datadir.filePath(AdBlockManager::CSS_FILENAME);
    this->_tablefile = datadir.filePath(AdBlockManager::TABLE_FILENAME);
    this->_rulefileinstance.setFileName(this->_rulesfile);

    if(!datadir.exists(AdBlockManager::CSS_FILENAME))
        this->createEmptyRulesFile();

    if(!datadir.exists(AdBlockManager::TABLE_FILENAME))
        this->createEmptyTableFile();
}
开发者ID:sakustar,项目名称:harbour-webpirate,代码行数:18,代码来源:adblockmanager.cpp

示例3: findScript

/**
 * @brief Search for the Perl script which make the conversion itself.
 *
 * @param node  the name of script without path.
 * @return      the full name of the script (with path)
 */
QString findScript(const QString& node)
{
    static QString rc;
    if (rc.isEmpty()){

        QDir dir = QDir::current();
        QFile scriptFile(dir.filePath(node));
        if (! scriptFile.exists())
        {
            extern char** g_argv;
            dir.setPath(g_argv[0]);
            dir.cdUp();
            scriptFile.setFileName(dir.filePath(node));
        }
        if (scriptFile.exists())
            rc = scriptFile.fileName();
    }
    return rc;
}
开发者ID:republib,项目名称:rplshrink,代码行数:25,代码来源:converter.cpp

示例4: lastSession

QString SessionManager::lastSession()
{
    QDir dir = sessionsDir();
    if (dir.path().isEmpty())
        return QString();

    QString path = QFile::symLinkTarget( dir.filePath( ".last-session.lnk" ) );

    return QFileInfo(path).baseName();
}
开发者ID:andrewcsmith,项目名称:supercollider,代码行数:10,代码来源:session_manager.cpp

示例5: run

void EditorInterface::run()
{
	FNTRACE("", "EditorInterface", "run", "");
	assert(!editorProcess || editorProcess->state() == QProcess::NotRunning);

	if (!(QFileInfo(editorDir.filePath(editorName))).exists())
		ETHROW(Exception("The Loader can't find the Ds1 Editor. "
			"You must setup the Loader's ini to select where the Ds1 Editor .exe is. "
			"Use the menu \"Settings->Configure Loader\"."));

	QDir temp = QDir::temp();
	int i = 0;
	// find first tempX.ini that doesn't exist in temporary directory
	while (QFileInfo(temp.filePath(QString("temp%1.ini").arg(i))).exists())
		++i;

	if (!editorProcess)
		editorProcess = new QProcess(this);

	fileName = temp.filePath(QString("temp%1").arg(i));
	makeRelativePaths();
	QStringList args = makeArgs();

	output->clear();
	output->insertPlainText("ds1edit Loader: starting editor using program\n");
	output->insertPlainText(editorDir.filePath(editorName));
	output->insertPlainText("\nand arguments\n\"");
	output->insertPlainText(args.join("\" \""));

	connect(editorProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
		SLOT(terminated(int, QProcess::ExitStatus)));
	connect(editorProcess, SIGNAL(readyReadStandardOutput()),
		SLOT(editorOutputReady()));

	editorProcess->setWorkingDirectory(editorDir.absolutePath());
	output->insertPlainText("\"\nStarting from directory: ");
	output->insertPlainText(editorProcess->workingDirectory());
	output->insertPlainText("\n\n");

	editorProcess->start(editorDir.filePath(editorName), args, QIODevice::ReadOnly | QIODevice::Text);
	//if (!editorProcess->waitForStarted())
	//	ETHROW(Exception("Editor process failed to start"));
}
开发者ID:devnev,项目名称:ds1edit-loader,代码行数:43,代码来源:editorinterface.cpp

示例6: slashify

QFileInfo::QFileInfo( const QDir &d, const QString &fileName )
{
    fn	  = d.filePath( fileName );
    slashify( fn );
    fic	  = 0;
    cache = TRUE;
#if defined(Q_OS_UNIX)
    symLink = FALSE;
#endif
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:10,代码来源:qfileinfo.cpp

示例7: get2xIconPath

QString get2xIconPath(const QString& path)
{
    QFileInfo finfo(path);
    QString base = finfo.baseName();
    QString ext = finfo.completeSuffix();

    QDir dir = finfo.dir();

    return dir.filePath(base + "@2x" + "." + ext);
}
开发者ID:Bamaan,项目名称:seafile-client,代码行数:10,代码来源:paint-utils.cpp

示例8: filePath

QString QgsLayoutAtlas::filePath( const QString &baseFilePath, const QString &extension )
{
  QFileInfo fi( baseFilePath );
  QDir dir = fi.dir(); // ignore everything except the directory
  QString base = dir.filePath( mCurrentFilename );
  if ( !extension.startsWith( '.' ) )
    base += '.';
  base += extension;
  return base;
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:10,代码来源:qgslayoutatlas.cpp

示例9: load

void ToolCatalog::load()
{
  typedef QMap<QString, QList<ToolInformation> > categorymap;

  QDir toolsetDir = QDir(QCoreApplication::applicationDirPath());
  if (toolsetDir.dirName().toLower() == "bin")
    toolsetDir.cdUp();

  QString catalogFilename = toolsetDir.filePath("share/mcrl2/tool_catalog.xml");

  QFile file(catalogFilename);
  if(!file.open( QFile::ReadOnly ))
  {
    file.setFileName(":/share/mcrl2/tool_catalog.xml");
    if (!file.open(QFile::ReadOnly))
    {
      mCRL2log(mcrl2::log::error) << "Could not open XML file: " << catalogFilename.toStdString() << std::endl;
      return;
    }
    mCRL2log(mcrl2::log::warning) << "Could not open XML file: " << catalogFilename.toStdString() << ", using embedded copy instead." << std::endl;;
  }
  QString errorMsg;
  if(!m_xml.setContent(&file, false, &errorMsg))
  {
    file.close();
    mCRL2log(mcrl2::log::error) << "Could not parse XML file: " << errorMsg.toStdString() << std::endl;
    return;
  }
  file.close();

  QDomElement root = m_xml.documentElement();
  if(root.tagName() != "tool-catalog")
  {
    mCRL2log(mcrl2::log::error) << catalogFilename.toStdString() << " contains no valid tool catalog" << std::endl;
    return;
  }

  QDomNode node = root.firstChild();
  while (!node.isNull()) {
    QDomElement e = node.toElement();

    if (e.tagName() == "tool") {
      QString cat = e.attribute("category", "Miscellaneous");
      categorymap::iterator icat = m_categories.find(cat);
      if (icat == m_categories.end())
        icat = m_categories.insert(cat, QList<ToolInformation>());

      ToolInformation toolinfo(e.attribute("name"), e.attribute("input_format"), e.attribute("input_format1"), e.attribute("output_format", ""), e.attribute("gui", "").toLower() == "true");
      toolinfo.load();
      icat.value().append(toolinfo);
    }

    node = node.nextSibling();
  }
}
开发者ID:gijskant,项目名称:mcrl2-pmc,代码行数:55,代码来源:toolcatalog.cpp

示例10: main

int main(int argc, char *argv[])
{
    if ( argc != 2 )
    {
        /* display usage on error stream */
        fprintf(stderr, "usage: znm-project project_name\n\n");
        exit(1);  /* exit status of the program : non-zero for errors */
    }

    if ( QString("--help") == argv[1] )
    {
        printf ("usage: znm-project project_name\nCreates a zenom project.\n\n");
        exit(0);  /* exit status of the program : non-zero for errors */
    }

    QDir projectDir;
    if ( projectDir.exists( argv[1] ) )
    {
        fprintf(stderr, "The project cannot be created because '%s' folder already exists.\n", argv[1]);
        exit(1);  /* exit status of the program : non-zero for errors */
    }

    projectDir.mkpath( argv[1] );
    projectDir.cd( argv[1] );

    QFileInfo programFileInfo( getexepath() );
    QString projectName( QFileInfo(argv[1]).fileName() );

    createFile( programFileInfo.dir().filePath("znm-project-main.template"), projectDir.filePath("main.cpp"), projectName );
    createFile( programFileInfo.dir().filePath("znm-project-makefile.template"), projectDir.filePath("Makefile"), projectName );

    // Open project file to write
    QFile configFile( projectDir.filePath(QString("%1.znm").arg(projectName)) );
    if ( !configFile.open(QFile::WriteOnly | QFile::Text) )
    {
        fprintf(stderr, "The project cannot be created because the file '%s' could not be opened.\n", configFile.fileName().toAscii().data());
        exit(1);  /* exit status of the program : non-zero for errors */
    }
    configFile.close();

    return 0;
}
开发者ID:emreaslan,项目名称:zenom,代码行数:42,代码来源:main.cpp

示例11: addPage

QScriptValue ConfigurationDialog::addPage( const QString &name, const QString &filename, const QString &icon ) {
	QDir dir = this->baseDir();

	QUiLoader loader;
	QFile file(dir.filePath(filename));
	file.open(QFile::ReadOnly);
	QWidget *widget = loader.load(&file, this);
	file.close();

	return this->addPage(name, widget, icon);
}
开发者ID:Balex93,项目名称:telldus,代码行数:11,代码来源:configurationdialog.cpp

示例12: setStylePath

void WebKitMessageViewStyle::setStylePath(const QString &path)
{
	Q_D(WebKitMessageViewStyle);
	QDir dir = path;
	dir.cd(QLatin1String("Contents"));
	Config cfg(dir.filePath(QLatin1String("Info.plist")));
	d->config = cfg.rootValue().toMap();
	dir.cd(QLatin1String("Resources"));
	d->stylePath = dir.absolutePath() + QLatin1Char('/');
	reloadStyle();
}
开发者ID:VladRassokhin,项目名称:qutim,代码行数:11,代码来源:webkitmessageviewstyle.cpp

示例13: readFile

static QString readFile(const QDir& dir, const QString& fileName)
{
    QFile file;
    if (QFileInfo(fileName).isRelative())
        file.setFileName(dir.filePath(fileName));
    else
        file.setFileName(fileName);
    if (file.open(QFile::ReadOnly | QIODevice::Text))
        return QString::fromUtf8(file.readAll());
    return QString();
}
开发者ID:0Knowledge,项目名称:communi-desktop,代码行数:11,代码来源:themeinfo.cpp

示例14: FindQmFiles

QStringList Application::FindQmFiles(const QDir& dir)
{
     QStringList fileNames = dir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
     QMutableStringListIterator i(fileNames);
     while (i.hasNext())
     {
         i.next();
         i.setValue(dir.filePath(i.value()));
     }
     return fileNames;
}
开发者ID:Pouique,项目名称:naali,代码行数:11,代码来源:Application.cpp

示例15: createDir

void QxFileBrowser::createDir()
{
	QDir dir = cwdModel_->rootDirectory();
	if (dirView_->currentIndex().isValid()) {
		if (cwdModel_->isDir(dirView_->currentIndex()))
			dir = QDir(cwdModel_->filePath(dirView_->currentIndex()));
	}
	if (!dir.exists()) return;
	QString prefix = "noname";
	QString newName = prefix;
	int i = 1;
	while (QFileInfo(dir.filePath(newName)).exists()) {
		newName = QString("%1_%2").arg(prefix).arg(i);
		++i;
	}
	
	if (dir.mkdir(newName)) {
		newFilePath_ = dir.filePath(newName);
		QTimer::singleShot(0, this, SLOT(createFilePolling()));
	}
}
开发者ID:corelon,项目名称:paco,代码行数:21,代码来源:QxFileBrowser.cpp


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