Example #1
0
QString BoxesBackend::newBox(const QString &name, const QString &icon)
{
    QString boxID = name;
    if(name == "") {
        boxID = i18n("Box");
    }


    if(boxIDs().contains(name)) {
        for(int i = 1;; i++) {
            QString n(name + " (" + QString::number(i) + ")");
            if(!boxIDs().contains(n)) {
                boxID = n;
                break;
            }
        }
    }
    Resource boxR = boxRes(boxID);
    boxR.setTypes(QList<QUrl>() << Nepomuk::Vocabulary::FB::FileBox());
    boxR.setLabel(name);
    // boxR.setTypes();
    boxR.addProperty(Nepomuk::Vocabulary::FB::isFileBoxIn(), fileBoxesRes());
    boxR.addProperty(Nepomuk::Vocabulary::FB::hasNewFiles(), false);
    boxR.addProperty(Nepomuk::Vocabulary::FB::boxID(), boxID);
    boxR.addProperty(Soprano::Vocabulary::NAO::iconName() , icon);

    org::kde::KDirNotify::emitFilesAdded("fileboxes:/");
    return boxID;
}
Resource RasterCoverage::source(int mode) const
{
    Resource resource = Coverage::source(mode);
    if ( mode & IlwisObject::cmEXTENDED) {
        resource.addProperty("georeference", georeference()->id());
        resource.addProperty("domain", _datadefCoverage.domain()->id());
        resource.setExtendedType( resource.extendedType() | itDOMAIN |  itGEOREF);
    }
    return resource;
}
CatalogModel *MasterCatalogModel::newCatalog(const QString &inpath, const QString& filter)
{
    if ( inpath == "" || inpath == sUNDEF )
        return 0;

    QUrl location(inpath);
    _currentUrl = inpath;
    if ( inpath.indexOf("ilwis://internalcatalog/workspaces") == 0){
        for(auto workspace : _workspaces){
            if ( workspace->url() == inpath){
                emit currentCatalogChanged();
                WorkSpaceModel *wsm = 0; // new WorkSpaceModel(*workspace);
                return wsm;
            }
        }
    }else {
        bool canBeAnimated = false;
        Resource res = mastercatalog()->name2Resource(inpath,itCATALOG);
        if ( res.isValid()){
            canBeAnimated = hasType(res.extendedType(), itCATALOG)        ;
        }else
            res = Resource(inpath, itCATALOG);

        if ( filter != "container=ilwis://mastercatalog")
            res.addProperty("filter",filter);
        res.addProperty("canbeanimated",canBeAnimated);

        CatalogModel *model = 0;
        if ( inpath.indexOf("ilwis://operations") == 0){
            res.addProperty("filter", "(type=" + QString::number(itSINGLEOPERATION) + " or type=" + QString::number(itWORKFLOW) + ")");
            model = new OperationCatalogModel(res, this);
        }else
            model = new CatalogModel(res, CatalogModel::getCatalogType(res, CatalogModel::ctMUTABLE));
        if ( _currentCatalog == 0){
            QString num = context()->configurationRef()("users/" + Ilwis::context()->currentUser() + "/filter-count",QString("0"));
            int n = num.toInt();
            for(int i = 0; i < n; ++i){
                QString basekey = "users/" + Ilwis::context()->currentUser() + "/filters-" + QString::number(i);
                QString name = context()->configurationRef()(basekey + "/filter-name", QString(""));
                QString newfilter = context()->configurationRef()(basekey + "/filter-definition", QString(""));
                model->filter(name,newfilter);
            }
        }
        _currentCatalog = model;
        ICatalog catalog(model->url());
        context()->setWorkingCatalog(catalog);
        model->scanContainer(true, false);
        emit currentCatalogChanged();
        return model;


    }
    return 0;
}
Example #4
0
Resource Coverage::source(int mode) const
{
    Resource resource = IlwisObject::source(mode);
    if ( mode & IlwisObject::cmEXTENDED) {
        resource.addProperty("coordinatesystem", coordinateSystem()->id());
        resource.setExtendedType( resource.extendedType() | itCOORDSYSTEM);
    }
    return resource;
}
CatalogModel *IlwisObjectModel::catalog(const QString &id)
{
    bool ok;
    quint64 lid = id.toULongLong(&ok);
    if (!ok)
        return 0;
    Resource res = mastercatalog()->id2Resource(lid);
    //res.addProperty("filter","container=" + res.url().toString());
    res.addProperty("locations", res.url().toString());
    return new CatalogModel(res, this);
}