• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

kabc

  • sources
  • kde-4.12
  • kdepimlibs
  • kabc
secrecy.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "secrecy.h"
22 
23 #include <klocalizedstring.h>
24 
25 #include <QtCore/QDataStream>
26 #include <QtCore/QSharedData>
27 
28 using namespace KABC;
29 
30 class Secrecy::PrivateData : public QSharedData
31 {
32  public:
33  PrivateData()
34  : mType( Secrecy::Invalid )
35  {
36  }
37 
38  PrivateData( const PrivateData &other )
39  : QSharedData( other )
40  {
41  mType = other.mType;
42  }
43 
44  Type mType;
45 };
46 
47 Secrecy::Secrecy( Type type )
48  : d( new PrivateData )
49 {
50  d->mType = type;
51 }
52 
53 Secrecy::Secrecy( const Secrecy &other )
54  : d( other.d )
55 {
56 }
57 
58 Secrecy::~Secrecy()
59 {
60 }
61 
62 Secrecy &Secrecy::operator=( const Secrecy &other )
63 {
64  if ( this != &other ) {
65  d = other.d;
66  }
67 
68  return *this;
69 }
70 
71 bool Secrecy::operator==( const Secrecy &other ) const
72 {
73  return d->mType == other.d->mType;
74 }
75 
76 bool Secrecy::operator!=( const Secrecy &other ) const
77 {
78  return !( *this == other );
79 }
80 
81 bool Secrecy::isValid() const
82 {
83  return d->mType != Invalid;
84 }
85 
86 void Secrecy::setType( Type type )
87 {
88  d->mType = type;
89 }
90 
91 Secrecy::Type Secrecy::type() const
92 {
93  return d->mType;
94 }
95 
96 Secrecy::TypeList Secrecy::typeList()
97 {
98  static TypeList list;
99 
100  if ( list.isEmpty() ) {
101  list << Public << Private << Confidential;
102  }
103 
104  return list;
105 }
106 
107 QString Secrecy::typeLabel( Type type )
108 {
109  switch ( type ) {
110  case Public:
111  return i18nc( "access is for everyone", "Public" );
112  break;
113  case Private:
114  return i18nc( "access is by owner only", "Private" );
115  break;
116  case Confidential:
117  return i18nc( "access is by owner and a controlled group", "Confidential" );
118  break;
119  default:
120  return i18nc( "unknown secrecy type", "Unknown type" );
121  break;
122  }
123 }
124 
125 QString Secrecy::toString() const
126 {
127  QString str;
128 
129  str += QString::fromLatin1( "Secrecy {\n" );
130  str += QString::fromLatin1( " Type: %1\n" ).arg( typeLabel( d->mType ) );
131  str += QString::fromLatin1( "}\n" );
132 
133  return str;
134 }
135 
136 QDataStream &KABC::operator<<( QDataStream &s, const Secrecy &secrecy )
137 {
138  return s << (uint)secrecy.d->mType;
139 }
140 
141 QDataStream &KABC::operator>>( QDataStream &s, Secrecy &secrecy )
142 {
143  uint type;
144  s >> type;
145 
146  switch ( type ) {
147  case 0:
148  secrecy.d->mType = Secrecy::Public;
149  break;
150  case 1:
151  secrecy.d->mType = Secrecy::Private;
152  break;
153  case 2:
154  secrecy.d->mType = Secrecy::Confidential;
155  break;
156  default:
157  secrecy.d->mType = Secrecy::Invalid;
158  break;
159  }
160 
161  return s;
162 }
KRES::Resource::type
QString type() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

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

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal