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


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

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


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

示例1: InitializeMythDirs

void InitializeMythDirs(void)
{
    installprefix = QString(RUNPREFIX);

    char *tmp_installprefix = std::getenv("MYTHTVDIR");
    if (tmp_installprefix)
        installprefix = tmp_installprefix;

#if CONFIG_DARWIN
    // Work around bug in OS X where applicationDirPath() can crash
    // (if binary is not in a bundle, and is daemon()ized)

    QDir prefixDir = QFileInfo(qApp->argv()[0]).dir();
#else
    QDir prefixDir = qApp->applicationDirPath();
#endif

    if (QDir(installprefix).isRelative())
    {
        // If the PREFIX is relative, evaluate it relative to our
        // executable directory. This can be fragile on Unix, so
        // use relative PREFIX values with care.

        LOG(VB_GENERAL, LOG_DEBUG, QString("Relative PREFIX! (%1), appDir=%2")
            .arg(installprefix) .arg(prefixDir.canonicalPath()));

        if (!prefixDir.cd(installprefix))
        {
            LOG(VB_GENERAL, LOG_ERR,
                QString("Relative PREFIX does not resolve, using %1")
                .arg(prefixDir.canonicalPath()));
        }
        installprefix = prefixDir.canonicalPath();
    }

    LOG(VB_GENERAL, LOG_NOTICE, "Using runtime prefix = " + installprefix);

    char *tmp_confdir = std::getenv("MYTHCONFDIR");
    if (tmp_confdir)
    {
        confdir = QString(tmp_confdir);
        LOG(VB_GENERAL, LOG_NOTICE, QString("Read conf dir = %1").arg(confdir));
        confdir.replace("$HOME", QDir::homePath());
    }
    else
        confdir = QDir::homePath() + "/.mythtv";

    LOG(VB_GENERAL, LOG_NOTICE,
        QString("Using configuration directory = %1").arg(confdir));

    sharedir = installprefix + "/share/mythtv/";
    libdir = installprefix + '/' + QString(LIBDIRNAME) + "/mythtv/";
    themedir = sharedir + "themes/";
    pluginsdir = libdir + "plugins/";
    translationsdir = sharedir + "i18n/";
    filtersdir = libdir + "filters/";
}
开发者ID:ChristopherNeufeld,项目名称:mythtv,代码行数:57,代码来源:mythdirs.cpp

示例2: main

int main(int argc, char *argv[])
{
  // apply default settings
  QucsSettings.x = 100;
  QucsSettings.y = 50;
  QucsSettings.dx = 600;
  QucsSettings.dy = 350;
  QucsSettings.font = QFont("Helvetica", 12);
  QucsSettings.QucsHomeDir.setPath(QDir::homePath() + "/.qucs");

  // is application relocated?
  char * var = getenv ("QUCSDIR");
  QDir QucsDir;
  if (var != NULL) {
    QucsDir = QDir(QString(var));
    QucsSettings.LangDir =     QucsDir.canonicalPath() + "/share/qucs/lang/";
    QucsSettings.LibDir =      QucsDir.canonicalPath() + "/share/qucs/library/";
  } else {
    QString QucsApplicationPath = QCoreApplication::applicationDirPath();
#ifdef __APPLE__
    QucsDir = QDir(QucsApplicationPath.section("/bin",0,0));
#else
    QucsDir = QDir(QucsApplicationPath);
    QucsDir.cdUp();
#endif
    QucsSettings.LangDir = QucsDir.canonicalPath() + "/share/qucs/lang/";
    QucsSettings.LibDir  = QucsDir.canonicalPath() + "/share/qucs/library/";
  }

  loadSettings();

  UserLibDir.setPath(QucsSettings.QucsHomeDir.canonicalPath() + "/user_lib/");

  QApplication a(argc, argv);
  a.setFont(QucsSettings.font);

  QTranslator tor( 0 );
  QString lang = QucsSettings.Language;
  if(lang.isEmpty())
    lang = QString(QLocale::system().name());
  tor.load( QString("qucs_") + lang, QucsSettings.LangDir);
  a.installTranslator( &tor );

  QucsLib *qucs = new QucsLib();
  qucs->raise();
  qucs->resize(QucsSettings.dx, QucsSettings.dy); // size and position ...
  qucs->move(QucsSettings.x, QucsSettings.y);     // ... before "show" !!!
  qucs->show();

  int result = a.exec();
  saveApplSettings(qucs);
  delete qucs;
  return result;
}
开发者ID:andresmmera,项目名称:qucs,代码行数:54,代码来源:main.cpp

