本文整理汇总了C++中FilePath::toStr方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::toStr方法的具体用法?C++ FilePath::toStr怎么用?C++ FilePath::toStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::toStr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RuntimeError
XmlDomDocument::XmlDomDocument(const QByteArray& xmlFileContent, const FilePath& filepath) throw (Exception) :
mFilePath(filepath), mRootElement(nullptr)
{
QDomDocument doc;
doc.implementation().setInvalidDataPolicy(QDomImplementation::ReturnNullNode);
QString errMsg;
int errLine;
int errColumn;
if (!doc.setContent(xmlFileContent, &errMsg, &errLine, &errColumn))
{
QString line = xmlFileContent.split('\n').at(errLine-1);
throw RuntimeError(__FILE__, __LINE__, QString("%1: %2 [%3:%4] LINE:%5")
.arg(filepath.toStr(), errMsg).arg(errLine).arg(errColumn).arg(line),
QString(tr("Error while parsing XML in file \"%1\": %2 [%3:%4]"))
.arg(filepath.toNative(), errMsg).arg(errLine).arg(errColumn));
}
// check if the root node exists
QDomElement root = doc.documentElement();
if (root.isNull())
{
throw RuntimeError(__FILE__, __LINE__, QString(),
QString(tr("No XML root node found in \"%1\"!")).arg(/*xmlFilePath.toNative()*/QString()));
}
mRootElement = XmlDomElement::fromQDomElement(root, this);
}
示例2: setLastRecentProject
void RecentProjectsModel::setLastRecentProject(const FilePath& filepath)
{
// if the filepath is already in the list, we just have to move it to the top of the list
for (int i = 0; i < mRecentProjects.count(); i++)
{
if (mRecentProjects.at(i).toStr() == filepath.toStr())
{
if (i == 0)
return; // the filename is already on top of the list, so nothing to do here...
beginMoveRows(QModelIndex(), i, i, QModelIndex(), 0);
mRecentProjects.move(i, 0);
endMoveRows();
save();
return;
}
}
// limit the maximum count of entries in the list
while (mRecentProjects.count() >= 5)
{
beginRemoveRows(QModelIndex(), mRecentProjects.count()-1, mRecentProjects.count()-1);
mRecentProjects.takeLast();
endRemoveRows();
}
// add the new filepath to the list
beginInsertRows(QModelIndex(), 0, 0);
mRecentProjects.prepend(filepath);
endInsertRows();
save();
}
示例3: on_btnBrowseOutputDir_clicked
void FabricationOutputDialog::on_btnBrowseOutputDir_clicked() {
BoardGerberExport grbExport(mBoard, mBoard.getFabricationOutputSettings());
FilePath dir = grbExport.getOutputDirectory();
if (dir.isExistingDir()) {
QDesktopServices::openUrl(QUrl::fromLocalFile(dir.toStr()));
} else {
QMessageBox::warning(this, tr("Warning"), tr("Directory does not exist."));
}
}
示例4: testDataDir
TEST_F(DeviceConverterTest, testConversion) {
FilePath testDataDir(TEST_DATA_DIR "/unittests/eagleimport");
// load eagle device
FilePath eagleLibFp = testDataDir.getPathTo("resistor.lbr");
parseagle::Library eagleLibrary(eagleLibFp.toStr());
ASSERT_EQ(1, eagleLibrary.getDeviceSets().count());
const parseagle::DeviceSet& eagleDeviceSet =
eagleLibrary.getDeviceSets().first();
ASSERT_EQ(1, eagleDeviceSet.getDevices().count());
const parseagle::Device& eagleDevice = eagleDeviceSet.getDevices().first();
// load converter database
ConverterDb db(testDataDir.getPathTo("db.ini"));
// convert device set
DeviceConverter converter(eagleDeviceSet, eagleDevice, db);
std::unique_ptr<library::Device> device = converter.generate();
}
示例5: mIniFile
ConverterDb::ConverterDb(const FilePath& ini) noexcept
: mIniFile(ini.toStr(), QSettings::IniFormat) {
}