예제 #1
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*)) );
}
예제 #2
0
void TVNamerService::slotTVShowResourceCreated(const Nepomuk2::Resource &res)
{
    kDebug() << res.uri();
    // inform KIO about the change
    Soprano::QueryResultIterator it = mainModel()->executeQuery(QString::fromLatin1("select ?s ?t where { "
                                                                                    "%1 nmm:series [ nie:title ?t ] ; "
                                                                                    "nmm:isPartOfSeason [ nmm:seasonNumber ?s ] "
                                                                                    "} LIMIT 1")
                                                                .arg(Soprano::Node::resourceToN3(res.uri())),
                                                                Soprano::Query::QueryLanguageSparql);
    if(it.next()) {
        kDebug() << QString::fromLatin1("tvshow:/%1/%1 - Season %2")
                    .arg(it["t"].toString())
                    .arg(it["s"].literal().toInt(), 2, 10, QLatin1Char('0'));
        org::kde::KDirNotify::emitFilesAdded(QString::fromLatin1("tvshow:/%1/%1 - Season %2")
                                             .arg(it["t"].toString())
                                             .arg(it["s"].literal().toInt()));
    }
}
예제 #3
0
void TVNamerService::slotTVShowUsageCountChanged(const Nepomuk2::Resource &res)
{
    // fetch the changed show's details and tell KIO to remove it in any case
    Soprano::QueryResultIterator it
            = mainModel()->executeQuery(QString::fromLatin1("select ?s ?e ?st ?t where { "
                                                            "%1 nmm:episodeNumber ?e ; "
                                                            "nmm:season ?s ; "
                                                            "nmm:series [ a nmm:TVSeries ; nie:title ?st ] ; "
                                                            "nie:title ?t . } LIMIT 1")
                                        .arg(Soprano::Node::resourceToN3(res.uri())),
                                        Soprano::Query::QueryLanguageSparql);
    if(it.next()) {
        const QString title = i18n("Next episode of %1: %2x%3 - %4",
                                   it["st"].toString(),
                                   QString::number(it["s"].literal().toInt()).rightJustified(2, QLatin1Char('0')),
                                   QString::number(it["e"].literal().toInt()).rightJustified(2, QLatin1Char('0')),
                                   it["t"].toString());
        org::kde::KDirNotify::emitFilesRemoved(QStringList() << (QLatin1String("tvshow:/latest/") + title));
    }

    // now simply tell KIO to check for added files
    org::kde::KDirNotify::emitFilesAdded(QLatin1String("tvshow:/latest"));
}