コード例 #1
0
ファイル: xmldomdocument.cpp プロジェクト: nemofisch/LibrePCB
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
0
FirstRunWizardPage_WorkspacePath::FirstRunWizardPage_WorkspacePath(
    QWidget* parent) noexcept
  : QWizardPage(parent), mUi(new Ui::FirstRunWizardPage_WorkspacePath) {
  mUi->setupUi(this);
  registerField("CreateWorkspace", mUi->rbtnCreateWs);
  registerField("CreateWorkspacePath", mUi->edtCreateWsPath);
  registerField("OpenWorkspace", mUi->rbtnOpenWs);
  registerField("OpenWorkspacePath", mUi->edtOpenWsPath);

  FilePath defaultWsPath =
      FilePath(QDir::homePath()).getPathTo("LibrePCB-Workspace");
  mUi->edtCreateWsPath->setText(defaultWsPath.toNative());
  mUi->edtOpenWsPath->setText(defaultWsPath.toNative());
  if (workspace::Workspace::isValidWorkspacePath(defaultWsPath))
    mUi->rbtnOpenWs->setChecked(true);
}
コード例 #3
0
ファイル: exceptions.cpp プロジェクト: LibrePCB/LibrePCB
FileParseError::FileParseError(const char* file, int line,
                               const FilePath& filePath, int fileLine,
                               int            fileColumn,
                               const QString& invalidFileContent,
                               const QString& msg) noexcept
  : RuntimeError(file, line,
                 QString("File parse error: %1\n\nFile: %2\nLine,Column: "
                         "%3,%4\nInvalid Content: \"%5\"")
                     .arg(msg)
                     .arg(filePath.toNative())
                     .arg(fileLine)
                     .arg(fileColumn)
                     .arg(invalidFileContent)) {
}