~ubuntu-branches/ubuntu/quantal/akonadi/quantal

« back to all changes in this revision

Viewing changes to server/src/nepomuk/queryserviceclient.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-01-24 23:43:13 UTC
  • mto: (3.1.12 sid)
  • mto: This revision was merged to the branch mainline in revision 69.
  • Revision ID: package-import@ubuntu.com-20120124234313-ooald4uh9w8jilyw
Tags: upstream-1.7.0
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
          loop( 0 ) {
83
83
    }
84
84
 
85
 
    void _k_entriesRemoved( const QStringList& );
86
85
    void _k_finishedListing();
87
86
    bool handleQueryReply( QDBusReply<QDBusObjectPath> reply );
88
87
 
96
95
    QEventLoop* loop;
97
96
};
98
97
 
99
 
 
100
 
void Nepomuk::Query::QueryServiceClient::Private::_k_entriesRemoved( const QStringList& uris )
101
 
{
102
 
    QList<QUrl> ul;
103
 
    foreach( const QString& s, uris ) {
104
 
        ul.append( QUrl( s ) );
105
 
    }
106
 
    emit q->entriesRemoved( ul );
107
 
}
108
 
 
109
 
 
110
98
void Nepomuk::Query::QueryServiceClient::Private::_k_finishedListing()
111
99
{
112
100
    emit q->finishedListing();
121
109
        queryInterface = new org::kde::nepomuk::Query( queryServiceInterface->service(),
122
110
                                                       r.value().path(),
123
111
                                                       dbusConnection  );
124
 
        connect( queryInterface, SIGNAL( newEntries( QList<Nepomuk::Query::Result> ) ),
125
 
                 q, SIGNAL( newEntries( QList<Nepomuk::Query::Result> ) ) );
126
 
        connect( queryInterface, SIGNAL( entriesRemoved( QStringList ) ),
127
 
                 q, SLOT( _k_entriesRemoved( QStringList ) ) );
128
 
        connect( queryInterface, SIGNAL( finishedListing() ),
129
 
                 q, SLOT( _k_finishedListing() ) );
 
112
        connect( queryInterface, SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
 
113
                 q, SIGNAL(newEntries(QList<Nepomuk::Query::Result>)) );
 
114
        connect( queryInterface, SIGNAL(entriesRemoved(QList<Nepomuk::Query::Result>)),
 
115
                 q, SIGNAL(entriesRemoved(QList<Nepomuk::Query::Result>)) );
 
116
        connect( queryInterface, SIGNAL(finishedListing()),
 
117
                 q, SLOT(_k_finishedListing()) );
130
118
        // run the listing async in case the event loop below is the only one we have
131
119
        // and we need it to handle the signals and list returns results immediately
132
120
        QTimer::singleShot( 0, queryInterface, SLOT(list()) );
162
150
}
163
151
 
164
152
 
165
 
bool Nepomuk::Query::QueryServiceClient::query( const QString& query )
 
153
bool Nepomuk::Query::QueryServiceClient::query( const QString& query, const QHash<QString, QString> &encodedRps )
166
154
{
167
155
    close();
168
156
 
169
157
    if ( d->queryServiceInterface->isValid() ) {
170
 
        return d->handleQueryReply( d->queryServiceInterface->sparqlQuery( query, QHash<QString, QString>() ) );
 
158
        return d->handleQueryReply( d->queryServiceInterface->sparqlQuery( query, encodedRps ) );
171
159
    }
172
160
    else {
173
161
        qDebug() << "Could not contact query service.";
176
164
}
177
165
 
178
166
 
179
 
bool Nepomuk::Query::QueryServiceClient::blockingQuery( const QString& q )
 
167
bool Nepomuk::Query::QueryServiceClient::blockingQuery( const QString& q, const QHash<QString, QString> &encodedRps )
180
168
{
181
 
    if( query( q ) ) {
 
169
    if( query( q, encodedRps ) ) {
182
170
        QEventLoop loop;
183
171
        d->loop = &loop;
184
172
        loop.exec();