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

akonadi

  • akonadi
tagselectwidget.cpp
1 /*
2  Copyright (c) 2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "tagselectwidget.h"
19 #include "monitor.h"
20 #include "tagmodel.h"
21 #include "tageditwidget.h"
22 
23 #include <QHBoxLayout>
24 
25 using namespace Akonadi;
26 
27 class TagSelectWidget::Private
28 {
29 public:
30  Private(TagSelectWidget *parent)
31  : mParent(parent)
32  {
33  init();
34  }
35  void init();
36  TagSelectWidget *mParent;
37  Akonadi::TagEditWidget *mTagEditWidget;
38 };
39 
40 void TagSelectWidget::Private::init()
41 {
42  QHBoxLayout *mainLayout = new QHBoxLayout;
43  mParent->setLayout(mainLayout);
44 
45  Monitor *monitor = new Monitor(mParent);
46  monitor->setTypeMonitored(Monitor::Tags);
47 
48  Akonadi::TagModel *model = new Akonadi::TagModel(monitor, mParent);
49  mTagEditWidget = new Akonadi::TagEditWidget(model, mParent, true);
50  mTagEditWidget->setObjectName(QLatin1String("tageditwidget"));
51 
52  mainLayout->addWidget(mTagEditWidget);
53 
54 }
55 
56 TagSelectWidget::TagSelectWidget(QWidget *parent)
57  : QWidget(parent),
58  d(new Private(this))
59 {
60 }
61 
62 TagSelectWidget::~TagSelectWidget()
63 {
64  delete d;
65 }
66 
67 void TagSelectWidget::setSelection(const Tag::List &tags)
68 {
69  d->mTagEditWidget->setSelection(tags);
70 }
71 
72 Tag::List TagSelectWidget::selection() const
73 {
74  return d->mTagEditWidget->selection();
75 }
76 
77 QStringList TagSelectWidget::tagToStringList() const
78 {
79  QStringList list;
80  const Akonadi::Tag::List tags = selection();
81  foreach (const Akonadi::Tag &tag, tags) {
82  list.append(tag.url().url());
83  }
84  return list;
85 }
86 
87 void TagSelectWidget::setSelectionFromStringList(const QStringList &lst)
88 {
89  Akonadi::Tag::List tags;
90 
91  const QStringList categories = lst;
92  foreach (const QString &category, categories) {
93  tags.append(Akonadi::Tag::fromUrl(category));
94  }
95  setSelection(tags);
96 }
97 
Akonadi::TagEditWidget
A widget that offers facilities to add/remove tags and optionally provides a way to select tags...
Definition: tageditwidget.h:37
Akonadi::Monitor::setTypeMonitored
void setTypeMonitored(Type type, bool monitored=true)
Sets whether given type (Collection, Item, Tag should be monitored).
Definition: monitor.cpp:166
Akonadi::Monitor
Monitors an item or collection for changes.
Definition: monitor.h:74
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
Akonadi::Tag
An Akonadi Tag.
Definition: tag.h:43
Akonadi::Tag::url
KUrl url() const
Returns the url of the tag.
Definition: tag.cpp:118
This file is part of the KDE documentation.
Documentation copyright © 1996-2016 The KDE developers.
Generated on Fri Apr 22 2016 18:08:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

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

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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