[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/nepomuk-kde/annotation
From: Sebastian Trueg <sebastian () trueg ! de>
Date: 2009-08-26 20:00:53
Message-ID: 1251316853.298656.14498.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1016017 by trueg:
First version of olena plugin operational
M +6 -3 lib/metaannotationplugin.cpp
M +6 -5 lib/metaannotationplugin.h
M +42 -1 plugins/olena/olenaplugin.cpp
M +9 -2 plugins/olena/olenaplugin.h
M +6 -0 plugins/olena/olenatextextractionjob.cpp
M +2 -0 plugins/olena/olenatextextractionjob.h
M +1 -1 simpleannotator/mainwindow.cpp
--- trunk/playground/base/nepomuk-kde/annotation/lib/metaannotationplugin.cpp \
#1016016:1016017 @@ -74,11 +74,9 @@
}
-void Nepomuk::MetaAnnotationPlugin::getPossibleMetaAnnotations( const QString& \
filter ) +void Nepomuk::MetaAnnotationPlugin::getPossibleMetaAnnotations( const \
AnnotationRequest& request ) {
d->setupWrapper();
- AnnotationRequest request;
- request.setFilter( filter );
d->m_wrapper->getPossibleAnnotations( request );
}
@@ -88,4 +86,9 @@
addNewAnnotation( anno );
}
+void Nepomuk::MetaAnnotationPlugin::metaAnnotationsFinished()
+{
+ emitFinished();
+}
+
#include "metaannotationplugin.moc"
--- trunk/playground/base/nepomuk-kde/annotation/lib/metaannotationplugin.h \
#1016016:1016017 @@ -64,12 +64,12 @@
protected:
/**
* This is the heart of the MetaAnnotationPlugin. It triggers the plugin \
system
- * to create Annotation objects for \p filter.
+ * to create Annotation objects for \p request.
*
* Annotations created by other plugins are reported via newMetaAnnotation. \
Once done,
* metaAnnotationsFinished is called.
*/
- void getPossibleMetaAnnotations( const QString& filter );
+ void getPossibleMetaAnnotations( const AnnotationRequest& request );
/**
* This method is called for each annotation that the plugin system
@@ -88,10 +88,11 @@
* the filter and the plugin should provide a new keyword or finish
* its analysis itself.
*
- * A typical implementation would read the next keyword from a list or
- * call AnnotationPlugin::emitFinished once the list is done.
+ * A typical implementation would read the next keyword from a list.
+ *
+ * The default implementation calls AnnotationPlugin::emitFinished.
*/
- virtual void metaAnnotationsFinished() = 0;
+ virtual void metaAnnotationsFinished();
private:
class Private;
--- trunk/playground/base/nepomuk-kde/annotation/plugins/olena/olenaplugin.cpp \
#1016016:1016017 @@ -19,10 +19,12 @@
*/
#include "olenaplugin.h"
+#include "olenatextextractionjob.h"
#include "annotationrequest.h"
#include "simplepimoannotation.h"
#include "pimo.h"
#include "nfo.h"
+#include "nie.h"
#include <KIconLoader>
#include <KLocale>
@@ -35,10 +37,12 @@
#include <Nepomuk/ResourceManager>
#include <Nepomuk/Types/Property>
+#include <QtCore/QFile>
Nepomuk::OlenaAnnotationPlugin::OlenaAnnotationPlugin(QObject* parent, const \
QList<QVariant>&)
- : AnnotationPlugin(parent)
+ : MetaAnnotationPlugin(parent),
+ m_currentTextExtractionJob( 0 )
{
}
@@ -50,8 +54,45 @@
void Nepomuk::OlenaAnnotationPlugin::doGetPossibleAnnotations( const \
AnnotationRequest& request ) {
+ if ( m_currentTextExtractionJob ) {
+ m_currentTextExtractionJob->disconnect( this );
+ m_currentTextExtractionJob->cancel();
+ m_currentTextExtractionJob = 0;
+ }
+
+ if ( request.resource().isValid() ) {
+ Resource res = request.resource();
+ if ( res.hasType( Nepomuk::Vocabulary::NFO::RasterImage() ) ) {
+ QUrl url = res.property( Nepomuk::Vocabulary::NIE::url() \
).toResource().resourceUri(); + if ( QFile::exists( url.toLocalFile() ) ) \
{ + m_currentTextExtractionJob = OlenaTextExtractionJob::extractText( \
url ); + connect( m_currentTextExtractionJob, SIGNAL( result( KJob* ) \
), this, SLOT( slotTextExtractionDone(KJob*) ) ); + \
m_currentTextExtractionJob->start(); + return;
+ }
+ }
+ }
+
+ // nothing to be done
+ emitFinished();
}
+
+void Nepomuk::OlenaAnnotationPlugin::slotTextExtractionDone( KJob* )
+{
+ QString text = m_currentTextExtractionJob->text();
+ m_currentTextExtractionJob = 0;
+
+ if ( !text.isEmpty() ) {
+ AnnotationRequest request;
+ request.setText( text );
+ getPossibleMetaAnnotations( request );
+ }
+ else {
+ emitFinished();
+ }
+}
+
NEPOMUK_EXPORT_ANNOTATION_PLUGIN( Nepomuk::OlenaAnnotationPlugin, \
"nepomuk_olenaannotationplugin" )
#include "olenaplugin.moc"
--- trunk/playground/base/nepomuk-kde/annotation/plugins/olena/olenaplugin.h \
#1016016:1016017 @@ -21,15 +21,19 @@
#ifndef _OLENA_ANNOTATIONPLUGIN_H_
#define _OLENA_ANNOTATIONPLUGIN_H_
-#include "annotationplugin.h"
+#include "metaannotationplugin.h"
#include <soprano/soprano.h>
#include <KPluginFactory>
#include <KPluginLoader>
+class KJob;
namespace Nepomuk {
- class OlenaAnnotationPlugin : public AnnotationPlugin
+
+ class OlenaTextExtractionJob;
+
+ class OlenaAnnotationPlugin : public MetaAnnotationPlugin
{
Q_OBJECT
@@ -38,9 +42,12 @@
~OlenaAnnotationPlugin();
private Q_SLOTS:
+ void slotTextExtractionDone( KJob* job );
private:
void doGetPossibleAnnotations( const AnnotationRequest& request );
+
+ OlenaTextExtractionJob* m_currentTextExtractionJob;
};
} // End namespace Nepomuk
--- trunk/playground/base/nepomuk-kde/annotation/plugins/olena/olenatextextractionjob.cpp \
#1016016:1016017 @@ -142,6 +142,12 @@
}
+QString Nepomuk::OlenaTextExtractionJob::text() const
+{
+ return d->m_extractedText;
+}
+
+
void Nepomuk::OlenaTextExtractionJob::slotFinished()
{
KIO::NetAccess::removeTempFile( d->m_tmpFilePath );
--- trunk/playground/base/nepomuk-kde/annotation/plugins/olena/olenatextextractionjob.h \
#1016016:1016017 @@ -33,6 +33,8 @@
OlenaTextExtractionJob( QObject* parent = 0 );
~OlenaTextExtractionJob();
+ QString text() const;
+
static OlenaTextExtractionJob* extractText( const KUrl& url );
public Q_SLOTS:
--- trunk/playground/base/nepomuk-kde/annotation/simpleannotator/mainwindow.cpp \
#1016016:1016017 @@ -68,7 +68,7 @@
QList<Nepomuk::Resource> getTextExcerpts( const Nepomuk::Resource& textRes )
{
// get all parts that are TextDocuments
- QList<Nepomuk::Resource> parts = textRes.property( \
Nepomuk::Vocabulary::NIE::hasPart() ).toResourceList(); + \
QList<Nepomuk::Resource> parts = textRes.property( \
Nepomuk::Vocabulary::NIE::hasLogicalPart() ).toResourceList(); \
QList<Nepomuk::Resource>::iterator it = parts.begin(); while ( it != parts.end() ) {
if ( it->hasType( Nepomuk::Vocabulary::NFO::TextDocument() ) )
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic