本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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();
}
示例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"));
}
示例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
}
示例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);
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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()));
}
}