• Skip to content
  • Skip to link menu
KDE 4.8 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

akonadi

persistentsearchattribute.cpp
00001 /*
00002     Copyright (c) 2010 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "persistentsearchattribute.h"
00021 
00022 #include <akonadi/private/imapparser_p.h>
00023 
00024 #include <QtCore/QString>
00025 
00026 using namespace Akonadi;
00027 
00028 class PersistentSearchAttribute::Private
00029 {
00030   public:
00031     QString queryLanguage;
00032     QString queryString;
00033 };
00034 
00035 PersistentSearchAttribute::PersistentSearchAttribute()
00036   : d( new Private )
00037 {
00038 }
00039 
00040 PersistentSearchAttribute::~PersistentSearchAttribute()
00041 {
00042   delete d;
00043 }
00044 
00045 QString PersistentSearchAttribute::queryLanguage() const
00046 {
00047   return d->queryLanguage;
00048 }
00049 
00050 void PersistentSearchAttribute::setQueryLanguage(const QString& language)
00051 {
00052   d->queryLanguage = language;
00053 }
00054 
00055 QString PersistentSearchAttribute::queryString() const
00056 {
00057   return d->queryString;
00058 }
00059 
00060 void PersistentSearchAttribute::setQueryString(const QString& query)
00061 {
00062   d->queryString = query;
00063 }
00064 
00065 QByteArray PersistentSearchAttribute::type() const
00066 {
00067   return "PERSISTENTSEARCH"; // ### should eventually be AKONADI_PARAM_PERSISTENTSEARCH
00068 }
00069 
00070 Attribute* PersistentSearchAttribute::clone() const
00071 {
00072   PersistentSearchAttribute* attr = new PersistentSearchAttribute;
00073   attr->setQueryLanguage( queryLanguage() );
00074   attr->setQueryString( queryString() );
00075   return attr;
00076 }
00077 
00078 QByteArray PersistentSearchAttribute::serialized() const
00079 {
00080   QList<QByteArray> l;
00081   // ### eventually replace with the AKONADI_PARAM_PERSISTENTSEARCH_XXX constants
00082   l.append( "QUERYLANGUAGE" );
00083   l.append( d->queryLanguage.toLatin1() );
00084   l.append( "QUERYSTRING" );
00085   l.append( ImapParser::quote( d->queryString.toUtf8() ) );
00086   return "(" + ImapParser::join( l, " " ) + ')'; //krazy:exclude=doublequote_chars
00087 }
00088 
00089 void PersistentSearchAttribute::deserialize(const QByteArray& data)
00090 {
00091   QList<QByteArray> l;
00092   ImapParser::parseParenthesizedList( data, l );
00093   for ( int i = 0; i < l.size() - 1; i += 2 ) {
00094     const QByteArray key = l.at( i );
00095     if ( key == "QUERYLANGUAGE" )
00096       d->queryLanguage = QString::fromLatin1( l.at( i + 1 ) );
00097     else if ( key == "QUERYSTRING" )
00098       d->queryString = QString::fromUtf8( l.at( i + 1 ) );
00099   }
00100 }

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal