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

kontact

  • sources
  • kde-4.12
  • kdepim
  • kontact
  • plugins
  • kmail
kcmkmailsummary.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Kontact.
3 
4  Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
5  Copyright (c) 2013 Laurent Montel <montel@kde.org>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 #include "kcmkmailsummary.h"
27 
28 #include "mailcommon/folderdialog/checkedcollectionwidget.h"
29 
30 #include <Akonadi/EntityTreeModel>
31 #include <Akonadi/ETMViewStateSaver>
32 #include <Akonadi/ChangeRecorder>
33 #include <Akonadi/CollectionFilterProxyModel>
34 #include <KRecursiveFilterProxyModel>
35 
36 #include <KMime/KMimeMessage>
37 
38 #include <KAboutData>
39 #include <KAcceleratorManager>
40 #include <KCheckableProxyModel>
41 #include <KComponentData>
42 #include <KDebug>
43 #include <KDialog>
44 #include <KLocale>
45 #include <KLineEdit>
46 
47 #include <QCheckBox>
48 #include <QTreeView>
49 #include <QVBoxLayout>
50 
51 extern "C"
52 {
53 KDE_EXPORT KCModule *create_kmailsummary( QWidget *parent, const char * )
54 {
55  KComponentData inst( "kcmkmailsummary" );
56  return new KCMKMailSummary( inst, parent );
57 }
58 }
59 
60 KCMKMailSummary::KCMKMailSummary( const KComponentData &inst, QWidget *parent )
61  : KCModule( inst, parent )
62 {
63  initGUI();
64 
65  connect( mCheckedCollectionWidget->folderTreeView(), SIGNAL(clicked(QModelIndex)),
66  SLOT(modified()) );
67  connect( mFullPath, SIGNAL(toggled(bool)), SLOT(modified()) );
68 
69  KAcceleratorManager::manage( this );
70 
71  load();
72 
73  KAboutData *about =
74  new KAboutData( I18N_NOOP( "kcmkmailsummary" ), 0,
75  ki18n( "Mail Summary Configuration Dialog" ),
76  0, KLocalizedString(), KAboutData::License_GPL,
77  ki18n( "Copyright © 2004–2010 Tobias Koenig" ) );
78 
79  about->addAuthor( ki18n( "Tobias Koenig" ),
80  KLocalizedString(), "tokoe@kde.org" );
81  setAboutData( about );
82 }
83 
84 void KCMKMailSummary::modified()
85 {
86  emit changed( true );
87 }
88 
89 void KCMKMailSummary::initGUI()
90 {
91  QVBoxLayout *layout = new QVBoxLayout( this );
92  layout->setSpacing( KDialog::spacingHint() );
93  layout->setMargin( 0 );
94 
95  mCheckedCollectionWidget = new MailCommon::CheckedCollectionWidget;
96 
97  mFullPath = new QCheckBox( i18n( "Show full path for folders" ), this );
98  mFullPath->setToolTip(
99  i18nc( "@info:tooltip", "Show full path for each folder" ) );
100  mFullPath->setWhatsThis(
101  i18nc( "@info:whatsthis",
102  "Enable this option if you want to see the full path "
103  "for each folder listed in the summary. If this option is "
104  "not enabled, then only the base folder path will be shown." ) );
105  layout->addWidget( mCheckedCollectionWidget );
106  layout->addWidget( mFullPath );
107 }
108 
109 void KCMKMailSummary::initFolders()
110 {
111  KSharedConfigPtr _config = KSharedConfig::openConfig( QLatin1String("kcmkmailsummaryrc") );
112 
113  mModelState =
114  new KViewStateMaintainer<Akonadi::ETMViewStateSaver>( _config->group( "CheckState" ), this );
115  mModelState->setSelectionModel( mCheckedCollectionWidget->selectionModel() );
116 }
117 
118 void KCMKMailSummary::loadFolders()
119 {
120  KConfig _config( QLatin1String("kcmkmailsummaryrc") );
121  KConfigGroup config(&_config, "General" );
122  mModelState->restoreState();
123  const bool showFolderPaths = config.readEntry( "showFolderPaths", false );
124  mFullPath->setChecked( showFolderPaths );
125 }
126 
127 void KCMKMailSummary::storeFolders()
128 {
129  KConfig _config( QLatin1String("kcmkmailsummaryrc") );
130  KConfigGroup config(&_config, "General" );
131  mModelState->saveState();
132  config.writeEntry( "showFolderPaths", mFullPath->isChecked() );
133  config.sync();
134 }
135 
136 void KCMKMailSummary::load()
137 {
138  initFolders();
139  loadFolders();
140 
141  emit changed( false );
142 }
143 
144 void KCMKMailSummary::save()
145 {
146  storeFolders();
147 
148  emit changed( false );
149 }
150 
151 void KCMKMailSummary::defaults()
152 {
153  mFullPath->setChecked( true );
154 
155  emit changed( true );
156 }
157 
158 #include "kcmkmailsummary.moc"
KCMKMailSummary
Definition: kcmkmailsummary.h:42
create_kmailsummary
KCModule * create_kmailsummary(QWidget *parent, const char *)
Definition: kcmkmailsummary.cpp:53
QWidget
KCMKMailSummary::load
virtual void load()
Definition: kcmkmailsummary.cpp:136
KCMKMailSummary::KCMKMailSummary
KCMKMailSummary(const KComponentData &inst, QWidget *parent=0)
Definition: kcmkmailsummary.cpp:60
KCMKMailSummary::save
virtual void save()
Definition: kcmkmailsummary.cpp:144
kcmkmailsummary.h
KCMKMailSummary::defaults
virtual void defaults()
Definition: kcmkmailsummary.cpp:151
KCModule
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:30 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • 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