Exemplo n.º 1
0
QStringList ExpressionCompleter::splitPath ( const QString & path ) const
{
    try {
        App::ObjectIdentifier p = ObjectIdentifier::parse(0, path.toUtf8().constData());
        QStringList l;

        if (p.getProperty()) {
            for (int i = 0; i < p.numComponents(); ++i)
                l << Base::Tools::fromStdString(p.getPropertyComponent(i).toString());
            return l;
        }
        else {
            std::vector<std::string> sl = p.getStringList();
            std::vector<std::string>::const_iterator sli = sl.begin();

            while (sli != sl.end()) {
                l << Base::Tools::fromStdString(*sli);
                ++sli;
            }

            return l;
        }
    }
    catch (const Base::Exception &) {
        return QStringList() << path;
    }
}
void ExpressionBinding::bind(const App::ObjectIdentifier &_path)
{
    const Property * prop = _path.getProperty();

    Q_ASSERT(prop != 0);

    path = prop->canonicalPath(_path);
}
Exemplo n.º 3
0
void ExpressionBinding::bind(const App::ObjectIdentifier &_path)
{
    const Property * prop = _path.getProperty();

    Q_ASSERT(prop != 0);

    path = prop->canonicalPath(_path);
    
    //connect to be informed about changes
    DocumentObject * docObj = path.getDocumentObject();
    connection = docObj->ExpressionEngine.expressionChanged.connect(boost::bind(&ExpressionBinding::expressionChange, this, _1));
}
Exemplo n.º 4
0
QString ExpressionCompleter::pathFromIndex ( const QModelIndex & index ) const
{
    QStandardItemModel * m = static_cast<QStandardItemModel*>(model());

    if (m->data(index, Qt::UserRole).canConvert<App::ObjectIdentifier>()) {
        App::ObjectIdentifier p = m->data(index, Qt::UserRole).value<App::ObjectIdentifier>();
        QString pStr = Base::Tools::fromStdString(p.toString());

        QString parentStr;
        QModelIndex parent = index.parent();
        while (parent.isValid()) {
            QString thisParentStr = m->data(parent, Qt::UserRole).toString();

            parentStr = thisParentStr + parentStr;

            parent = parent.parent();
        }

        return parentStr + pStr;
    }
    else if (m->data(index, Qt::UserRole).canConvert<QString>()) {
        QModelIndex parent = index;
        QString parentStr;

        while (parent.isValid()) {
            QString thisParentStr = m->data(parent, Qt::UserRole).toString();

            parentStr = thisParentStr + parentStr;

            parent = parent.parent();
        }

        return parentStr;
    }
    else
        return QString();
}