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);
}
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));
}