示例3: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QString LangDir;
    // apply default settings
    QucsSettings.x = 200;
    QucsSettings.y = 100;
    QucsSettings.font = QFont("Helvetica", 12);
    QucsSettings.showConsole = true;

    // is application relocated?
    char * var = getenv ("QUCSDIR");
    QDir QucsDir;
    if (var != NULL) {
      QucsDir = QDir (var);
      QString QucsDirStr = QucsDir.canonicalPath ();
      LangDir =
        QDir::toNativeSeparators(QucsDirStr + "/share/qucs/lang/");
    } else {
      QString QucsApplicationPath = QCoreApplication::applicationDirPath();
#ifdef __APPLE__
      QucsDir = QDir(QucsApplicationPath.section("/bin",0,0));
#else
      QucsDir = QDir(QucsApplicationPath);
      QucsDir.cdUp();
#endif
      LangDir = QucsDir.canonicalPath() + "/share/qucs/lang/";
    }

    loadSettings();

    a.setFont(QucsSettings.font);

    QTranslator tor( 0 );
    QString Lang = QucsSettings.Language;
    if(Lang.isEmpty())
      Lang = QString(QLocale::system().name());
    tor.load( QString("qucs_") + Lang, LangDir);
    a.installTranslator( &tor );

    QucsActiveFilter *w = new QucsActiveFilter();
    w->raise();
    w->move(QucsSettings.x, QucsSettings.y);  // position before "show" !!!
    w->show();
    
    int result = a.exec();
    saveApplSettings(w);
    return result;
}
开发者ID:Qucs,项目名称:qucs,代码行数:50,代码来源:main.cpp

示例4: setCurrent

void FileBrowser::setCurrent(const QString &path)
{
	QFileInfo file(path);
	QDir dir = file.absoluteDir();

	if (_files.isEmpty() || _files.last().canonicalPath()
	  != dir.canonicalPath()) {
		if (!_watcher->directories().isEmpty())
			_watcher->removePaths(_watcher->directories());
		_watcher->addPath(dir.canonicalPath());
		_files = dir.entryInfoList(_filter, QDir::Files);
	}

	_index = _files.empty() ? -1 : _files.indexOf(file);
}
开发者ID:luznicky,项目名称:GPXSee,代码行数:15,代码来源:filebrowser.cpp

示例5: if

// Default constructor
QGAlgoMenuFactory::QGAlgoMenuFactory() {

  // Change cursor to 'wait' while reading file information
  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

  //-- Locate configuration file
  QDir qgarDir = QDir(getenv("HOME") + QString("/") + QGAR_DIRNAME);  

  // Check if a the file exists in the users home
  if (! findInDir(QGAR_CFG_FILENAME, qgarDir) ) {
    qgarDir = QDir(getenv("QGARSHARE"));
  }


  // Check if a .qgar exists in the qgar shared directory.
  else if (! findInDir(QGAR_CFG_FILENAME, qgarDir) ) {
    return; // No config file found, return without further
    // processing.
  }


  QString filename = qgarDir.canonicalPath() + "/" + QGAR_CFG_FILENAME;

  // Load application entries from config file.
  QGAppRegister reg(filename.toLatin1());
  buildDescrMap(reg);

  QApplication::restoreOverrideCursor();

}
开发者ID:rentpath,项目名称:qgar,代码行数:31,代码来源:QGAlgoMenuFactory.cpp

示例6: d

static QVector< deviceList > _getDevices()
{
	const char * p = "/dev/disk/by-id/" ;

	QDir d( p ) ;
	QDir e ;

	QStringList l = d.entryList() ;

	l.removeOne( "." ) ;
	l.removeOne( ".." ) ;

	QVector< deviceList > devices ;

	if( l.isEmpty() ){

		return devices ;
	}else{
		for( const auto& it : l ){

			e.setPath ( p + it ) ;

			devices.append( deviceList( e.canonicalPath(),it ) ) ;
		}
	}

	return devices ;
}
开发者ID:joachimdostal,项目名称:zuluCrypt,代码行数:28,代码来源:zulumounttask.cpp

示例7: _convert_md_raid_path

static QString _convert_md_raid_path( const QString& dev,bool wait )
{
	QString volume = dev ;

	QString dev_1 ;
	QDir d( "/dev/md/" ) ;
	QDir f ;

	if( wait ){
		/*
		 * wait for a while because things dont always happen as expected if we check too soon.
		 */
		utility::Task::wait( 4 ) ;
	}

	if( d.exists() ){

		QStringList l = d.entryList() ;

		for( const auto& it : l ){

			dev_1 = "/dev/md/" + it ;
			f.setPath( dev_1 ) ;

			if( f.canonicalPath() == dev ){

				volume = dev_1 ;

				break ;
			}
		}
	}

	return volume ;
}
开发者ID:joachimdostal,项目名称:zuluCrypt,代码行数:35,代码来源:zulumounttask.cpp

