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

knotes

  • sources
  • kde-4.12
  • kdepim
  • knotes
  • print
knoteprintselectednotesdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 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 "knoteprintselectednotesdialog.h"
19 #include "knoteprintselectthemecombobox.h"
20 #include "knoteprintobject.h"
21 #include "notes/knote.h"
22 
23 #include <kcal/journal.h>
24 
25 #include <KLocale>
26 #include <KConfigGroup>
27 
28 #include <QListWidget>
29 #include <QHBoxLayout>
30 #include <QLabel>
31 
32 KNotePrintSelectedNotesDialog::KNotePrintSelectedNotesDialog(QWidget *parent)
33  : KDialog(parent),
34  mPreview(false)
35 {
36  setCaption( i18n( "Select notes" ) );
37  setButtons( User1 | Ok | Cancel );
38  QWidget *w = new QWidget;
39  QVBoxLayout *vbox = new QVBoxLayout;
40  w->setLayout(vbox);
41 
42  mListNotes = new QListWidget;
43  mListNotes->setSelectionMode(QAbstractItemView::ExtendedSelection);
44  vbox->addWidget(mListNotes);
45 
46  QHBoxLayout *lay = new QHBoxLayout;
47  lay->setMargin(0);
48  vbox->addLayout(lay);
49  QLabel *lab = new QLabel(i18n("Printing theme:"));
50  lay->addWidget(lab);
51  mTheme = new KNotePrintSelectThemeComboBox;
52  mTheme->loadThemes();
53  lay->addWidget(mTheme);
54 
55  setButtonIcon(User1, KIcon(QLatin1String("document-print-preview")));
56  setButtonText(User1, i18n("Preview"));
57  setButtonIcon(Ok, KIcon(QLatin1String("document-print")));
58  setButtonText(Ok, i18n("Print"));
59  connect(this, SIGNAL(user1Clicked()), this, SLOT(slotPreview()));
60  connect(mListNotes, SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectionChanged()));
61  setMainWidget(w);
62  readConfig();
63  slotSelectionChanged();
64 }
65 
66 KNotePrintSelectedNotesDialog::~KNotePrintSelectedNotesDialog()
67 {
68  writeConfig();
69 }
70 
71 void KNotePrintSelectedNotesDialog::slotSelectionChanged()
72 {
73  const bool hasSelection = (mListNotes->selectedItems().count() > 0);
74  enableButton(User1, hasSelection);
75  enableButtonOk(hasSelection);
76 }
77 
78 void KNotePrintSelectedNotesDialog::setNotes(const QMap<QString, KNote *> &notes)
79 {
80  mNotes = notes;
81  QMapIterator<QString, KNote *> i(notes);
82  while (i.hasNext()) {
83  i.next();
84  QListWidgetItem *item =new QListWidgetItem(mListNotes);
85  item->setText(i.value()->name());
86  item->setToolTip(i.value()->journal()->description());
87  item->setData(JournalId, i.key());
88  }
89 }
90 
91 QList<KNotePrintObject *> KNotePrintSelectedNotesDialog::selectedNotes() const
92 {
93  QList<KNotePrintObject *> lstPrintObj;
94  QList<QListWidgetItem *> lst = mListNotes->selectedItems ();
95  Q_FOREACH(QListWidgetItem *item, lst) {
96  const QString journalId = item->data(JournalId).toString();
97  if (!journalId.isEmpty()) {
98  KNotePrintObject *obj = new KNotePrintObject(mNotes.value(journalId)->journal());
99  lstPrintObj.append(obj);
100  }
101  }
102  return lstPrintObj;
103 }
104 
105 QString KNotePrintSelectedNotesDialog::selectedTheme() const
106 {
107  return mTheme->selectedTheme();
108 }
109 
110 bool KNotePrintSelectedNotesDialog::preview() const
111 {
112  return mPreview;
113 }
114 
115 void KNotePrintSelectedNotesDialog::readConfig()
116 {
117  KConfigGroup grp( KGlobal::config(), "KNotePrintSelectedNotesDialog" );
118  const QSize size = grp.readEntry( "Size", QSize(300, 200) );
119  if ( size.isValid() ) {
120  resize( size );
121  }
122 }
123 
124 void KNotePrintSelectedNotesDialog::writeConfig()
125 {
126  KConfigGroup grp( KGlobal::config(), "KNotePrintSelectedNotesDialog" );
127  grp.writeEntry( "Size", size() );
128  grp.sync();
129 }
130 
131 void KNotePrintSelectedNotesDialog::slotPreview()
132 {
133  mPreview = true;
134  accept();
135 }
136 
137 #include "knoteprintselectednotesdialog.moc"
KNotePrintSelectThemeComboBox::selectedTheme
QString selectedTheme() const
Definition: knoteprintselectthemecombobox.cpp:90
KNotePrintObject
Definition: knoteprintobject.h:29
KNotePrintSelectedNotesDialog::preview
bool preview() const
Definition: knoteprintselectednotesdialog.cpp:110
KNotePrintSelectedNotesDialog::KNotePrintSelectedNotesDialog
KNotePrintSelectedNotesDialog(QWidget *parent=0)
Definition: knoteprintselectednotesdialog.cpp:32
QWidget
KDialog
knote.h
KNotePrintSelectThemeComboBox::loadThemes
void loadThemes()
Definition: knoteprintselectthemecombobox.cpp:39
knoteprintselectthemecombobox.h
knoteprintobject.h
KNotePrintSelectThemeComboBox
Definition: knoteprintselectthemecombobox.h:24
knoteprintselectednotesdialog.h
KNotePrintSelectedNotesDialog::~KNotePrintSelectedNotesDialog
~KNotePrintSelectedNotesDialog()
Definition: knoteprintselectednotesdialog.cpp:66
KNotePrintSelectedNotesDialog::selectedNotes
QList< KNotePrintObject * > selectedNotes() const
Definition: knoteprintselectednotesdialog.cpp:91
KNotePrintSelectedNotesDialog::selectedTheme
QString selectedTheme() const
Definition: knoteprintselectednotesdialog.cpp:105
KNotePrintSelectedNotesDialog::setNotes
void setNotes(const QMap< QString, KNote * > &notes)
Definition: knoteprintselectednotesdialog.cpp:78
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:33 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

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