QString MasterCatalogModel::changeCatalog(const QString &inpath){ if ( inpath == "" || inpath == sUNDEF) return ""; CatalogModel *model = selectedCatalog(); if ( model && model->url() == inpath) return ""; QString path = inpath; int index = inpath.indexOf("/.."); if ( index != -1){ path = path.left(path.size() - 3); index = path.lastIndexOf("/"); if ( index == -1) return ""; path = path.left(index); } //we are not sure here if it is a filepath or an url; we need an url though QFileInfo inf(path); // qfileinfo only works with filepaths no urls, so if it exists it is a path QString url = inf.exists() ? QUrl::fromLocalFile(path).toString() : path; for(int i =0; i < _splitCatalogs[_activeSplit].size(); ++i){ CatalogModel *cat = _splitCatalogs[_activeSplit][i]; if ( cat->url() == url){ pushToFront(i); emit emitResourcesChanged(); return cat->url(); } } return url; }
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; }