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

mailcommon

  • sources
  • kde-4.12
  • kdepim
  • mailcommon
  • tag
addtagdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012-2013 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 "addtagdialog.h"
19 #include "mailcommon/tag/tagwidget.h"
20 
21 #include <KLocale>
22 #include <KLineEdit>
23 #include <KMessageBox>
24 
25 #include <Nepomuk2/Tag>
26 
27 #include <QVBoxLayout>
28 
29 using namespace MailCommon;
30 
31 AddTagDialog::AddTagDialog(const QList<KActionCollection *>& actions, QWidget *parent)
32  : KDialog(parent)
33 {
34  setModal( true );
35  setCaption( i18n( "Add Tag" ) );
36  setButtons( Ok | Cancel );
37  setDefaultButton( Ok );
38  showButtonSeparator( true );
39  QVBoxLayout *lay = new QVBoxLayout( mainWidget() );
40  mTagWidget = new MailCommon::TagWidget(actions,this);
41  lay->addWidget(mTagWidget);
42  connect( this, SIGNAL(okClicked()), SLOT(slotOk()) );
43  connect(mTagWidget->tagNameLineEdit(), SIGNAL(textChanged(QString)), SLOT(slotTagNameChanged(QString)));
44  enableButtonOk(false);
45 }
46 
47 AddTagDialog::~AddTagDialog()
48 {
49 }
50 
51 void AddTagDialog::setTags(const QList<MailCommon::Tag::Ptr>& tags)
52 {
53  mTags = tags;
54 }
55 
56 void AddTagDialog::slotTagNameChanged(const QString& text)
57 {
58  enableButtonOk(!text.isEmpty());
59 }
60 
61 void AddTagDialog::slotOk()
62 {
63  const QString name(mTagWidget->tagNameLineEdit()->text());
64 
65  Q_FOREACH ( const MailCommon::Tag::Ptr &tag, mTags ) {
66  if ( tag->tagName == name ) {
67  KMessageBox::error( this, i18n( "Tag %1 already exists", name ) );
68  return;
69  }
70  }
71 
72  Nepomuk2::Tag nepomukTag( name );
73  nepomukTag.setLabel( name );
74 
75  MailCommon::Tag::Ptr tag = MailCommon::Tag::fromNepomuk( nepomukTag );
76  mTagWidget->recordTagSettings(tag);
77  MailCommon::Tag::SaveFlags saveFlags = mTagWidget->saveFlags();
78  tag->saveToNepomuk( saveFlags );
79 
80  mLabel = name;
81  mNepomukUrl = tag->nepomukResourceUri.toString();
82 
83  accept();
84 }
85 
86 QString AddTagDialog::label() const
87 {
88  return mLabel;
89 }
90 
91 QString AddTagDialog::nepomukUrl() const
92 {
93  return mNepomukUrl;
94 }
95 
96 #include "addtagdialog.moc"
QSharedPointer
Definition: collectiongeneralpage.h:30
text
const char * text
Definition: mdnadvicedialog.cpp:52
tagwidget.h
QWidget
MailCommon::Tag::fromNepomuk
static Ptr fromNepomuk(const Nepomuk2::Tag &nepomukTag)
Definition: tag.cpp:31
KDialog
MailCommon::TagWidget::recordTagSettings
void recordTagSettings(MailCommon::Tag::Ptr tag)
Definition: tagwidget.cpp:208
MailCommon::AddTagDialog::nepomukUrl
QString nepomukUrl() const
Definition: addtagdialog.cpp:91
MailCommon::Tag::SaveFlags
QFlags< SaveFlag > SaveFlags
Definition: tag.h:52
MailCommon::AddTagDialog::AddTagDialog
AddTagDialog(const QList< KActionCollection * > &actions, QWidget *parent=0)
Definition: addtagdialog.cpp:31
MailCommon::AddTagDialog::setTags
void setTags(const QList< MailCommon::Tag::Ptr > &tags)
Definition: addtagdialog.cpp:51
addtagdialog.h
MailCommon::TagWidget
Definition: tagwidget.h:37
MailCommon::AddTagDialog::label
QString label() const
Definition: addtagdialog.cpp:86
MailCommon::TagWidget::tagNameLineEdit
KLineEdit * tagNameLineEdit()
Definition: tagwidget.h:48
MailCommon::TagWidget::saveFlags
MailCommon::Tag::SaveFlags saveFlags() const
Definition: tagwidget.cpp:195
QList
MailCommon::AddTagDialog::~AddTagDialog
~AddTagDialog()
Definition: addtagdialog.cpp:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

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