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

Nepomuk-Core

  • KTp
  • Declarative
contact-pin.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Aleix Pol <aleixpol@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #include "contact-pin.h"
20 #include <TelepathyQt/Account>
21 #include <TelepathyQt/Contact>
22 #include "pinned-contacts-model.h"
23 
24 ContactPin::ContactPin(QObject *parent)
25  : QObject(parent)
26  , m_model(0)
27 {
28 }
29 
30 Tp::AccountPtr ContactPin::account() const
31 {
32  return m_account;
33 }
34 
35 KTp::ContactPtr ContactPin::contact() const
36 {
37  return m_contact;
38 }
39 
40 PinnedContactsModel* ContactPin::model() const
41 {
42  return m_model;
43 }
44 
45 bool ContactPin::isPinned() const
46 {
47  bool ret = false;
48  if (m_model && m_account && m_contact) {
49  QModelIndex idx = m_model->indexForContact(m_contact);
50  ret = idx.isValid();
51  }
52  return ret;
53 }
54 
55 void ContactPin::toggle()
56 {
57  Q_ASSERT(m_model && m_account && m_contact);
58  m_model->setPinning(m_account, m_contact, !isPinned());
59  Q_EMIT pinnedChanged();
60 }
61 
62 
63 void ContactPin::setAccount(const Tp::AccountPtr &account)
64 {
65  Q_ASSERT(account);
66  m_account = account;
67  Q_EMIT pinnedChanged();
68 }
69 
70 void ContactPin::setContact(const KTp::ContactPtr &contact)
71 {
72  m_contact = contact;
73  Q_EMIT pinnedChanged();
74 }
75 
76 void ContactPin::setModel(PinnedContactsModel *model)
77 {
78  m_model = model;
79  Q_EMIT pinnedChanged();
80 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Fri Mar 22 2013 10:58:52 by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ktp-common-internals API Reference

Skip menu "ktp-common-internals API Reference"
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