示例8: main

int main(int argc, char *argv[])
{
    QString Lang,LangDir;
    QSettings settings("qucs","qucs");
    if(settings.contains("Language")) {
        Lang=settings.value("Language").toString();
    }

    char * var = getenv ("QUCSDIR");
    if (var != NULL) {
      QDir QucsDir = QDir (var);
      QString QucsDirStr = QucsDir.canonicalPath ();
      LangDir =
        QDir::convertSeparators (QucsDirStr + "/share/qucs/lang/");
    } else {
      LangDir = LANGUAGEDIR;
    }

    QApplication a(argc, argv);

    QTranslator tor( 0 );
    if(Lang.isEmpty())
      Lang = QString(QLocale::system().name());
    tor.load( QString("qucs_") + Lang, LangDir);
    a.installTranslator( &tor );

    QucsActiveFilter w;
    w.show();
    
    return a.exec();
}
开发者ID:NextGenIntelligence,项目名称:qucs,代码行数:31,代码来源:main.cpp

示例9: lamexp_try_init_folder

/*
 * Try to initialize the folder (with *write* access)
 */
static QString lamexp_try_init_folder(const QString &folderPath)
{
	static const char *TEST_DATA = "Lorem ipsum dolor sit amet, consectetur, adipisci velit!";
	
	bool success = false;

	const QFileInfo folderInfo(folderPath);
	const QDir folderDir(folderInfo.absoluteFilePath());

	//Create folder, if it does *not* exist yet
	for(int i = 0; (i < 16) && (!folderDir.exists()); i++)
	{
		folderDir.mkpath(".");
	}

	//Make sure folder exists now *and* is writable
	if(folderDir.exists())
	{
		const QByteArray testData = QByteArray(TEST_DATA);
		for(int i = 0; (i < 32) && (!success); i++)
		{
			QFile testFile(folderDir.absoluteFilePath(QString("~%1.tmp").arg(lamexp_rand_str())));
			if(testFile.open(QIODevice::ReadWrite | QIODevice::Truncate))
			{
				if(testFile.write(testData) >= testData.size())
				{
					success = true;
				}
				testFile.remove();
			}
		}
	}

	return (success ? folderDir.canonicalPath() : QString());
}
开发者ID:BackupTheBerlios,项目名称:lamexp,代码行数:38,代码来源:Global_Utils.cpp

示例10: QSqlDatabase

void
TrainDB::initDatabase(QDir home)
{


    if(db->database(sessionid).isOpen()) return;

    // get a connection
    sessionid = "train";
    db = new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE", sessionid));
    db->setDatabaseName(home.canonicalPath() + "/trainDB");

    if (!db->database(sessionid).isOpen()) {
        QMessageBox::critical(0, qApp->translate("TrainDB","Cannot open database"),
                       qApp->translate("TrainDB","Unable to establish a database connection.\n"
                                       "This feature requires SQLite support. Please read "
                                       "the Qt SQL driver documentation for information how "
                                       "to build it.\n\n"
                                       "Click Cancel to exit."), QMessageBox::Cancel);
    } else {

        // create database - does nothing if its already there
        createDatabase();
    }
}
开发者ID:peterjoo,项目名称:GoldenCheetah,代码行数:25,代码来源:TrainDB.cpp

示例11: scopedLocker

OsmAnd::ObfsCollection::SourceOriginId OsmAnd::ObfsCollection_P::addDirectory(const QDir& dir, bool recursive)
{
    QWriteLocker scopedLocker(&_sourcesOriginsLock);

    const auto allocatedId = _lastUnusedSourceOriginId++;
    auto sourceOrigin = new DirectoryAsSourceOrigin();
    sourceOrigin->directory = dir;
    sourceOrigin->isRecursive = recursive;
    _sourcesOrigins.insert(allocatedId, qMove(std::shared_ptr<const SourceOrigin>(sourceOrigin)));

    _fileSystemWatcher->addPath(dir.canonicalPath());
    if (recursive)
    {
        QFileInfoList subdirs;
        Utilities::findDirectories(dir, QStringList() << QLatin1String("*"), subdirs, true);
        for(const auto& subdir : subdirs)
        {
            const auto canonicalPath = subdir.canonicalFilePath();
            sourceOrigin->watchedSubdirectories.insert(canonicalPath);
            _fileSystemWatcher->addPath(canonicalPath);
        }
    }

    invalidateCollectedSources();

    return allocatedId;
}
开发者ID:rotorliu,项目名称:OsmAnd-core,代码行数:27,代码来源:ObfsCollection_P.cpp

示例12: file

bool
LibraryParser::serialize(QDir home)
{
    // we write to root of all cyclists
    home.cdUp();

    // open file - truncate contents
    QString filename = home.canonicalPath() + "/library.xml";
    QFile file(filename);
    file.open(QFile::WriteOnly);
    file.resize(0);
    QTextStream out(&file);
    out.setCodec("UTF-8");


    // write out to file
    foreach (Library *l, ::libraries) {
        // begin document
        out << QString("<library name=\"%1\">\n").arg(l->name);

        // paths...
        foreach(QString p, l->paths)
            out << QString("\t<path>%1</path>\n").arg(p);

        // paths...
        foreach(QString r, l->refs)
            out << QString("\t<ref>%1</ref>\n").arg(r);

        // end document
        out << "</library>\n";
    }
开发者ID:cernst72,项目名称:GoldenCheetah,代码行数:31,代码来源:LibraryParser.cpp

示例13: normalizeRealPath

void QtZLFSManager::normalizeRealPath(std::string &path) const
{
    QString oldPath = QString::fromStdString(path);

    if (isDataPath(path)) {
        const size_t offset = path.find_first_not_of('/', DATA_PATH_SIZE - 1);
        const QString fileName = oldPath.mid(offset);

        oldPath = QStandardPaths::locate(QStandardPaths::DataLocation, fileName, QStandardPaths::LocateDirectory);
        if (oldPath.isEmpty())
            oldPath = QStandardPaths::locate(QStandardPaths::DataLocation, fileName, QStandardPaths::LocateFile);

        if (oldPath.isEmpty()) {
            qWarning("data path not found: \"%s\"", qPrintable(fileName));
            oldPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + fileName;
        }

    } else if (oldPath.startsWith(QStringLiteral("~/")) || oldPath == QStringLiteral("~")) {
        oldPath.replace(0, 1, QDir::homePath());
    }
    
    const QFileInfo info = oldPath;
    const QDir dir = info.absolutePath();
    const QString newPath = dir.canonicalPath() + QLatin1Char('/') + info.fileName();
    path = newPath.toStdString();
}
开发者ID:euroelessar,项目名称:cutereader,代码行数:26,代码来源:qtzlfsmanager.cpp

示例14:

QList<ProjectExplorer::ToolChain *> CrossLinuxToolChain32BitFactory::autoDetectToolChains(
        const QString &displayName, const QString &commandPath,
        const QStringList &debuggers, const ProjectExplorer::Abi &requiredAbi)
{
    //TODO add debuger options

    Q_UNUSED(debuggers);
    QList<ProjectExplorer::ToolChain *> result;
    CrossToolChain32Bit *tc = static_cast<CrossToolChain32Bit *>(createToolChain(true));
    QDir sdkDir =CrossSDKInfo::instance().sdkRoot();
    Utils::FileName tcCommand;
    QString sdkPath;

    sdkPath = sdkDir.canonicalPath();
    tcCommand.append(sdkPath + commandPath);

    if (!tcCommand.toFileInfo().exists()) {
        return result;
    }

    tc->setDisplayName(displayName);
    tc->setCompilerCommand(tcCommand);
    tc->setTargetAbi(requiredAbi);
    result.append(tc);
    return result;
}
开发者ID:elta,项目名称:Cross-SDK,代码行数:26,代码来源:crosslinuxtoolchain32bitfactory.cpp

示例15: slotAddClicked

void BtInstallPathDialog::slotAddClicked() {
    QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
    if (dirname.isEmpty()) { // if user cancelled the dialog
        return;
    }
    QDir dir = QDir(dirname);
    if (dir.isReadable()) {
        const QFileInfo fi( dir.canonicalPath() );
        if (!fi.exists() || !fi.isWritable()) {
            const int result = message::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you still want to add it to the list of bookshelf folders?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
            if (result != QMessageBox::Yes) {
                return;
            }
        }
        addPathToList(util::directory::convertDirSeparators(dir.canonicalPath()));
        updateTopLevelItems();
    }
}
开发者ID:betsegaw,项目名称:bibletime,代码行数:18,代码来源:btinstallpathdialog.cpp


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