本文整理汇总了C++中QDir::makeAbsolute方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::makeAbsolute方法的具体用法?C++ QDir::makeAbsolute怎么用?C++ QDir::makeAbsolute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDir
的用法示例。
在下文中一共展示了QDir::makeAbsolute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertDirectory
/*!
Converts a directory recursively.
*/
void ConverterCore::convertDirectory(const QDir &input, const QDir &output)
{
QDir tempInput = input;
tempInput.makeAbsolute();
if (!tempInput.exists()) {
qFatal("Error! Input: %s does not exist!", tempInput.path().toLocal8Bit().data());
}
QStringList dirs(tempInput.entryList(QDir::Dirs | QDir::NoDotAndDotDot));
QStringList files(tempInput.entryList(QDir::Files));
QDir tempOutput = output;
tempOutput.makeAbsolute();
if (!tempOutput.exists()) {
if (!tempOutput.mkpath(output.path()))
qFatal("Creating directory failed! %s", tempOutput.path().toLocal8Bit().data());
}
foreach (const QString &file, files) {
ConverterFile converter(tempInput.path() + "/" + file, output.path() + "/" + file, flags);
converter.convertToQrc();
if (converter.isErrorState()) {
enterErrorState(converter.errorMessage());
return;
}
}
示例2: isValidDirectory
bool MercurialPlugin::isValidDirectory(const QUrl &directory)
{
// Mercurial uses the same test, so we don't lose any functionality
static const QString hgDir(".hg");
if (m_lastRepoRoot.isParentOf(directory))
return true;
const QString initialPath(directory.adjusted(QUrl::StripTrailingSlash).toLocalFile());
const QFileInfo finfo(initialPath);
QDir dir;
if (finfo.isFile()) {
dir = finfo.absoluteDir();
} else {
dir = QDir(initialPath);
dir.makeAbsolute();
}
while (!dir.cd(hgDir) && dir.cdUp())
{} // cdUp, until there is a sub-directory called .hg
if (hgDir != dir.dirName())
return false;
dir.cdUp(); // Leave .hg
// TODO: Check whether this is the right port, original code was: m_lastRepoRoot.setDirectory(dir.absolutePath());
m_lastRepoRoot.setPath(dir.absolutePath());
return true;
}
示例3: isValidDirectory
bool GitRunner::isValidDirectory()
{
const QString initialPath(m_lastRepoRoot->toLocalFile(KUrl::RemoveTrailingSlash));
setDirectory(*m_lastRepoRoot);
// A possible git repo has a .git subdicerctory
const QString gitDir(".git");
// Also, git rev-parse --is-inside-work-tree returns "true" if we are
// inside any subdirectory of the git tree.
DvcsJob *job = new DvcsJob();
initJob(*job);
*job << "rev-parse";
*job << "--is-inside-work-tree";
startJob(*job);
QFileInfo finfo(initialPath);
QDir dir;
if (finfo.isFile()) {
dir = finfo.absoluteDir();
} else {
dir = QDir(initialPath);
dir.makeAbsolute();
}
return (dir.exists(gitDir) && m_result.compare("true")) ? true : false;
}
示例4: findExeAtPath
QString findExeAtPath (const QString appname, const QString &path) {
QDir dir (path);
dir.makeAbsolute ();
if (QFileInfo (dir.filePath (appname)).isExecutable ()) return dir.filePath (appname);
#ifdef Q_WS_WIN
if (QFileInfo (dir.filePath (appname + ".exe")).isExecutable ()) return dir.filePath (appname + ".exe");
if (QFileInfo (dir.filePath (appname + ".com")).isExecutable ()) return dir.filePath (appname + ".com");
if (QFileInfo (dir.filePath (appname + ".bat")).isExecutable ()) return dir.filePath (appname + ".bat");
#endif
return QString ();
}
示例5: ShowOutput
void MainWidget::ShowOutput()
{
QString helpString;
helpString += "projects\\" + leProjectName->text() + "\\output.html";
QDir dir;
dir.setPath(helpString);
dir.makeAbsolute();
helpString = dir.path();
emit showWebWidget(helpString);
}
示例6: on_exePath_textChanged
void CaptureDialog::on_exePath_textChanged(const QString &exe)
{
QFileInfo f(exe);
QDir dir = f.dir();
bool valid = dir.makeAbsolute();
if(valid && f.isAbsolute())
ui->workDirPath->setPlaceholderText(QDir::toNativeSeparators(dir.absolutePath()));
else if(exe == "")
ui->workDirPath->setPlaceholderText("");
updateGlobalHook();
}
示例7: on_exePath_textChanged
void CaptureDialog::on_exePath_textChanged(const QString &text)
{
QString exe = text;
// This is likely due to someone pasting a full path copied using copy path. Removing the quotes
// is safe in any case
if(exe.startsWith(QLatin1Char('"')) && exe.endsWith(QLatin1Char('"')) && exe.count() > 2)
{
exe = exe.mid(1, exe.count() - 2);
ui->exePath->setText(exe);
return;
}
QFileInfo f(exe);
QDir dir = f.dir();
bool valid = dir.makeAbsolute();
if(valid && f.isAbsolute())
{
QString path = dir.absolutePath();
if(!m_Ctx.Replay().CurrentRemote())
path = QDir::toNativeSeparators(path);
// match the path separators from the path
if(exe.count(QLatin1Char('/')) > exe.count(QLatin1Char('\\')))
path = path.replace(QLatin1Char('\\'), QLatin1Char('/'));
else
path = path.replace(QLatin1Char('/'), QLatin1Char('\\'));
ui->workDirPath->setPlaceholderText(path);
}
else if(exe.isEmpty())
{
ui->workDirPath->setPlaceholderText(QString());
}
UpdateGlobalHook();
}