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

Nepomuk-Core

  • KTp
  • Widgets
accounts-combo-box.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 David Edmundson <kde@davidedmundson.co.uk>
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 St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 
20 #include "accounts-combo-box.h"
21 
22 #include <TelepathyQt/AccountSet>
23 #include <TelepathyQt/Account>
24 
25 #include <KTp/Models/accounts-list-model.h>
26 
27 
28 class KTp::AccountsComboBox::Private
29 {
30 public:
31  AccountsListModel *model;
32 };
33 
34 KTp::AccountsComboBox::AccountsComboBox(QWidget *parent) :
35  QComboBox(parent),
36  d(new KTp::AccountsComboBox::Private())
37 {
38  d->model = new AccountsListModel(this);
39  setModel(d->model);
40 }
41 
42 void KTp::AccountsComboBox::setAccountSet(const Tp::AccountSetPtr &accountSet)
43 {
44  d->model->setAccountSet(accountSet);
45 }
46 
47 Tp::AccountPtr KTp::AccountsComboBox::currentAccount()
48 {
49  return itemData(currentIndex(), AccountsListModel::AccountRole).value<Tp::AccountPtr>();
50 }
51 
52 void KTp::AccountsComboBox::setCurrentAccount(const QString &selectedAccountId)
53 {
54  for (int i=0;i<count();i++) {
55  if (itemData(i, AccountsListModel::AccountRole).value<Tp::AccountPtr>()->uniqueIdentifier() == selectedAccountId) {
56  setCurrentIndex(i);
57  break;
58  }
59  }
60 }
61 
62 void KTp::AccountsComboBox::setCurrentAccount(const Tp::AccountPtr &selectedAccount)
63 {
64  setCurrentAccount(selectedAccount->uniqueIdentifier());
65 }
66 
67 
68 
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