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

knotes

  • sources
  • kde-4.14
  • kdepim
  • knotes
  • dialog
knoteselectednotesdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-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 "knoteselectednotesdialog.h"
19 #include "notes/knote.h"
20 
21 #include <KLocalizedString>
22 #include <KConfigGroup>
23 
24 #include <QListWidget>
25 
26 KNoteSelectedNotesDialog::KNoteSelectedNotesDialog(QWidget *parent)
27  : KDialog(parent)
28 {
29  setCaption( i18n( "Select notes" ) );
30  setButtons( Ok | Cancel );
31 
32  mListNotes = new QListWidget;
33  mListNotes->setSelectionMode(QAbstractItemView::ExtendedSelection);
34 
35 
36  connect(mListNotes, SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectionChanged()));
37  setMainWidget(mListNotes);
38  readConfig();
39  slotSelectionChanged();
40 }
41 
42 KNoteSelectedNotesDialog::~KNoteSelectedNotesDialog()
43 {
44  writeConfig();
45 }
46 
47 void KNoteSelectedNotesDialog::slotSelectionChanged()
48 {
49  const bool hasSelection = (mListNotes->selectedItems().count() > 0);
50  enableButtonOk(hasSelection);
51 }
52 
53 void KNoteSelectedNotesDialog::setNotes(const QHash<Akonadi::Item::Id, KNote*> &notes)
54 {
55  mNotes = notes;
56  QHashIterator<Akonadi::Item::Id, KNote *> i(notes);
57  while (i.hasNext()) {
58  i.next();
59  QListWidgetItem *item =new QListWidgetItem(mListNotes);
60  item->setText(i.value()->name());
61  item->setToolTip(i.value()->text());
62  item->setData(AkonadiId, i.key());
63  }
64 }
65 
66 QStringList KNoteSelectedNotesDialog::selectedNotes() const
67 {
68  QStringList lst;
69  Q_FOREACH(QListWidgetItem *item, mListNotes->selectedItems()) {
70  Akonadi::Item::Id akonadiId = item->data(AkonadiId).toLongLong();
71  if (akonadiId != -1) {
72  lst.append(QString::number(akonadiId));
73  }
74  }
75  return lst;
76 }
77 
78 void KNoteSelectedNotesDialog::readConfig()
79 {
80  KConfigGroup grp( KGlobal::config(), "KNoteSelectedNotesDialog" );
81  const QSize size = grp.readEntry( "Size", QSize(300, 200) );
82  if ( size.isValid() ) {
83  resize( size );
84  }
85 }
86 
87 void KNoteSelectedNotesDialog::writeConfig()
88 {
89  KConfigGroup grp( KGlobal::config(), "KNoteSelectedNotesDialog" );
90  grp.writeEntry( "Size", size() );
91  grp.sync();
92 }
QVariant::toLongLong
qlonglong toLongLong(bool *ok) const
QWidget
QSize::isValid
bool isValid() const
QAbstractItemView::setSelectionMode
void setSelectionMode(QAbstractItemView::SelectionMode mode)
KNoteSelectedNotesDialog::KNoteSelectedNotesDialog
KNoteSelectedNotesDialog(QWidget *parent=0)
Definition: knoteselectednotesdialog.cpp:26
QHashIterator::key
const Key & key() const
QHashIterator::hasNext
bool hasNext() const
KNoteSelectedNotesDialog::setNotes
void setNotes(const QHash< Akonadi::Item::Id, KNote * > &notes)
Definition: knoteselectednotesdialog.cpp:53
QListWidgetItem
KDialog
QListWidget
KNoteSelectedNotesDialog::selectedNotes
QStringList selectedNotes() const
Definition: knoteselectednotesdialog.cpp:66
QString::number
QString number(int n, int base)
knote.h
QList::append
void append(const T &value)
QHash< Akonadi::Item::Id, KNote * >
knoteselectednotesdialog.h
QListWidgetItem::setToolTip
void setToolTip(const QString &toolTip)
QHashIterator
QListWidgetItem::data
virtual QVariant data(int role) const
QStringList
KNoteSelectedNotesDialog::~KNoteSelectedNotesDialog
~KNoteSelectedNotesDialog()
Definition: knoteselectednotesdialog.cpp:42
QHashIterator::next
Item next()
QListWidget::selectedItems
QList< QListWidgetItem * > selectedItems() const
QSize
QListWidgetItem::setData
virtual void setData(int role, const QVariant &value)
QHashIterator::value
const T & value() const
QListWidgetItem::setText
void setText(const QString &text)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knotes

Skip menu "knotes"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

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
  • pimprint

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