~ubuntu-branches/ubuntu/raring/kdepim/raring-proposed

« back to all changes in this revision

Viewing changes to libkdepim/addresseelineedit.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2013-02-06 11:49:08 UTC
  • mfrom: (0.2.38)
  • Revision ID: package-import@ubuntu.com-20130206114908-eb7adh9xp54jk7gi
Tags: 4:4.10.0a-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
        m_completionInitialized( false ),
225
225
        m_smartPaste( false ),
226
226
        m_addressBookConnected( false ),
 
227
        m_lastSearchMode( false ),
227
228
        m_searchExtended( false ),
228
229
        m_useSemicolonAsSeparator( false )
229
230
    {
 
231
        m_delayedQueryTimer.setSingleShot(true);
 
232
        connect( &m_delayedQueryTimer, SIGNAL(timeout()), q, SLOT(slotTriggerDelayedQueries()) );
230
233
    }
231
234
 
232
235
    void init();
258
261
    void stopNepomukSearch();
259
262
    void slotNepomukHits( const QList<Nepomuk2::Query::Result>& result );
260
263
    void slotNepomukSearchFinished();
 
264
    void slotTriggerDelayedQueries();
261
265
    static KCompletion::CompOrder completionOrder();
262
266
 
263
267
    AddresseeLineEdit *q;
270
274
    bool m_lastSearchMode;
271
275
    bool m_searchExtended; //has \" been added?
272
276
    bool m_useSemicolonAsSeparator;
 
277
    QTimer m_delayedQueryTimer;
273
278
};
274
279
 
275
280
void AddresseeLineEdit::Private::init()
345
350
 
346
351
 
347
352
static const char* sparqlquery =
348
 
    //"select distinct ?email where { ?r a nco:Contact . ?r nco:hasEmailAddress ?v . ?v nco:emailAddress ?email . FILTER regex(str(?email), \"\\\\b%1\", \"i\")}";
349
 
    "select distinct ?email ?fullname where { ?r a nco:Contact . ?r nco:hasEmailAddress ?v .  ?v nco:emailAddress ?email . "
350
 
    "{ FILTER regex( str(?email), \"\\\\b%1\", \"i\") . ?r nco:fullname ?fullname } "
351
 
    "union "
352
 
    "{ ?r nco:fullname ?fullname . FILTER regex( str(?fullname), \"\\\\b%1\", \"i\") } "
353
 
    "union "
354
 
    "{ ?r nco:fullname ?fullname . ?r nco:nameFamily ?family . FILTER regex( str(?family), \"\\\\b%1\", \"i\") } "
355
 
    "union "
356
 
    "{ ?r nco:fullname ?fullname . ?r nco:nameGiven ?given . FILTER regex( str(?given), \"\\\\b%1\", \"i\") } "
357
 
    "} ";
 
353
    "select distinct ?email ?fullname where {"
 
354
    "{"
 
355
        "?r nco:hasEmailAddress   ?em ."
 
356
        "?em nco:emailAddress ?email ."
 
357
        "?r ?p ?fullname ."
 
358
        "FILTER( ?p in (nco:fullname, nco:nameFamily, nco:nameGiven)  )."
 
359
        "FILTER( bif:contains(?fullname, \"'%1*'\")  )."
 
360
    "} UNION {"
 
361
        "?r nco:hasEmailAddress   ?em ."
 
362
        "?em nco:emailAddress ?email ."
 
363
        "FILTER( bif:contains(?email, \"'%1*'\")  )."
 
364
        "?r nco:fullname ?fullname ."
 
365
    "}"
 
366
    "}";
358
367
 
359
368
void AddresseeLineEdit::Private::startNepomukSearch()
360
369
{
621
630
  }
622
631
}
623
632
 
 
633
void AddresseeLineEdit::Private::slotTriggerDelayedQueries()
 
634
{
 
635
    if (m_searchString.isEmpty())
 
636
        return;
 
637
 
 
638
    // If Nepomuk is running, we send a ContactSearch job to
 
639
    // Akonadi, which will forward the query to Nepomuk, be
 
640
    // notified of matching items and return those to us.
 
641
    akonadiPerformSearch();
 
642
    // additionally, we ask Nepomuk directly, to get hits that
 
643
    // did not come in through Akonadi
 
644
    startNepomukSearch();
 
645
}
 
646
 
624
647
void AddresseeLineEdit::Private::startSearches()
625
648
{
626
649
    if ( Nepomuk2::ResourceManager::instance()->initialized() ) {
627
 
      // If Nepomuk is running, we send a ContactSearch job to
628
 
      // Akonadi, which will forward the query to Nepomuk, be
629
 
      // notified of matching items and return those to us.
630
 
      akonadiPerformSearch();
631
 
      // additionally, we ask Nepomuk directly, to get hits that
632
 
      // did not come in through Akonadi
633
 
      startNepomukSearch();
 
650
        if (!m_delayedQueryTimer.isActive())
 
651
            m_delayedQueryTimer.start(500);
634
652
    } else {
635
653
      // If Nepomuk is not available, we instead simply fetch
636
654
      // all contacts from Akonadi and filter them ourselves.