Beispiel #1
0
void DocumentPreviewTab::setResource(Nepomuk2::Resource & resource)
{
    m_resource = resource;
    ui->urlSelector->clear();
    if(m_part) {
        m_part->closeUrl();
    }

    QString specificUrl;
    if(resource.isValid()) {

        specificUrl = resource.property(Nepomuk2::Vocabulary::NIE::url()).toString();
        if(!specificUrl.isEmpty()) {
            resource = resource.property(Nepomuk2::Vocabulary::NBIB::publishedAs()).toResource();
            m_resource = resource;
        }

        QList<Nepomuk2::Resource> fileList;

        if(resource.hasType(Nepomuk2::Vocabulary::NBIB::Reference())) {
            Nepomuk2::Resource publication = resource.property(Nepomuk2::Vocabulary::NBIB::publication()).toResource();
            fileList = publication.property(Nepomuk2::Vocabulary::NBIB::isPublicationOf()).toResourceList();
            fileList.append( publication.property(Nepomuk2::Vocabulary::NIE::links()).toResourceList() );
        }
        else if(resource.hasType(Nepomuk2::Vocabulary::NBIB::Publication())) {
            fileList = resource.property(Nepomuk2::Vocabulary::NBIB::isPublicationOf()).toResourceList();
            fileList.append( resource.property(Nepomuk2::Vocabulary::NIE::links()).toResourceList() );
        }
        else {
            fileList.append(resource);
        }

        // add all DataObjects to the preview
        foreach(const Nepomuk2::Resource & r, fileList) {
            KUrl url = KUrl(r.property(Nepomuk2::Vocabulary::NIE::url()).toString());
            KIcon icon;
            QString mimetype;

            if( r.hasType(Nepomuk2::Vocabulary::NFO::Website())// || r.hasType(Nepomuk2::Vocabulary::NFO::WebDataObject())
                || url.scheme() == QLatin1String("http")) {

                QString favIcon = KMimeType::favIconForUrl(url);
                if(favIcon.isEmpty()) {
                    favIcon = QLatin1String("text-html");
                }

                icon = KIcon(favIcon);
                mimetype = QLatin1String("text/html");
            }
            else {
                KMimeType::Ptr mimeTypePtr = KMimeType::findByUrl(url);

                icon = KIcon(mimeTypePtr->iconName());
                mimetype = mimeTypePtr->name();
            }

            ui->urlSelector->addItem(icon,url.url(),QVariant(mimetype));
        }
void ResourceBrowserWidget::createResource()
{
    // create a new resource
    Nepomuk2::Resource res = NewClassDialog::createResource( selectedClass(), this );
    if ( res.isValid() ) {
        // update
        m_resourceView->addResource( res );
    }
}
Beispiel #3
0
void VolumeNumberEdit::updateResource(const QString & text)
{
    // the volume /number can either be attached directly to an nbib:Publication entity
    // happens for techreport for example

    // or it marks the volume/number of an JournalIssue or any other issue collection where an article was published in.
    // or the volume for the CodeOfLaw of an legislation

    // check if the resource has a Collection attached to it
    Nepomuk2::Resource journalIssue = resource().property(NBIB::collection()).toResource();
    Nepomuk2::Resource codeOfLaw = resource().property(NBIB::codeOfLaw()).toResource();
    Nepomuk2::Resource courtReporter = resource().property(NBIB::courtReporter()).toResource();

    QList<QUrl> resourceUris;
    if(journalIssue.isValid()) {
        // in this case attach volume/number to the issue rather than the publication from resource()
        resourceUris << journalIssue.uri();
    }
    else if(codeOfLaw.isValid() && propertyUrl() == NBIB::volume()) {
        // in this case attach volume to the issue rather than the publication from resource()
        // the number is the bill number for the Legislation
        resourceUris << codeOfLaw.uri();
    }
    else if(courtReporter.isValid() && propertyUrl() == NBIB::volume()) {
        // in this case attach volume to the issue rather than the publication from resource()
        // the number is the docket number for the LegalCaseDocument
        resourceUris << courtReporter.uri();
    }
    else {
        resourceUris << resource().uri();
    }

    QVariantList value; value << text;

    connect(Nepomuk2::setProperty(resourceUris, propertyUrl(), value), SIGNAL(result(KJob*)),this,
            SLOT(showDMSError(KJob*)) );
}
Beispiel #4
0
void VolumeNumberEdit::setupLabel()
{
    QString string;

    // four different cases must be checked here
    Nepomuk2::Resource issueResource;

    // I. resource() is an article, with an attached Collection, from a Series
    if(resource().hasType(NBIB::Article())) {
        issueResource = resource().property(NBIB::collection()).toResource();
    }
    // II. resource() is a Legislation
    // the number in this case is for the nbib:Bill
    // while the volume if for the nbib:CodeOfLaw
    else if(resource().hasType(NBIB::Legislation())) {
        if(propertyUrl() == NBIB::volume()) {
            issueResource = resource().property(NBIB::codeOfLaw()).toResource();
        }
    }
    // III. the number in this case is for the case not the courtreporter
    else if(resource().hasType(NBIB::LegalCaseDocument())) {
        if(propertyUrl() == NBIB::volume()) {
            issueResource = resource().property(NBIB::courtReporter()).toResource();
        }
    }
    // IV. resource() is an Collection, from a Series
    else if(resource().hasType(NBIB::Collection())) {
        issueResource = resource();
    }

    if(issueResource.isValid()) {
        // propertyUrl either leads to the issue number or volume number, see publicationwidget for the selection
        string = issueResource.property(propertyUrl()).toString();
    }
    else {
        // if no issue is attached, show issue/volume from publication instead
        string = resource().property(propertyUrl()).toString();
    }

    setLabelText(string);
}